(*** Begin Module Signature Definitions and lemmas ***)
(* Here we show that canonical share trees form a boolean algrbra.  These proofs mainly involve showing that the results above commute in the proper ways with mkCanon. *)
Module BA <: BOOLEAN_ALGEBRA.
Definition t := canonTree.
Definition Ord (x y:canonTree) := shareTreeOrd (proj1_sig x) (proj1_sig y).
Definition lub (x y:canonTree) : canonTree :=
exist (fun t => canonicalTree t)
(mkCanon (union_tree (proj1_sig x) (proj1_sig y)))
(mkCanon_correct _).
Definition glb (x y:canonTree) : canonTree :=
exist (fun t => canonicalTree t)
(mkCanon (intersect_tree (proj1_sig x) (proj1_sig y)))
(mkCanon_correct _).
Definition top : canonTree := exist (fun t => canonicalTree t) (Leaf true) I.
Definition bot : canonTree := exist (fun t => canonicalTree t) (Leaf false) I.
Definition comp (x:canonTree) : canonTree :=
exist (fun t => canonicalTree t) (comp_tree (proj1_sig x))
(comp_canonical _ (proj2_sig x)).

(* Specifications: *)
Lemma ord_refl : forall x, Ord x x.
Lemma ord_trans : forall x y z, Ord x y -> Ord y z -> Ord x z.
Lemma ord_antisym : forall x y, Ord x y -> Ord y x -> x = y.
Lemma lub_upper1 : forall x y, Ord x (lub x y).
Lemma lub_upper2 : forall x y, Ord y (lub x y).
Lemma lub_least : forall x y z,
Ord x z -> Ord y z -> Ord (lub x y) z.
Lemma glb_lower1 : forall x y, Ord (glb x y) x.
Lemma glb_lower2 : forall x y, Ord (glb x y) y.
Lemma glb_greatest : forall x y z,
Ord z x -> Ord z y -> Ord z (glb x y).
Lemma top_correct : forall x, Ord x top.
Lemma bot_correct : forall x, Ord bot x.
Lemma comp1 : forall x, lub x (comp x) = top.
Lemma comp2 : forall x, glb x (comp x) = bot.
Lemma nontrivial : top <> bot.
End BA.