(* // This file is for Assignment 2, BU CAS CS 520, Fall, 2009 // // Instructor: Hongwei Xi (hwxi AT cs DOT bu DOT edu) // *) (* ****** ****** *) datasort bt = B of (bt, bt) | E of () (* ****** ****** *) dataprop btsz (bt, int) = | {t1,t2:bt} {s1,s2:nat} btsz_B (B (t1, t2), 1 + s1 + s2) of (btsz (t1, s1), btsz (t2, s2)) | btsz_E (E (), 0) prfun btsz_istot {t:bt} .. (): [s:nat] btsz (t, s) = scase t of | B (t1, t2) => btsz_B (btsz_istot {t1} (), btsz_istot {t2} ()) | E () => btsz_E () // end of [btsz_istot] (* ****** ****** *) dataprop btht (bt, int) = | {t1,t2:bt} {h1,h2:nat} btht_B (B (t1, t2), 1 + max (h1, h2)) of (btht (t1, h1), btht (t2, h2)) | btht_E (E (), 0) (* ****** ****** *) dataprop POW2 (int, int) = | POW2bas (0, 1) | {n,p:nat} POW2ind (n+1, p+p) of POW2 (n, p) // end of [POW2] (* ****** ****** *) dataprop isBraun (bt) = | {t1,t2:bt} {s1,s2:nat | s2 <= s1; s1 <= 1 + s2} isBraun_B (B (t1, t2)) of (isBraun t1, isBraun t2, btsz (t1, s1), btsz (t2, s2)) | isBraun_E (E ()) of () // end of [isBraun] (* ****** ****** *) extern prfun brauntree_height_lemma {t1,t2:bt} {h,h1:nat} (pf0: isBraun (B (t1, t2)), pf1: btht (B (t1, t2), h), pf2: btht (t1, h1)) : [h == h1+1] void extern prfun brauntree_size_height_lemma {t:bt} {s,h,p:nat} (pf0: isBraun (t), pf1: btsz (t, s), pf2: btht (t, h), pf3: POW2 (h, p)) : [p <= s + s + 1] void (* ****** ****** *) (* end of [brauntree.dats] *)