(*==========================================================
============================================================
            TOPOLOGICAL FMAPS, QHMAPS, HMAPS -

       PROOFS OF THE GENUS THEOREM AND THE EULER RELATION 

                        PART 3:

  EQUIVALENCES, CHARACTERISTICS, GENUS, EULER_POINCARE, 
         CONSTRUCTIVE CONDITION OF PLANARITY 

       (J.-F. Dufourd - June 2006 - FOR PUBLICATION
        completed in October 2007 / January 2008)

(* COMPLETE, APART FROM LEMMA expf_clos_symm, WHICH IS 
ADMITTED TO PROVE THE NECESSARY CONDITION OF PLANARITY *)
============================================================
==========================================================*)

(*==========================================================
           DART EQUIVALENCES IN QHMAPS
==========================================================*)

Require Export Euler2.

(* Face equivalence: *)

Definition eqf(m:fmap)(x y:dart):=
  expf m x y \/ expf m y x.

(* Reflexivity of eqf: *)

Lemma refl_eqf : forall (m:fmap)(x:dart),
  exd m x -> eqf m x x.
Proof.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: forall (m : fmap) (x y : dart), sumbool (eqf m x y) (not (eqf m x y)) *)
unfold eqf in |- *.
(* Goal: or (expf m x x) (expf m x x) *)
assert (expf m x x).
(* Goal: expf m d0 d0 *)
(* Goal: forall (_ : not (@eq nat (A_1 m di0 x) d1)) (_ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (A_1 m di0 x)) nil))), or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (A_1 m di1 (A_1 m di0 x))))) *)
 apply refl_expf.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: inv_qhmap m *)
 tauto.
Qed.

(* Symmetry of eqf: *)

Lemma symm_eqf : forall (m:fmap)(x y:dart),
  eqf m x y -> eqf m y x.
Proof.
(* Goal: forall (m : fmap) (x y : dart), sumbool (eqf m x y) (not (eqf m x y)) *)
unfold eqf in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: inv_qhmap m *)
tauto.
Qed.

(* Transitivity of eqf: *)

Lemma trans_eqf : forall (m:fmap),
  inv_qhmap m -> forall (x y z:dart),
  eqf m x y -> eqf m y z -> eqf m x z.
Proof.
(* Goal: forall (m : fmap) (x y : dart), sumbool (eqf m x y) (not (eqf m x y)) *)
unfold eqf in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
elim H0.
(* Goal: or (and (@eq dart (A_1 m k x) d) (@eq dart y d)) (eqc m (A_1 m k x) y) *)
(* Goal: or (and (@eq dart (A_1 m k x) d) (@eq dart y d)) (eqc m (A_1 m k x) y) *)
(* Goal: forall (_ : inv_qhmap (L m d d0 d1)) (k : dim) (x y : dart) (_ : eqc (L m d d0 d1) x y) (_ : pred (L m d d0 d1) k x), eqc (L m d d0 d1) (A_1 (L m d d0 d1) k x) y *)
 elim H1.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
  left.
    apply trans_expf with y.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
    eapply diff2_expf.
(* Goal: inv_qhmap m *)
   tauto.
   apply H3.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: or (and (@eq dart (A_1 m k x) d) (@eq dart y d)) (eqc m (A_1 m k x) y) *)
(* Goal: or (and (@eq dart (A_1 m k x) d) (@eq dart y d)) (eqc m (A_1 m k x) y) *)
(* Goal: forall (_ : inv_qhmap (L m d d0 d1)) (k : dim) (x y : dart) (_ : eqc (L m d d0 d1) x y) (_ : pred (L m d d0 d1) k x), eqc (L m d d0 d1) (A_1 (L m d d0 d1) k x) y *)
 elim H1.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
    eapply diff1_expf.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: inv_qhmap m *)
   apply H3; tauto.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  right.
    eapply trans_expf with y.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: inv_qhmap m *)
   tauto.
Qed.

(* Decidability of eqf: *)

Lemma eqf_dec : forall (m:fmap)(x y:dart),
  {eqf m x y} + {~eqf m x y}.
Proof.
(* Goal: forall (m : fmap) (x y : dart), sumbool (eqf m x y) (not (eqf m x y)) *)
unfold eqf in |- *.
(* Goal: forall (m : fmap) (x y : dart), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
intros m x y.
(* Goal: sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
generalize (expf_dec m x y).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
intro.
(* Goal: or (eqc m y x) (or (and (eqc m y d0) (eqc m d1 x)) (and (eqc m y d1) (eqc m d0 x))) *)
elim H.
(* Goal: inv_qhmap m *)
 tauto.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
 generalize (expf_dec m y x).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   intro.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
   elim H0.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: inv_qhmap m *)
  tauto.
Qed.

(* Connectivity : Definition in Prop "a la" Warshall *)

Fixpoint eqc(m:fmap)(x y:dart){struct m}:Prop:=
 match m with
     V => False
  |  I m0 x0 => x=x0 /\ y=x0 \/ eqc m0 x y
  |  L m0 _ x0 y0 =>
      eqc m0 x y
     \/ eqc m0 x x0 /\ eqc m0 y0 y
     \/ eqc m0 x y0 /\ eqc m0 x0 y
 end.

(* Decidability of eqc: *)

Lemma eqc_dec : forall (m:fmap)(x y:dart),
   {eqc m x y} + {~eqc m x y}.
Proof.
(* Goal: plf m *)
induction m.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
(* Goal: sumbool (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y)))) (not (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y))))) *)
   elim (IHm x y).
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: forall _ : not (eqc m x y), sumbool (or (and (@eq dart x d) (@eq dart y d)) (eqc m x y)) (not (or (and (@eq dart x d) (@eq dart y d)) (eqc m x y))) *)
(* Goal: forall x y : dart, sumbool (eqc (L m d d0 d1) x y) (not (eqc (L m d d0 d1) x y)) *)
  elim (eq_dart_dec x d).
(* Goal: forall (_ : @eq nat x d) (_ : not (eqc m x y)), sumbool (or (and (@eq dart x d) (@eq dart y d)) (eqc m x y)) (not (or (and (@eq dart x d) (@eq dart y d)) (eqc m x y))) *)
(* Goal: forall (_ : not (@eq nat x d)) (_ : not (eqc m x y)), sumbool (or (and (@eq dart x d) (@eq dart y d)) (eqc m x y)) (not (or (and (@eq dart x d) (@eq dart y d)) (eqc m x y))) *)
(* Goal: forall x y : dart, sumbool (eqc (L m d d0 d1) x y) (not (eqc (L m d d0 d1) x y)) *)
   elim (eq_dart_dec y d).
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: forall x y : dart, sumbool (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y)))) (not (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y))))) *)
   intros x y.
(* Goal: sumbool (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y)))) (not (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y))))) *)
   elim (IHm x y).
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: forall _ : not (eqc m x y), sumbool (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y)))) (not (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y))))) *)
  elim (IHm x d0).
(* Goal: forall (_ : not (eqc m x d0)) (_ : not (eqc m x y)), sumbool (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y)))) (not (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y))))) *)
   elim (IHm d1 y).
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall (_ : not (eqc m d1 y)) (_ : not (eqc m x d0)) (_ : not (eqc m x y)), sumbool (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y)))) (not (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y))))) *)
    elim (IHm x d1).
(* Goal: forall (_ : not (eqc m x d1)) (_ : not (eqc m d1 y)) (_ : not (eqc m x d0)) (_ : not (eqc m x y)), sumbool (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y)))) (not (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y))))) *)
     elim (IHm d0 y).
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (_ : not (eqc m x d0)) (_ : not (eqc m x y)), sumbool (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y)))) (not (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y))))) *)
   elim (IHm d1 y).
(* Goal: forall (_ : not (eqc m d1 y)) (_ : not (eqc m x d0)) (_ : not (eqc m x y)), sumbool (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y)))) (not (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y))))) *)
    elim (IHm x d1).
(* Goal: forall (_ : not (eqc m x d1)) (_ : not (eqc m d1 y)) (_ : not (eqc m x d0)) (_ : not (eqc m x y)), sumbool (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y)))) (not (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y))))) *)
     elim (IHm d0 y).
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (_ : not (eqc m d1 y)) (_ : not (eqc m x d0)) (_ : not (eqc m x y)), sumbool (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y)))) (not (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y))))) *)
    elim (IHm x d1).
(* Goal: forall (_ : not (eqc m x d1)) (_ : not (eqc m d1 y)) (_ : not (eqc m x d0)) (_ : not (eqc m x y)), sumbool (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y)))) (not (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y))))) *)
     elim (IHm d0 y).
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: forall (_ : not (eqc m x d1)) (_ : not (eqc m d1 y)) (_ : not (eqc m x d0)) (_ : not (eqc m x y)), sumbool (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y)))) (not (or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y))))) *)
     elim (IHm d0 y).
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
      tauto.
Qed.

(* Reflexivity of eqc: *)

Lemma refl_eqc: forall(m:fmap)(x:dart),
   exd m x -> eqc m x x.
Proof.
(* Goal: plf m *)
induction m.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
(* Goal: or (eqc m y x) (or (and (eqc m y d0) (eqc m d1 x)) (and (eqc m y d1) (eqc m d0 x))) *)
   elim H.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  right.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
    apply IHm.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
   left.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
   apply IHm.
(* Goal: inv_qhmap m *)
   tauto.
Qed.

(* Symmetry of eqc: *)

Lemma symm_eqc: forall(m:fmap)(x y:dart),
   eqc m x y -> eqc m y x.
Proof.
(* Goal: plf m *)
induction m.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
(* Goal: or (eqc m y x) (or (and (eqc m y d0) (eqc m d1 x)) (and (eqc m y d1) (eqc m d0 x))) *)
   elim H.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
  intro.
(* Goal: or (and (@eq dart y d) (@eq dart x d)) (eqc m y x) *)
(* Goal: forall (x y : dart) (_ : eqc (L m d d0 d1) x y), eqc (L m d d0 d1) y x *)
    generalize (IHm x y).
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
(* Goal: or (eqc m y x) (or (and (eqc m y d0) (eqc m d1 x)) (and (eqc m y d1) (eqc m d0 x))) *)
   elim H.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
  left.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
    apply IHm.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: @eq Z (genus m) Z0 *)
  clear H.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    intro.
(* Goal: or (eqc m y x) (or (and (eqc m y d0) (eqc m d1 x)) (and (eqc m y d1) (eqc m d0 x))) *)
    elim H.
(* Goal: @eq Z (genus m) Z0 *)
   clear H.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     right.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     right.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
     split.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
    apply IHm.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
    apply IHm.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     right.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
     left.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
     split.
(* Goal: inv_qhmap m *)
    apply IHm; tauto.
(* Goal: inv_qhmap m *)
    apply IHm; tauto.
Qed.

(* Transitivity of eqc: *)

Lemma trans_eqc: forall(m:fmap)(x y z:dart),
   eqc m x y -> eqc m y z -> eqc m x z.
Proof.
(* Goal: plf m *)
induction m.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
(* Goal: or (eqc m y x) (or (and (eqc m y d0) (eqc m d1 x)) (and (eqc m y d1) (eqc m d0 x))) *)
   elim H.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
  elim H0.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   intro.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
     intros.
(* Goal: planar (L m di1 x y) *)
     elim H2.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
     intros.
     rewrite H3.
     rewrite H4 in H1.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
    elim H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   intro.
(* Goal: planar (L m di1 x y) *)
     elim H2.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
     intros.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
     rewrite H4.
     rewrite H3 in H1.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   right.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
     eapply IHm.
(* Goal: plf m *)
    apply H1.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
(* Goal: or (eqc m y x) (or (and (eqc m y d0) (eqc m d1 x)) (and (eqc m y d1) (eqc m d0 x))) *)
   elim H.
(* Goal: @eq Z (genus m) Z0 *)
  clear H.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
    elim H0.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
   clear H0.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
     left.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
     eapply IHm.
    apply H0.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
   clear H0.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
     intros.
(* Goal: or (eqc m y x) (or (and (eqc m y d0) (eqc m d1 x)) (and (eqc m y d1) (eqc m d0 x))) *)
     elim H.
(* Goal: @eq Z (genus m) Z0 *)
    clear H.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
      intro.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
      right.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
      left.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
      split.
     apply (IHm x y d0).
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    intro.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
      right.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
      right.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
      split.
     apply (IHm x y d1).
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: @eq Z (genus m) Z0 *)
  clear H.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    intro.
(* Goal: or (eqc m y x) (or (and (eqc m y d0) (eqc m d1 x)) (and (eqc m y d1) (eqc m d0 x))) *)
    elim H.
(* Goal: @eq Z (genus m) Z0 *)
   clear H.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
     elim H0.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
    clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
      intro.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
      right.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
      left.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
      split.
(* Goal: inv_qhmap m *)
     tauto.
     apply (IHm d1 y z).
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
    intros.
(* Goal: or (and (@eq dart (A_1 m k x) d) (@eq dart y d)) (eqc m (A_1 m k x) y) *)
(* Goal: or (and (@eq dart (A_1 m k x) d) (@eq dart y d)) (eqc m (A_1 m k x) y) *)
(* Goal: forall (_ : inv_qhmap (L m d d0 d1)) (k : dim) (x y : dart) (_ : eqc (L m d d0 d1) x y) (_ : pred (L m d d0 d1) k x), eqc (L m d d0 d1) (A_1 (L m d d0 d1) k x) y *)
      elim H1.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
     intros.
       clear H1.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
       right.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
       left.
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
       clear H1.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
       left.
       apply (IHm x d0 z).
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   intro.
(* Goal: @eq Z (genus m) Z0 *)
     clear H.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
     elim H0.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
    clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
      intro.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
      right.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
      right.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
      split.
(* Goal: inv_qhmap m *)
     tauto.
     apply (IHm d0 y z).
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
    clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
      intro.
(* Goal: or (eqc m y x) (or (and (eqc m y d0) (eqc m d1 x)) (and (eqc m y d1) (eqc m d0 x))) *)
      elim H.
(* Goal: @eq Z (genus m) Z0 *)
     clear H.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
       intro.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
       left.
       apply (IHm x d1 z).
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
(* Goal: @eq Z (genus m) Z0 *)
       clear H.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
       right.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
       right.
(* Goal: inv_qhmap m *)
       tauto.
Qed.

(* LEMMAS, USED IN THE FOLLOWING: *)

Lemma succ_eqc_A_r : forall m:fmap,
 inv_qhmap m ->
  forall (k:dim)(x:dart),
      succ m k x -> eqc m x (A m k x).
Proof.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: plf m *)
induction m.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: eqc (L m d d0 d1) x (A (L m d d0 d1) k x) *)
   unfold succ in H0.
(* Goal: or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (@eq dart x d) (@eq dart (A_1 m di1 (A_1 m di0 x)) d)) *)
(* Goal: forall (x : dart) (_ : inv_qhmap (L m d d0 d1)) (_ : succf (L m d d0 d1) x), expf (L m d d0 d1) x (F (L m d d0 d1) x) *)
   simpl in H0.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: eqc (L m d d0 d1) x (A (L m d d0 d1) k x) *)
 unfold succ in H0.
(* Goal: or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (@eq dart x d) (@eq dart (A_1 m di1 (A_1 m di0 x)) d)) *)
(* Goal: forall (x : dart) (_ : inv_qhmap (L m d d0 d1)) (_ : succf (L m d d0 d1) x), expf (L m d d0 d1) x (F (L m d d0 d1) x) *)
   simpl in H0.
(* Goal: plf (L m di1 d0 d1) *)
   simpl in |- *.
(* Goal: or (and (@eq dart x d) (@eq dart (A_1 m k x) d)) (eqc m x (A_1 m k x)) *)
(* Goal: eqc (L m d d0 d1) x (A_1 (L m d d0 d1) k x) *)
   unfold inv_qhmap in H.
(* Goal: or (and (@eq dart x d) (@eq dart (A_1 m k x) d)) (eqc m x (A_1 m k x)) *)
(* Goal: eqc (L m d d0 d1) x (A_1 (L m d d0 d1) k x) *)
   fold inv_qhmap in H.
(* Goal: or (and (@eq dart x d) (@eq dart (A_1 m k x) d)) (eqc m x (A_1 m k x)) *)
(* Goal: eqc (L m d d0 d1) x (A_1 (L m d d0 d1) k x) *)
   unfold prec_I in H.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   right.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
   apply IHm.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: succ m k x *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A m k x) nil)), or (eqc m x (A m k x)) (or (and (eqc m x d0) (eqc m d1 (A m k x))) (and (eqc m x d1) (eqc m d0 (A m k x)))) *)
  unfold succ in |- *.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: inv_qhmap m *)
(* Goal: @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
 simpl in H.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   unfold prec_Lq in H.
(* Goal: eqc (L m d d0 d1) x (A (L m d d0 d1) k x) *)
   unfold succ in H0.
(* Goal: or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (@eq dart x d) (@eq dart (A_1 m di1 (A_1 m di0 x)) d)) *)
(* Goal: forall (x : dart) (_ : inv_qhmap (L m d d0 d1)) (_ : succf (L m d d0 d1) x), expf (L m d d0 d1) x (F (L m d d0 d1) x) *)
   simpl in H0.
