(*===========================================================
                expe AND bottom
============================================================*)

(* expo and between in an edge: *)

Definition expe(m:fmap)(z t:dart):=
  MA0.expo m z t.Definition betweene(m:fmap)(z v t:dart):=
  MA0.between m z v t.

(* Specifications: *)
Lemma cA0_MA0:forall(m:fmap)(z:dart), cA m zero z = MA0.f m z.
Lemma cA0_MA0_Iter:forall(m:fmap)(i:nat)(z:dart), Iter (cA m zero) i z = Iter (MA0.f m) i z.
Lemma bottom_cA: forall(m:fmap)(k:dim)(z:dart), inv_hmap m -> exd m z -> bottom m k (cA m k z) = bottom m k z.
Lemma expe_bottom_ind: forall(m:fmap)(z:dart)(i:nat), inv_hmap m -> exd m z -> let t:= Iter (cA m zero) i z in bottom m zero z = bottom m zero t.
Lemma expe_bottom: forall(m:fmap)(z t:dart), inv_hmap m -> MA0.expo m z t -> bottom m zero z = bottom m zero t.
Lemma top_cA_1: forall(m:fmap)(k:dim)(z:dart), inv_hmap m -> exd m z -> top m k (cA_1 m k z) = top m k z.
Lemma cA0_1_MA0_1:forall(m:fmap)(z:dart), cA_1 m zero z = MA0.f_1 m z.
Lemma cA0_1_MA0_1_Iter:forall(m:fmap)(i:nat)(z:dart), Iter (cA_1 m zero) i z = Iter (MA0.f_1 m) i z.
Lemma expe_top_ind: forall(m:fmap)(z:dart)(i:nat), inv_hmap m -> exd m z -> let t:= Iter (cA m zero) i z in top m zero z = top m zero t.
Lemma expe_top: forall(m:fmap)(z t:dart), inv_hmap m -> MA0.expo m z t -> top m zero z = top m zero t.
Lemma betweene_dec1: forall(m:fmap)(z v t:dart), inv_hmap m -> exd m z -> exd m v -> (betweene m z v t \/ ~betweene m z v t).
Lemma bottom_B0: forall(m:fmap)(z:dart), inv_hmap m -> exd m z -> bottom (B m zero z) zero z = bottom m zero z.
Lemma succ_zi: forall(m:fmap)(z:dart)(i:nat), inv_hmap m -> exd m z -> ~pred m zero z -> (i + 1 < MA0.Iter_upb m z)%nat -> let zi:= Iter (MA0.f m) i z in succ m zero zi.
Lemma bottom_B0_bis: forall(m:fmap)(z:dart)(i j:nat), inv_hmap m -> exd m z -> ~pred m zero z -> let zi := Iter (MA0.f m) i z in let zj := Iter (MA0.f m) j z in let m0 := B m zero zi in (i < j < MA0.Iter_upb m z)%nat -> bottom m0 zero zj = A m zero zi.
Lemma bottom_B0_ter: forall(m:fmap)(z:dart)(i j:nat), inv_hmap m -> exd m z -> ~pred m zero z -> let zi := Iter (MA0.f m) i z in let zj := Iter (MA0.f m) j z in let m0 := B m zero zi in (j <= i < MA0.Iter_upb m z)%nat -> bottom m0 zero zj = bottom m zero zj.
Lemma bottom_B0_quad: forall(m:fmap)(z v:dart)(j:nat), inv_hmap m -> exd m z -> ~pred m zero z -> let m0 := B m zero v in let t := Iter (MA0.f m) j z in (j < MA0.Iter_upb m z)%nat -> ~MA0.expo m z v -> bottom m0 zero t = bottom m zero t.
Lemma not_between_B0:forall(m:fmap)(x z:dart), inv_hmap m -> exd m x -> exd m z -> x <> z -> let z0:= bottom m zero z in ~betweene m z0 x z -> (~MA0.expo m z0 x \/ forall(i j:nat), x = Iter (MA0.f m) i z0 -> z = Iter (MA0.f m) j z0 -> (i < MA0.Iter_upb m z0)%nat -> (j < MA0.Iter_upb m z0)%nat -> (j <= i)%nat).
Lemma Iter_cA0_I: forall(m:fmap)(d z:dart)(t:tag)(p:point)(i:nat), inv_hmap (I m d t p) -> exd m z -> Iter (cA (I m d t p) zero) i z = Iter (cA m zero) i z.
Lemma nopred_expe_L_i: forall(m:fmap)(i:nat)(k:dim)(x y z:dart), inv_hmap (L m k x y) -> exd m z -> ~pred m zero z -> let t:= Iter (cA m zero) i z in (i < MA0.Iter_upb m z)%nat -> expe (L m k x y) z t.
Lemma expe_bottom_z: forall(m:fmap)(z:dart), inv_hmap m -> exd m z -> MA0.expo m (bottom m zero z) z.
Lemma bottom_bottom_expe: forall(m:fmap)(z t:dart), inv_hmap m -> exd m z -> exd m t -> bottom m zero z = bottom m zero t -> MA0.expo m z t.
Lemma top_top_expe: forall(m:fmap)(z t:dart), inv_hmap m -> exd m z -> exd m t -> top m zero z = top m zero t -> MA0.expo m z t.
Lemma between_bottom_B0_bis: forall(m:fmap)(x' x:dart), inv_hmap m -> exd m x -> exd m x' -> x' <> x -> let x0 := bottom m zero x in let m0 := B m zero x' in ((betweene m x0 x' x -> bottom m0 zero x = A m zero x') /\ (~betweene m x0 x' x -> bottom m0 zero x = bottom m zero x)).
Lemma not_expe_bottom_B0: forall(m:fmap)(x' x:dart), inv_hmap m -> exd m x -> exd m x' -> let m0 := B m zero x' in ~ expe m x' x -> bottom m0 zero x = bottom m zero x.
Lemma existi_dec:forall(m:fmap)(z v:dart)(k:nat), (exists i:nat, (i < k)%nat /\ Iter (MA0.f m) i z = v) \/ (~exists i:nat, (i < k)%nat /\ Iter (MA0.f m) i z = v).
Lemma MA0_between_dec: forall(m:fmap)(z v t:dart), inv_hmap m -> exd m z -> (MA0.between m z v t \/ ~MA0.between m z v t).
Lemma betweene_bottom_x_top: forall(m:fmap)(x:dart), inv_hmap m -> succ m zero x -> betweene m (bottom m zero x) x (top m zero x).
Lemma cA_L_B_top_bot:forall(m:fmap)(k:dim)(x z:dart), inv_hmap m -> succ m k x -> cA (L (B m k x) k (top m k x) (bottom m k x)) k z = cA m k z.
Lemma cA_L_B_top_bot_ter:forall(m:fmap)(k:dim)(x z:dart), inv_hmap m -> succ m k x -> let k1 := dim_opp k in cA (L (B m k x) k (top m k x) (bottom m k x)) k1 z = cA m k1 z.
Lemma A_L_B_top_bot:forall(m:fmap)(k:dim)(x z:dart), inv_hmap m -> succ m k x -> A (L (B m k x) k (top m k x) (bottom m k x)) k z = if eq_dart_dec x z then nil else if eq_dart_dec (top m k x) z then (bottom m k x) else A m k z.
Lemma A_L_B_top_bot_ter:forall(m:fmap)(k:dim)(x z:dart), inv_hmap m -> succ m k x -> let k1:=dim_opp k in A (L (B m k x) k (top m k x) (bottom m k x)) k1 z = A m k1 z.
Lemma cA_1_L_B_top_bot:forall(m:fmap)(k:dim)(x z:dart), inv_hmap m -> succ m k x -> cA_1 (L (B m k x) k (top m k x) (bottom m k x)) k z = cA_1 m k z.
Lemma cA_1_L_B_top_bot_ter:forall(m:fmap)(k:dim)(x z:dart), inv_hmap m -> succ m k x -> let k1 := dim_opp k in cA_1 (L (B m k x) k (top m k x) (bottom m k x)) k1 z = cA_1 m k1 z.
Lemma A_1_L_B_top_bot:forall(m:fmap)(k:dim)(x z:dart), inv_hmap m -> succ m k x -> A_1 (L (B m k x) k (top m k x) (bottom m k x)) k z = if eq_dart_dec (A m k x) z then nil else if eq_dart_dec (bottom m k x) z then (top m k x) else A_1 m k z.
Lemma A_1_L_B_top_bot_ter:forall(m:fmap)(k:dim)(x z:dart), inv_hmap m -> succ m k x -> let k1:=dim_opp k in A_1 (L (B m k x) k (top m k x) (bottom m k x)) k1 z = A_1 m k1 z.
Lemma inv_hmap_L_B_top_bot:forall(m:fmap)(k:dim)(x:dart), inv_hmap m -> succ m k x -> inv_hmap (L (B m k x) k (top m k x) (bottom m k x)).
Lemma exd_L_B_top_bot: forall(m:fmap)(k:dim)(x z:dart), exd m z <-> exd (L (B m k x) k (top m k x) (bottom m k x)) z.
Lemma planar_L_B_top_bot_0:forall(m:fmap)(x:dart), inv_hmap m -> succ m zero x -> planar m -> planar (L (B m zero x) zero (top m zero x) (bottom m zero x)).
Lemma between_bottom_x_top: forall(m:fmap)(x:dart), inv_hmap m -> succ m zero x -> betweene m (bottom m zero x) x (top m zero x).
Lemma bottom_L_B_top_bot: forall(m:fmap)(x z:dart)(H:inv_hmap m), succ m zero x -> exd m z -> x <> z -> let m0:= L (B m zero x) zero (top m zero x) (bottom m zero x) in bottom m0 zero z = if MA0.expo_dec m x z H then (A m zero x) else bottom m zero z.
Lemma top_L_B_top_bot:forall(m:fmap)(x z:dart)(H:inv_hmap m), succ m zero x -> exd m z -> x <> z -> let m0:= L (B m zero x) zero (top m zero x) (bottom m zero x) in top m0 zero z = if MA0.expo_dec m x z H then x else top m zero z.
Lemma cF_L_B_top_bot:forall(m:fmap)(k:dim)(x z:dart), inv_hmap m -> succ m k x -> cF (L (B m k x) k (top m k x) (bottom m k x)) z = cF m z.
Lemma cF_1_L_B_top_bot:forall(m:fmap)(k:dim)(x z:dart), inv_hmap m -> succ m k x -> cF_1 (L (B m k x) k (top m k x) (bottom m k x)) z = cF_1 m z.
Lemma Iter_f_L_B: forall(m:fmap)(k:dim)(x z:dart)(i:nat), inv_hmap m -> succ m k x -> let m0:= L (B m k x) k (top m k x) (bottom m k x) in Iter (MF.f m0) i z = Iter (MF.f m) i z.
Lemma expf_L_B_top_bot:forall(m:fmap)(k:dim)(x z t:dart), inv_hmap m -> succ m k x -> (expf (L (B m k x) k (top m k x) (bottom m k x)) z t <-> expf m z t).
Lemma nc_L_B_top_bot :forall(m:fmap)(k:dim)(x:dart), inv_hmap m -> succ m k x -> let m0:= L (B m k x) k (top m k x) (bottom m k x) in nc m0 = nc m.
Lemma eqc_L_B_top_bot:forall (m:fmap)(k:dim)(x z t:dart), inv_hmap m -> succ m k x -> let m0:= L (B m k x) k (top m k x) (bottom m k x) in eqc m0 z t <-> eqc m z t.
Lemma MA0_f_cA0:forall(m:fmap)(z:dart), MA0.f m z = cA m zero z.
Lemma Iter_cA0_L_B: forall(m:fmap)(k:dim)(x z:dart)(i:nat), inv_hmap m -> succ m k x -> let m0:= L (B m k x) k (top m k x) (bottom m k x) in Iter (MA0.f m0) i z = Iter (MA0.f m) i z.
Lemma expe_L_B_top_bot:forall (m:fmap)(x z t:dart), inv_hmap m -> succ m zero x -> let m0:= L (B m zero x) zero (top m zero x) (bottom m zero x) in expe m0 z t <-> expe m z t.