Module BAF := BA_Facts BA.
Include BAF.
(* Now, we prove the axioms about relativization. Again, this mostly involves packing and unpacking the canonTree type and pushing around mkCanon. *)
Definition rel (a x:t) : t.
case_eq (proj1_sig x); intros.
destruct b.
exact a.
exact (exist (fun t => canonicalTree t) (Leaf false) I).
refine (exist _ (relativ_tree (proj1_sig a) (proj1_sig x)) _).
apply relativ_almost_canon.
apply (proj2_sig a).
apply (proj2_sig x).
destruct x; simpl in *; subst; simpl in *; intuition.
Defined.

(* Specifications: *)
Lemma relativ_tree_empty : forall a x,
nonEmptyTree a -> nonEmptyTree x ->
nonEmptyTree (relativ_tree a x).
Lemma relativ_tree_nonid : forall a x1 x2,
nonEmptyTree a ->
a = relativ_tree a (Node x1 x2) ->
False.
Lemma rel_classification : forall a x,
{ x = bot /\ rel a x = bot } +
{ x <> bot /\ proj1_sig (rel a x) = relativ_tree (proj1_sig a) (proj1_sig x)
/\ (a = bot <-> rel a x = bot) }.
Lemma rel_inj_l : forall a x y, a <> bot -> rel a x = rel a y -> x = y.
Lemma rel_assoc : forall x y z, rel x (rel y z) = rel (rel x y) z.
Lemma rel_bot1 : forall a, rel a bot = bot.
Lemma rel_bot2 : forall x, rel bot x = bot.
Lemma rel_top1 : forall a, rel a top = a.
Lemma rel_top2 : forall x, rel top x = x.
Lemma rel_preserves_glb : forall a x y, rel a (glb x y) = glb (rel a x) (rel a y).
Lemma rel_preserves_lub : forall a x y, rel a (lub x y) = lub (rel a x) (rel a y).
Definition leftTree : canonTree.