(* Goal: or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
   generalize H0.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
   clear H0.
(* Goal: @eq Z (genus m) Z0 *)
   decompose [and] H.
(* Goal: @eq Z (genus m) Z0 *)
   clear H.
(* Goal: plf (L m di1 d0 d1) *)
   simpl in |- *.
(* Goal: forall _ : not (@eq dart (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) nil), or (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) y) (or (and (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) d1) (eqc m d0 y))) *)
   elim (eq_dim_dec k d).
(* Goal: forall (_ : @eq dim k d) (_ : not (@eq dart (if eq_dart_dec x d0 then d1 else A m k x) nil)), or (eqc m x (if eq_dart_dec x d0 then d1 else A m k x)) (or (and (eqc m x d0) (eqc m d1 (if eq_dart_dec x d0 then d1 else A m k x))) (and (eqc m x d1) (eqc m d0 (if eq_dart_dec x d0 then d1 else A m k x)))) *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A m k x) nil)), or (eqc m x (A m k x)) (or (and (eqc m x d0) (eqc m d1 (A m k x))) (and (eqc m x d1) (eqc m d0 (A m k x)))) *)
  elim (eq_dart_dec x d0).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
(* Goal: expf m x d1 *)
(* Goal: expf m (A_1 m di1 d0) (A_1 m di1 d0) *)
(* Goal: forall (_ : not (@eq nat x d1)) (_ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (A_1 m di0 x)) nil))), or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A_1 m di1 d0) nil)) (and (expf m x d1) (expf m (A_1 m di1 d0) (A_1 m di1 (A_1 m di0 x))))) *)
(* Goal: forall (x : dart) (_ : and (inv_qhmap m) (and (exd m d0) (and (exd m d1) (and (not (succ m di1 d0)) (not (not (@eq dart (A_1 m di1 d1) nil))))))) (_ : and (not (@eq dart (A_1 (L m di1 d0 d1) di0 x) nil)) (not (@eq dart (A_1 (L m di1 d0 d1) di1 (A_1 (L m di1 d0 d1) di0 x)) nil))), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
     rewrite a.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     right.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
     left.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
     split.
(* Goal: eqc m d0 d0 *)
(* Goal: eqc m d1 y *)
(* Goal: or (eqc m d0 y) (or (and (eqc m d0 d0) (eqc m d1 y)) (and (eqc m d0 d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq nat x d1)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
    apply refl_eqc.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: eqc m d0 d0 *)
(* Goal: eqc m d1 y *)
(* Goal: or (eqc m d0 y) (or (and (eqc m d0 d0) (eqc m d1 y)) (and (eqc m d0 d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq nat x d1)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
    apply refl_eqc.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
     left.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
     apply IHm.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: succ m k x *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A m k x) nil)), or (eqc m x (A m k x)) (or (and (eqc m x d0) (eqc m d1 (A m k x))) (and (eqc m x d1) (eqc m d0 (A m k x)))) *)
    unfold succ in |- *.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
    left.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
    apply IHm.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: inv_qhmap m *)
   unfold succ in |- *; tauto.
Qed.

(* Idem, for A_1: *)

Lemma pred_eqc_A_1_r : forall m:fmap, inv_qhmap m ->
 forall (k:dim)(x:dart),
     pred m k x -> eqc m x (A_1 m k x).
Proof.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: plf m *)
induction m.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: eqc (L m d d0 d1) x (A_1 (L m d d0 d1) k x) *)
   unfold pred in H0.
(* Goal: or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (@eq dart x d) (@eq dart (A_1 m di1 (A_1 m di0 x)) d)) *)
(* Goal: forall (x : dart) (_ : inv_qhmap (L m d d0 d1)) (_ : succf (L m d d0 d1) x), expf (L m d d0 d1) x (F (L m d d0 d1) x) *)
   simpl in H0.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: eqc (L m d d0 d1) x (A_1 (L m d d0 d1) k x) *)
unfold pred in H0.
(* Goal: or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (@eq dart x d) (@eq dart (A_1 m di1 (A_1 m di0 x)) d)) *)
(* Goal: forall (x : dart) (_ : inv_qhmap (L m d d0 d1)) (_ : succf (L m d d0 d1) x), expf (L m d d0 d1) x (F (L m d d0 d1) x) *)
  simpl in H0.
(* Goal: plf (L m di1 d0 d1) *)
  simpl in |- *.
(* Goal: or (and (@eq dart x d) (@eq dart (A_1 m k x) d)) (eqc m x (A_1 m k x)) *)
(* Goal: eqc (L m d d0 d1) x (A_1 (L m d d0 d1) k x) *)
  unfold inv_qhmap in H.
(* Goal: or (and (@eq dart x d) (@eq dart (A_1 m k x) d)) (eqc m x (A_1 m k x)) *)
(* Goal: eqc (L m d d0 d1) x (A_1 (L m d d0 d1) k x) *)
  fold inv_qhmap in H.
(* Goal: or (and (@eq dart x d) (@eq dart (A_1 m k x) d)) (eqc m x (A_1 m k x)) *)
(* Goal: eqc (L m d d0 d1) x (A_1 (L m d d0 d1) k x) *)
  unfold prec_I in H.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  right.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
  apply IHm.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
unfold pred in |- *.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: inv_qhmap m *)
(* Goal: @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
simpl in H.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  unfold prec_Lq in H.
(* Goal: eqc (L m d d0 d1) x (A_1 (L m d d0 d1) k x) *)
  unfold pred in H0.
(* Goal: or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (@eq dart x d) (@eq dart (A_1 m di1 (A_1 m di0 x)) d)) *)
(* Goal: forall (x : dart) (_ : inv_qhmap (L m d d0 d1)) (_ : succf (L m d d0 d1) x), expf (L m d d0 d1) x (F (L m d d0 d1) x) *)
  simpl in H0.
(* Goal: or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  generalize H0.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  clear H0.
(* Goal: @eq Z (genus m) Z0 *)
  decompose [and] H.
(* Goal: @eq Z (genus m) Z0 *)
  clear H.
(* Goal: plf (L m di1 d0 d1) *)
  simpl in |- *.
(* Goal: forall _ : not (@eq dart (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) nil), or (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) y) (or (and (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) d1) (eqc m d0 y))) *)
  elim (eq_dim_dec k d).
(* Goal: forall _ : and (not (@eq dart (if eq_dart_dec x d1 then d0 else A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (if eq_dart_dec x d1 then d0 else A_1 m di0 x)) nil)), or (expf m x (A_1 m di1 (if eq_dart_dec x d1 then d0 else A_1 m di0 x))) (and (not (@eq dart (A_1 m di1 d0) nil)) (and (expf m x d1) (expf m (A_1 m di1 d0) (A_1 m di1 (if eq_dart_dec x d1 then d0 else A_1 m di0 x))))) *)
(* Goal: forall (x : dart) (_ : and (inv_qhmap m) (and (exd m d0) (and (exd m d1) (and (not (succ m di1 d0)) (not (not (@eq dart (A_1 m di1 d1) nil))))))) (_ : and (not (@eq dart (A_1 (L m di1 d0 d1) di0 x) nil)) (not (@eq dart (A_1 (L m di1 d0 d1) di1 (A_1 (L m di1 d0 d1) di0 x)) nil))), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
 elim (eq_dart_dec x d1).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
(* Goal: expf m x d1 *)
(* Goal: expf m (A_1 m di1 d0) (A_1 m di1 d0) *)
(* Goal: forall (_ : not (@eq nat x d1)) (_ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (A_1 m di0 x)) nil))), or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A_1 m di1 d0) nil)) (and (expf m x d1) (expf m (A_1 m di1 d0) (A_1 m di1 (A_1 m di0 x))))) *)
(* Goal: forall (x : dart) (_ : and (inv_qhmap m) (and (exd m d0) (and (exd m d1) (and (not (succ m di1 d0)) (not (not (@eq dart (A_1 m di1 d1) nil))))))) (_ : and (not (@eq dart (A_1 (L m di1 d0 d1) di0 x) nil)) (not (@eq dart (A_1 (L m di1 d0 d1) di1 (A_1 (L m di1 d0 d1) di0 x)) nil))), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
    rewrite a in |- *.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    right.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    right.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
    split.
(* Goal: eqc m d0 d0 *)
(* Goal: eqc m d1 y *)
(* Goal: or (eqc m d0 y) (or (and (eqc m d0 d0) (eqc m d1 y)) (and (eqc m d0 d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq nat x d1)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
   apply refl_eqc.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: eqc m d0 d0 *)
(* Goal: eqc m d1 y *)
(* Goal: or (eqc m d0 y) (or (and (eqc m d0 d0) (eqc m d1 y)) (and (eqc m d0 d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq nat x d1)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
  apply refl_eqc.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
 intros.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
   left.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
   apply IHm.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 unfold pred in |- *.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
  left.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
  apply IHm.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
unfold pred in |- *.  
(* Goal: inv_qhmap m *)
tauto.
Qed.

(* OK: *)

Lemma eqc_eqc_A_1_l : forall m:fmap, inv_qhmap m ->
 forall (k:dim)(x y:dart),
   eqc m x y -> pred m k x -> eqc m (A_1 m k x) y.
Proof.
(* Goal: plf m *)
induction m.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: forall (m : fmap) (x : dart) (_ : inv_qhmap m) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : prec_I m x), @eq Z (Z.sub (Z.add (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.add (nv m) (Zpos xH)) (Z.add (ne m) (Zpos xH))) (Z.add (nf m) (Zpos xH))) (Z.add (nd m) (Zpos xH))) (Zpos (xO xH)))) Z0 *)
   unfold prec_I in |- *.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   unfold pred in |- *.
(* Goal: plf (L m di1 d0 d1) *)
   simpl in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   elim H0; clear H0; intro.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  decompose [and] H0; clear H0.
(* Goal: Z.ge a (Z.div b (Zpos (xO xH))) *)
    rewrite H2 in H1.
(* Goal: or (and (@eq dart (A_1 m k x) d) (@eq dart y d)) (eqc m (A_1 m k x) y) *)
(* Goal: or (and (@eq dart (A_1 m k x) d) (@eq dart y d)) (eqc m (A_1 m k x) y) *)
(* Goal: forall (_ : inv_qhmap (L m d d0 d1)) (k : dim) (x y : dart) (_ : eqc (L m d d0 d1) x y) (_ : pred (L m d d0 d1) k x), eqc (L m d d0 d1) (A_1 (L m d d0 d1) k x) y *)
    elim H1.
(* Goal: @eq dart (A_1 m k d) nil *)
(* Goal: or (and (@eq dart (A_1 m k x) d) (@eq dart y d)) (eqc m (A_1 m k x) y) *)
(* Goal: forall (_ : inv_qhmap (L m d d0 d1)) (k : dim) (x y : dart) (_ : eqc (L m d d0 d1) x y) (_ : pred (L m d d0 d1) k x), eqc (L m d d0 d1) (A_1 (L m d d0 d1) k x) y *)
    apply not_exd_A_1_nil.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  right.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
    apply IHm.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   unfold pred in |- *.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   unfold pred in |- *.
(* Goal: plf (L m di1 d0 d1) *)
   simpl in |- *.
(* Goal: forall (x : dart) (_ : and (inv_qhmap m) (prec_Lq m d d0 d1)) (_ : succf (L m d d0 d1) x), match d with | di0 => or (expf m x (F (L m d d0 d1) x)) (and (not (@eq dart (A_1 m di1 d0) nil)) (and (expf m x d1) (expf m (A_1 m di1 d0) (F (L m d d0 d1) x)))) | di1 => or (expf m x (F (L m d d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m d d0 d1) x)))) end *)
   unfold prec_Lq in |- *.
(* Goal: forall (_ : and (inv_qhmap m) (and (exd m d0) (and (exd m d1) (and (not (succ m d d0)) (not (pred m d d1)))))) (k : dim) (x y : dart) (_ : or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y)))) (_ : not (@eq dart (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) nil)), or (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) y) (or (and (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) d1) (eqc m d0 y))) *)
   intros Hinv k x y.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   intro.
(* Goal: forall _ : not (@eq dart (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) nil), or (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) y) (or (and (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) d1) (eqc m d0 y))) *)
   elim (eq_dim_dec k d).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
  intro.
(* Goal: forall _ : and (not (@eq dart (if eq_dart_dec x d1 then d0 else A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (if eq_dart_dec x d1 then d0 else A_1 m di0 x)) nil)), or (expf m x (A_1 m di1 (if eq_dart_dec x d1 then d0 else A_1 m di0 x))) (and (not (@eq dart (A_1 m di1 d0) nil)) (and (expf m x d1) (expf m (A_1 m di1 d0) (A_1 m di1 (if eq_dart_dec x d1 then d0 else A_1 m di0 x))))) *)
(* Goal: forall (x : dart) (_ : and (inv_qhmap m) (and (exd m d0) (and (exd m d1) (and (not (succ m di1 d0)) (not (not (@eq dart (A_1 m di1 d1) nil))))))) (_ : and (not (@eq dart (A_1 (L m di1 d0 d1) di0 x) nil)) (not (@eq dart (A_1 (L m di1 d0 d1) di1 (A_1 (L m di1 d0 d1) di0 x)) nil))), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
    elim (eq_dart_dec x d1).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     elim H; clear H; intro.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    right.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
      left.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
      split.
(* Goal: eqc m d0 d0 *)
(* Goal: eqc m d1 y *)
(* Goal: or (eqc m d0 y) (or (and (eqc m d0 d0) (eqc m d1 y)) (and (eqc m d0 d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq nat x d1)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
     apply refl_eqc.
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: eqc m d1 y *)
(* Goal: or (eqc m d0 y) (or (and (eqc m d0 d0) (eqc m d1 y)) (and (eqc m d0 d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq nat x d1)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
     rewrite <- a0.
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    elim H; clear H; intro.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     right.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
       left.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
       split.
(* Goal: eqc m d0 d0 *)
(* Goal: eqc m d1 y *)
(* Goal: or (eqc m d0 y) (or (and (eqc m d0 d0) (eqc m d1 y)) (and (eqc m d0 d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq nat x d1)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
      apply refl_eqc.
(* Goal: inv_qhmap m *)
        tauto.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     elim H; clear H; intro.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
    left.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
      apply IHm.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     unfold pred in |- *.
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    elim H; clear H; intro.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     right.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
       left.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
       split.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
      apply IHm.
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: inv_qhmap m *)
       unfold pred in |- *; tauto.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     right.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
       right.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
       split.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
      apply IHm.
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: inv_qhmap m *)
       unfold pred in |- *; tauto.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
 elim H; clear H; intro.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
   left.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
     apply IHm.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    unfold pred in |- *.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   elim H; clear H; intro.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    right.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
      left.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
      split.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
     apply IHm.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
      unfold pred in |- *; tauto.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    right.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
      right.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
      split.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
     apply IHm.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
      unfold pred in |- *; tauto.
(* Goal: inv_qhmap m *)
     tauto.
Qed.

(* INVERSES, Idem: *)

Lemma eqc_A_1_l_eqc : forall m:fmap, inv_qhmap m ->
 forall (k:dim)(x y:dart),
   pred m k x ->  eqc m (A_1 m k x) y -> eqc m x y.
Proof.
(* Goal: plf m *)
induction m.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: plf (L m di1 d0 d1) *)
simpl in |- *.
(* Goal: forall (m : fmap) (x : dart) (_ : inv_qhmap m) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : prec_I m x), @eq Z (Z.sub (Z.add (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.add (nv m) (Zpos xH)) (Z.add (ne m) (Zpos xH))) (Z.add (nf m) (Zpos xH))) (Z.add (nd m) (Zpos xH))) (Zpos (xO xH)))) Z0 *)
  unfold prec_I in |- *.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  unfold pred in |- *.
(* Goal: plf (L m di1 d0 d1) *)
  simpl in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
(* Goal: or (and (@eq dart (A_1 m k x) d) (@eq dart y d)) (eqc m (A_1 m k x) y) *)
(* Goal: or (and (@eq dart (A_1 m k x) d) (@eq dart y d)) (eqc m (A_1 m k x) y) *)
(* Goal: forall (_ : inv_qhmap (L m d d0 d1)) (k : dim) (x y : dart) (_ : eqc (L m d d0 d1) x y) (_ : pred (L m d d0 d1) k x), eqc (L m d d0 d1) (A_1 (L m d d0 d1) k x) y *)
  elim H1.
 clear H1.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   intro.
   decompose [and] H1.
   clear H1.
   rewrite <- H2 in H.
    absurd (exd m (A_1 m k x)).
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: exd m (A_1 m di1 d0) *)
(* Goal: forall (_ : not (@eq nat x d1)) (_ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (A_1 m di0 x)) nil))), or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A_1 m di1 d0) nil)) (and (expf m x d1) (expf m (A_1 m di1 d0) (A_1 m di1 (A_1 m di0 x))))) *)
(* Goal: forall (x : dart) (_ : and (inv_qhmap m) (and (exd m d0) (and (exd m d1) (and (not (succ m di1 d0)) (not (not (@eq dart (A_1 m di1 d1) nil))))))) (_ : and (not (@eq dart (A_1 (L m di1 d0 d1) di0 x) nil)) (not (@eq dart (A_1 (L m di1 d0 d1) di1 (A_1 (L m di1 d0 d1) di0 x)) nil))), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
 apply pred_exd_A_1.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 unfold pred in |- *.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
intro.
  clear H1.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  right.
  apply IHm with k.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
unfold pred in |- *.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: inv_qhmap m *)
 tauto.
