(*==========================================================
       I- AND L-PRECONDITIONS, QUASI-HMAPS
==========================================================*)

(* For a unique insertion of a non nil dart
in a (future) qhmap: *)

Definition prec_I (m:fmap)(x:dart):=
  x <> nil /\ ~ exd m x .(* For correctness of functional link insertion, maybe incomplete, in a (future) qhmap: *)

Definition prec_Lq (m:fmap)(k:dim)(x y:dart) :=
  exd m x /\ exd m y /\ ~ succ m k x /\ ~ pred m k y.(* Quasi-map's topological invariant: in 2 parts *)

Fixpoint inv_qhmap(m:fmap){struct m}:Prop:=
  match m with
      V => True
    | I m0 x0 => inv_qhmap m0
         /\ prec_I m0 x0
    | L m0 k0 x0 y0 => inv_qhmap m0
         /\ prec_Lq m0 k0 x0 y0
  end.(* Definition of the qhmap type: (not used) *)

Definition qhmap:Set := {m:fmap | inv_qhmap m}.(* Projection of a qhmap to its fmap support: *)

Definition qhmap_to_fmap(q:qhmap):fmap:=
  match q with exist m _=> m end.

(* Specifications: *)
Lemma not_exd_nil : forall m:fmap, inv_qhmap m -> ~ exd m nil.
Lemma exd_not_nil : forall (m:fmap)(x:dart), inv_qhmap m -> exd m x -> x <> nil.
Lemma succ_exd : forall (m:fmap)(k:dim)(x:dart), inv_qhmap m -> succ m k x -> exd m x.
Lemma pred_exd : forall (m:fmap)(k:dim)(x:dart), inv_qhmap m -> pred m k x -> exd m x.
Lemma not_exd_A_nil: forall (m:fmap)(k:dim)(x:dart), inv_qhmap m -> ~ exd m x -> A m k x = nil.
Lemma not_exd_A_1_nil: forall (m:fmap)(k:dim)(x:dart), inv_qhmap m -> ~ exd m x -> A_1 m k x = nil.
Lemma A_nil: forall (m:fmap)(k:dim), inv_qhmap m -> A m k nil = nil.
Lemma A_1_nil: forall (m:fmap)(k:dim), inv_qhmap m -> A_1 m k nil = nil.
Lemma succ_exd_A : forall (m:fmap)(k:dim)(x:dart), inv_qhmap m -> succ m k x -> exd m (A m k x).
Lemma pred_exd_A_1 : forall (m:fmap)(k:dim)(x:dart), inv_qhmap m -> pred m k x -> exd m (A_1 m k x).
Lemma exd_A_exd : forall (m : fmap) (k : dim) (x : dart), inv_qhmap m -> exd m (A m k x) -> exd m x.
Lemma exd_A_1_exd : forall (m : fmap) (k : dim) (x : dart), inv_qhmap m -> exd m (A_1 m k x) -> exd m x.
Lemma A_A_1 : forall (m:fmap)(k:dim)(x y:dart), inv_qhmap m -> exd m x -> exd m y -> y = A m k x -> x = A_1 m k y.
Lemma A_1_A : forall (m:fmap)(k:dim)(x y:dart), inv_qhmap m -> exd m x -> exd m y -> x = A_1 m k y -> y = A m k x.