(* This program is free software; you can redistribute it and/or      *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1   *)
(* of the License, or (at your option) any later version.             *)
(*                                                                    *)
(* This program is distributed in the hope that it will be useful,    *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of     *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *)
(* GNU General Public License for more details.                       *)
(*                                                                    *)
(* You should have received a copy of the GNU Lesser General Public   *)
(* License along with this program; if not, write to the Free         *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA                                                     *)


Require Import Bool.
Require Import Sumbool.
Require Import Arith.
Require Import ZArith NArith Nnat Ndec Ndigits.
From IntMap Require Import Allmaps.
Require Import Wf_nat.

Require Import BDDvar_ad_nat.
Require Import bdd1.
Require Import bdd2.
Require Import bdd3.
Require Import bdd4.
Require Import bdd5_1.

Lemma BDDneg_memo_OK_1_lemma_2_1' :
 forall (cfg : BDDconfig) (memo : BDDneg_memo),
 BDDconfig_OK cfg ->
 BDDneg_memo_OK_2 cfg memo ->
 BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDzero BDDone).
Proof.
(* Goal: forall (cfg : BDDconfig) (x : BDDvar) (l r node : ad) (n m : nat) (memo : BDDneg_memo) (_ : BDDconfig_OK cfg) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) cfg) node) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) x (@pair ad ad l r)))) (_ : lt (N.to_nat (var cfg node)) n) (_ : @eq nat n (S m)) (_ : BDDneg_memo_OK_2 (@fst BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 cfg l m)) r m)) memo), BDDneg_memo_OK_2 (@fst BDDconfig ad (BDDneg_2 cfg node n)) (BDDneg_memo_put memo node (@snd BDDconfig ad (BDDneg_2 cfg node n))) *)
  intro cfg.  elim cfg; clear cfg; intros bs y; elim y; clear y; intros share counter.
(* Goal: forall (memo : BDDneg_memo) (_ : BDDconfig_OK (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter))) (_ : BDDneg_memo_OK_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) memo), BDDneg_memo_OK_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) (BDDneg_memo_put memo BDDone BDDzero) *)
  intros memo H H0.  unfold BDDneg_memo_OK_2 in |- *.  intros node node' bound H1 H2.  unfold BDDneg_memo_put, BDDneg_memo_lookup in H1.