(* Goal: plf (L m di1 d0 d1) *)
simpl in |- *.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  unfold pred in |- *.
(* Goal: plf (L m di1 d0 d1) *)
  simpl in |- *.
(* Goal: forall (x : dart) (_ : and (inv_qhmap m) (prec_Lq m d d0 d1)) (_ : succf (L m d d0 d1) x), match d with | di0 => or (expf m x (F (L m d d0 d1) x)) (and (not (@eq dart (A_1 m di1 d0) nil)) (and (expf m x d1) (expf m (A_1 m di1 d0) (F (L m d d0 d1) x)))) | di1 => or (expf m x (F (L m d d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m d d0 d1) x)))) end *)
  unfold prec_Lq in |- *.
(* Goal: forall (_ : and (inv_qhmap m) (and (exd m d0) (and (exd m d1) (and (not (succ m d d0)) (not (pred m d d1)))))) (k : dim) (x y : dart) (_ : or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y)))) (_ : not (@eq dart (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) nil)), or (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) y) (or (and (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) d1) (eqc m d0 y))) *)
  intros Hinv k x y.
(* Goal: forall _ : not (@eq dart (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) nil), or (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) y) (or (and (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) d1) (eqc m d0 y))) *)
  elim (eq_dim_dec k d).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
 intro.
(* Goal: forall _ : and (not (@eq dart (if eq_dart_dec x d1 then d0 else A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (if eq_dart_dec x d1 then d0 else A_1 m di0 x)) nil)), or (expf m x (A_1 m di1 (if eq_dart_dec x d1 then d0 else A_1 m di0 x))) (and (not (@eq dart (A_1 m di1 d0) nil)) (and (expf m x d1) (expf m (A_1 m di1 d0) (A_1 m di1 (if eq_dart_dec x d1 then d0 else A_1 m di0 x))))) *)
(* Goal: forall (x : dart) (_ : and (inv_qhmap m) (and (exd m d0) (and (exd m d1) (and (not (succ m di1 d0)) (not (not (@eq dart (A_1 m di1 d1) nil))))))) (_ : and (not (@eq dart (A_1 (L m di1 d0 d1) di0 x) nil)) (not (@eq dart (A_1 (L m di1 d0 d1) di1 (A_1 (L m di1 d0 d1) di0 x)) nil))), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
   elim (eq_dart_dec x d1).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
    elim H0.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
   clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     right.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     right.
     rewrite a0 in |- *.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
     split.
(* Goal: eqc m d0 d0 *)
(* Goal: eqc m d1 y *)
(* Goal: or (eqc m d0 y) (or (and (eqc m d0 d0) (eqc m d1 y)) (and (eqc m d0 d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq nat x d1)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
    apply refl_eqc.
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    intro.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
    elim H0.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
   clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
     rewrite a0 in |- *.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    intro.
    rewrite a0 in |- *.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    right.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    right.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
    split.
(* Goal: eqc m d0 d0 *)
(* Goal: eqc m d1 y *)
(* Goal: or (eqc m d0 y) (or (and (eqc m d0 d0) (eqc m d1 y)) (and (eqc m d0 d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq nat x d1)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
   apply refl_eqc.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
 intros.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
   elim H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
  intro.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
    clear H0.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
    left.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
     eapply IHm.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    unfold pred in |- *.
    apply H.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
   clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   intro.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
   elim H0.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    intro.
    assert (eqc m x d0).
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
    eapply IHm.
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     unfold pred in |- *.
     apply H.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
   clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   intro.
   assert (eqc m x d1).
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
   eapply IHm.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    unfold pred in |- *.
    apply H.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
  elim H0.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
 clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   intro.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
   left.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
    eapply IHm.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   unfold pred in |- *.
   apply H.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
  intro.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
  elim H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
 intro.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
   clear H0.
   assert (eqc m x d0).
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
   eapply IHm.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    unfold pred in |- *.
    apply H.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
  intro.
  assert (eqc m x d1).
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
  eapply IHm.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   unfold pred in |- *.
   apply H.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: inv_qhmap m *)
   tauto.
Qed.

(* OK: *)

Lemma eqc_A_r_eqc : forall m:fmap, inv_qhmap m ->
 forall (k:dim)(x y:dart),
   succ m k y ->  eqc m x (A m k y) -> eqc m x y.
Proof.
(* Goal: plf m *)
induction m.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: plf (L m di1 d0 d1) *)
simpl in |- *.
(* Goal: forall (m : fmap) (x : dart) (_ : inv_qhmap m) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : prec_I m x), @eq Z (Z.sub (Z.add (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.add (nv m) (Zpos xH)) (Z.add (ne m) (Zpos xH))) (Z.add (nf m) (Zpos xH))) (Z.add (nd m) (Zpos xH))) (Zpos (xO xH)))) Z0 *)
  unfold prec_I in |- *.
(* Goal: succ m k x *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A m k x) nil)), or (eqc m x (A m k x)) (or (and (eqc m x d0) (eqc m d1 (A m k x))) (and (eqc m x d1) (eqc m d0 (A m k x)))) *)
  unfold succ in |- *.
(* Goal: plf (L m di1 d0 d1) *)
  simpl in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
(* Goal: or (and (@eq dart (A_1 m k x) d) (@eq dart y d)) (eqc m (A_1 m k x) y) *)
(* Goal: or (and (@eq dart (A_1 m k x) d) (@eq dart y d)) (eqc m (A_1 m k x) y) *)
(* Goal: forall (_ : inv_qhmap (L m d d0 d1)) (k : dim) (x y : dart) (_ : eqc (L m d d0 d1) x y) (_ : pred (L m d d0 d1) k x), eqc (L m d d0 d1) (A_1 (L m d d0 d1) k x) y *)
  elim H1.
 clear H1.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   intro.
   decompose [and] H1.
   clear H1.
   rewrite <- H3 in H.
    absurd (exd m (A m k y)).
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: exd (clos m) (A (clos m) di0 y) *)
(* Goal: @eq dart y0 (A mc di0 y) *)
(* Goal: expf mc x y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 apply succ_exd_A.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: succ m k x *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A m k x) nil)), or (eqc m x (A m k x)) (or (and (eqc m x d0) (eqc m d1 (A m k x))) (and (eqc m x d1) (eqc m d0 (A m k x)))) *)
 unfold succ in |- *.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
intro.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  right.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
   eapply IHm.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: succ m k x *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A m k x) nil)), or (eqc m x (A m k x)) (or (and (eqc m x d0) (eqc m d1 (A m k x))) (and (eqc m x d1) (eqc m d0 (A m k x)))) *)
  unfold succ in |- *.
  apply H0.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: plf (L m di1 d0 d1) *)
  simpl in |- *.
(* Goal: succ m k x *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A m k x) nil)), or (eqc m x (A m k x)) (or (and (eqc m x d0) (eqc m d1 (A m k x))) (and (eqc m x d1) (eqc m d0 (A m k x)))) *)
  unfold succ in |- *.
(* Goal: plf (L m di1 d0 d1) *)
  simpl in |- *.
(* Goal: forall (x : dart) (_ : and (inv_qhmap m) (prec_Lq m d d0 d1)) (_ : succf (L m d d0 d1) x), match d with | di0 => or (expf m x (F (L m d d0 d1) x)) (and (not (@eq dart (A_1 m di1 d0) nil)) (and (expf m x d1) (expf m (A_1 m di1 d0) (F (L m d d0 d1) x)))) | di1 => or (expf m x (F (L m d d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m d d0 d1) x)))) end *)
  unfold prec_Lq in |- *.
(* Goal: forall (_ : and (inv_qhmap m) (and (exd m d0) (and (exd m d1) (and (not (succ m d d0)) (not (pred m d d1)))))) (k : dim) (x y : dart) (_ : or (eqc m x y) (or (and (eqc m x d0) (eqc m d1 y)) (and (eqc m x d1) (eqc m d0 y)))) (_ : not (@eq dart (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) nil)), or (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) y) (or (and (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) d1) (eqc m d0 y))) *)
  intros Hinv k x y.
(* Goal: forall _ : not (@eq dart (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) nil), or (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) y) (or (and (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (if eq_dim_dec k d then if eq_dart_dec x d1 then d0 else A_1 m k x else A_1 m k x) d1) (eqc m d0 y))) *)
  elim (eq_dim_dec k d).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
 intro.
   elim (eq_dart_dec y d0).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
    elim H0.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
   clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
     rewrite a0 in |- *.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     right.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     right.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
     split.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: eqc m d0 d0 *)
(* Goal: eqc m d1 y *)
(* Goal: or (eqc m d0 y) (or (and (eqc m d0 d0) (eqc m d1 y)) (and (eqc m d0 d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq nat x d1)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
   apply refl_eqc.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    intro.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
    elim H0.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
   clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
     rewrite a0 in |- *.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    intro.
    rewrite a0 in |- *.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    right.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    right.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
    split.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: eqc m d0 d0 *)
(* Goal: eqc m d1 y *)
(* Goal: or (eqc m d0 y) (or (and (eqc m d0 d0) (eqc m d1 y)) (and (eqc m d0 d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq nat x d1)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A_1 m k x) nil)), or (eqc m (A_1 m k x) y) (or (and (eqc m (A_1 m k x) d0) (eqc m d1 y)) (and (eqc m (A_1 m k x) d1) (eqc m d0 y))) *)
  apply refl_eqc.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
 intros.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
   elim H0.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    intro.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
    left.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
     eapply IHm.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: succ m k x *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A m k x) nil)), or (eqc m x (A m k x)) (or (and (eqc m x d0) (eqc m d1 (A m k x))) (and (eqc m x d1) (eqc m d0 (A m k x)))) *)
    unfold succ in |- *.
    apply H.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
   clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   intro.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
   elim H0.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    intro.
    assert (eqc m d1 y).
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
    eapply IHm.
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: succ m k x *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A m k x) nil)), or (eqc m x (A m k x)) (or (and (eqc m x d0) (eqc m d1 (A m k x))) (and (eqc m x d1) (eqc m d0 (A m k x)))) *)
     unfold succ in |- *.
     apply H.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
   clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   intro.
   assert (eqc m d0 y).
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
   eapply IHm.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: succ m k x *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A m k x) nil)), or (eqc m x (A m k x)) (or (and (eqc m x d0) (eqc m d1 (A m k x))) (and (eqc m x d1) (eqc m d0 (A m k x)))) *)
    unfold succ in |- *.
    apply H.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
  elim H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
 intro.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
   clear H0.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
   left.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
    eapply IHm.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: succ m k x *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A m k x) nil)), or (eqc m x (A m k x)) (or (and (eqc m x d0) (eqc m d1 (A m k x))) (and (eqc m x d1) (eqc m d0 (A m k x)))) *)
   unfold succ in |- *.
   apply H.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
  intro.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
  elim H0.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
 clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   intro.
   assert (eqc m d1 y).
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
   eapply IHm.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: succ m k x *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A m k x) nil)), or (eqc m x (A m k x)) (or (and (eqc m x d0) (eqc m d1 (A m k x))) (and (eqc m x d1) (eqc m d0 (A m k x)))) *)
    unfold succ in |- *.
    apply H.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
  intro.
  assert (eqc m d0 y).
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
  eapply IHm.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: succ m k x *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A m k x) nil)), or (eqc m x (A m k x)) (or (and (eqc m x d0) (eqc m d1 (A m k x))) (and (eqc m x d1) (eqc m d0 (A m k x)))) *)
   unfold succ in |- *.
   apply H.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: inv_qhmap m *)
   tauto.
Qed.

(* Face path implies equivalence: with the LEMMAS above: *)

Lemma expf_eqc : forall m:fmap,
 inv_qhmap m ->
   forall (x y:dart), expf m x y -> eqc m x y.
Proof.
(* Goal: plf m *)
induction m.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: forall (m : fmap) (x : dart) (_ : inv_qhmap m) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : prec_I m x), @eq Z (Z.sub (Z.add (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.add (nv m) (Zpos xH)) (Z.add (ne m) (Zpos xH))) (Z.add (nf m) (Zpos xH))) (Z.add (nd m) (Zpos xH))) (Zpos (xO xH)))) Z0 *)
   unfold prec_I in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
(* Goal: forall _ : not (expf m x y), sumbool (or (expf m x y) (expf m y x)) (not (or (expf m x y) (expf m y x))) *)
   elim H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
  clear H0; intro.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    right.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
    apply IHm.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  clear H0.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    intro.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
    decompose [and] H0; clear H0.
(* Goal: inv_qhmap m *)
    rewrite H1; rewrite H2; tauto.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: forall (x : dart) (_ : and (inv_qhmap m) (prec_Lq m d d0 d1)) (_ : succf (L m d d0 d1) x), match d with | di0 => or (expf m x (F (L m d d0 d1) x)) (and (not (@eq dart (A_1 m di1 d0) nil)) (and (expf m x d1) (expf m (A_1 m di1 d0) (F (L m d d0 d1) x)))) | di1 => or (expf m x (F (L m d d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m d d0 d1) x)))) end *)
   unfold prec_Lq in |- *.
   intros Hinv x y.
(* Goal: plf (L m d d0 d1) *)
   induction d.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
(* Goal: or (eqc m y x) (or (and (eqc m y d0) (eqc m d1 x)) (and (eqc m y d1) (eqc m d0 x))) *)
    elim H.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   intro.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
     left.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
     apply IHm.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   clear H; intro.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     right.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     right.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
     split.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
    apply IHm.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: inv_qhmap m *)
     tauto.
    assert (eqc m (A_1 m di1 d0) y).
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
     apply IHm.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
      tauto.
     eapply eqc_A_1_l_eqc.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: @eq Z (genus m) Z0 *)
      decompose [and] H.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
        unfold pred in |- *.
(* Goal: plf m *)
        apply H1.
(* Goal: inv_qhmap m *)
        tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
  intro.
(* Goal: or (eqc m y x) (or (and (eqc m y d0) (eqc m d1 x)) (and (eqc m y d1) (eqc m d0 x))) *)
    elim H.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
   left.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
     apply IHm.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   clear H; intro.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     right.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     right.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
     split.
    assert (eqc m x (A m di0 d1)).
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
     apply IHm.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
      tauto.
     eapply eqc_A_r_eqc.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: succ m k x *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A m k x) nil)), or (eqc m x (A m k x)) (or (and (eqc m x d0) (eqc m d1 (A m k x))) (and (eqc m x d1) (eqc m d0 (A m k x)))) *)
      unfold succ in |- *.
(* Goal: @eq Z (genus m) Z0 *)
        decompose [and] H.
(* Goal: plf m *)
        apply H1.
(* Goal: inv_qhmap m *)
        tauto.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
    apply IHm.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: inv_qhmap m *)
     tauto.
Qed.

(* OK: *)

Lemma expf_A_1_l_eqc : forall m:fmap,
 inv_qhmap m ->
   forall (x y:dart)(k:dim),
       expf m (A_1 m k x) y -> eqc m x y.
Proof.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
eapply eqc_A_1_l_eqc.
(* Goal: inv_qhmap m *)
 tauto.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 unfold pred in |- *.
   assert (A_1 m k x <> nil).
  generalize (expf_exd_exd m (A_1 m k x) y).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
    intros.
    assert (exd m (A_1 m k x)).
(* Goal: inv_qhmap m *)
   tauto.
   eapply exd_not_nil.
    apply H.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: plf m *)
  apply H1.
   apply expf_eqc.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: inv_qhmap m *)
  tauto.
Qed.

(* IDEM : *)

Lemma expf_A_r_eqc : forall(m:fmap)(k:dim),
 inv_qhmap m ->
   forall (x y:dart), expf m x (A m k y) -> eqc m x y.
Proof.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
eapply eqc_A_r_eqc.
(* Goal: inv_qhmap m *)
 tauto.
(* Goal: succ m k x *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A m k x) nil)), or (eqc m x (A m k x)) (or (and (eqc m x d0) (eqc m d1 (A m k x))) (and (eqc m x d1) (eqc m d0 (A m k x)))) *)
 unfold succ in |- *.
   assert (A m k y <> nil).
  generalize (expf_exd_exd m x (A m k y)).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
    intros.
    assert (exd m (A m k y)).
