(*==========================================================
           CLOSURES of A AND A_1 IN qhmap
==========================================================*)

(* Closures of A and A_1, together designed for qhmaps,
mutually recursive: *)

Fixpoint cA
   (m:fmap)(k:dim)(x:dart){struct m}:dart:=
 match m with
     V => nil
  |  I m0 x0 =>
        if eq_dart_dec x x0 then x
	else cA m0 k x
  |  L m0 k0 x0 y0 =>
      if (eq_dim_dec k k0)
      then
         if (eq_dart_dec x x0) then y0
	 else
	   if (eq_dart_dec x (cA_1 m0 k y0))
	   then cA m0 k x0
	   else cA m0 k x
      else cA m0 k x
 end
with cA_1
   (m:fmap)(k:dim)(x:dart){struct m}:dart:=
 match m with
     V => nil
  |  I m0 x0 =>
        if eq_dart_dec x x0 then x
	else cA_1 m0 k x
  |  L m0 k0 x0 y0 =>
      if (eq_dim_dec k k0)
      then
         if (eq_dart_dec x y0) then x0
	 else
	   if (eq_dart_dec x (cA m0 k x0))
	   then cA_1 m0 k y0
	   else cA_1 m0 k x
      else cA_1 m0 k x
 end.

(* Specifications: *)
Lemma succ_pred_clos : forall (m:fmap)(k:dim)(z:dart), inv_qhmap m -> exd m z -> (cA m k z <> nil /\ cA_1 m k z <> nil).
Lemma exd_cA_cA_1 : forall (m:fmap)(k:dim)(z:dart), inv_qhmap m -> exd m z -> exd m (cA m k z) /\ exd m (cA_1 m k z).
Lemma cA_exd : forall (m:fmap)(k:dim)(z:dart), inv_qhmap m -> cA m k z <> nil -> exd m z.
Lemma cA_1_exd : forall (m:fmap)(k:dim)(z:dart), inv_qhmap m -> cA_1 m k z <> nil -> exd m z.
Lemma exd_cA_exd : forall (m:fmap)(k:dim)(z:dart), inv_qhmap m -> exd m (cA m k z) -> exd m z.
Lemma exd_cA_1_exd : forall (m:fmap)(k:dim)(z:dart), inv_qhmap m -> exd m (cA_1 m k z) -> exd m z.
Lemma cA_1_cA : forall (m:fmap)(k:dim)(z:dart), inv_qhmap m -> exd m z -> cA_1 m k (cA m k z) = z.
Lemma cA_cA_1 : forall (m:fmap)(k:dim)(z:dart), inv_qhmap m -> exd m z -> cA m k (cA_1 m k z) = z.
Lemma inj_cA: forall (m:fmap)(k:dim), inv_qhmap m -> inj_dart (exd m) (cA m k).
Lemma inj_cA_1: forall (m:fmap)(k:dim), inv_qhmap m -> inj_dart (exd m) (cA_1 m k).
Lemma fixpoint_cA_cA_1 : forall (m:fmap)(k:dim)(z:dart), inv_qhmap m -> exd m z -> ~succ m k z -> ~pred m k z -> cA m k z = z /\ cA_1 m k z = z.
Lemma A_cA : forall (m:fmap)(k:dim)(x y:dart), inv_qhmap m -> exd m x -> exd m y -> A m k x = y -> cA m k x = y.
Lemma A_1_cA_1 : forall (m:fmap)(k:dim)(x y:dart), inv_qhmap m -> exd m x -> exd m y -> A_1 m k x = y -> cA_1 m k x = y.
Lemma A_B : forall (m:fmap)(k:dim)(x:dart), inv_qhmap m -> A (B m k x) k x = nil.
Lemma A_B_bis : forall (m:fmap)(k:dim)(x y:dart), y<>x -> A (B m k x) k y = A m k y.
Lemma A_B_ter : forall (m:fmap)(k j:dim)(x y:dart), k<>j -> A (B m k x) j y = A m j y.
Lemma B_not_exd : forall (m:fmap)(k:dim)(x:dart), inv_qhmap m -> ~ exd m x -> B m k x = m.
Lemma B_nil : forall (m:fmap)(k:dim), inv_qhmap m -> B m k nil = m.
Lemma B_1_not_exd : forall (m:fmap)(k:dim)(x:dart), inv_qhmap m -> ~ exd m x -> B_1 m k x = m.
Lemma B_1_nil : forall (m:fmap)(k:dim), inv_qhmap m -> B_1 m k nil = m.
Lemma A_1_B : forall (m:fmap)(k:dim)(x:dart), inv_qhmap m -> A_1 (B m k x) k (A m k x) = nil.
Lemma A_1_B_bis : forall (m:fmap)(k:dim)(x y:dart), inv_qhmap m -> y <> A m k x -> A_1 (B m k x) k y = A_1 m k y.
Lemma A_1_B_ter : forall (m:fmap)(k j:dim)(x y:dart), k<>j -> A_1 (B m k x) j y = A_1 m j y.
Lemma A_1_B_1 : forall (m:fmap)(k:dim)(x:dart), inv_qhmap m -> A_1 (B_1 m k x) k x = nil.
Lemma A_1_B_1_bis : forall (m:fmap)(k:dim)(x y:dart), inv_qhmap m -> y <> x -> A_1 (B_1 m k x) k y = A_1 m k y.
Lemma A_1_B_1_ter : forall (m:fmap)(k j:dim)(x y:dart), k<>j -> A_1 (B_1 m k x) j y = A_1 m j y.
Lemma A_B_1 : forall (m:fmap)(k:dim)(x:dart), inv_qhmap m -> A (B_1 m k x) k (A_1 m k x) = nil.
Lemma A_B_1_bis : forall (m:fmap)(k:dim)(x y:dart), inv_qhmap m -> y <> A_1 m k x -> A (B_1 m k x) k y = A m k y.
Lemma A_B_1_ter : forall (m:fmap)(k j:dim)(x y:dart), k<>j -> A (B_1 m k x) j y = A m j y.
Lemma inv_qhmap_B : forall (m:fmap)(k:dim)(x:dart), inv_qhmap m -> inv_qhmap (B m k x).
Lemma inv_qhmap_B_1 : forall (m:fmap)(k:dim)(x:dart), inv_qhmap m -> inv_qhmap (B_1 m k x).