(* Goal: and (config_node_OK (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node) (@eq (prod BDDconfig ad) (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node bound) (@pair BDDconfig ad (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node')) *)
  rewrite (MapPut_semantics ad memo BDDzero BDDone node) in H1.  elim (sumbool_of_bool (Neqb BDDzero node)).
(* Goal: forall _ : @eq (option ad) (BDDneg_memo_lookup (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None ad), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro y.  cut (BDDzero = node).  intro H3.  rewrite y in H1.  injection H1.  intros H4.
(* Goal: and (config_node_OK (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node) (@eq (prod BDDconfig ad) (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node bound) (@pair BDDconfig ad (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node')) *)
(* Goal: @eq N BDDone node *)
(* Goal: forall _ : @eq bool (N.eqb BDDone node) false, and (config_node_OK (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node) (@eq (prod BDDconfig ad) (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node bound) (@pair BDDconfig ad (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node')) *)
  rewrite <- H3.  rewrite <- H4.  split.  left; reflexivity.  elim bound.
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  simpl in |- *.  elim H.  intros H5 H6.  elim H5; intros.  rewrite H7.  reflexivity.  
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  intros n H5.  simpl in |- *.  elim H.  intros H6 H7.  elim H6; intros.  simpl in H9.  rewrite H8.
(* Goal: forall _ : @eq (option ad) (BDDneg_memo_lookup (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None ad), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  reflexivity.  apply Neqb_complete.  assumption.  intro y.  rewrite y in H1.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  unfold BDDneg_memo_OK_2 in H0.  apply H0.  assumption.  assumption.
Qed.

Lemma BDDneg_memo_OK_1_lemma_3_1' :
 forall (cfg : BDDconfig) (memo : BDDneg_memo),
 BDDconfig_OK cfg ->
 BDDneg_memo_OK_2 cfg memo ->
 BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero).
Proof.
(* Goal: forall (cfg : BDDconfig) (x : BDDvar) (l r node : ad) (n m : nat) (memo : BDDneg_memo) (_ : BDDconfig_OK cfg) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) cfg) node) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) x (@pair ad ad l r)))) (_ : lt (N.to_nat (var cfg node)) n) (_ : @eq nat n (S m)) (_ : BDDneg_memo_OK_2 (@fst BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 cfg l m)) r m)) memo), BDDneg_memo_OK_2 (@fst BDDconfig ad (BDDneg_2 cfg node n)) (BDDneg_memo_put memo node (@snd BDDconfig ad (BDDneg_2 cfg node n))) *)
  intro cfg.  elim cfg; clear cfg; intros bs y; elim y; clear y; intros share counter.
(* Goal: forall (memo : BDDneg_memo) (_ : BDDconfig_OK (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter))) (_ : BDDneg_memo_OK_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) memo), BDDneg_memo_OK_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) (BDDneg_memo_put memo BDDone BDDzero) *)
  intros memo H H0.  unfold BDDneg_memo_OK_2 in |- *.  intros node node' bound H1 H2.  unfold BDDneg_memo_put, BDDneg_memo_lookup in H1.
(* Goal: and (config_node_OK (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node) (@eq (prod BDDconfig ad) (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node bound) (@pair BDDconfig ad (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node')) *)
  rewrite (MapPut_semantics ad memo BDDone BDDzero node) in H1.  elim (sumbool_of_bool (Neqb BDDone node)).
(* Goal: forall _ : @eq (option ad) (BDDneg_memo_lookup (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None ad), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro y.  cut (BDDone = node).  intro H3.  rewrite y in H1.  injection H1.  intros H4.
(* Goal: and (config_node_OK (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node) (@eq (prod BDDconfig ad) (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node bound) (@pair BDDconfig ad (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node')) *)
(* Goal: @eq N BDDone node *)
(* Goal: forall _ : @eq bool (N.eqb BDDone node) false, and (config_node_OK (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node) (@eq (prod BDDconfig ad) (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node bound) (@pair BDDconfig ad (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node')) *)
  rewrite <- H3.  rewrite <- H4.  split.  right; left; reflexivity.  elim bound.
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  simpl in |- *.  elim H.  intros H5 H6.  elim H5; intros.  rewrite (proj1 H8).  reflexivity.
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  intros n H5.  simpl in |- *.  elim H.  intros H6 H7.  elim H6; intros.  rewrite (proj1 H9).
(* Goal: forall _ : @eq (option ad) (BDDneg_memo_lookup (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None ad), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  reflexivity.  apply Neqb_complete.  assumption.  intro y.  rewrite y in H1.  unfold BDDneg_memo_OK_2 in H0.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  apply H0.  assumption.  assumption.
Qed.

Lemma BDDneg_memo_OK_1_lemma_1_2' :
 forall (cfg : BDDconfig) (x : BDDvar) (l r node : ad) 
   (n m : nat) (memo : BDDneg_memo),
 BDDconfig_OK cfg ->
 MapGet _ (fst cfg) node = Some (x, (l, r)) ->
 nat_of_N (var cfg node) < n ->
 n = S m ->
 BDDneg_memo_OK_2 (fst (BDDneg_2 (fst (BDDneg_2 cfg l m)) r m)) memo ->
 BDDneg_memo_OK_2 (fst (BDDneg_2 cfg node n))
   (BDDneg_memo_put memo node (snd (BDDneg_2 cfg node n))).
Proof.
(* Goal: forall (cfg : BDDconfig) (x : BDDvar) (l r node : ad) (n m : nat) (memo : BDDneg_memo) (_ : BDDconfig_OK cfg) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) cfg) node) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) x (@pair ad ad l r)))) (_ : lt (N.to_nat (var cfg node)) n) (_ : @eq nat n (S m)) (_ : BDDneg_memo_OK_2 (@fst BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 cfg l m)) r m)) memo), BDDneg_memo_OK_2 (@fst BDDconfig ad (BDDneg_2 cfg node n)) (BDDneg_memo_put memo node (@snd BDDconfig ad (BDDneg_2 cfg node n))) *)
  intro cfg.  elim cfg; clear cfg; intros bs y; elim y; clear y; intros share counter.
(* Goal: BDDneg_memo_OK_2 initBDDconfig (newMap ad) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intros x l r node n m memo H H0 H1.  intro H3.  intros H2.  unfold BDDneg_memo_OK_2 in |- *.
(* Goal: forall (node0 node' : ad) (bound : nat) (_ : @eq (option ad) (BDDneg_memo_lookup (BDDneg_memo_put memo node (@snd BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n))) node0) (@Some ad node')) (_ : forall _ : is_internal_node (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node0, lt (N.to_nat (var (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node0)) bound), and (config_node_OK (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node0) (@eq (prod BDDconfig ad) (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node0 bound) (@pair BDDconfig ad (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node')) *)
  intros node0 node' bound H4 H5.  unfold BDDneg_memo_put, BDDneg_memo_lookup in H4.  rewrite
   (MapPut_semantics ad memo node
      (snd (BDDneg_2 (bs, (share, counter)) node n)) node0)
    in H4.
(* Goal: forall _ : @eq (option ad) (BDDneg_memo_lookup (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None ad), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  elim (sumbool_of_bool (Neqb node node0)).  intro y.  rewrite y in H4.  injection H4; intros.
(* Goal: and (@eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero)) *)
  cut (node = node0).  intro H7.  rewrite <- H7.  rewrite <- H7 in H5.  split.
(* Goal: config_node_OK (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node *)
(* Goal: config_node_OK (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node' *)
(* Goal: forall _ : is_internal_node (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node, lt (N.to_nat (var (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node)) bound *)
(* Goal: bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node') (bool_fun_neg (bool_fun_of_BDD (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node)) *)
(* Goal: @eq ad node node0 *)
(* Goal: forall _ : @eq bool (N.eqb node node0) false, and (config_node_OK (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node0) (@eq (prod BDDconfig ad) (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node0 bound) (@pair BDDconfig ad (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node')) *)
  apply nodes_preserved_2 with (cfg := (bs, (share, counter))).  right; right.  unfold in_dom in |- *.
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  rewrite H0.  reflexivity.  unfold nodes_preserved in |- *.  cut (config_node_OK (bs, (share, counter)) node).
  cut
   (is_internal_node (bs, (share, counter)) node ->
    nat_of_N (var (bs, (share, counter)) node) < n).
(* Goal: forall (_ : forall _ : is_internal_node (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node, lt (N.to_nat (var (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node)) n) (_ : config_node_OK (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node) (x : BDDvar) (l r node0 : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter))) node0) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) x (@pair ad ad l r)))), @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n))) node0) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) x (@pair ad ad l r))) *)
(* Goal: forall _ : is_internal_node (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node, lt (N.to_nat (var (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node)) n *)
(* Goal: config_node_OK (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node *)
(* Goal: config_node_OK (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node' *)
(* Goal: forall _ : is_internal_node (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node, lt (N.to_nat (var (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node)) bound *)
(* Goal: bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node') (bool_fun_neg (bool_fun_of_BDD (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node)) *)
(* Goal: @eq ad node node0 *)
(* Goal: forall _ : @eq bool (N.eqb node node0) false, and (config_node_OK (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node0) (@eq (prod BDDconfig ad) (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node0 bound) (@pair BDDconfig ad (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node')) *)
  intros H8 H9.  exact
   (proj1 (proj2 (BDDneg_2_lemma n (bs, (share, counter)) node H H9 H8))).
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  intro; assumption.  right; right.  unfold in_dom in |- *.  rewrite H0; reflexivity.
(* Goal: BDDconfig_OK (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) *)
(* Goal: forall (x : BDDvar) (l0 r0 a : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) l m)) r m))) a) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) x (@pair ad ad l0 r0)))), @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n))) a) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) x (@pair ad ad l0 r0))) *)
(* Goal: config_node_OK (@fst BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) l m)) r m)) node0 *)
  apply BDDneg_memo_OK_1_lemma_1_1_1.  cut (config_node_OK (bs, (share, counter)) node).
(* Goal: forall _ : @eq BDDvar (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r) (var cfg r), lt (N.to_nat (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r)) m *)
(* Goal: @eq BDDvar (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r) (var cfg r) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H8.  cut
   (is_internal_node (bs, (share, counter)) node ->
    nat_of_N (var (bs, (share, counter)) node) < n).
(* Goal: forall _ : forall _ : is_internal_node (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node, lt (N.to_nat (var (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node)) n, config_node_OK (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) (@snd BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) *)
(* Goal: forall _ : is_internal_node (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node, lt (N.to_nat (var (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node)) n *)
(* Goal: config_node_OK (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node *)
(* Goal: forall _ : is_internal_node (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node, lt (N.to_nat (var (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node)) bound *)
(* Goal: bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node') (bool_fun_neg (bool_fun_of_BDD (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node)) *)
(* Goal: @eq ad node node0 *)
(* Goal: forall _ : @eq bool (N.eqb node node0) false, and (config_node_OK (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node0) (@eq (prod BDDconfig ad) (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node0 bound) (@pair BDDconfig ad (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node')) *)
  intros H9.  exact (proj1 (BDDneg_2_lemma n (bs, (share, counter)) node H H8 H9)).
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  intro H9.  assumption.  right.  right.  unfold in_dom in |- *.  rewrite H0.  reflexivity.
(* Goal: config_node_OK (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node *)
(* Goal: config_node_OK (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node' *)
(* Goal: forall _ : is_internal_node (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node, lt (N.to_nat (var (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node)) bound *)
(* Goal: bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node') (bool_fun_neg (bool_fun_of_BDD (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node)) *)
(* Goal: @eq ad node node0 *)
(* Goal: forall _ : @eq bool (N.eqb node node0) false, and (config_node_OK (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node0) (@eq (prod BDDconfig ad) (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node0 bound) (@pair BDDconfig ad (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node')) *)
  apply nodes_preserved_2 with (cfg := (bs, (share, counter))).  right; right.  unfold in_dom in |- *.
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  rewrite H0.  reflexivity.  unfold nodes_preserved in |- *.  cut (config_node_OK (bs, (share, counter)) node).
  cut
   (is_internal_node (bs, (share, counter)) node ->
    nat_of_N (var (bs, (share, counter)) node) < n).
(* Goal: forall (_ : forall _ : is_internal_node (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node, lt (N.to_nat (var (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node)) n) (_ : config_node_OK (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node) (x : BDDvar) (l r node0 : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter))) node0) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) x (@pair ad ad l r)))), @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n))) node0) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) x (@pair ad ad l r))) *)
(* Goal: forall _ : is_internal_node (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node, lt (N.to_nat (var (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node)) n *)
(* Goal: config_node_OK (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node *)
(* Goal: config_node_OK (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node' *)
(* Goal: forall _ : is_internal_node (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node, lt (N.to_nat (var (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node)) bound *)
(* Goal: bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node') (bool_fun_neg (bool_fun_of_BDD (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node)) *)
(* Goal: @eq ad node node0 *)
(* Goal: forall _ : @eq bool (N.eqb node node0) false, and (config_node_OK (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node0) (@eq (prod BDDconfig ad) (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node0 bound) (@pair BDDconfig ad (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node')) *)
  intros H8 H9.  exact
   (proj1 (proj2 (BDDneg_2_lemma n (bs, (share, counter)) node H H9 H8))).
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  intro; assumption.  right; right.  unfold in_dom in |- *.  rewrite H0; reflexivity.
(* Goal: BDDconfig_OK (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) *)
(* Goal: forall (x : BDDvar) (l0 r0 a : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) l m)) r m))) a) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) x (@pair ad ad l0 r0)))), @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n))) a) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) x (@pair ad ad l0 r0))) *)
(* Goal: config_node_OK (@fst BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) l m)) r m)) node0 *)
  rewrite <- H6.  cut (config_node_OK (bs, (share, counter)) node).  intro H8.
  cut
   (is_internal_node (bs, (share, counter)) node ->
    nat_of_N (var (bs, (share, counter)) node) < n).
(* Goal: forall _ : forall _ : is_internal_node (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node, lt (N.to_nat (var (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node)) n, config_node_OK (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) (@snd BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) *)
(* Goal: forall _ : is_internal_node (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node, lt (N.to_nat (var (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node)) n *)
(* Goal: config_node_OK (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node *)
(* Goal: forall _ : is_internal_node (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node, lt (N.to_nat (var (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node)) bound *)
(* Goal: bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node') (bool_fun_neg (bool_fun_of_BDD (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node)) *)
(* Goal: @eq ad node node0 *)
(* Goal: forall _ : @eq bool (N.eqb node node0) false, and (config_node_OK (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node0) (@eq (prod BDDconfig ad) (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node0 bound) (@pair BDDconfig ad (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node')) *)
  intros H9.  exact
   (proj1
      (proj2
         (proj2
            (proj2 (BDDneg_2_lemma n (bs, (share, counter)) node H H8 H9))))).  
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  intro; assumption.  right; right.  unfold in_dom in |- *.  rewrite H0; reflexivity.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption.  rewrite <- H6.  cut (config_node_OK (bs, (share, counter)) node).
(* Goal: forall _ : @eq BDDvar (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r) (var cfg r), lt (N.to_nat (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r)) m *)
(* Goal: @eq BDDvar (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r) (var cfg r) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H8.  cut
   (is_internal_node (bs, (share, counter)) node ->
    nat_of_N (var (bs, (share, counter)) node) < n).
(* Goal: forall _ : @eq ad r (high cfg node), @eq comparison (BDDcompare (var cfg r) (var cfg node)) Lt *)
(* Goal: @eq ad r (high cfg node) *)
(* Goal: lt (N.to_nat (var cfg node)) (S m) *)
(* Goal: @eq BDDvar (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r) (var cfg r) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H9.  apply
   bool_fun_eq_trans
    with (bf2 := bool_fun_neg (bool_fun_of_BDD (bs, (share, counter)) node)).
  exact
   (proj2
      (proj2
         (proj2
            (proj2 (BDDneg_2_lemma n (bs, (share, counter)) node H H8 H9))))).
(* Goal: bool_fun_eq (bool_fun_neg (bool_fun_of_BDD (@fst BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) l m)) r m)) node0)) (bool_fun_neg (bool_fun_of_BDD (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node0)) *)
  apply bool_fun_eq_neg_1.  apply bool_fun_eq_symm.  apply bool_fun_preservation.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption.  exact (proj1 (BDDneg_2_lemma n (bs, (share, counter)) node H H8 H9)).
  exact
   (proj1 (proj2 (BDDneg_2_lemma n (bs, (share, counter)) node H H8 H9))).
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption.  intro; assumption.  right; right.  unfold in_dom in |- *.  rewrite H0.
(* Goal: forall _ : @eq (option ad) (BDDneg_memo_lookup (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None ad), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  reflexivity.  apply Neqb_complete.  assumption.  intro y.  rewrite y in H4.
(* Goal: and (@eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero)) *)
  unfold BDDneg_memo_OK_2 in H2.  split.  apply
   nodes_preserved_2
    with
      (cfg := fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m)).
  cut
   (is_internal_node
      (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m)) node0 ->
    nat_of_N
      (var (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m))
         node0) <
    S
      (nat_of_N
         (var
            (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m))
            node0))).
(* Goal: forall _ : is_internal_node cfg l, lt (N.to_nat (var cfg l)) m *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H6.  exact
   (proj1
      (H2 node0 node'
         (S
            (nat_of_N
               (var
                  (fst
                     (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r
                        m)) node0))) H4 H6)).
(* Goal: forall _ : is_internal_node cfg l, lt (N.to_nat (var cfg l)) m *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H6.  unfold lt in |- *.  apply le_n.  apply nodes_preserved_1 with (n := n) (x := x).
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption.  assumption.  assumption.  assumption.  apply BDDneg_memo_OK_1_lemma_1_1_1.
(* Goal: BDDconfig_OK (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) *)
(* Goal: forall (x : BDDvar) (l0 r0 a : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) l m)) r m))) a) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) x (@pair ad ad l0 r0)))), @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n))) a) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) x (@pair ad ad l0 r0))) *)
(* Goal: config_node_OK (@fst BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) l m)) r m)) node0 *)
  cut (config_node_OK (bs, (share, counter)) node).  intro H6.  cut
   (is_internal_node (bs, (share, counter)) node ->
    nat_of_N (var (bs, (share, counter)) node) < n).
(* Goal: forall _ : @eq ad l (low cfg node), @eq comparison (BDDcompare (var cfg l) (var cfg node)) Lt *)
(* Goal: @eq ad l (low cfg node) *)
(* Goal: lt (N.to_nat (var cfg node)) (S m) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H7.  exact (proj1 (BDDneg_2_lemma n (bs, (share, counter)) node H H6 H7)).
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  intro H7.  assumption.  right.  right.  unfold in_dom in |- *.  rewrite H0.  reflexivity.
  apply
   nodes_preserved_2
    with
      (cfg := fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m)).
  cut
   (is_internal_node
      (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m)) node0 ->
    nat_of_N
      (var (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m))
         node0) <
    S
      (nat_of_N
         (var
            (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m))
            node0))).
(* Goal: forall _ : is_internal_node cfg l, lt (N.to_nat (var cfg l)) m *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H6.  exact
   (proj1
      (H2 node0 node'
         (S
            (nat_of_N
               (var
                  (fst
                     (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r
                        m)) node0))) H4 H6)).
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  intro H6.  unfold lt in |- *.  apply le_n.  apply nodes_preserved_1 with (n := n) (x := x).  assumption.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption.  assumption.  assumption.  cut
   (config_node_OK
      (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m)) node').
(* Goal: forall _ : is_internal_node cfg l, lt (N.to_nat (var cfg l)) m *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H6.  cut
   (nodes_preserved
      (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m))
      (fst (BDDneg_2 (bs, (share, counter)) node n))).
(* Goal: forall _ : @eq ad l (low cfg node), @eq comparison (BDDcompare (var cfg l) (var cfg node)) Lt *)
(* Goal: @eq ad l (low cfg node) *)
(* Goal: lt (N.to_nat (var cfg node)) (S m) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H7.  apply
   nodes_preserved_2
    with
      (cfg := fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m)).
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption.  assumption.  apply nodes_preserved_1 with (x := x).  assumption.  
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption.  assumption.  assumption.  apply BDDneg_memo_OK_lemma_1_4' with (memo := memo) (node := node0).
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  apply BDDneg_2_config_OK_lemma_2 with (n := n) (x := x) (node := node).  assumption.  assumption.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption.  assumption.  assumption.  cut
   (is_internal_node
      (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m)) node0 ->
    nat_of_N
      (var (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m))
         node0) <
    S
      (nat_of_N
         (var
            (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m))
            node0))).
(* Goal: forall _ : is_internal_node cfg l, lt (N.to_nat (var cfg l)) m *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H6.  exact
   (proj1
      (H2 node0 node'
         (S
            (nat_of_N
               (var
                  (fst
                     (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r
                        m)) node0))) H4 H6)).
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  intro H6.  unfold lt in |- *.  apply le_n.  assumption.  assumption.  apply
   bool_fun_eq_trans
    with
      (bf2 := bool_fun_of_BDD
                (fst
                   (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m))
                node').
(* Goal: bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node0) (bool_fun_of_BDD (@fst BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) l m)) r m)) node0) *)
  apply bool_fun_preservation.  apply BDDneg_2_config_OK_lemma_2 with (node := node) (x := x) (n := n).
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption.  assumption.  assumption.  assumption.  cut (config_node_OK (bs, (share, counter)) node).
(* Goal: forall _ : is_internal_node cfg l, lt (N.to_nat (var cfg l)) m *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H6.  cut
   (is_internal_node (bs, (share, counter)) node ->
    nat_of_N (var (bs, (share, counter)) node) < n).
(* Goal: forall _ : @eq ad l (low cfg node), @eq comparison (BDDcompare (var cfg l) (var cfg node)) Lt *)
(* Goal: @eq ad l (low cfg node) *)
(* Goal: lt (N.to_nat (var cfg node)) (S m) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H7.  exact (proj1 (BDDneg_2_lemma n (bs, (share, counter)) node H H6 H7)).  
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  intro; assumption.  right; right.  unfold in_dom in |- *.  rewrite H0.  reflexivity.
  cut
   (nodes_preserved
      (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m))
      (fst (BDDneg_2 (bs, (share, counter)) node n))).
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  unfold nodes_preserved in |- *.  intro H6.  assumption.  apply nodes_preserved_1 with (x := x).
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption.  assumption.  assumption.  assumption.  apply BDDneg_memo_OK_lemma_1_4' with (memo := memo) (node := node0).
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  apply BDDneg_2_config_OK_lemma_2 with (node := node) (x := x) (n := n).  assumption.  assumption.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption.  assumption.  assumption.  cut
   (is_internal_node
      (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m)) node0 ->
    nat_of_N
      (var (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m))
         node0) <
    S
      (nat_of_N
         (var
            (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m))
            node0))).
