(*========================================================== ============================================================ TOPOLOGICAL FMAPS, QHMAPS, HMAPS -  PROOF OF EULER RELATION AND GENUS THEOREM  PART 2: CLOSURE OF QHMAPS, FACES, PATHS  (J.-F. Dufourd, June 2006 - FOR PUBLICATION completed in October 2007)  ============================================================ ==========================================================*)
(*========================================================== CLOSURE of qhmap ==========================================================*)
Require Export Euler1.
(* Closure designed for qhmaps, but written on fmaps, as usual: *)
Fixpoint clos(m:fmap):fmap:=
match m with
V => V
| I m0 x0 =>
i (clos m0) x0
| L m0 k x0 y0 =>
let mr:= clos m0 in
if eq_dart_dec y0 (A mr k x0)
then mr
else l mr k x0 y0
end.
(* Preservation of the dart set in the closure: *)
(* Two corollaries more usable: *)
(* The closure is a true hypermap: *)
(* IDENTITY between A, A_1 on the closure and the closure of A, A_1: *)
(*======================================================== FACE OPERATIONS IN QHMAPS ========================================================*)
(* The following operations are designed for qhmaps, but are defined on fmap for convenience *)
(* Successor F in a face - direct version, designed for qhmaps: *)
Definition F(m:fmap)(x:dart):=
A_1 m di1 (A_1 m di0 x).
(* To have a successor in a (direct) face for x: *)
Definition succf(m:fmap)(x:dart):Prop:=
pred m di0 x /\ pred m di1 (A_1 m di0 x).
(* Decidability of succf:*)
(* OK: *)
(* Predecessor in a face - direct version: *)
Definition F_1 (m:fmap)(x:dart):=
A m di0 (A m di1 x).
(* To have a predecessor in a (direct) face for x: *)
Definition predf(m:fmap)(y:dart):Prop:=
succ m di1 y /\ succ m di0 (A m di1 y).
(* Decidability of succf: *)
(* OK: *)
(* Idem: *)
(* OK: *)
(* Idem: *)
(* Idem: *)
(* OK: *)
(* F and F_1 are inverses of each other: *)
(* Idem: *)
(* Idem: *)
(*======================================================== PATHS IN FACES OF QHMAPS ========================================================*)
(* Existence of a REFLEXIVE path from a dart to another in a direct hmap face: *)
Fixpoint expf(m:fmap)(x y:dart){struct m}:Prop:=
match m with
V => False
|  I m0 x0 => expf m0 x y \/ x=x0 /\ y=x0
|  L m0 di0 x0 y0 =>
expf m0 x y
\/ let x_1 := A_1 m0 di1 x0 in
x_1<>nil /\ expf m0 x y0 /\ expf m0 x_1 y
|  L m0 di1 x0 y0 =>
expf m0 x y
\/ let y1 := A m0 di0 y0 in
y1<>nil /\ expf m0 x y1 /\ expf m0 x0 y
end.
(* Decidability of expf: OK *)
(* Reflexivity of expf:*)
(* Existence of two darts linked by expf: *)
(* Transitivity of expf: *)

Lemma trans_expf : forall(m:fmap)(x y z:dart),
expf m x y -> expf m y z -> expf m x z.