(* Goal: inv_qhmap m *)
   tauto.
   eapply exd_not_nil.
    apply H.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: plf m *)
  apply H1.
   apply expf_eqc.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: inv_qhmap m *)
  tauto.
Qed.

(*========================================================
      	      NUMBERING AND CHARACTERISTICS:
=========================================================*)

Require Import ZArith.
Open Scope Z_scope.

(* Number of darts: *)

Fixpoint nd(m:fmap):Z :=
 match m with
    V => 0
  | I m0 x => nd m0 + 1
  | L m0 _ _ _ => nd m0
 end.

(* Number of vertices: *)

Fixpoint nv(m:fmap):Z :=
 match m with
    V => 0
  | I m0 x => nv m0 + 1
  | L m0 di0 x y => nv m0
  | L m0 di1 x y => nv m0 -
      if eq_dart_dec (A (clos m0) di1 x) y
      then 0 else 1
 end.

(* Number of edges: *)

Fixpoint ne(m:fmap):Z :=
 match m with
    V => 0
  | I m0 x => ne m0 + 1
  | L m0 di0 x y => ne m0 -
      if eq_dart_dec (A (clos m0) di0 x) y
      then 0 else 1
  | L m0 di1 x y => ne m0
 end.

(* Number of faces: *)

Fixpoint nf(m:fmap):Z :=
 match m with
    V => 0
  | I m0 x => nf m0 + 1
  | L m0 di0 x y =>
      let mc := clos m0 in
      let x0 := A mc di0 x in
      let x_1:= A_1 mc di1 x in
      nf m0 +
       if eq_dart_dec y x0 then 0
       else if expf_dec mc x_1 y then 1
	    else -1
  | L m0 di1 x y =>
      let mc := clos m0 in
      let x1 := A mc di1 x in
      let y0 := A mc di0 y in
      nf m0 +
       if eq_dart_dec y x1 then 0
       else if expf_dec mc x y0 then 1
	    else -1
 end.

(* Number of connected components: *)

Fixpoint nc(m:fmap):Z :=
 match m with
    V => 0
  | I m0 x => nc m0 + 1
  | L m0 _ x y => nc m0 -
       if eqc_dec (clos m0) x y then 0 else 1
 end.

(* Euler-Poincare characteristic: *)

Definition ec(m:fmap): Z:=
  nv m + ne m + nf m - nd m.

(* The Euler-Poincare characteristic is even: OK: *)

Theorem even_ec : forall m:fmap, Zeven (ec m).
Proof.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (nc (L m di1 x y)) (Z.div (ec (L m di1 x y)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
unfold ec in |- *.
(* Goal: plf m *)
induction m.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
   cut
    (nv m + 1 + (ne m + 1) + (nf m + 1) - (nd m + 1) =
     Zsucc (Zsucc (nv m + ne m + nf m - nd m))).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
(* Goal: Zeven (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) *)
(* Goal: @eq Z (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Z.pred (Z.pred (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)))) *)
    rewrite H.
(* Goal: Zeven (Z.succ (Z.succ (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)))) *)
(* Goal: @eq Z (Z.sub (Z.add (Z.add (Z.add (nv m) (Zpos xH)) (Z.add (ne m) (Zpos xH))) (Z.add (nf m) (Zpos xH))) (Z.add (nd m) (Zpos xH))) (Z.succ (Z.succ (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)))) *)
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv (L m d d0 d1)) (ne (L m d d0 d1))) (nf (L m d d0 d1))) (nd (L m d d0 d1))) *)
    apply Zeven_Sn.
(* Goal: Zodd (Z.succ (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m))) *)
(* Goal: @eq Z (Z.sub (Z.add (Z.add (Z.add (nv m) (Zpos xH)) (Z.add (ne m) (Zpos xH))) (Z.add (nf m) (Zpos xH))) (Z.add (nd m) (Zpos xH))) (Z.succ (Z.succ (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)))) *)
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv (L m d d0 d1)) (ne (L m d d0 d1))) (nf (L m d d0 d1))) (nd (L m d d0 d1))) *)
    apply Zodd_Sn.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
  omega.
(* Goal: plf (L m d d0 d1) *)
 induction d.
(* Goal: plf (L m di1 d0 d1) *)
  simpl in |- *.
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 d0) d1 then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec d1 (A (clos m) di0 d0) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 d0) d1 then Zpos xH else Zneg xH))) (nd m)) *)
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv (L m di1 d0 d1)) (ne (L m di1 d0 d1))) (nf (L m di1 d0 d1))) (nd (L m di1 d0 d1))) *)
    elim (eq_dart_dec (A (clos m) di0 d0) d1).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   intro.
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if eq_dart_dec d1 (A (clos m) di0 d0) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 d0) d1 then Zpos xH else Zneg xH))) (nd m)) *)
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv (L m di1 d0 d1)) (ne (L m di1 d0 d1))) (nf (L m di1 d0 d1))) (nd (L m di1 d0 d1))) *)
     elim (eq_dart_dec d1 (A (clos m) di0 d0)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    intro.
      cut
       (nv m + (ne m - 0) + (nf m + 0) - nd m =
        nv m + ne m + nf m - nd m).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
(* Goal: Zeven (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) *)
(* Goal: @eq Z (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Z.pred (Z.pred (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)))) *)
       rewrite H.
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
     omega.
    symmetry  in a.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   intro.
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if eq_dart_dec d1 (A (clos m) di0 d0) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 d0) d1 then Zpos xH else Zneg xH))) (nd m)) *)
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv (L m di1 d0 d1)) (ne (L m di1 d0 d1))) (nf (L m di1 d0 d1))) (nd (L m di1 d0 d1))) *)
     elim (eq_dart_dec d1 (A (clos m) di0 d0)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    intro.
      symmetry  in a.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    intro.
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if expf_dec (clos m) (A_1 (clos m) di1 d0) d1 then Zpos xH else Zneg xH))) (nd m)) *)
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv (L m di1 d0 d1)) (ne (L m di1 d0 d1))) (nf (L m di1 d0 d1))) (nd (L m di1 d0 d1))) *)
      elim (expf_dec (clos m) (A_1 (clos m) di1 d0) d1).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
       cut
        (nv m + (ne m - 1) + (nf m + 1) - nd m =
         nv m + ne m + nf m - nd m).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
      intro.
(* Goal: Zeven (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) *)
(* Goal: @eq Z (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Z.pred (Z.pred (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)))) *)
        rewrite H.
(* Goal: inv_qhmap m *)
        tauto.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
      omega.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
       cut
        (nv m + (ne m - 1) + (nf m + -1) - nd m =
         Zpred (Zpred (nv m + ne m + nf m - nd m))).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
      intro.
(* Goal: Zeven (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) *)
(* Goal: @eq Z (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Z.pred (Z.pred (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)))) *)
        rewrite H.
(* Goal: Zeven (Z.pred (Z.pred (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)))) *)
(* Goal: @eq Z (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Z.pred (Z.pred (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)))) *)
        apply Zeven_pred.
(* Goal: Zodd (Z.pred (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m))) *)
(* Goal: @eq Z (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Z.pred (Z.pred (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)))) *)
        apply Zodd_pred.
(* Goal: inv_qhmap m *)
        tauto.
(* Goal: @eq Z (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Z.pred (Z.pred (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)))) *)
      unfold Zpred in |- *.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
        omega.
(* Goal: plf (L m di1 d0 d1) *)
  simpl in |- *.
(* Goal: Zeven (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 d0) d1 then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec d1 (A (clos m) di1 d0) then Z0 else if expf_dec (clos m) d0 (A (clos m) di0 d1) then Zpos xH else Zneg xH))) (nd m)) *)
    elim (eq_dart_dec (A (clos m) di1 d0) d1).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   intro.
(* Goal: Zeven (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if eq_dart_dec d1 (A (clos m) di1 d0) then Z0 else if expf_dec (clos m) d0 (A (clos m) di0 d1) then Zpos xH else Zneg xH))) (nd m)) *)
(* Goal: forall _ : not (@eq nat (A (clos m) di1 d0) d1), Zeven (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec d1 (A (clos m) di1 d0) then Z0 else if expf_dec (clos m) d0 (A (clos m) di0 d1) then Zpos xH else Zneg xH))) (nd m)) *)
     elim (eq_nat_dec d1 (A (clos m) di1 d0)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    intro.
      cut
       (nv m - 0 + ne m + (nf m + 0) - nd m =
        nv m + ne m + nf m - nd m).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
       symmetry  in a.
(* Goal: Zeven (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec d1 (A (clos m) di1 d0) then Z0 else if expf_dec (clos m) d0 (A (clos m) di0 d1) then Zpos xH else Zneg xH))) (nd m)) *)
       elim (eq_dart_dec d1 (A (clos m) di1 d0)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
      intro.
        cut
         (nv m - 0 + ne m + (nf m + 0) - nd m =
          nv m + ne m + nf m - nd m).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
       intro.
(* Goal: Zeven (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) *)
(* Goal: @eq Z (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Z.pred (Z.pred (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)))) *)
         rewrite H.
(* Goal: inv_qhmap m *)
         tauto.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
       omega.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
     omega.
    symmetry  in a.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   intro.
(* Goal: Zeven (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec d1 (A (clos m) di1 d0) then Z0 else if expf_dec (clos m) d0 (A (clos m) di0 d1) then Zpos xH else Zneg xH))) (nd m)) *)
     elim (eq_dart_dec d1 (A (clos m) di1 d0)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    intro.
      symmetry  in a.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    intro.
(* Goal: Zeven (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if expf_dec (clos m) d0 (A (clos m) di0 d1) then Zpos xH else Zneg xH))) (nd m)) *)
      elim (expf_dec (clos m) d0 (A (clos m) di0 d1)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
       cut
        (nv m - 1 + ne m + (nf m + 1) - nd m =
         nv m + ne m + nf m - nd m).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
      intro.
(* Goal: Zeven (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) *)
(* Goal: @eq Z (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Z.pred (Z.pred (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)))) *)
        rewrite H.
(* Goal: inv_qhmap m *)
        tauto.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
      omega.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
       cut
        (nv m - 1 + ne m + (nf m + -1) - nd m =
         Zpred (Zpred (nv m + ne m + nf m - nd m))).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
      intro.
(* Goal: Zeven (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) *)
(* Goal: @eq Z (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Z.pred (Z.pred (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)))) *)
        rewrite H.
(* Goal: Zeven (Z.pred (Z.pred (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)))) *)
(* Goal: @eq Z (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Z.pred (Z.pred (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)))) *)
        apply Zeven_pred.
(* Goal: Zodd (Z.pred (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m))) *)
(* Goal: @eq Z (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Z.pred (Z.pred (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)))) *)
        apply Zodd_pred.
(* Goal: inv_qhmap m *)
        tauto.
(* Goal: @eq Z (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Z.pred (Z.pred (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)))) *)
      unfold Zpred in |- *.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
        omega.
Qed.

(* THEOREME OF THE GENUS: OK *)

Theorem genus_theorem : forall m:fmap,
  inv_qhmap m -> 2 * (nc m) >= (ec m).
Proof.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (nc (L m di1 x y)) (Z.div (ec (L m di1 x y)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
unfold ec in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
rename H into Invm.
(* Goal: plf m *)
induction m.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
   omega.
 unfold nc in |- *.
   fold nc in |- *.
   unfold nv in |- *; fold nv in |- *.
   unfold ne in |- *; fold ne in |- *.
   unfold nf in |- *; fold nf in |- *.
   unfold nd in |- *; fold nd in |- *.
   unfold inv_qhmap in Invm.
   fold inv_qhmap in Invm.
   assert (2 * nc m >= nv m + ne m + nf m - nd m).
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
  omega.
 unfold inv_qhmap in Invm; fold inv_qhmap in Invm.
(* Goal: plf (L m d d0 d1) *)
   induction d.
  unfold nc in |- *; fold nc in |- *.
    unfold nv in |- *; fold nv in |- *.
    unfold ne in |- *; fold ne in |- *.
    unfold nf in |- *; fold nf in |- *.
    unfold nd in |- *; fold nd in |- *.
    elim (eqc_dec (clos m) d0 d1).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
   intro.
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 d0) d1 then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec d1 (A (clos m) di0 d0) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 d0) d1 then Zpos xH else Zneg xH))) (nd m)) *)
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv (L m di1 d0 d1)) (ne (L m di1 d0 d1))) (nf (L m di1 d0 d1))) (nd (L m di1 d0 d1))) *)
     elim (eq_dart_dec (A (clos m) di0 d0) d1).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    intro.
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if eq_dart_dec d1 (A (clos m) di0 d0) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 d0) d1 then Zpos xH else Zneg xH))) (nd m)) *)
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv (L m di1 d0 d1)) (ne (L m di1 d0 d1))) (nf (L m di1 d0 d1))) (nd (L m di1 d0 d1))) *)
      elim (eq_dart_dec d1 (A (clos m) di0 d0)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
       assert (2 * nc m >= nv m + ne m + nf m - nd m).
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
      apply IHm.
(* Goal: inv_qhmap m *)
        tauto.
      cut
       (nv m + (ne m - 0) + (nf m + 0) - nd m =
        nv m + ne m + nf m - nd m).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
       intro.
(* Goal: @eq Z (Z.sub (Z.add (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.add (nv m) (Zpos xH)) (Z.add (ne m) (Zpos xH))) (Z.add (nf m) (Zpos xH))) (Z.add (nd m) (Zpos xH))) (Zpos (xO xH)))) (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) *)
         rewrite H0.
         cut (nc m - 0 = nc m).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
        intro.
          rewrite H1.
(* Goal: inv_qhmap m *)
          tauto.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
        omega.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
       omega.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
       symmetry  in a0.
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if eq_dart_dec d1 (A (clos m) di0 d0) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 d0) d1 then Zpos xH else Zneg xH))) (nd m)) *)
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv (L m di1 d0 d1)) (ne (L m di1 d0 d1))) (nf (L m di1 d0 d1))) (nd (L m di1 d0 d1))) *)
    elim (eq_dart_dec d1 (A (clos m) di0 d0)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
       symmetry  in a0.
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if expf_dec (clos m) (A_1 (clos m) di1 d0) d1 then Zpos xH else Zneg xH))) (nd m)) *)
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv (L m di1 d0 d1)) (ne (L m di1 d0 d1))) (nf (L m di1 d0 d1))) (nd (L m di1 d0 d1))) *)
     elim (expf_dec (clos m) (A_1 (clos m) di1 d0) d1).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
      intros.
        assert (2 * nc m >= nv m + ne m + nf m - nd m).
(* Goal: inv_qhmap m *)
       apply IHm; tauto.
       cut
        (nv m + (ne m - 1) + (nf m + 1) - nd m =
         nv m + ne m + nf m - nd m).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
        intro.
          cut (nc m - 0 = nc m).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
         intro.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
           omega.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
         omega.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
        omega.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
      intros.
        assert (2 * nc m >= nv m + ne m + nf m - nd m).
(* Goal: inv_qhmap m *)
       apply IHm; tauto.
       cut
        (nv m + (ne m - 1) + (nf m + -1) - nd m =
         Zpred (Zpred (nv m + ne m + nf m - nd m))).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
        intro.
(* Goal: @eq Z (Z.sub (Z.add (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.add (nv m) (Zpos xH)) (Z.add (ne m) (Zpos xH))) (Z.add (nf m) (Zpos xH))) (Z.add (nd m) (Zpos xH))) (Zpos (xO xH)))) (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) *)
          rewrite H0.
(* Goal: @eq Z (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Z.pred (Z.pred (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)))) *)
          unfold Zpred in |- *.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
          omega.
(* Goal: @eq Z (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Z.pred (Z.pred (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)))) *)
        unfold Zpred in |- *.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
          omega.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
     assert (2 * nc m >= nv m + ne m + nf m - nd m).
(* Goal: inv_qhmap m *)
    apply IHm; tauto.
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 d0) d1 then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec d1 (A (clos m) di0 d0) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 d0) d1 then Zpos xH else Zneg xH))) (nd m)) *)
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv (L m di1 d0 d1)) (ne (L m di1 d0 d1))) (nf (L m di1 d0 d1))) (nd (L m di1 d0 d1))) *)
    elim (eq_dart_dec (A (clos m) di0 d0) d1).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
       elim b.
(* Goal: eqc (clos m) x y *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
       rewrite <- a.
(* Goal: eqc (clos m) x (A (clos m) di1 x) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
       apply succ_eqc_A_r.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
      assert (inv_hmap (clos m)).
(* Goal: inv_hmap (clos m) *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
       apply inv_hmap_clos.
(* Goal: inv_qhmap m *)
         tauto.
       rename H0 into Invc.
         unfold inv_hmap in Invc.
(* Goal: inv_qhmap m *)
         tauto.
(* Goal: succ m k x *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A m k x) nil)), or (eqc m x (A m k x)) (or (and (eqc m x d0) (eqc m d1 (A m k x))) (and (eqc m x d1) (eqc m d0 (A m k x)))) *)
      unfold succ in |- *.