(* Goal: forall _ : is_internal_node cfg l, lt (N.to_nat (var cfg l)) m *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H6.  exact
   (proj1
      (H2 node0 node'
         (S
            (nat_of_N
               (var
                  (fst
                     (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r
                        m)) node0))) H4 H6)).
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  intro H6.  unfold lt in |- *.  apply le_n.  assumption.  apply
   bool_fun_eq_trans
    with
      (bf2 := bool_fun_neg
                (bool_fun_of_BDD
                   (fst
                      (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r
                         m)) node0)).
(* Goal: BDDconfig_OK (@fst BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) l m)) r m)) *)
(* Goal: BDDneg_memo_OK_2 (@fst BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) l m)) r m)) memo *)
(* Goal: config_node_OK (@fst BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) l m)) r m)) node0 *)
(* Goal: @eq (option ad) (BDDneg_memo_lookup memo node0) (@Some ad node') *)
(* Goal: bool_fun_eq (bool_fun_neg (bool_fun_of_BDD (@fst BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) l m)) r m)) node0)) (bool_fun_neg (bool_fun_of_BDD (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node0)) *)
  apply BDDneg_memo_OK_bool_fun_1' with (memo := memo).  apply BDDneg_2_config_OK_lemma_2 with (node := node) (x := x) (n := n).
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption.  assumption.  assumption.  assumption.  assumption.  cut
   (is_internal_node
      (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m)) node0 ->
    nat_of_N
      (var (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m))
         node0) <
    S
      (nat_of_N
         (var
            (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m))
            node0))).
