Fixpoint power (base : nat) (exp : nat) : nat :=
match exp with
| 0 => 1
| S n => base * (power base n)
end.

(* Specifications: *)
(*L39*)
Lemma countBLeafCT_limit: forall n s, countBLeafCT n s <= power 2 n.
(*L40*)
Lemma countBLeafCT_bot: forall n, countBLeafCT n bot = 0.
(*L41*)
Lemma countBLeafCT_top: forall n, countBLeafCT n top = power 2 n.
(*L42*)
Lemma countBLeafCT_positive : forall s n,
height s <= n -> bot <> s ->
0 < countBLeafCT n s.
(*L43*)
Lemma countBLeafCT_mono_le: forall n1 n2 s,
n1 <= n2 ->
countBLeafCT n1 s <= countBLeafCT n2 s .
(*L44*)
Lemma countBLeafCT_mono_diff: forall n1 n2 s1 s2,
n1 <= n2 ->
(s1 <= s2)%ba ->
countBLeafCT n1 s2 - countBLeafCT n1 s1 <= countBLeafCT n2 s2 - countBLeafCT n2 s1.
(*L45*)
Lemma countBLeafCT_mono_lt: forall n1 n2 s,
n1 < n2 ->
0 < countBLeafCT n1 s ->
countBLeafCT n1 s < countBLeafCT n2 s .
(*Borrow those two lemmas from to_formula*)
Lemma bot_join: forall t1 t2,
join bot t1 t2 ->  t1 = t2.
Lemma join_top : forall t1 t2, join top t1 t2 -> t1 = bot /\ t2 = top.
Lemma tree_height_0: forall s, height s = 0 -> s = top \/ s = bot.
(*L55*)
Lemma tree_height_glb_limit: forall n s1 s2,
height s1 <= n ->
height s2 <= n ->
height (glb s1 s2) <= n.
(*L57*)
Lemma height_glb1 : forall s1 s2,
height s1 <= tree_height s2->
height (glb s1 s2) <= height s2.
(*L54*)
Lemma tree_height_lub_limit: forall n s1 s2,
height s1 <= n ->
height s2 <= n ->
height (lub s1 s2) <= n.
(*L56*)
Lemma height_lub1 : forall s1 s2,
height s1 <= height s2->
height (lub s1 s2) <= height s2.
(*L58*)
Lemma height_comp: forall s, height (comp s)= height s.
(*L46*)
Lemma countBLeafCT_join_le: forall n s1 s2 s3,
join s1 s2 s3 ->
countBLeafCT n s1 + countBLeafCT n s2 <= countBLeafCT n s3.
(*L47*)
Lemma countBLeafCT_join_eq: forall n s1 s2 s3,
join s1 s2 s3 ->
height s1 <= n ->
height s2 <= n ->
countBLeafCT n s1 + countBLeafCT n s2 = countBLeafCT n s3.