(* Goal: expf m x d1 *)
(* Goal: expf m (A_1 m di1 d0) (A_1 m di1 d0) *)
(* Goal: forall (_ : not (@eq nat x d1)) (_ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (A_1 m di0 x)) nil))), or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A_1 m di1 d0) nil)) (and (expf m x d1) (expf m (A_1 m di1 d0) (A_1 m di1 (A_1 m di0 x))))) *)
(* Goal: forall (x : dart) (_ : and (inv_qhmap m) (and (exd m d0) (and (exd m d1) (and (not (succ m di1 d0)) (not (not (@eq dart (A_1 m di1 d1) nil))))))) (_ : and (not (@eq dart (A_1 (L m di1 d0 d1) di0 x) nil)) (not (@eq dart (A_1 (L m di1 d0 d1) di1 (A_1 (L m di1 d0 d1) di0 x)) nil))), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
        rewrite a.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
        intro.
        unfold prec_Lq in Invm.
        rewrite H0 in Invm.
        absurd (exd m nil).
       apply not_exd_nil.
(* Goal: inv_qhmap m *)
         tauto.
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if eq_dart_dec d1 (A (clos m) di0 d0) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 d0) d1 then Zpos xH else Zneg xH))) (nd m)) *)
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv (L m di1 d0 d1)) (ne (L m di1 d0 d1))) (nf (L m di1 d0 d1))) (nd (L m di1 d0 d1))) *)
       elim (eq_dart_dec d1 (A (clos m) di0 d0)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
      intro.
        symmetry  in a.
(* Goal: inv_qhmap m *)
        tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
      intro.
        assert (2 * nc m >= nv m + ne m + nf m - nd m).
(* Goal: inv_qhmap m *)
       apply IHm; tauto.
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if expf_dec (clos m) (A_1 (clos m) di1 d0) d1 then Zpos xH else Zneg xH))) (nd m)) *)
(* Goal: Zeven (Z.sub (Z.add (Z.add (nv (L m di1 d0 d1)) (ne (L m di1 d0 d1))) (nf (L m di1 d0 d1))) (nd (L m di1 d0 d1))) *)
       elim (expf_dec (clos m) (A_1 (clos m) di1 d0) d1).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
        intro.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
          elim b.
          eapply expf_A_1_l_eqc.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
         assert (inv_hmap (clos m)).
(* Goal: inv_hmap (clos m) *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
          apply inv_hmap_clos.
(* Goal: inv_qhmap m *)
            tauto.
          rename H1 into Invc.
            unfold inv_hmap in Invc.
(* Goal: inv_qhmap m *)
            tauto.
         apply a.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
        intro.
          assert (2 * nc m >=
	   nv m + ne m + nf m - nd m).
(* Goal: inv_qhmap m *)
         apply IHm; tauto.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
         omega.
  unfold nc in |- *; fold nc in |- *.
    unfold nv in |- *; fold nv in |- *.
    unfold ne in |- *; fold ne in |- *.
    unfold nf in |- *; fold nf in |- *.
    unfold nd in |- *; fold nd in |- *.
    assert (2 * nc m >= nv m + ne m + nf m - nd m).
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
   apply IHm.
(* Goal: inv_qhmap m *)
     tauto.
   elim (eqc_dec (clos m) d0 d1).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    intro.
(* Goal: Zeven (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 d0) d1 then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec d1 (A (clos m) di1 d0) then Z0 else if expf_dec (clos m) d0 (A (clos m) di0 d1) then Zpos xH else Zneg xH))) (nd m)) *)
      elim (eq_dart_dec (A (clos m) di1 d0) d1).
(* Goal: Zeven (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec d1 (A (clos m) di1 d0) then Z0 else if expf_dec (clos m) d0 (A (clos m) di0 d1) then Zpos xH else Zneg xH))) (nd m)) *)
     elim (eq_dart_dec d1 (A (clos m) di1 d0)).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
      intros.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
        omega.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
      intros.
        symmetry  in a0.
(* Goal: inv_qhmap m *)
        tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
     intros.
(* Goal: Zeven (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec d1 (A (clos m) di1 d0) then Z0 else if expf_dec (clos m) d0 (A (clos m) di0 d1) then Zpos xH else Zneg xH))) (nd m)) *)
       elim (eq_dart_dec d1 (A (clos m) di1 d0)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
      intro.
        symmetry  in a0.
(* Goal: inv_qhmap m *)
        tauto.
(* Goal: Zeven (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if expf_dec (clos m) d0 (A (clos m) di0 d1) then Zpos xH else Zneg xH))) (nd m)) *)
      elim (expf_dec (clos m) d0 (A (clos m) di0 d1)).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
       intros.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
         omega.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
       intros.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
         omega.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
    intro.
(* Goal: Zeven (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 d0) d1 then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec d1 (A (clos m) di1 d0) then Z0 else if expf_dec (clos m) d0 (A (clos m) di0 d1) then Zpos xH else Zneg xH))) (nd m)) *)
      elim (eq_dart_dec (A (clos m) di1 d0) d1).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
       elim b.
(* Goal: eqc (clos m) x y *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
       rewrite <- a.
(* Goal: eqc (clos m) x (A (clos m) di1 x) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
       apply succ_eqc_A_r.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
      assert (inv_hmap (clos m)).
(* Goal: inv_hmap (clos m) *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
       apply inv_hmap_clos.
(* Goal: inv_qhmap m *)
         tauto.
       rename H0 into Invc.
         unfold inv_hmap in Invc.
(* Goal: inv_qhmap m *)
         tauto.
(* Goal: succ m k x *)
(* Goal: forall (_ : not (@eq dim k d)) (_ : not (@eq dart (A m k x) nil)), or (eqc m x (A m k x)) (or (and (eqc m x d0) (eqc m d1 (A m k x))) (and (eqc m x d1) (eqc m d0 (A m k x)))) *)
      unfold succ in |- *.
(* Goal: expf m x d1 *)
(* Goal: expf m (A_1 m di1 d0) (A_1 m di1 d0) *)
(* Goal: forall (_ : not (@eq nat x d1)) (_ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (A_1 m di0 x)) nil))), or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A_1 m di1 d0) nil)) (and (expf m x d1) (expf m (A_1 m di1 d0) (A_1 m di1 (A_1 m di0 x))))) *)
(* Goal: forall (x : dart) (_ : and (inv_qhmap m) (and (exd m d0) (and (exd m d1) (and (not (succ m di1 d0)) (not (not (@eq dart (A_1 m di1 d1) nil))))))) (_ : and (not (@eq dart (A_1 (L m di1 d0 d1) di0 x) nil)) (not (@eq dart (A_1 (L m di1 d0 d1) di1 (A_1 (L m di1 d0 d1) di0 x)) nil))), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
        rewrite a.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
        intro.
        unfold prec_Lq in Invm.
        rewrite H0 in Invm.
        absurd (exd m nil).
       apply not_exd_nil.
(* Goal: inv_qhmap m *)
         tauto.
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
     intro.
(* Goal: Zeven (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec d1 (A (clos m) di1 d0) then Z0 else if expf_dec (clos m) d0 (A (clos m) di0 d1) then Zpos xH else Zneg xH))) (nd m)) *)
       elim (eq_dart_dec d1 (A (clos m) di1 d0)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
      intro.
        symmetry  in a.
(* Goal: inv_qhmap m *)
        tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
      intro.
(* Goal: Zeven (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if expf_dec (clos m) d0 (A (clos m) di0 d1) then Zpos xH else Zneg xH))) (nd m)) *)
        elim (expf_dec (clos m) d0 (A (clos m) di0 d1)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
       intro.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
         elim b.
         eapply expf_A_r_eqc.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
        assert (inv_hmap (clos m)).
(* Goal: inv_hmap (clos m) *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
         apply inv_hmap_clos.
(* Goal: inv_qhmap m *)
           tauto.
         rename H0 into Invc.
           unfold inv_hmap in Invc.
(* Goal: inv_qhmap m *)
           tauto.
        apply a.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
       intro.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
         omega.
Qed.

Definition genus(m:fmap):= (nc m) - (ec m)/2.

(* COROLLARY, OK: *)

Theorem genus_corollary : forall m:fmap,
  inv_qhmap m -> genus m >= 0.
Proof.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: forall _ : forall _ : @eq Z (genus m) Z0, plf m, plf m *)
unfold genus in |- *.
(* Goal: Z.ge (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
generalize (genus_theorem m H).
(* Goal: forall _ : Z.ge (Z.mul (Zpos (xO xH)) (nc m)) (ec m), Z.ge (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
generalize (even_ec m).
(* Goal: forall (_ : Zeven (ec m)) (_ : Z.ge (Z.mul (Zpos (xO xH)) (nc m)) (ec m)), Z.ge (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
generalize (ec m).
(* Goal: forall (z : Z) (_ : Zeven z) (_ : Z.ge (Z.mul (Zpos (xO xH)) (nc m)) z), Z.ge (Z.sub (nc m) (Z.div z (Zpos (xO xH)))) Z0 *)
generalize (nc m).
(* Goal: forall (z z0 : Z) (_ : Zeven z0) (_ : Z.ge (Z.mul (Zpos (xO xH)) z) z0), Z.ge (Z.sub z (Z.div z0 (Zpos (xO xH)))) Z0 *)
intros a b.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: Z.ge (Z.sub a (Z.div b (Zpos (xO xH)))) Z0 *)
cut (a >= b / 2).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
intro.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
   omega.
(* Goal: Z.ge a (Z.div b (Zpos (xO xH))) *)
 assert (b = 2 * Zdiv2 b).
(* Goal: @eq Z b (Z.mul (Zpos (xO xH)) (Z.div2 b)) *)
(* Goal: Z.ge a (Z.div b (Zpos (xO xH))) *)
  apply Zeven_div2.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: Z.ge a (Z.div b (Zpos (xO xH))) *)
  rewrite H2 in H1.
(* Goal: Z.ge a (Z.div b (Zpos (xO xH))) *)
    assert (a >= Zdiv2 b).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
   omega.
(* Goal: @eq Z (Z.sub (Z.add (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.add (nv m) (Zpos xH)) (Z.add (ne m) (Zpos xH))) (Z.add (nf m) (Zpos xH))) (Z.add (nd m) (Zpos xH))) (Zpos (xO xH)))) Z0 *)
   rewrite H2.
(* Goal: Z.ge a (Z.div (Z.mul (Zpos (xO xH)) (Z.div2 b)) (Zpos (xO xH))) *)
 rewrite Zmult_comm.
(* Goal: Z.ge a (Z.div (Z.mul (Z.div2 b) (Zpos (xO xH))) (Zpos (xO xH))) *)
     assert (Zdiv2 b * 2 / 2 = Zdiv2 b).
(* Goal: @eq Z (Z.div (Z.mul (Z.div2 b) (Zpos (xO xH))) (Zpos (xO xH))) (Z.div2 b) *)
(* Goal: Z.ge a (Z.div (Z.mul (Z.div2 b) (Zpos (xO xH))) (Zpos (xO xH))) *)
  apply Z_div_mult.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
      omega.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
    rewrite H4.
(* Goal: inv_qhmap m *)
      tauto.
Qed.

Definition planar(m:fmap):= genus m = 0.

(* EULER-POINCARE FORMULA: *)

Lemma Euler_Poincare: forall m:fmap,
  inv_qhmap m -> planar m ->
    ec m / 2 = nc m.
Proof.
(* Goal: forall _ : forall (_ : inv_qhmap (L m di1 d0 d1)) (_ : planar (L m di1 d0 d1)), planar m, @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
unfold planar in |- *.
(* Goal: forall _ : forall _ : @eq Z (genus m) Z0, plf m, plf m *)
unfold genus in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
omega.
Qed.

(* REMARK: SYMMETRY OF expf in the closure NOT USED *)

(* ==========================================================
         PLANARITY CRITERIA (SUFFICIENT CONDITIONS)  
=============================================================*)

(* Sewing at dimension 0: *)

Lemma expf_planar_0: forall (m:fmap)(x y:dart),
  inv_qhmap m -> planar m -> 
   prec_Lq m di0 x y -> let mc:= clos m in
    expf mc (A_1 mc di1 x) y -> 
      planar (L m di0 x y).
Proof.
(* Goal: forall _ : forall (_ : inv_qhmap (L m di1 d0 d1)) (_ : planar (L m di1 d0 d1)), planar m, @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
unfold planar in |- *.
(* Goal: forall _ : forall _ : @eq Z (genus m) Z0, plf m, plf m *)
unfold genus in |- *.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (nc (L m di1 x y)) (Z.div (ec (L m di1 x y)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
unfold ec in |- *.
(* Goal: plf (L m di1 d0 d1) *)
simpl in |- *.
(* Goal: forall (x : dart) (_ : and (inv_qhmap m) (prec_Lq m d d0 d1)) (_ : succf (L m d d0 d1) x), match d with | di0 => or (expf m x (F (L m d d0 d1) x)) (and (not (@eq dart (A_1 m di1 d0) nil)) (and (expf m x d1) (expf m (A_1 m di1 d0) (F (L m d d0 d1) x)))) | di1 => or (expf m x (F (L m d d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m d d0 d1) x)))) end *)
unfold prec_Lq in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (if eqc_dec (clos m) x y then Z0 else Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
elim (eqc_dec (clos m) x y).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
 intro.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
   elim (eq_dart_dec (A (clos m) di0 x) y).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
  intro.
(* Goal: forall (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
    elim (eq_dart_dec y (A (clos m) di0 x)).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
     assert
      (nv m + (ne m - 0) + (nf m + 0) - nd m = 
          nv m + ne m + nf m - nd m).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
     omega.
   rewrite H3 in |- *.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
      omega.
  symmetry  in a0.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
 elim (eq_dart_dec y (A (clos m) di0 x)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
  intro.
    symmetry  in a0.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (_ : not (@eq nat y (A (clos m) di0 x))) (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
 elim (expf_dec (clos m) (A_1 (clos m) di1 x) y).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
    assert
     (nv m + (ne m - 1) + (nf m + 1) - nd m = 
       nv m + ne m + nf m - nd m).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
    omega.
  rewrite H3 in |- *.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
     omega.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
intro.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
  elim b.
   eapply expf_A_1_l_eqc.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   assert (inv_hmap (clos m)).
(* Goal: inv_hmap (clos m) *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  apply inv_hmap_clos.
(* Goal: inv_qhmap m *)
     tauto.
 unfold inv_hmap in H3.
(* Goal: inv_qhmap m *)
    tauto.
  apply H2.
Qed.

(* Sewing at dimension 1: *) 

Lemma expf_planar_1: forall (m:fmap)(x y:dart),
  inv_qhmap m -> planar m ->
    prec_Lq m di1 x y -> let mc:= clos m in
      expf mc x (A mc di0 y) -> 
        planar (L m di1 x y).
Proof.
(* Goal: forall _ : forall (_ : inv_qhmap (L m di1 d0 d1)) (_ : planar (L m di1 d0 d1)), planar m, @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
unfold planar in |- *.
(* Goal: forall _ : forall _ : @eq Z (genus m) Z0, plf m, plf m *)
unfold genus in |- *.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (nc (L m di1 x y)) (Z.div (ec (L m di1 x y)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
unfold ec in |- *.
(* Goal: plf (L m di1 d0 d1) *)
simpl in |- *.
(* Goal: forall (x : dart) (_ : and (inv_qhmap m) (prec_Lq m d d0 d1)) (_ : succf (L m d d0 d1) x), match d with | di0 => or (expf m x (F (L m d d0 d1) x)) (and (not (@eq dart (A_1 m di1 d0) nil)) (and (expf m x d1) (expf m (A_1 m di1 d0) (F (L m d d0 d1) x)))) | di1 => or (expf m x (F (L m d d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m d d0 d1) x)))) end *)
unfold prec_Lq in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (if eqc_dec (clos m) x y then Z0 else Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
elim (eqc_dec (clos m) x y).
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 elim (eq_dart_dec (A (clos m) di1 x) y).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    elim (eq_dart_dec y (A (clos m) di1 x)).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
     assert (nv m - 0 + ne m + (nf m + 0) - nd m = 
         nv m + ne m + nf m - nd m).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
     omega.
   rewrite H3 in |- *.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
      omega.
  symmetry  in a.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
 intros.
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   elim (eq_dart_dec y (A (clos m) di1 x)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
  intro.
    symmetry  in a0.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 elim (expf_dec (clos m) x (A (clos m) di0 y)).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
    assert (nv m - 1 + ne m + (nf m + 1) - nd m = 
        nv m + ne m + nf m - nd m).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
    omega.
  rewrite H3 in |- *.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
     omega.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
intro.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
  elim b.
   eapply expf_A_r_eqc.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   assert (inv_hmap (clos m)).
(* Goal: inv_hmap (clos m) *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  apply inv_hmap_clos.
(* Goal: inv_qhmap m *)
     tauto.
 unfold inv_hmap in H3.
(* Goal: inv_qhmap m *)
    tauto.
  apply H2.
Qed.

(* V is planar: *)

Lemma planar_V: planar V.
Proof.
(* Goal: forall _ : forall (_ : inv_qhmap (L m di1 d0 d1)) (_ : planar (L m di1 d0 d1)), planar m, @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
unfold planar in |- *.
(* Goal: forall _ : forall _ : @eq Z (genus m) Z0, plf m, plf m *)
unfold genus in |- *.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (nc (L m di1 x y)) (Z.div (ec (L m di1 x y)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
unfold ec in |- *.
(* Goal: plf (L m di1 d0 d1) *)
simpl in |- *.
(* Goal: inv_qhmap m *)
 tauto.
Qed.

(* Inserting a dart preserves planarity: *)

Lemma planar_I: forall (m:fmap)(x:dart),
  inv_qhmap m -> planar m -> prec_I m x -> 
       planar (I m x).
Proof.
(* Goal: forall _ : forall (_ : inv_qhmap (L m di1 d0 d1)) (_ : planar (L m di1 d0 d1)), planar m, @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
unfold planar in |- *.
(* Goal: forall _ : forall _ : @eq Z (genus m) Z0, plf m, plf m *)
unfold genus in |- *.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (nc (L m di1 x y)) (Z.div (ec (L m di1 x y)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
unfold ec in |- *.
(* Goal: plf (L m di1 d0 d1) *)
simpl in |- *.
(* Goal: forall (m : fmap) (x : dart) (_ : inv_qhmap m) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : prec_I m x), @eq Z (Z.sub (Z.add (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.add (nv m) (Zpos xH)) (Z.add (ne m) (Zpos xH))) (Z.add (nf m) (Zpos xH))) (Z.add (nd m) (Zpos xH))) (Zpos (xO xH)))) Z0 *)
unfold prec_I in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
assert
 (nv m + 1 + (ne m + 1) + (nf m + 1) - (nd m + 1) =
  nv m + ne m + nf m - nd m + 1 * 2).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
  omega.
(* Goal: @eq Z (Z.sub (Z.add (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.add (nv m) (Zpos xH)) (Z.add (ne m) (Zpos xH))) (Z.add (nf m) (Zpos xH))) (Z.add (nd m) (Zpos xH))) (Zpos (xO xH)))) Z0 *)
rewrite H2 in |- *.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.add (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Z.mul (Zneg xH) (Zpos (xO xH)))) (Zpos (xO xH)))) *)
  rewrite Z_div_plus in |- *.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 clear H2.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
    omega.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
 omega.
Qed.

(* Sewing two disconnected darts preserves planarity:*)
 
Lemma not_eqc_planar: forall (m:fmap)(k:dim)(x y:dart),
  inv_qhmap m -> planar m ->  prec_Lq m k x y -> 
     let mc:= clos m in ~eqc mc x y -> 
         planar (L m k x y).
Proof.
(* Goal: forall _ : forall (_ : inv_qhmap (L m di1 d0 d1)) (_ : planar (L m di1 d0 d1)), planar m, @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
unfold planar in |- *.
(* Goal: forall _ : forall _ : @eq Z (genus m) Z0, plf m, plf m *)
unfold genus in |- *.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (nc (L m di1 x y)) (Z.div (ec (L m di1 x y)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
unfold ec in |- *.
(* Goal: forall (x : dart) (_ : and (inv_qhmap m) (prec_Lq m d d0 d1)) (_ : succf (L m d d0 d1) x), match d with | di0 => or (expf m x (F (L m d d0 d1) x)) (and (not (@eq dart (A_1 m di1 d0) nil)) (and (expf m x d1) (expf m (A_1 m di1 d0) (F (L m d d0 d1) x)))) | di1 => or (expf m x (F (L m d d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m d d0 d1) x)))) end *)
unfold prec_Lq in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
assert (inv_hmap (clos m)).
(* Goal: inv_hmap (clos m) *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 apply inv_hmap_clos.
(* Goal: inv_qhmap m *)
    tauto.
unfold inv_hmap in H3.
  decompose [and] H3.
  induction k.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (if eqc_dec (clos m) x y then Z0 else Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   elim (eqc_dec (clos m) x y).
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
 intro.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
   elim (eq_dart_dec (A (clos m) di0 x) y).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
  intro.
    rewrite <- a in b.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
    elim b.
(* Goal: eqc (clos m) x (A (clos m) di1 x) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
    apply succ_eqc_A_r.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  assert (exd (clos m) x).
(* Goal: exd (clos m) x *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   generalize (exd_clos m x).
(* Goal: inv_qhmap m *)
      tauto.
  generalize (H5 x di0).
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
 elim (eq_dart_dec y (A (clos m) di0 x)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
  intro.
    symmetry  in a.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (_ : not (@eq nat y (A (clos m) di0 x))) (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
 elim (expf_dec (clos m) (A_1 (clos m) di1 x) y).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
    elim b.
     eapply expf_A_1_l_eqc.
(* Goal: inv_qhmap m *)
      tauto.
    apply a.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
   assert
    (nv m + (ne m - 1) + (nf m + -1) - nd m =
     nv m + ne m + nf m - nd m + -1 * 2).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
   omega.
 rewrite H6 in |- *.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.add (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Z.mul (Zneg xH) (Zpos (xO xH)))) (Zpos (xO xH)))) *)
   rewrite Z_div_plus in |- *.
  clear H6.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
     omega.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
  omega.
(* Goal: plf (L m di1 d0 d1) *)
  simpl in |- *.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (if eqc_dec (clos m) x y then Z0 else Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  elim (eqc_dec (clos m) x y).
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
elim (eq_dart_dec (A (clos m) di1 x) y).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
 intros.
   rewrite <- a in b.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
   elim b.
(* Goal: eqc (clos m) x (A (clos m) di1 x) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
   apply succ_eqc_A_r.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 assert (exd (clos m) x).
(* Goal: exd (clos m) x *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  generalize (exd_clos m x).
(* Goal: inv_qhmap m *)
     tauto.
 generalize (H5 x di1).
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
elim (eq_dart_dec y (A (clos m) di1 x)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
 intro.
   symmetry  in a.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
elim (expf_dec (clos m) x (A (clos m) di0 y)).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
 intros.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zpos xH))) (nd m)) (Zpos (xO xH)))) *)
(* Goal: forall (_ : not (expf (clos m) x (A (clos m) di0 y))) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
   elim b1.
    eapply expf_A_r_eqc.
(* Goal: inv_qhmap m *)
     tauto.
   apply a.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
  assert
   (nv m - 1 + ne m + (nf m + -1) - nd m = 
     nv m + ne m + nf m - nd m + -1 * 2).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
  omega.
rewrite H6 in |- *.
  clear H6.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.add (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Z.mul (Zneg xH) (Zpos (xO xH)))) (Zpos (xO xH)))) *)
  rewrite Z_div_plus in |- *.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
  omega.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
 omega.
Qed.

(* Sewing at dimension 0 and planarity preservation: *)

Lemma expf_planar_L0: forall (m:fmap)(x y:dart),
  inv_qhmap m -> planar m -> 
   prec_Lq m di0 x y -> let mc:= clos m in
     (~eqc mc x y \/ expf mc (A_1 mc di1 x) y) -> 
        planar (L m di0 x y).
Proof.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: planar (L m di1 x y) *)
elim H2.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
 intro.
(* Goal: planar (L m di1 x y) *)
(* Goal: forall _ : expf mc x (A mc di0 y), planar (L m di1 x y) *)
   apply not_eqc_planar.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
intro.
(* Goal: planar (L m di0 x y) *)
  apply expf_planar_0.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: inv_qhmap m *)
 tauto.
(* Goal: inv_qhmap m *)
 tauto.
(* Goal: forall (_ : expf (clos m) x (A (clos m) di0 y)) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zpos xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (expf (clos m) x (A (clos m) di0 y))) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
fold mc in |- *.
(* Goal: inv_qhmap m *)
   tauto.
Qed.

(* Sewing at dimension 1 and planarity preservation: *)

Lemma expf_planar_L1: forall (m:fmap)(x y:dart),
  inv_qhmap m -> planar m -> 
   prec_Lq m di1 x y -> let mc:= clos m in
    (~eqc mc x y \/ expf mc x (A mc di0 y)) -> 
       planar (L m di1 x y).
Proof.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: planar (L m di1 x y) *)
elim H2.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
 intro.
(* Goal: planar (L m di1 x y) *)
(* Goal: forall _ : expf mc x (A mc di0 y), planar (L m di1 x y) *)
   apply not_eqc_planar.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
intro.
(* Goal: planar (L m di1 x y) *)
  apply expf_planar_1.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: inv_qhmap m *)
 tauto.
(* Goal: inv_qhmap m *)
 tauto.
(* Goal: forall (_ : expf (clos m) x (A (clos m) di0 y)) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zpos xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (expf (clos m) x (A (clos m) di0 y))) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
fold mc in |- *.
(* Goal: inv_qhmap m *)
   tauto.
Qed.

(* Definition of "Planar formation" of fmap: *)

Fixpoint plf(m:fmap):Prop:=
  match m with 
     V => True
   | I m0 x => plf m0
   | L m0 di0 x y => plf m0 /\ 
      (let mc := (clos m0) in
        ~eqc mc x y \/ expf mc (A_1 mc di1 x) y)
   | L m0 di1 x y => plf m0 /\ 
      (let mc := (clos m0) in
        ~eqc mc x y \/ expf mc x (A mc di0 y))
  end.

(* Constructive Sufficient Condition of planarity: *)

Theorem plf_planar:forall (m:fmap),
  inv_qhmap m -> plf m -> planar m.
Proof.
(* Goal: plf m *)
induction m.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
(* Goal: planar V *)
(* Goal: forall (_ : inv_qhmap (I m d)) (_ : plf (I m d)), planar (I m d) *)
(* Goal: forall (_ : inv_qhmap (L m d d0 d1)) (_ : plf (L m d d0 d1)), planar (L m d d0 d1) *)
   apply planar_V.
(* Goal: plf (L m di1 d0 d1) *)
simpl in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
(* Goal: planar (I m d) *)
(* Goal: forall (_ : inv_qhmap (L m d d0 d1)) (_ : plf (L m d d0 d1)), planar (L m d d0 d1) *)
  apply planar_I.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: inv_qhmap m *)
 tauto.
(* Goal: inv_qhmap m *)
 tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: plf (L m d d0 d1) *)
  induction d.