(* Goal: forall _ : is_internal_node cfg l, lt (N.to_nat (var cfg l)) m *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H6.  exact
   (proj1
      (H2 node0 node'
         (S
            (nat_of_N
               (var
                  (fst
                     (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r
                        m)) node0))) H4 H6)).
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  intro H6.  unfold lt in |- *.  apply le_n.  assumption.  apply bool_fun_eq_neg_1.  apply bool_fun_eq_symm.
(* Goal: bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) node n)) node0) (bool_fun_of_BDD (@fst BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 (@pair BDDstate (prod BDDsharing_map ad) bs (@pair BDDsharing_map ad share counter)) l m)) r m)) node0) *)
  apply bool_fun_preservation.  apply BDDneg_2_config_OK_lemma_2 with (n := n) (x := x) (node := node).
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption.  assumption.  assumption.  assumption.  cut (config_node_OK (bs, (share, counter)) node).
(* Goal: forall _ : is_internal_node cfg l, lt (N.to_nat (var cfg l)) m *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H6.  cut
   (is_internal_node (bs, (share, counter)) node ->
    nat_of_N (var (bs, (share, counter)) node) < n).
(* Goal: forall _ : @eq ad l (low cfg node), @eq comparison (BDDcompare (var cfg l) (var cfg node)) Lt *)
(* Goal: @eq ad l (low cfg node) *)
(* Goal: lt (N.to_nat (var cfg node)) (S m) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H7.  exact (proj1 (BDDneg_2_lemma n (bs, (share, counter)) node H H6 H7)).
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  intro; assumption.  right; right.  unfold in_dom in |- *.  rewrite H0.  reflexivity.
  cut
   (nodes_preserved
      (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m))
      (fst (BDDneg_2 (bs, (share, counter)) node n))).
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  unfold nodes_preserved in |- *.  intro H6.  assumption.  apply nodes_preserved_1 with (x := x).
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption.  assumption.  assumption.  assumption.  cut
   (is_internal_node
      (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m)) node0 ->
    nat_of_N
      (var (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m))
         node0) <
    S
      (nat_of_N
         (var
            (fst (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r m))
            node0))).
