(*========================================================== 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.
(* Notations ? Notation "A~" := cA.  Notation "A_1~" := cA_1.  Notation "A~" := cA.  Notation "A_1~" := cA_1. *)
(* In fact, a qhmap m equipped with (cA m di0) and (cA m di1) is a hmap: cf. below. *)
(* Each dart of an fmap has a succ and a pred in the closure: *)

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).