(* Goal: or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (@eq dart x d) (@eq dart (A_1 m di1 (A_1 m di0 x)) d)) *)
(* Goal: forall (x : dart) (_ : inv_qhmap (L m d d0 d1)) (_ : succf (L m d d0 d1) x), expf (L m d d0 d1) x (F (L m d d0 d1) x) *)
 simpl in H0.
(* Goal: inv_qhmap m *)
(* Goal: @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
   simpl in H.
(* Goal: planar (L m di0 d0 d1) *)
(* Goal: planar (L m di1 d0 d1) *)
   apply expf_planar_L0.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (@eq dart x d) (@eq dart (A_1 m di1 (A_1 m di0 x)) d)) *)
(* Goal: forall (x : dart) (_ : inv_qhmap (L m d d0 d1)) (_ : succf (L m d d0 d1) x), expf (L m d d0 d1) x (F (L m d d0 d1) x) *)
simpl in H0.
(* Goal: inv_qhmap m *)
(* Goal: @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
  simpl in H.
(* Goal: planar (L m di1 d0 d1) *)
  apply expf_planar_L1.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: inv_qhmap m *)
 tauto.
(* Goal: inv_qhmap m *)
 tauto.
(* Goal: inv_qhmap m *)
tauto.
Qed.

(* plf_EULER-POINCARE FORMULA: *)

Theorem plf_Euler_Poincare: forall m:fmap,
  inv_qhmap m -> plf m ->
     ec m / 2 = nc m.
Proof.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: @eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m) *)
apply Euler_Poincare.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: planar m *)
apply plf_planar.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: inv_qhmap m *)
 tauto.
Qed.

(* ==========================================================
       
        PLANARITY CRITERIA (NECESSARY CONDITIONS)  

OK, modulo expf SYMMETRY!!
=============================================================*)

(* OK: *)

Lemma eq_genus_I : forall(m:fmap)(x:dart),
   inv_qhmap (I m x) -> genus (I m x) = genus m.
Proof.
(* Goal: forall _ : forall _ : @eq Z (genus m) Z0, plf m, plf m *)
unfold genus in |- *.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (nc (L m di1 x y)) (Z.div (ec (L m di1 x y)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
unfold ec in |- *.
(* Goal: plf (L m di1 d0 d1) *)
simpl in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
assert
 (nv m + 1 + (ne m + 1) + (nf m + 1) - (nd m + 1) =
  nv m + ne m + nf m - nd m + 1 * 2).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
  omega.
(* Goal: @eq Z (Z.sub (Z.add (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.add (nv m) (Zpos xH)) (Z.add (ne m) (Zpos xH))) (Z.add (nf m) (Zpos xH))) (Z.add (nd m) (Zpos xH))) (Zpos (xO xH)))) (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) *)
rewrite H0 in |- *.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.add (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Z.mul (Zneg xH) (Zpos (xO xH)))) (Zpos (xO xH)))) *)
  rewrite Z_div_plus in |- *.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
  omega.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
 omega.
Qed.

Lemma incr_genus_L0:forall(m:fmap)(x y:dart),
  inv_qhmap (L m di0 x y) ->
     genus m <= genus (L m di0 x y).