(* Goal: forall _ : is_internal_node cfg l, lt (N.to_nat (var cfg l)) m *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H6.  exact
   (proj1
      (H2 node0 node'
         (S
            (nat_of_N
               (var
                  (fst
                     (BDDneg_2 (fst (BDDneg_2 (bs, (share, counter)) l m)) r
                        m)) node0))) H4 H6)).
(* Goal: forall _ : is_internal_node cfg l, lt (N.to_nat (var cfg l)) m *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H6.  unfold lt in |- *.  apply le_n.
Qed.

Lemma BDDneg_1_lemma' :
 forall (bound : nat) (arg : BDDconfig * ad * BDDneg_memo),
 BDDconfig_OK (fst (fst arg)) ->
 config_node_OK (fst (fst arg)) (snd (fst arg)) ->
 BDDneg_memo_OK_2 (fst (fst arg)) (snd arg) ->
 (is_internal_node (fst (fst arg)) (snd (fst arg)) ->
  nat_of_N (var (fst (fst arg)) (snd (fst arg))) < bound) ->
 fst (BDDneg_1 arg bound) = BDDneg_2 (fst (fst arg)) (snd (fst arg)) bound /\
 BDDneg_memo_OK_2 (fst (fst (BDDneg_1 arg bound))) (snd (BDDneg_1 arg bound)).
Proof.
(* Goal: forall (bound : nat) (arg : prod (prod BDDconfig ad) BDDneg_memo) (_ : BDDconfig_OK (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo arg))) (_ : config_node_OK (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo arg)) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo arg))) (_ : BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo arg)) (@snd (prod BDDconfig ad) BDDneg_memo arg)) (_ : forall _ : is_internal_node (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo arg)) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo arg)), lt (N.to_nat (var (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo arg)) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo arg)))) bound), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 arg bound)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo arg)) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo arg)) bound)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 arg bound))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 arg bound))) *)
  intro bound.  apply
   lt_wf_ind
    with
      (P := fun bound : nat =>
            forall arg : BDDconfig * ad * BDDneg_memo,
            BDDconfig_OK (fst (fst arg)) ->
            config_node_OK (fst (fst arg)) (snd (fst arg)) ->
            BDDneg_memo_OK_2 (fst (fst arg)) (snd arg) ->
            (is_internal_node (fst (fst arg)) (snd (fst arg)) ->
             nat_of_N (var (fst (fst arg)) (snd (fst arg))) < bound) ->
            fst (BDDneg_1 arg bound) =
            BDDneg_2 (fst (fst arg)) (snd (fst arg)) bound /\
            BDDneg_memo_OK_2 (fst (fst (BDDneg_1 arg bound)))
              (snd (BDDneg_1 arg bound))).
(* Goal: forall _ : @eq (option ad) (BDDneg_memo_lookup (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None ad), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intros n H arg.  elim arg; clear arg; intro y.  elim y; clear y.  intros cfg node memo.
(* Goal: forall (_ : BDDconfig_OK (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (_ : config_node_OK (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (_ : BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (_ : forall _ : is_internal_node (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))), lt (N.to_nat (var (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))))) n), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intros H0 H1 H2 H3.  elim
   (option_sum _
      (BDDneg_memo_lookup (snd (cfg, node, memo))
         (snd (fst (cfg, node, memo))))).
(* Goal: forall _ : @eq (option ad) (BDDneg_memo_lookup (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None ad), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro y.  elim y; clear y; intros node' H4.  rewrite (BDDneg_1_lemma_1 (cfg, node, memo) node' n H4).
(* Goal: and (@eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero)) *)
  simpl in |- *.  split.  simpl in H2.  unfold BDDneg_memo_OK_2 in H2.  rewrite (proj2 (H2 node node' n H4 H3)).
(* Goal: forall _ : @eq (option ad) (BDDneg_memo_lookup (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None ad), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  reflexivity.  assumption.  intro y.  elim
   (option_sum _
      (MapGet _ (fst (fst (fst (cfg, node, memo))))
         (snd (fst (cfg, node, memo))))).
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) cfg) node) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 cfg node n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro y0.  elim y0; clear y0.  intro x.  elim x; clear x.  intros x y0.  elim y0; clear y0; intros l r H4.
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  elim (nat_sum n).  intros y0.  elim y0; clear y0.  intros m H5.  rewrite (BDDneg_1_lemma_4 (cfg, node, memo) x l r n m H5 y H4).





(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  simpl in |- *.  cut
   (fst (BDDneg_1 (cfg, l, memo) m) =
    BDDneg_2 (fst (fst (cfg, l, memo))) (snd (fst (cfg, l, memo))) m /\
    BDDneg_memo_OK_2 (fst (fst (BDDneg_1 (cfg, l, memo) m)))
      (snd (BDDneg_1 (cfg, l, memo) m))).
(* Goal: forall _ : is_internal_node cfg l, lt (N.to_nat (var cfg l)) m *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H6.  cut
   (fst
      (BDDneg_1
         (fst
            (fst
               (BDDneg_1
                  (fst (fst (cfg, node, memo)), l, snd (cfg, node, memo)) m)),
         r,
         snd
           (BDDneg_1 (fst (fst (cfg, node, memo)), l, snd (cfg, node, memo))
              m)) m) =
    BDDneg_2
      (fst
         (fst
            (fst
               (fst
                  (BDDneg_1
                     (fst (fst (cfg, node, memo)), l, snd (cfg, node, memo))
                     m)), r,
            snd
              (BDDneg_1
                 (fst (fst (cfg, node, memo)), l, snd (cfg, node, memo)) m))))
      (snd
         (fst
            (fst
               (fst
                  (BDDneg_1
                     (fst (fst (cfg, node, memo)), l, snd (cfg, node, memo))
                     m)), r,
            snd
              (BDDneg_1
                 (fst (fst (cfg, node, memo)), l, snd (cfg, node, memo)) m))))
      m /\
    BDDneg_memo_OK_2
      (fst
         (fst
            (BDDneg_1
               (fst
                  (fst
                     (BDDneg_1
                        (fst (fst (cfg, node, memo)), l,
                        snd (cfg, node, memo)) m)), r,
               snd
                 (BDDneg_1
                    (fst (fst (cfg, node, memo)), l, snd (cfg, node, memo)) m))
               m)))
      (snd
         (BDDneg_1
            (fst
               (fst
                  (BDDneg_1
                     (fst (fst (cfg, node, memo)), l, snd (cfg, node, memo))
                     m)), r,
            snd
              (BDDneg_1
                 (fst (fst (cfg, node, memo)), l, snd (cfg, node, memo)) m))
(* Goal: forall _ : @eq ad l (low cfg node), @eq comparison (BDDcompare (var cfg l) (var cfg node)) Lt *)
(* Goal: @eq ad l (low cfg node) *)
(* Goal: lt (N.to_nat (var cfg node)) (S m) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
            m))).  intro H7.  simpl in H6, H7. 
(* Goal: and (@eq (prod BDDconfig ad) (BDDmake (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) m))) x (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) m)))) (BDDneg_2 cfg node n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (BDDmake (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) m))) x (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) m))))) (BDDneg_memo_put (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) m)) node (@snd BDDconfig ad (BDDmake (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) m))) x (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) m))))))) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) m))) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  rewrite (proj1 H7).  rewrite (proj1 H6).  cut
   (BDDmake (fst (BDDneg_2 (fst (BDDneg_2 cfg l m)) r m)) x
      (snd (BDDneg_2 cfg l m)) (snd (BDDneg_2 (fst (BDDneg_2 cfg l m)) r m)) =
    BDDneg_2 cfg node n).

(* Goal: and (@eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero)) *)
  intro H8.  split.  assumption.  rewrite (proj1 H6) in H7.
