(*==========================================================  TOPOLOGICAL FMAPS, HMAPS - WITH TAGS AND EMBEDDINGS  PART 6:.  PROPERTIES OF MERGING AND SPLITTING FACES expf / L1  COMPLETE: OK! ============================================================*)
(* Load Jordan1. Load Jordan2. Load Jordan3. Load Jordan4. Load Jordan5. *)
Require Export Jordan5.
(*========================================================== 1. MERGING FACES BY L1 (CASE ~expf m x y0) ===========================================================*)
(* CASE k = one IN cF_L (from Jordan5) : OK *)
(* 1. CASE ~expf m x y0: FACE MERGING *)
(* FIRST, SOME LEMMAS: *)
(* OK: *)
Open Scope nat_scope.
(* i-SUCCS OF x BY cF_L1, FOR i < DEG OF x, ARE INVARIANT: *)
(* OK: *)
(* i-SUCCS OF x BY cF_L1, FOR i < DEG x, DIFFER FROM x *)
(* OK: *)
(* THE dx_SUCC OF x BY cF_L1 IS y_1: *)
(* IT IS DIFFRENT FROM x: *)
(* j-SUCCS OF y BY cF_L1, FOR j < DEGREE OF y, ARE INVARIANT: *)
(* j-SUCCS OF y_1 BY cF_L1, FOR j < DEG OF y0 (OR y_1), ARE INVARIANT:*)
(* THE ARE DIFFERENT FROM x: *)
(* THE ARE DIFFERENT FROM x - OTHER FORM: *)
(* OK: *)
(* THEN, ABOUT THE DEGREES, OK: *)
(* TECHNICAL LEMMA: *)
(* AND (MORE TECHNICAL), OK!!: *)
(* FROM WHERE "THE" GREAT RESULT ABOUT THE DEGREES: *)
(* CHANGER LES NOMS... *)
(* THEN, OK: *)
(* OTHER FORM, w.r.t. y_1: *)
(* THEN, WE HAVE: *)
(* OTHER FORM FOR y0: *)
(* FINALLY, THE OTHER ORBITS ARE INCHANGED: *)
(* OK, BY INDUCTION ON i: *)
(* THEN, THE RESULT: *)
(* COROLLARY: *)
(* VERSION orb, OK: *)
(* TECHNICAL LEMMA: THE OTHER DEGREES ARE INCHANGED: *)
(* AND (VERY USEFUL): *)
(* PRESERVATION OF THE PARTITION, EXCEPT 2 MERGED FACES *)
(* OK: *)
(* FINALLY, THE RESULT ABOUT THE DEGREES: *)
(*============================================================ PUIS LA 1ERE PARTIE DE expf_L1_CNS... =============================================================*)
(* RECALL:  Lemma expf_L1_CNS:forall (m:fmap)(x y z t:dart), inv_hmap (L m one x y) -> exd m z -> (expf (L m one x y) z t <-> let x1 := cA m one x in let x10 := cA m zero x1 in let y0 := cA m zero y in let y_1 := cA_1 m one y in if expf_dec m x y0 then betweenf m x z y0 /\ betweenf m x t y0 \/ betweenf m y_1 z x10 /\ betweenf m y_1 t x10 \/ ~ expf m x z /\ expf m z t else   expf m z t \/ expf m z x /\ expf m t y0 \/ expf m t x /\ expf m z y0). *)
(* ESSAIS:  Definition dec (A:Prop):Set:= {A}+{~A}.  Lemma or_and_dec : forall (A B C D:Prop), dec A -> dec B -> dec C -> dec D -> {A /\ B \/ C /\ D} + {~(A /\ B \/ C /\ D)}.  *)
(* AUXILARIES: *)
Definition dec (A:Prop):Set:= {A}+{~A}.
(* OK: *)
(* OK!! *)
(* THEN, IN SUMMARY: NON-NECESSARY  Lemma expf_L1_II_CNS:forall (m:fmap)(x y z t:dart), inv_hmap (L m one x y) -> exd m z -> expf_dec m x y0 -> (expf (L m one x y) z t <-> let x1 := cA m one x in let x10 := cA m zero x1 in let y0 := cA m zero y in let y_1 := cA_1 m one y in expf m z t \/ expf m z x /\ expf m t y0 \/ expf m t x /\ expf m z y0 ).  *)
(*========================================================== 2. SPLITTING A FACE BY L1 (Case expf m x y0) ===========================================================*)
(* A FEW USEFUL LEMMAS: *)
Open Scope nat_scope.
intros.
intros.
induction i.
simpl in |- *.
assert (j + 1 + 0 = S j).
omega.
rewrite H5 in |- *.
simpl in |- *.
rewrite <- H1 in |- *.
unfold y0 in |- *.
unfold y_1 in |- *.
unfold cF in |- *.
rewrite cA_1_cA in |- *.
tauto.
tauto.
unfold prec_L in H0.
tauto.
assert (j + 1 + S i = S (j + 1 + i)).
omega.
rewrite H5 in |- *.
simpl in |- *.
clear H5.
rewrite IHi in |- *.
unfold m1 in |- *.
rewrite cF_L1 in |- *.
fold y0 in |- *.
elim (eq_dart_dec y0 (Iter (cF m) (j + 1 + i) x)).
intros.
rewrite H1 in a.
assert (j = j + 1 + i).
assert (exd m x).
unfold prec_L in H0.
tauto.
apply (MF.degree_unicity m x).
tauto.
tauto.
fold dx in |- *.
omega.
fold dx in |- *.
omega.
tauto.
absurd (j = j + 1 + i).
omega.
tauto.
elim (eq_dart_dec (cF_1 m x) (Iter (cF m) (j + 1 + i) x)).
intros.
assert (x = Iter (cF m) (S (j + 1 + i)) x).
simpl in |- *.
rewrite <- a in |- *.
rewrite cF_cF_1 in |- *.
tauto.
tauto.
unfold prec_L in H0.
tauto.
symmetry  in H5.
absurd (Iter (cF m) (S (j + 1 + i)) x = x).
apply MF.degree_diff.
tauto.
unfold prec_L in H0.
tauto.
fold dx in |- *.
omega.
tauto.
tauto.
tauto.
tauto.
omega.
Qed.
(* OK: *)
(* COROLLARY, OK: *)
(* OK: *)
(* OK: *)
(* OK: *)
(* THEN, OK: *)
(* OK! *)
(* THEN, THE RESULT: *)
(* OUTSIDE x'ORBIT: *)
(*=========================================================== expf_L1 : PART 2 (Case expf x y0) ============================================================*)
(* SUFFICIENT CONDITION: *)
(* OK: *)
(* OK: *)
(* THEN, THE RESULT: *)
(* THEN, THE SUMMARY: *)

Theorem expf_L1_CNS:forall (m:fmap)(x y z t:dart),
inv_hmap (L m one x y) -> exd m z ->
(expf (L m one x y) z t <->
let x1 := cA m one x in
let x10 := cA m zero x1 in
let y0 := cA m zero y in
let y_1 := cA_1 m one y in
if expf_dec m x y0
then betweenf m x z y0 /\ betweenf m x t y0
\/ betweenf m y_1 z x10 /\ betweenf m y_1 t x10
\/ ~ expf m x z /\ expf m z t
else   expf m z t
\/ expf m z x /\ expf m t y0
\/ expf m t x /\ expf m z y0).