Proof.
(* Goal: forall _ : forall _ : @eq Z (genus m) Z0, plf m, plf m *)
unfold genus in |- *.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (nc (L m di1 x y)) (Z.div (ec (L m di1 x y)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
unfold ec in |- *.
(* Goal: plf (L m di1 d0 d1) *)
simpl in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
unfold prec_Lq in H.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
assert (inv_hmap (clos m)).
(* Goal: inv_hmap (clos m) *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 apply inv_hmap_clos.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (if eqc_dec (clos m) x y then Z0 else Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
unfold inv_hmap in H0.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (if eqc_dec (clos m) x y then Z0 else Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
  decompose [and] H0.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  clear H0.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  assert (exd (clos m) x).
(* Goal: exd (clos m) x *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 generalize (exd_clos m x).
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
assert (exd (clos m) y).
(* Goal: exd (clos m) y *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 generalize (exd_clos m y).
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (if eqc_dec (clos m) x y then Z0 else Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
elim (eqc_dec (clos m) x y).
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
 elim (eq_dart_dec (A (clos m) di0 x) y).
(* Goal: forall (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
  elim (eq_dart_dec y (A (clos m) di0 x)).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
     assert
      (nv m + (ne m - 0) + (nf m + 0) - nd m = 
       nv m + ne m + nf m - nd m).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
     omega.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
   rewrite H4 in |- *.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
      omega.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
    symmetry  in a.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
 elim (eq_dart_dec y (A (clos m) di0 x)).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
    symmetry  in a.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (_ : not (@eq nat y (A (clos m) di0 x))) (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
 elim (expf_dec (clos m) (A_1 (clos m) di1 x) y).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
    assert
     (nv m + (ne m - 1) + (nf m + 1) - nd m = 
         nv m + ne m + nf m - nd m).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
    omega.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
  rewrite H4 in |- *.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
     omega.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
 intros.
   assert
    (nv m + (ne m - 1) + (nf m + -1) - nd m =
     nv m + ne m + nf m - nd m + -1 * 2).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
   omega.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
 rewrite H4 in |- *.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.add (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Z.mul (Zneg xH) (Zpos (xO xH)))) (Zpos (xO xH)))) *)
   rewrite Z_div_plus in |- *.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
   omega.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
  omega.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
elim (eq_dart_dec (A (clos m) di0 x) y).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
 intros.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
   elim b.
(* Goal: eqc (clos m) x y *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
   rewrite <- a in |- *.
(* Goal: eqc (clos m) x (A (clos m) di1 x) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
   apply succ_eqc_A_r.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: succ (clos m) di0 x *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
 generalize (H2 x di0).
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
elim (eq_dart_dec y (A (clos m) di0 x)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
 intro.
   symmetry  in a.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall (_ : not (@eq nat y (A (clos m) di0 x))) (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
elim (expf_dec (clos m) (A_1 (clos m) di1 x) y).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
 intros.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zpos xH))) (nd m)) (Zpos (xO xH)))) *)
(* Goal: forall (_ : not (expf (clos m) x (A (clos m) di0 y))) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
   elim b1.
(* Goal: eqc (clos m) x y *)
(* Goal: forall (_ : not (expf (clos m) (A_1 (clos m) di1 x) y)) (_ : not (@eq nat y (A (clos m) di0 x))) (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
   apply expf_A_1_l_eqc with di1.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
assert
   (nv m + (ne m - 1) + (nf m + -1) - nd m =
    nv m + ne m + nf m - nd m + -1 * 2).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
  omega.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
rewrite H4 in |- *.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.add (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Z.mul (Zneg xH) (Zpos (xO xH)))) (Zpos (xO xH)))) *)
  rewrite Z_div_plus in |- *.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
  omega.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
 omega.
Qed.

Lemma incr_genus_L1:forall(m:fmap)(x y:dart),
  inv_qhmap (L m di1 x y) ->
     genus m <= genus (L m di1 x y).
Proof.
(* Goal: forall _ : forall _ : @eq Z (genus m) Z0, plf m, plf m *)
unfold genus.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (nc (L m di1 x y)) (Z.div (ec (L m di1 x y)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
unfold ec in |- *.
(* Goal: plf (L m di1 d0 d1) *)
simpl in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
unfold prec_Lq in H.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
assert (inv_hmap (clos m)).
(* Goal: inv_hmap (clos m) *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 apply inv_hmap_clos.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (if eqc_dec (clos m) x y then Z0 else Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
unfold inv_hmap in H0.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (if eqc_dec (clos m) x y then Z0 else Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
  decompose [and] H0.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  clear H0.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  assert (exd (clos m) x).
(* Goal: exd (clos m) x *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 generalize (exd_clos m x).
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
assert (exd (clos m) y).
(* Goal: exd (clos m) y *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 generalize (exd_clos m y).
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (if eqc_dec (clos m) x y then Z0 else Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
elim (eqc_dec (clos m) x y).
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 elim (eq_dart_dec (A (clos m) di1 x) y).
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  elim (eq_dart_dec y (A (clos m) di1 x)).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
     assert (nv m - 0 + ne m + (nf m + 0) - nd m = 
        nv m + ne m + nf m - nd m).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
     omega.

(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
   rewrite H4 in |- *.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
      omega.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
    symmetry  in a.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 elim (eq_dart_dec y (A (clos m) di1 x)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
  intro.
    symmetry  in a.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 elim (expf_dec (clos m) x (A (clos m) di0 y)).
  assert (nv m - 1 + ne m + (nf m + 1) - nd m =
    nv m + ne m + nf m - nd m).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
    omega.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
  rewrite H4 in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
    intros.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
     omega.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
 intros.
   assert
    (nv m - 1 + ne m + (nf m + -1) - nd m =
     nv m + ne m + nf m - nd m + -1 * 2).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
   omega.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
 rewrite H4 in |- *.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.add (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Z.mul (Zneg xH) (Zpos (xO xH)))) (Zpos (xO xH)))) *)
   rewrite Z_div_plus in |- *.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
   omega.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
  omega.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
elim (eq_dart_dec (A (clos m) di1 x) y).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
 intros.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
   elim b.
(* Goal: eqc (clos m) x y *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
   rewrite <- a in |- *.
(* Goal: eqc (clos m) x (A (clos m) di1 x) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
   apply succ_eqc_A_r.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: succ (clos m) di1 x *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
 generalize (H2 x di1).
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
elim (eq_dart_dec y (A (clos m) di1 x)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
 intro.
   symmetry  in a.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
elim (expf_dec (clos m) x (A (clos m) di0 y)).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
 intros.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zpos xH))) (nd m)) (Zpos (xO xH)))) *)
(* Goal: forall (_ : not (expf (clos m) x (A (clos m) di0 y))) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
   elim b1.
(* Goal: eqc (clos m) x y *)
(* Goal: forall (_ : not (expf (clos m) x (A (clos m) di0 y))) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : not (eqc (clos m) x y)), Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
   apply expf_A_r_eqc with di0.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
  assert
   (nv m - 1 + ne m + (nf m + -1) - nd m = 
     nv m + ne m + nf m - nd m + -1 * 2).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
  omega.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) *)
rewrite H4 in |- *.
(* Goal: Z.le (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.add (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Z.mul (Zneg xH) (Zpos (xO xH)))) (Zpos (xO xH)))) *)
  rewrite Z_div_plus in |- *.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
  omega.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
 omega.
Qed.

Lemma planar_I_rcp: forall(m:fmap)(x:dart),
  inv_qhmap (I m x) -> planar (I m x) -> planar m.
Proof.
(* Goal: forall _ : forall (_ : inv_qhmap (L m di1 d0 d1)) (_ : planar (L m di1 d0 d1)), planar m, @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
unfold planar in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: @eq Z (genus m) Z0 *)
(* Goal: plf (L m d d0 d1) *)
rewrite eq_genus_I in H0.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: inv_qhmap m *)
 tauto.
Qed.

Lemma planar_L0_rcp: forall(m:fmap)(x y:dart),
  inv_qhmap (L m di0 x y) -> 
     planar (L m di0 x y) -> planar m.
Proof.
(* Goal: forall _ : forall (_ : inv_qhmap (L m di1 d0 d1)) (_ : planar (L m di1 d0 d1)), planar m, @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
unfold planar in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: @eq Z (genus m) Z0 *)
generalize (incr_genus_L0 m x y H).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
intro.
(* Goal: inv_qhmap m *)
(* Goal: @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
simpl in H.
(* Goal: @eq Z (genus m) Z0 *)
decompose [and] H.
(* Goal: @eq Z (genus m) Z0 *)
clear H.
(* Goal: @eq Z (genus m) Z0 *)
generalize (genus_corollary m H2).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
intro.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
 omega.
Qed.

Lemma planar_L1_rcp: forall(m:fmap)(x y:dart),
  inv_qhmap (L m di1 x y) -> 
    planar (L m di1 x y) -> planar m.
Proof.
(* Goal: forall _ : forall (_ : inv_qhmap (L m di1 d0 d1)) (_ : planar (L m di1 d0 d1)), planar m, @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
unfold planar in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: @eq Z (genus m) Z0 *)
generalize (incr_genus_L1 m x y H).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
intro.
(* Goal: inv_qhmap m *)
(* Goal: @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
simpl in H.
(* Goal: @eq Z (genus m) Z0 *)
decompose [and] H.
(* Goal: @eq Z (genus m) Z0 *)
clear H.
(* Goal: @eq Z (genus m) Z0 *)
generalize (genus_corollary m H2).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
intro.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
 omega.
Qed.

Lemma succf_expf_F: forall(m:fmap)(x:dart),
  inv_qhmap m -> succf m x -> expf m x (F m x).
Proof.
(* Goal: plf m *)
induction m.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: succf mc y0 *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   unfold succf in |- *.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   unfold pred in |- *.
(* Goal: plf (L m di1 d0 d1) *)
   simpl in |- *.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: succf mc y0 *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
unfold succf in |- *.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  unfold pred in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
(* Goal: plf (L m di1 d0 d1) *)
  simpl in |- *.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  unfold F in |- *.
(* Goal: plf (L m di1 d0 d1) *)
  simpl in |- *.
(* Goal: or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (@eq dart x d) (@eq dart (A_1 m di1 (A_1 m di0 x)) d)) *)
(* Goal: forall (x : dart) (_ : inv_qhmap (L m d d0 d1)) (_ : succf (L m d d0 d1) x), expf (L m d d0 d1) x (F (L m d d0 d1) x) *)
  simpl in H0.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
  left.
(* Goal: or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (A_1 m di1 (A_1 m di0 x))))) *)
  fold (F m x) in |- *.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
  apply IHm.
(* Goal: inv_qhmap m *)
(* Goal: @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
 simpl in H.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: succf mc y0 *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
unfold succf in |- *.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  unfold pred in |- *.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: plf (L m di1 d0 d1) *)
simpl in |- *.
(* Goal: forall (x : dart) (_ : and (inv_qhmap m) (prec_Lq m d d0 d1)) (_ : succf (L m d d0 d1) x), match d with | di0 => or (expf m x (F (L m d d0 d1) x)) (and (not (@eq dart (A_1 m di1 d0) nil)) (and (expf m x d1) (expf m (A_1 m di1 d0) (F (L m d d0 d1) x)))) | di1 => or (expf m x (F (L m d d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m d d0 d1) x)))) end *)
  unfold prec_Lq in |- *.
(* Goal: succf mc y0 *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  unfold succf in |- *.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  unfold pred in |- *.
(* Goal: plf (L m d d0 d1) *)
  induction d.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
(* Goal: or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
   generalize H0.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
   clear H0.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
   unfold F in |- *.
(* Goal: plf (L m di1 d0 d1) *)
   simpl in |- *.
(* Goal: forall _ : and (not (@eq dart (if eq_dart_dec x d1 then d0 else A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (if eq_dart_dec x d1 then d0 else A_1 m di0 x)) nil)), or (expf m x (A_1 m di1 (if eq_dart_dec x d1 then d0 else A_1 m di0 x))) (and (not (@eq dart (A_1 m di1 d0) nil)) (and (expf m x d1) (expf m (A_1 m di1 d0) (A_1 m di1 (if eq_dart_dec x d1 then d0 else A_1 m di0 x))))) *)
(* Goal: forall (x : dart) (_ : and (inv_qhmap m) (and (exd m d0) (and (exd m d1) (and (not (succ m di1 d0)) (not (not (@eq dart (A_1 m di1 d1) nil))))))) (_ : and (not (@eq dart (A_1 (L m di1 d0 d1) di0 x) nil)) (not (@eq dart (A_1 (L m di1 d0 d1) di1 (A_1 (L m di1 d0 d1) di0 x)) nil))), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
   elim (eq_dart_dec x d1).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    right.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
    split.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  split.
(* Goal: expf m x d1 *)
(* Goal: expf m (A_1 m di1 d0) (A_1 m di1 d0) *)
(* Goal: forall (_ : not (@eq nat x d1)) (_ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (A_1 m di0 x)) nil))), or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A_1 m di1 d0) nil)) (and (expf m x d1) (expf m (A_1 m di1 d0) (A_1 m di1 (A_1 m di0 x))))) *)
(* Goal: forall (x : dart) (_ : and (inv_qhmap m) (and (exd m d0) (and (exd m d1) (and (not (succ m di1 d0)) (not (not (@eq dart (A_1 m di1 d1) nil))))))) (_ : and (not (@eq dart (A_1 (L m di1 d0 d1) di0 x) nil)) (not (@eq dart (A_1 (L m di1 d0 d1) di1 (A_1 (L m di1 d0 d1) di0 x)) nil))), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
   rewrite a in |- *.
(* Goal: expf m d0 d0 *)
(* Goal: forall (_ : not (@eq nat (A_1 m di0 x) d1)) (_ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (A_1 m di0 x)) nil))), or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (A_1 m di1 (A_1 m di0 x))))) *)
     apply refl_expf.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: expf m d0 d0 *)
(* Goal: forall (_ : not (@eq nat (A_1 m di0 x) d1)) (_ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (A_1 m di0 x)) nil))), or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (A_1 m di1 (A_1 m di0 x))))) *)
  apply refl_expf.
(* Goal: exd m (A_1 m di1 d0) *)
(* Goal: forall (_ : not (@eq nat x d1)) (_ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (A_1 m di0 x)) nil))), or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A_1 m di1 d0) nil)) (and (expf m x d1) (expf m (A_1 m di1 d0) (A_1 m di1 (A_1 m di0 x))))) *)
(* Goal: forall (x : dart) (_ : and (inv_qhmap m) (and (exd m d0) (and (exd m d1) (and (not (succ m di1 d0)) (not (not (@eq dart (A_1 m di1 d1) nil))))))) (_ : and (not (@eq dart (A_1 (L m di1 d0 d1) di0 x) nil)) (not (@eq dart (A_1 (L m di1 d0 d1) di1 (A_1 (L m di1 d0 d1) di0 x)) nil))), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
    apply pred_exd_A_1.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  unfold pred in |- *.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
 intros.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
   left.
(* Goal: or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (A_1 m di1 (A_1 m di0 x))))) *)
   fold (F m x) in |- *.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
   apply IHm.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: succf mc y0 *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 unfold succf in |- *.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   unfold pred in |- *.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: plf (L m di1 d0 d1) *)
simpl in |- *.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
(* Goal: or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  generalize H0.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  clear H0.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (F (L m di1 d0 d1) x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F (L m di1 d0 d1) x)))) *)
  unfold F in |- *.
(* Goal: plf (L m di1 d0 d1) *)
  simpl in |- *.
(* Goal: forall _ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x)) nil)), or (expf m x (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (if eq_dart_dec (A_1 m di0 x) d1 then d0 else A_1 m di1 (A_1 m di0 x))))) *)
  elim (eq_dart_dec (A_1 m di0 x) d1).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
 intros.
(* Goal: or (expf m x d0) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 d0))) *)
(* Goal: forall (_ : not (@eq nat (A_1 m di0 x) d1)) (_ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (A_1 m di0 x)) nil))), or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (A_1 m di1 (A_1 m di0 x))))) *)
   assert (x = A m di0 d1).
(* Goal: @eq dart x (A m di0 d1) *)
(* Goal: or (expf m x d0) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 d0))) *)
(* Goal: forall (_ : not (@eq nat (A_1 m di0 x) d1)) (_ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (A_1 m di0 x)) nil))), or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (A_1 m di1 (A_1 m di0 x))))) *)
  apply A_1_A.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: exd m x *)
(* Goal: expf m d0 d0 *)
(* Goal: forall (_ : not (@eq nat (A_1 m di0 x) d1)) (_ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (A_1 m di0 x)) nil))), or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (A_1 m di1 (A_1 m di0 x))))) *)
  apply pred_exd with di0.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  unfold pred in |- *.
(* Goal: inv_qhmap m *)
     tauto.
  symmetry  in |- *.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: or (expf m x d0) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 d0))) *)
(* Goal: forall (_ : not (@eq nat (A_1 m di0 x) d1)) (_ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (A_1 m di0 x)) nil))), or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (A_1 m di1 (A_1 m di0 x))))) *)
 rewrite <- H1 in |- *.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   right.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   split.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
  intro.
(* Goal: False *)
(* Goal: and (expf m x x) (expf m d0 d0) *)
(* Goal: forall (_ : not (@eq nat (A_1 m di0 x) d1)) (_ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (A_1 m di0 x)) nil))), or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (A_1 m di1 (A_1 m di0 x))))) *)
    rewrite H2 in H0.
(* Goal: False *)
(* Goal: and (expf m x x) (expf m d0 d0) *)
(* Goal: forall (_ : not (@eq nat (A_1 m di0 x) d1)) (_ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (A_1 m di0 x)) nil))), or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (A_1 m di1 (A_1 m di0 x))))) *)
    rewrite A_1_nil in H0.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
 split.
(* Goal: expf m d0 d0 *)
(* Goal: forall (_ : not (@eq nat (A_1 m di0 x) d1)) (_ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (A_1 m di0 x)) nil))), or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (A_1 m di1 (A_1 m di0 x))))) *)
  apply refl_expf.
(* Goal: exd m x *)
(* Goal: expf m d0 d0 *)
(* Goal: forall (_ : not (@eq nat (A_1 m di0 x) d1)) (_ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (A_1 m di0 x)) nil))), or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (A_1 m di1 (A_1 m di0 x))))) *)
    apply pred_exd with di0.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  unfold pred in |- *.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: expf m d0 d0 *)
(* Goal: forall (_ : not (@eq nat (A_1 m di0 x) d1)) (_ : and (not (@eq dart (A_1 m di0 x) nil)) (not (@eq dart (A_1 m di1 (A_1 m di0 x)) nil))), or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (A_1 m di1 (A_1 m di0 x))))) *)
 apply refl_expf.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: or (expf m x (A_1 m di1 (A_1 m di0 x))) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (A_1 m di1 (A_1 m di0 x))))) *)
  fold (F m x) in |- *.
(* Goal: or (expf m x (F m x)) (and (not (@eq dart (A m di0 d1) nil)) (and (expf m x (A m di0 d1)) (expf m d0 (F m x)))) *)
  left.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
  apply IHm.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: succf mc y0 *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
unfold succf in |- *.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  unfold pred in |- *.
(* Goal: inv_qhmap m *)
   tauto.
Qed.

(* HYPOTHESIS: VERY IMPORTANT!!! *)

Lemma expf_clos_symm: forall(m:fmap)(x y:dart),
  inv_qhmap m -> expf (clos m) x y -> expf (clos m) y x.
Admitted.

Lemma expf_planar_L0_rcp: forall (m:fmap)(x y:dart),
   inv_qhmap (L m di0 x y) -> planar (L m di0 x y) -> 
      let mc:= clos m in
        (~eqc mc x y \/ expf mc (A_1 mc di1 x) y).