(* Goal: BDDneg_memo_OK_2 (@fst BDDconfig ad (BDDmake (@fst BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 cfg l m)) r m)) x (@snd BDDconfig ad (BDDneg_2 cfg l m)) (@snd BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 cfg l m)) r m)))) (BDDneg_memo_put (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (BDDneg_2 cfg l m)) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) m)) node (@snd BDDconfig ad (BDDmake (@fst BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 cfg l m)) r m)) x (@snd BDDconfig ad (BDDneg_2 cfg l m)) (@snd BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 cfg l m)) r m))))) *)
(* Goal: @eq (prod BDDconfig ad) (BDDmake (@fst BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 cfg l m)) r m)) x (@snd BDDconfig ad (BDDneg_2 cfg l m)) (@snd BDDconfig ad (BDDneg_2 (@fst BDDconfig ad (BDDneg_2 cfg l m)) r m))) (BDDneg_2 cfg node n) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) m))) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  elim H7; intros. rewrite H9 in H7. clear H9 H10. (* instead of Rewrite (proj1 ? ? H7) in H7. which does not work in 6.3. *)
(* Goal: lt (N.to_nat (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r)) m *)
(* Goal: @eq BDDvar (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r) (var cfg r) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  rewrite H8.  apply BDDneg_memo_OK_1_lemma_1_2' with (x := x) (l := l) (r := r) (m := m).  assumption.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption.  apply H3.  split with x; split with l; split with r; assumption.
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  assumption.  exact (proj2 H7).  rewrite H5.  simpl in |- *.  simpl in H4.  rewrite H4.
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  reflexivity.  apply H.  rewrite H5.  unfold lt in |- *.  apply le_n.  simpl in |- *.  rewrite (proj1 H6).
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  simpl in |- *.  cut (config_node_OK cfg l).  intro.  cut (is_internal_node cfg l -> nat_of_N (var cfg l) < m).
(* Goal: forall _ : @eq BDDvar (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r) (var cfg r), lt (N.to_nat (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r)) m *)
(* Goal: @eq BDDvar (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r) (var cfg r) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intros H8.  exact (proj1 (BDDneg_2_lemma m cfg l H0 H7 H8)).  intro H8.  apply lt_trans_1 with (y := nat_of_N (var cfg node)).
(* Goal: forall _ : @eq ad r (high cfg node), @eq comparison (BDDcompare (var cfg r) (var cfg node)) Lt *)
(* Goal: @eq ad r (high cfg node) *)
(* Goal: lt (N.to_nat (var cfg node)) (S m) *)
(* Goal: @eq BDDvar (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r) (var cfg r) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  cut (l = low cfg node).  intro H9.  rewrite H9.  apply BDDcompare_lt.  apply BDDvar_ordered_low.





(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption.  split with x; split with l; split with r.  assumption.  rewrite <- H9; assumption.
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  unfold low in |- *.  simpl in H4.  rewrite H4.  reflexivity.  rewrite <- H5.  apply H3.
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  simpl in |- *.  split with x; split with l; split with r; assumption.  cut (l = low cfg node); intros.
(* Goal: @eq comparison (BDDcompare (var cfg l) (var cfg node)) Lt *)
(* Goal: @eq ad l (low cfg node) *)
(* Goal: lt (N.to_nat (var cfg node)) (S m) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  rewrite H7.  apply low_OK.  assumption.  split with x; split with l; split with r; assumption.
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  unfold low in |- *; simpl in H4; rewrite H4; reflexivity.  simpl in |- *.  rewrite (proj1 H6).
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  simpl in |- *.  cut (config_node_OK cfg l).  intro H7.  cut (is_internal_node cfg l -> nat_of_N (var cfg l) < m).
(* Goal: forall _ : @eq BDDvar (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r) (var cfg r), lt (N.to_nat (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r)) m *)
(* Goal: @eq BDDvar (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r) (var cfg r) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H8.  cut (config_node_OK cfg r).  intro H9.  elim H9; intro.  rewrite H10.
(* Goal: config_node_OK (@fst BDDconfig ad (BDDneg_2 cfg l m)) BDDzero *)
(* Goal: config_node_OK (@fst BDDconfig ad (BDDneg_2 cfg l m)) r *)
(* Goal: config_node_OK cfg r *)
(* Goal: forall _ : is_internal_node cfg l, lt (N.to_nat (var cfg l)) m *)
(* Goal: config_node_OK cfg l *)
(* Goal: BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m)))) *)
(* Goal: forall _ : is_internal_node (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))), lt (N.to_nat (var (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))))) m *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  left; reflexivity.  elim H10; intro.  rewrite H11; right; left; reflexivity.
(* Goal: config_node_OK (@fst BDDconfig ad (BDDneg_2 cfg l m)) r *)
(* Goal: config_node_OK cfg r *)
(* Goal: forall _ : is_internal_node cfg l, lt (N.to_nat (var cfg l)) m *)
(* Goal: config_node_OK cfg l *)
(* Goal: BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m)))) *)
(* Goal: forall _ : is_internal_node (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))), lt (N.to_nat (var (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))))) m *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  right; right.  unfold in_dom in |- *.  cut (is_internal_node cfg r).  intro H12.  inversion H12.
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  inversion H13.  inversion H14.  simpl in H0.  simpl in |- *.  cut
   (MapGet (BDDvar * (ad * ad)) (fst (fst (BDDneg_2 cfg l m))) r =
    Some (x0, (x1, x2))).
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  intro H16.  rewrite H16.  reflexivity.  exact (proj1 (proj2 (BDDneg_2_lemma m cfg l H0 H7 H8)) x0 x1 x2 r H15).
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  apply in_dom_is_internal.  assumption.  cut (r = high cfg node).  intro H9.  rewrite H9.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  apply high_OK.  assumption.  split with x; split with l; split with r; assumption.  
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  unfold high in |- *.  simpl in H4; rewrite H4; reflexivity.  intro H8.  apply lt_trans_1 with (y := nat_of_N (var cfg node)).
(* Goal: @eq comparison (BDDcompare (var cfg l) (var cfg node)) Lt *)
(* Goal: lt (N.to_nat (var cfg node)) (S m) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  apply BDDcompare_lt.  cut (l = low cfg node).  intro; rewrite H9.  apply BDDvar_ordered_low.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption.  split with x; split with l; split with r; assumption.  rewrite <- H9; assumption.
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  unfold low in |- *; simpl in H4; rewrite H4; reflexivity.  rewrite <- H5; apply H3.
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  simpl in |- *.  split with x; split with l; split with r; assumption.  cut (l = low cfg node).
(* Goal: @eq comparison (BDDcompare (var cfg l) (var cfg node)) Lt *)
(* Goal: @eq ad l (low cfg node) *)
(* Goal: lt (N.to_nat (var cfg node)) (S m) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H7.  rewrite H7.  apply low_OK.  assumption.  split with x; split with l; split with r; assumption.
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  unfold low in |- *; simpl in H4; rewrite H4; reflexivity.  simpl in |- *.  exact (proj2 H6).





(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  simpl in |- *.  rewrite (proj1 H6).  simpl in |- *.  intro H7.  cut (var (fst (BDDneg_2 cfg l m)) r = var cfg r).
(* Goal: lt (N.to_nat (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r)) m *)
(* Goal: @eq BDDvar (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r) (var cfg r) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H8.  rewrite H8.  apply lt_trans_1 with (y := nat_of_N (var cfg node)).  apply BDDcompare_lt.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  cut (r = high cfg node).  intro H9.  rewrite H9.  apply BDDvar_ordered_high.  assumption.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  split with x; split with l; split with r; assumption.  cut (config_node_OK cfg (high cfg node)).
(* Goal: forall _ : config_node_OK cfg l, BDDconfig_OK (@fst BDDconfig ad (BDDneg_2 cfg l m)) *)
(* Goal: config_node_OK cfg l *)
(* Goal: config_node_OK (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) *)
(* Goal: BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m)))) *)
(* Goal: forall _ : is_internal_node (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))), lt (N.to_nat (var (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))))) m *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H10.  elim H10; intro.  inversion H7.  inversion H12.  inversion H13.
(* Goal: is_internal_node cfg (high cfg node) *)
(* Goal: is_internal_node cfg (high cfg node) *)
(* Goal: config_node_OK cfg (high cfg node) *)
(* Goal: @eq ad r (high cfg node) *)
(* Goal: lt (N.to_nat (var cfg node)) (S m) *)
(* Goal: @eq BDDvar (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r) (var cfg r) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  rewrite H9 in H14; rewrite H11 in H14.  cut (BDDconfig_OK (fst (BDDneg_2 cfg l m))).
(* Goal: forall _ : is_internal_node cfg l, lt (N.to_nat (var cfg l)) m *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: @eq ad r (high cfg node) *)
(* Goal: @eq ad l (low cfg node) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H15.  rewrite (config_OK_zero (fst (BDDneg_2 cfg l m)) H15) in H14.  discriminate H14.
(* Goal: @eq BDDvar x0 match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) cfg) r with | Some (pair x (pair l r as p0) as p) => x | None => BDDzero end *)
(* Goal: @eq ad r (high cfg node) *)
(* Goal: @eq ad l (low cfg node) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  cut (config_node_OK cfg l).  intro H15.  cut (is_internal_node cfg l -> nat_of_N (var cfg l) < m).
(* Goal: lt (N.to_nat (var cfg l)) m *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H16.  exact (proj1 (BDDneg_2_lemma m cfg l H0 H15 H16)).  intro H16.  apply lt_trans_1 with (y := nat_of_N (var cfg node)).
(* Goal: @eq comparison (BDDcompare (var cfg l) (var cfg node)) Lt *)
(* Goal: lt (N.to_nat (var cfg node)) (S m) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  cut (l = low cfg node).  intro H17.  rewrite H17.  apply BDDcompare_lt.  apply BDDvar_ordered_low.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption.  split with x; split with l; split with r; assumption.  rewrite <- H17; assumption.
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  unfold low in |- *; simpl in H4; rewrite H4.  reflexivity.  rewrite <- H5; apply H3.
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  simpl in |- *.  split with x; split with l; split with r; assumption.  cut (l = low cfg node).
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  intro H15.  rewrite H15.  apply low_OK.  assumption.  split with x; split with l; split with r; assumption.
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  unfold low in |- *; simpl in H4; rewrite H4; reflexivity.  elim H11; intro.  rewrite H9 in H7.
(* Goal: is_internal_node cfg (high cfg node) *)
(* Goal: is_internal_node cfg (high cfg node) *)
(* Goal: config_node_OK cfg (high cfg node) *)
(* Goal: @eq ad r (high cfg node) *)
(* Goal: lt (N.to_nat (var cfg node)) (S m) *)
(* Goal: @eq BDDvar (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r) (var cfg r) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  rewrite H12 in H7.  inversion H7.  inversion H13.  inversion H14.  cut (BDDconfig_OK (fst (BDDneg_2 cfg l m))).
(* Goal: forall _ : config_node_OK cfg l, BDDconfig_OK (@fst BDDconfig ad (BDDneg_2 cfg l m)) *)
(* Goal: config_node_OK cfg l *)
(* Goal: is_internal_node cfg (high cfg node) *)
(* Goal: config_node_OK cfg (high cfg node) *)
(* Goal: @eq ad r (high cfg node) *)
(* Goal: lt (N.to_nat (var cfg node)) (S m) *)
(* Goal: @eq BDDvar (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r) (var cfg r) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H16.  rewrite (config_OK_one (fst (BDDneg_2 cfg l m)) H16) in H15.  discriminate H15.
(* Goal: @eq BDDvar x0 match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) cfg) r with | Some (pair x (pair l r as p0) as p) => x | None => BDDzero end *)
(* Goal: @eq ad r (high cfg node) *)
(* Goal: @eq ad l (low cfg node) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  cut (config_node_OK cfg l).  intro H16.  cut (is_internal_node cfg l -> nat_of_N (var cfg l) < m).





(* Goal: forall _ : is_internal_node cfg l, lt (N.to_nat (var cfg l)) m *)
(* Goal: config_node_OK cfg l *)
(* Goal: is_internal_node cfg (high cfg node) *)
(* Goal: config_node_OK cfg (high cfg node) *)
(* Goal: @eq ad r (high cfg node) *)
(* Goal: lt (N.to_nat (var cfg node)) (S m) *)
(* Goal: @eq BDDvar (var (@fst BDDconfig ad (BDDneg_2 cfg l m)) r) (var cfg r) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intros H17.  exact (proj1 (BDDneg_2_lemma m cfg l H0 H16 H17)).  intro H17.
(* Goal: lt (N.to_nat (var cfg l)) m *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  apply lt_trans_1 with (y := nat_of_N (var cfg node)).  cut (l = low cfg node).  
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  intro H18.  rewrite H18.  apply BDDcompare_lt.  apply BDDvar_ordered_low.  assumption.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  split with x; split with l; split with r.  assumption.  rewrite <- H18; assumption.
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  unfold low in |- *.  simpl in H4.  rewrite H4.  reflexivity.  rewrite <- H5.  apply H3.
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  simpl in |- *.  split with x; split with l; split with r; assumption.  cut (l = low cfg node); intros.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  rewrite H16.  apply low_OK.  assumption.  split with x; split with l; split with r; assumption.
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  unfold low in |- *; simpl in H4; rewrite H4; reflexivity.  apply in_dom_is_internal.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption.  apply high_OK.  assumption.  split with x; split with l; split with r; assumption.
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  unfold high in |- *.  simpl in H4; rewrite H4; reflexivity.  rewrite <- H5; apply H3.
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  simpl in |- *.  split with x; split with l; split with r; assumption.  inversion H7.
(* Goal: @eq comparison (BDDcompare (var cfg l) (var cfg node)) Lt *)
(* Goal: lt (N.to_nat (var cfg node)) (S m) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  inversion H8.  inversion H9.  unfold var in |- *.  rewrite H10.  cut (l = low cfg node).
(* Goal: @eq BDDvar x0 match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) cfg) r with | Some (pair x (pair l r as p0) as p) => x | None => BDDzero end *)
(* Goal: @eq ad r (high cfg node) *)
(* Goal: @eq ad l (low cfg node) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  cut (r = high cfg node).  intros H11 H12.  cut (config_node_OK cfg l).  cut (config_node_OK cfg r).
(* Goal: forall _ : config_node_OK cfg l, BDDconfig_OK (@fst BDDconfig ad (BDDneg_2 cfg l m)) *)
(* Goal: config_node_OK cfg l *)
(* Goal: config_node_OK (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) *)
(* Goal: BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m)))) *)
(* Goal: forall _ : is_internal_node (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))), lt (N.to_nat (var (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))))) m *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intros H13 H14.  cut (BDDconfig_OK (fst (BDDneg_2 cfg l m))).  intro H15.  elim H13; intro.







