(*========================================================== ============================================================ AUGUST 2008 TOPOLOGICAL FMAPS, HMAPS - WITH EMBEDDINGS AND TAGS  (2008 RING FORMALIZATION)  PART 1: BASES, FMAPS, HMAPS, CLOSURES OF A, A_1  COMPLETE: OK! ============================================================ ==========================================================*)
(* cd Desktop/JFD/JFD08/GALAPAGOS/HMAPSTE_08 coqtop -opt *)
Global Set Asymmetric Patterns.
Require Export Reals.
Require Export Omega.
Open Scope R_scope.
(*======================================================== DIMENSIONS ========================================================*)
(* Dimensions: *)
Inductive dim:Set := zero : dim | one : dim.
(* Decidability of point equality: OK, but DANGEREOUS ! *)
(*======================================================== DARTS AS NATURALS ========================================================*)
(* For simplicity, dart is nat, but it could be a deferred type: *)
Definition dart := nat.
(* Decidability of dart equality: *)
Definition eq_dart_dec := eq_nat_dec.
(* Nil dart: *)
Definition nil := 0%nat.
(*======================================================== FREE MAPS, CONSTRUCTORS, OBSERVERS AND DESTRUCTORS ========================================================*)
Open Scope Z_scope.
(* Free maps: *)
Inductive fmap:Set :=
V : fmap
| I : fmap->dart->tag->point->fmap
| L : fmap->dim->dart->dart->fmap.
(* Map emptiness: *)
Definition empty(m:fmap): Prop:=
match m with
V => True
|  _ => False
end.
(* Map emptiness is decidable: *)
(* and the variant: *)
(* Relationship between succ and exd: *)
(* Idem: *)
(* Idem with: *)
(* Note that, in a hmap m, we have neither exd m z -> A m k z <> nil nor exd m z -> A_1 m k z <> nil *)
(* Note also: *)
(* Idem: *)
(* IDEM: *)
(*========================================================= A AND A_1 ARE INVERSES INJECTIONS IN A hmap: ==========================================================*)
(* In a qmap, A et A_1 are inverses: *)
(* Idem with A_1: *)
(* Partial injection on dart, Df giving the domain of f: *)
Definition inj_dart(Df:dart->Prop)(f:dart->dart):Prop:=
forall x x':dart,
(Df x)->(Df x')->(f x)=(f x')->x=x'.
(* (A m k) is an injection on (succ m k): OK *)
(* Idem, for pred and A_1: *)
(*========================================================== PROPERTIES of A and A_1 CLOSURES in hmap ==========================================================*)
(* Each existing dart has a succ in the k-closure : *)
(* Each dart of a fmap has a succ and a pred for the closure: *)
(* If the succ for cA is in the hmap, the initial dart also: *)
(* Idem for cA_1: *)
(* A non existing dart has a nil successor by cA: *)
(* Idem for cA_1: *)
(* Inverse for exd: *)
(* Idem: *)
(* Specializations: *)
(* cA and cA_1 are inverses of each other: *)
(* IDEM: *)
(* (cA m k) in an injection on (exd m): *)
(* Idem: cA_1 is an injection on exd: *)
(* Isolated darts are fixpoints for the closure:*)
(* Preservation of the existing successors in the closure: *)
(* IDEM: Preservation of the existing predecessors: *)
(* Definition of the notion of surjection on a domain: *)
Definition surj_dart(Df:dart->Prop)(f:dart->dart):Prop :=
forall y:dart, Df y ->
exists x : dart, Df x /\ f x = y.
(* (cA m k) is surjective on (exd m): *)
(* IDEM: *)
(* Notion of bijection: *)
Definition bij_dart(Df:dart->Prop)(f:dart->dart):Prop:=              inj_dart Df f /\ surj_dart Df f.
(* (cA m k) is bijective on (exd m): *)
(* IDEM: *)
(*========================================================== exd, A, A_1 on D for hmap ==========================================================*)
(* Action of D on exd: *)

Lemma exd_D : forall (m:fmap)(x z:dart),
inv_hmap m ->
x <> z -> (exd m z <-> exd (D m x) z).