Proof.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
assert (planar m).
(* Goal: planar m *)
(* Goal: or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
 apply (planar_L0_rcp m x y H H0).
(* Goal: inv_qhmap m *)
(* Goal: @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
simpl in H.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  assert (inv_hmap (clos m)).
(* Goal: inv_hmap (clos m) *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 apply inv_hmap_clos.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
unfold inv_hmap in H2.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  decompose [and] H2.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  clear H2.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  unfold prec_Lq in H.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  assert (exd (clos m) x).
(* Goal: exd (clos m) x *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 generalize (exd_clos m x).
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
assert (exd (clos m) y).
(* Goal: exd (clos m) y *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 generalize (exd_clos m y).
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
generalize H1 H0.
(* Goal: forall _ : forall (_ : inv_qhmap (L m di1 d0 d1)) (_ : planar (L m di1 d0 d1)), planar m, @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
  unfold planar in |- *.
(* Goal: forall _ : forall _ : @eq Z (genus m) Z0, plf m, plf m *)
  unfold genus in |- *.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (nc (L m di1 x y)) (Z.div (ec (L m di1 x y)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  unfold ec in |- *.
(* Goal: plf (L m di1 d0 d1) *)
  simpl in |- *.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (if eqc_dec (clos m) x y then Z0 else Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  elim (eqc_dec (clos m) x y).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
 intro.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
   elim (eq_dart_dec (A (clos m) di0 x) y).
(* Goal: forall (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
  elim (eq_dart_dec y (A (clos m) di0 x)).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     right.
(* Goal: expf mc (A_1 mc di1 x) y *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di0 x))) (_ : @eq nat (A (clos m) di0 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) Z0)) (Z.add (nf m) (if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
     assert (x = A_1 (clos m) di0 y).
(* Goal: @eq dart y (A_1 mc di0 y0) *)
(* Goal: expf mc x y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    apply A_A_1.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: expf mc x y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   rewrite H8 in |- *.
(* Goal: forall (_ : expf (clos m) x (A (clos m) di0 y)) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zpos xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (expf (clos m) x (A (clos m) di0 y))) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     fold mc in |- *.
(* Goal: expf mc (A_1 mc di1 (A_1 mc di0 y)) y *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di0 x))) (_ : @eq nat (A (clos m) di0 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) Z0)) (Z.add (nf m) (if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
     fold (F mc y) in |- *.
(* Goal: expf mc (F mc y) y *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di0 x))) (_ : @eq nat (A (clos m) di0 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) Z0)) (Z.add (nf m) (if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
     assert (succf mc y).
(* Goal: succf mc y0 *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    unfold succf in |- *.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
      split.
(* Goal: forall (_ : expf (clos m) x (A (clos m) di0 y)) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zpos xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (expf (clos m) x (A (clos m) di0 y))) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     unfold mc in |- *.
(* Goal: succ (clos m) di0 y *)
(* Goal: exd (clos m) (A (clos m) di0 y) *)
(* Goal: @eq dart y0 (A mc di0 y) *)
(* Goal: expf mc x y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
       generalize (H4 y di0).
(* Goal: inv_qhmap m *)
        tauto.
(* Goal: forall (_ : expf (clos m) x (A (clos m) di0 y)) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zpos xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (expf (clos m) x (A (clos m) di0 y))) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    unfold mc in |- *.
(* Goal: pred (clos m) di1 (A_1 (clos m) di0 y) *)
(* Goal: expf mc (F mc y) y *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di0 x))) (_ : @eq nat (A (clos m) di0 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) Z0)) (Z.add (nf m) (if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
      rewrite <- H8 in |- *.
(* Goal: pred (clos m) di1 x *)
(* Goal: expf mc (F mc y) y *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di0 x))) (_ : @eq nat (A (clos m) di0 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) Z0)) (Z.add (nf m) (if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
      generalize (H4 x di1).
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: forall (_ : expf (clos m) x (A (clos m) di0 y)) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zpos xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (expf (clos m) x (A (clos m) di0 y))) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   unfold mc in |- *.
(* Goal: expf (clos m) (F (clos m) y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     apply expf_clos_symm.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (_ : expf (clos m) x (A (clos m) di0 y)) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zpos xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (expf (clos m) x (A (clos m) di0 y))) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   fold mc in |- *.
(* Goal: expf mc y (F mc y) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di0 x))) (_ : @eq nat (A (clos m) di0 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) Z0)) (Z.add (nf m) (if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
     apply (succf_expf_F mc y).
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
    symmetry  in a0.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
 elim (eq_dart_dec y (A (clos m) di0 x)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
  intro.
    symmetry  in a0.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (_ : not (@eq nat y (A (clos m) di0 x))) (_ : not (@eq nat (A (clos m) di0 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (Zpos xH))) (Z.add (nf m) (if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (nv m) (Z.sub (ne m) (if eq_dart_dec (A (clos m) di0 x) y then Z0 else Zpos xH))) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di0 x) then Z0 else if expf_dec (clos m) (A_1 (clos m) di1 x) y then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc (A_1 mc di1 x) y) *)
 elim (expf_dec (clos m) (A_1 (clos m) di1 x) y).
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
 intros.
   assert
    (nv m + (ne m - 1) + (nf m + -1) - nd m =
     nv m + ne m + nf m - nd m + -1 * 2).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
   omega.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 rewrite H8 in H7.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   clear H8.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   rewrite Z_div_plus in H7.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: Z.gt (Zpos (xO xH)) Z0 *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  assert (nc m - (nv m + ne m + nf m - nd m) / 2 <> 0).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
    omega.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
  omega.
(* Goal: inv_qhmap m *)
 tauto.
Qed.

Lemma expf_planar_L1_rcp: forall (m:fmap)(x y:dart),
   inv_qhmap (L m di1 x y) -> planar (L m di1 x y) -> 
      let mc:= clos m in
        (~eqc mc x y \/ expf mc x (A mc di0 y)).
Proof.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
assert (planar m).
(* Goal: planar m *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 apply (planar_L1_rcp m x y H H0).
(* Goal: inv_qhmap m *)
(* Goal: @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
simpl in H.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  assert (inv_hmap (clos m)).
(* Goal: inv_hmap (clos m) *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 apply inv_hmap_clos.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
unfold inv_hmap in H2.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  decompose [and] H2.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  clear H2.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  unfold prec_Lq in H.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  assert (exd (clos m) x).
(* Goal: exd (clos m) x *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 generalize (exd_clos m x).
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
assert (exd (clos m) y).
(* Goal: exd (clos m) y *)
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 generalize (exd_clos m y).
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
generalize H1 H0.
(* Goal: forall _ : forall (_ : inv_qhmap (L m di1 d0 d1)) (_ : planar (L m di1 d0 d1)), planar m, @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
  unfold planar in |- *.
(* Goal: forall _ : forall _ : @eq Z (genus m) Z0, plf m, plf m *)
  unfold genus in |- *.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (nc (L m di1 x y)) (Z.div (ec (L m di1 x y)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  unfold ec in |- *.
(* Goal: plf (L m di1 d0 d1) *)
  simpl in |- *.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (if eqc_dec (clos m) x y then Z0 else Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  elim (eqc_dec (clos m) x y).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
 intro.
(* Goal: forall (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   elim (eq_dart_dec (A (clos m) di1 x) y).
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  elim (eq_dart_dec y (A (clos m) di1 x)).
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   intros.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     right.
(* Goal: expf mc x (A mc di0 y) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     assert (x = A_1 (clos m) di1 y).
(* Goal: @eq dart y (A_1 mc di0 y0) *)
(* Goal: expf mc x y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    apply A_A_1.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: expf mc x (A mc di0 y) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   set (y0 := A mc di0 y) in |- *.
(* Goal: expf mc x y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     assert (y = A_1 mc di0 y0).
(* Goal: @eq dart y (A_1 mc di0 y0) *)
(* Goal: expf mc x y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    apply A_A_1.
(* Goal: forall (_ : expf (clos m) x (A (clos m) di0 y)) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zpos xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (expf (clos m) x (A (clos m) di0 y))) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     unfold mc in |- *.
(* Goal: inv_qhmap m *)
        tauto.
(* Goal: forall (_ : expf (clos m) x (A (clos m) di0 y)) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zpos xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (expf (clos m) x (A (clos m) di0 y))) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    unfold mc in |- *.
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: forall (_ : expf (clos m) x (A (clos m) di0 y)) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zpos xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (expf (clos m) x (A (clos m) di0 y))) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    unfold mc in |- *.
(* Goal: and (pred mc di0 y0) (pred mc di1 (A_1 mc di0 y0)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
      unfold y0 in |- *.
(* Goal: forall (_ : expf (clos m) x (A (clos m) di0 y)) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zpos xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (expf (clos m) x (A (clos m) di0 y))) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
      unfold mc in |- *.
(* Goal: exd (clos m) (A (clos m) di0 y) *)
(* Goal: @eq dart y0 (A mc di0 y) *)
(* Goal: expf mc x y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
      assert (succ (clos m) di0 y).
(* Goal: succ (clos m) di0 y *)
(* Goal: exd (clos m) (A (clos m) di0 y) *)
(* Goal: @eq dart y0 (A mc di0 y) *)
(* Goal: expf mc x y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     generalize (H4 y di0).
(* Goal: inv_qhmap m *)
        tauto.
(* Goal: exd (clos m) (A (clos m) di0 y) *)
(* Goal: @eq dart y0 (A mc di0 y) *)
(* Goal: expf mc x y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    apply succ_exd_A.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: not (@eq dart (A_1 mc di1 (A_1 mc di0 (A mc di0 y))) nil) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    fold y0 in |- *.
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: expf mc x y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   rewrite H8 in |- *.
(* Goal: expf mc (A_1 (clos m) di1 y) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     rewrite H9 in |- *.
(* Goal: forall (_ : expf (clos m) x (A (clos m) di0 y)) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zpos xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (expf (clos m) x (A (clos m) di0 y))) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     fold mc in |- *.
(* Goal: expf mc (A_1 mc di1 (A_1 mc di0 y0)) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     fold (F mc y0) in |- *.
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     assert (succf mc y0).
(* Goal: succf mc y0 *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    unfold succf in |- *.
(* Goal: and (pred mc di0 y0) (pred mc di1 (A_1 mc di0 y0)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
      unfold y0 in |- *.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
      split.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     unfold pred in |- *.
(* Goal: not (@eq dart (A_1 mc di0 (A mc di0 y)) nil) *)
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
       fold y0 in |- *; rewrite <- H9 in |- *.
(* Goal: not (@eq dart y nil) *)
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
       apply exd_not_nil with m.
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: pred mc di1 (A_1 mc di0 (A mc di0 y)) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    unfold pred in |- *.
(* Goal: not (@eq dart (A_1 mc di1 (A_1 mc di0 (A mc di0 y))) nil) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
      fold y0 in |- *.
(* Goal: not (@eq dart (A_1 mc di1 (A_1 mc di0 y0)) nil) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
      rewrite <- H9 in |- *.
(* Goal: not (@eq dart (A_1 mc di1 y) nil) *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
      fold (pred mc di1 y) in |- *.
(* Goal: pred mc di1 y *)
(* Goal: expf mc (F mc y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
      generalize (H4 y di1).
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: forall (_ : expf (clos m) x (A (clos m) di0 y)) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zpos xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (expf (clos m) x (A (clos m) di0 y))) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   unfold mc in |- *.
(* Goal: expf (clos m) (F (clos m) y0) y0 *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     apply expf_clos_symm.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (_ : expf (clos m) x (A (clos m) di0 y)) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zpos xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (expf (clos m) x (A (clos m) di0 y))) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   fold mc in |- *.
(* Goal: expf mc y0 (F mc y0) *)
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : @eq nat (A (clos m) di1 x) y) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) Z0) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
     apply succf_expf_F.
(* Goal: forall (_ : expf (clos m) x (A (clos m) di0 y)) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zpos xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (expf (clos m) x (A (clos m) di0 y))) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
    unfold mc in |- *.
(* Goal: inv_qhmap m *)
       tauto.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
  intros.
    symmetry  in a0.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 elim (eq_dart_dec y (A (clos m) di1 x)).
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
  intro.
    symmetry  in a0.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 elim (expf_dec (clos m) x (A (clos m) di0 y)).
(* Goal: forall (_ : expf (clos m) x (A (clos m) di0 y)) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zpos xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (expf (clos m) x (A (clos m) di0 y))) (_ : not (@eq nat y (A (clos m) di1 x))) (_ : not (@eq nat (A (clos m) di1 x) y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) Z0) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (Zpos xH)) (ne m)) (Z.add (nf m) (Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  fold mc in |- *.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
 intros.
   assert
    (nv m - 1 + ne m + (nf m + -1) - nd m =
     nv m + ne m + nf m - nd m + -1 * 2).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
   omega.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
 rewrite H8 in H7.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   clear H8.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
   rewrite Z_div_plus in H7.
(* Goal: or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
(* Goal: Z.gt (Zpos (xO xH)) Z0 *)
(* Goal: forall (_ : not (eqc (clos m) x y)) (_ : @eq Z (Z.sub (nc m) (Z.div (Z.sub (Z.add (Z.add (nv m) (ne m)) (nf m)) (nd m)) (Zpos (xO xH)))) Z0) (_ : @eq Z (Z.sub (Z.sub (nc m) (Zpos xH)) (Z.div (Z.sub (Z.add (Z.add (Z.sub (nv m) (if eq_dart_dec (A (clos m) di1 x) y then Z0 else Zpos xH)) (ne m)) (Z.add (nf m) (if eq_dart_dec y (A (clos m) di1 x) then Z0 else if expf_dec (clos m) x (A (clos m) di0 y) then Zpos xH else Zneg xH))) (nd m)) (Zpos (xO xH)))) Z0), or (not (eqc mc x y)) (expf mc x (A mc di0 y)) *)
  assert (nc m - (nv m + ne m + nf m - nd m) / 2 <> 0).
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
    omega.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
  omega.
(* Goal: inv_qhmap m *)
 tauto.
Qed.

Theorem plf_planar_rcp: forall m:fmap,
  inv_qhmap m -> genus m = 0 -> plf m.
Proof.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: plf m *)
induction m.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: plf (L m di1 d0 d1) *)
simpl in |- *.
(* Goal: inv_qhmap m *)
(* Goal: @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
  simpl in H.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
  apply IHm.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: @eq Z (genus m) Z0 *)
(* Goal: plf (L m d d0 d1) *)
rewrite eq_genus_I in H0.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: plf (L m di1 d0 d1) *)
simpl in |- *.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: plf (L m d d0 d1) *)
induction d.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   split.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
  apply IHm.
(* Goal: inv_qhmap m *)
(* Goal: @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
   simpl in H.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) (A_1 (clos m) di1 d0) d1) *)
(* Goal: plf (L m di1 d0 d1) *)
  generalize (planar_L0_rcp m d0 d1).
(* Goal: forall _ : forall (_ : inv_qhmap (L m di1 d0 d1)) (_ : planar (L m di1 d0 d1)), planar m, @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
    unfold planar in |- *.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) (A_1 (clos m) di1 d0) d1) *)
(* Goal: plf (L m di1 d0 d1) *)
 apply expf_planar_L0_rcp.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: inv_qhmap m *)
  tauto.
(* Goal: plf (L m di1 d0 d1) *)
 simpl in |- *.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
   split.
(* Goal: plf m *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
  apply IHm.
(* Goal: inv_qhmap m *)
(* Goal: @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
   simpl in H.
(* Goal: inv_qhmap m *)
      tauto.
(* Goal: @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
  generalize (planar_L1_rcp m d0 d1).
(* Goal: forall _ : forall (_ : inv_qhmap (L m di1 d0 d1)) (_ : planar (L m di1 d0 d1)), planar m, @eq Z (genus m) Z0 *)
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
    unfold planar in |- *.
(* Goal: inv_qhmap m *)
     tauto.
(* Goal: or (not (eqc (clos m) d0 d1)) (expf (clos m) d0 (A (clos m) di0 d1)) *)
 apply expf_planar_L1_rcp.
(* Goal: inv_qhmap m *)
   tauto.
(* Goal: inv_qhmap m *)
  tauto.
Qed.

(* Corollary: *)

Theorem plf_Euler_Poincare_rcp: forall m:fmap,
  inv_qhmap m -> ec m / 2 = nc m -> plf m.
Proof.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: plf m *)
generalize (plf_planar_rcp m H).
(* Goal: forall _ : forall _ : @eq Z (genus m) Z0, plf m, plf m *)
unfold genus in |- *.
(* Goal: forall _ : forall _ : @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0, plf m, plf m *)
intro.
(* Goal: plf m *)
apply H1.
(* Goal: @eq Z (Z.sub (nc m) (Z.div (ec m) (Zpos (xO xH)))) Z0 *)
 omega.
Qed.

(* Corollary: CHARACTERIZATION OF THE PLANAR POLYHEDRA: *)

Theorem Euler_Poincare_criterion: forall m:fmap,
  inv_qhmap m -> (plf m <-> ec m / 2 = nc m).
Proof.
(* Goal: forall (m : fmap) (_ : inv_qhmap m), iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
intros.
(* Goal: iff (plf m) (@eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m)) *)
split.
(* Goal: forall _ : plf m, @eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m) *)
(* Goal: forall _ : @eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m), plf m *)
 apply plf_Euler_Poincare.
(* Goal: inv_qhmap m *)
    tauto.
(* Goal: forall _ : @eq Z (Z.div (ec m) (Zpos (xO xH))) (nc m), plf m *)
apply plf_Euler_Poincare_rcp.
(* Goal: inv_qhmap m *)
   tauto.
Qed.

(*==========================================================
============================================================

		      THE END

============================================================
===========================================================*)