(* Goal: @eq BDDvar x0 match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) cfg) r with | Some (pair x (pair l r as p0) as p) => x | None => BDDzero end *)
(* Goal: @eq BDDvar x0 match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) cfg) r with | Some (pair x (pair l r as p0) as p) => x | None => BDDzero end *)
(* Goal: BDDconfig_OK (@fst BDDconfig ad (BDDneg_2 cfg l m)) *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: @eq ad r (high cfg node) *)
(* Goal: @eq ad l (low cfg node) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  rewrite H16 in H10.  rewrite (config_OK_zero (fst (BDDneg_2 cfg l m)) H15) in H10; discriminate.
(* Goal: forall _ : config_node_OK cfg l, BDDconfig_OK (@fst BDDconfig ad (BDDneg_2 cfg l m)) *)
(* Goal: config_node_OK cfg l *)
(* Goal: config_node_OK (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) *)
(* Goal: BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m)))) *)
(* Goal: forall _ : is_internal_node (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))), lt (N.to_nat (var (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))) r) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) l) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) m))))))) m *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  elim H16; intro.  rewrite H17 in H10.  rewrite (config_OK_one (fst (BDDneg_2 cfg l m)) H15) in H10; discriminate.
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) cfg) node) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 cfg node n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  elim (option_sum _ (MapGet (BDDvar * (ad * ad)) (fst cfg) r)).  intro y0.  elim y0; intro x3.
(* Goal: BDDconfig_OK (@fst BDDconfig ad (BDDneg_2 cfg l m)) *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: @eq ad r (high cfg node) *)
(* Goal: @eq ad l (low cfg node) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  elim x3; intro y1; intro y2.  elim y2; intros y3 y4 y5.  rewrite y5.  cut (is_internal_node cfg l -> nat_of_N (var cfg l) < m).
(* Goal: forall _ : is_internal_node cfg l, lt (N.to_nat (var cfg l)) m *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) cfg) r) (@None (prod BDDvar (prod ad ad))), @eq BDDvar x0 match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) cfg) r with | Some (pair x (pair l r as p0) as p) => x | None => BDDzero end *)
(* Goal: BDDconfig_OK (@fst BDDconfig ad (BDDneg_2 cfg l m)) *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: @eq ad r (high cfg node) *)
(* Goal: @eq ad l (low cfg node) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H18.  cut
   (MapGet (BDDvar * (ad * ad)) (fst (fst (BDDneg_2 cfg l m))) r =
    Some (y1, (y3, y4))).
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  intro H19.  rewrite H19 in H10.  injection H10.  intros H20 H21 H22.  rewrite H22; reflexivity.
(* Goal: @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (BDDneg_2 cfg l m))) r) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) y1 (@pair ad ad y3 y4))) *)
(* Goal: forall _ : is_internal_node cfg l, lt (N.to_nat (var cfg l)) m *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) cfg) r) (@None (prod BDDvar (prod ad ad))), @eq BDDvar x0 match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) cfg) r with | Some (pair x (pair l r as p0) as p) => x | None => BDDzero end *)
(* Goal: BDDconfig_OK (@fst BDDconfig ad (BDDneg_2 cfg l m)) *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: @eq ad r (high cfg node) *)
(* Goal: @eq ad l (low cfg node) *)
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo))) m)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg l) memo) m))) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  exact (proj1 (proj2 (BDDneg_2_lemma m cfg l H0 H14 H18)) y1 y3 y4 r y5).
(* Goal: lt (N.to_nat (var cfg l)) m *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H18.  apply lt_trans_1 with (y := nat_of_N (var cfg node)).  apply BDDcompare_lt.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  rewrite H12.  apply BDDvar_ordered_low.  assumption.  split with x; split with l; split with r; assumption.
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  rewrite <- H12.  assumption.  rewrite <- H5.  apply H3.  simpl in |- *.  split with x; split with l; split with r; assumption.
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) cfg) node) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 cfg node n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro y0.  unfold in_dom in H17.  rewrite y0 in H17.  discriminate.  cut (is_internal_node cfg l -> nat_of_N (var cfg l) < m).
(* Goal: lt (N.to_nat (var cfg l)) m *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  intro H15.  exact (proj1 (BDDneg_2_lemma m cfg l H0 H14 H15)).  intro H15.  apply lt_trans_1 with (y := nat_of_N (var cfg node)).






(* Goal: BDDneg_memo_OK_2 cfg memo *)
  apply BDDcompare_lt.  rewrite H12.  apply BDDvar_ordered_low.  assumption.  
(* Goal: BDDneg_memo_OK_2 cfg memo *)
 split with x; split with l; split with r; assumption.  rewrite <- H12; assumption.
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  rewrite <- H5; apply H3.  simpl in |- *.  split with x; split with l; split with r; assumption.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  rewrite H11.  apply high_OK.  assumption.  split with x; split with l; split with r; assumption.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  rewrite H12.  apply low_OK.  assumption.  split with x; split with l; split with r; assumption.
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  unfold high in |- *; simpl in H4; rewrite H4; reflexivity.  unfold low in |- *; simpl in H4; rewrite H4; reflexivity.  
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  apply H.  rewrite H5.  unfold lt in |- *.  apply le_n.  simpl in |- *.  assumption.  simpl in |- *.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  cut (l = low cfg node).  intro; rewrite H6.  apply low_OK.  assumption.  
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  split with x; split with l; split with r; assumption.  unfold low in |- *; simpl in H4; rewrite H4; reflexivity.
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  simpl in |- *.  assumption.  simpl in |- *.  intro H6.  apply lt_trans_1 with (y := nat_of_N (var cfg node)).
(* Goal: @eq comparison (BDDcompare (var cfg l) (var cfg node)) Lt *)
(* Goal: @eq ad l (low cfg node) *)
(* Goal: lt (N.to_nat (var cfg node)) (S m) *)
(* Goal: forall _ : @eq nat n O, and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  apply BDDcompare_lt.  cut (l = low cfg node).  intro H7.  rewrite H7.  apply BDDvar_ordered_low.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption.  split with x; split with l; split with r; assumption.  rewrite <- H7; assumption.
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  unfold low in |- *; simpl in H4; rewrite H4; reflexivity.  rewrite <- H5; apply H3.
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  simpl in |- *.  split with x; split with l; split with r; assumption.  intro y0.  rewrite y0.
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  rewrite (BDDneg_1_lemma_3 (cfg, node, memo) x l r y H4).  simpl in |- *.  simpl in H4.
(* Goal: BDDneg_memo_OK_2 initBDDconfig (newMap ad) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map ad) (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo)))) (@None (prod BDDvar (prod ad ad))), and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n)) (BDDneg_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) (@snd BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo))) n)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) (@snd (prod BDDconfig ad) BDDneg_memo (BDDneg_1 (@pair (prod BDDconfig ad) BDDneg_memo (@pair BDDconfig ad cfg node) memo) n))) *)
  rewrite H4.  split.  reflexivity.  unfold BDDneg_memo_OK_2 in |- *.  intros node0 node' bound0 H5 H6.  unfold BDDneg_memo_lookup in H5.
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  rewrite (newMap_semantics ad node0) in H5.  discriminate.  simpl in |- *.  intro y0.  rewrite (BDDneg_1_lemma_2 (cfg, node, memo) n y y0).
(* Goal: and (@eq (prod BDDconfig ad) (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero))) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 (@fst BDDconfig ad (@fst (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) (@snd (prod BDDconfig ad) BDDneg_memo (@pair (prod BDDconfig N) (Map ad) (@pair BDDconfig N cfg BDDzero) (BDDneg_memo_put memo BDDone BDDzero)))) *)
  simpl in |- *.  unfold BDDneg_2 in |- *.  elim n; rewrite y0.  elim (Neqb node BDDzero).











(* Goal: and (@eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero)) *)
  simpl in |- *.  split.  reflexivity.  apply BDDneg_memo_OK_1_lemma_2_1'.  assumption.
(* Goal: and (@eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero)) *)
  assumption.  simpl in |- *.  split.  reflexivity.  apply BDDneg_memo_OK_1_lemma_3_1'.
(* Goal: BDDneg_memo_OK_2 cfg memo *)
  assumption. assumption.
(* Goal: and (@eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero)) *)
  fold BDDneg_2 in |- *.  intro n0.  intro H4.  elim (Neqb node BDDzero).  simpl in |- *.  split.
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  reflexivity.  apply BDDneg_memo_OK_1_lemma_2_1'.  assumption.  assumption.
(* Goal: and (@eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero)) (BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero)) *)
  simpl in |- *.  split.
(* Goal: @eq (prod BDDconfig ad) (@pair BDDconfig N cfg BDDzero) (@pair BDDconfig N cfg BDDzero) *)
(* Goal: BDDneg_memo_OK_2 cfg (BDDneg_memo_put memo BDDone BDDzero) *)
  reflexivity.  apply BDDneg_memo_OK_1_lemma_3_1'.  assumption.  assumption.
Qed.