(* 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 Map.
From IntMap Require Import Allmaps.
Require Import List.
Require Import Wf_nat.

Require Import misc.
Require Import bool_fun.
Require Import myMap.
Require Import config.
Require Import alloc.
Require Import make.
Require Import op.

Section BDDuniv_sec.


Variable gc : BDDconfig -> list ad -> BDDconfig.
Hypothesis gc_is_OK : gc_OK gc.

Fixpoint BDDuniv_1 (cfg : BDDconfig) (ul : list ad) 
 (node : ad) (y : BDDvar) (bound : nat) {struct bound} : 
 BDDconfig * ad :=
  match bound with
  | O => (* Error *)  (initBDDconfig, BDDzero)
  | S bound' =>
      match MapGet2 _ (um_of_cfg cfg) node y with
      | Some node' => (cfg, node')
      | None =>
          match MapGet _ (fst cfg) node with
          | None => (cfg, node)
          | Some (x, (l, r)) =>
              match BDDcompare x y with
              | Datatypes.Lt => (cfg, node)
              | Datatypes.Eq => BDDand gc cfg ul l r
              | Datatypes.Gt =>
                  match BDDuniv_1 cfg ul l y bound' with
                  | (cfgl, nodel) =>
                      match BDDuniv_1 cfgl (nodel :: ul) r y bound' with
                      | (cfgr, noder) =>
                          match
                            BDDmake gc cfgr x nodel noder
                              (noder :: nodel :: ul)
                          with
                          | (cfg', node') =>
                              (BDDuniv_memo_put cfg' y node node', node')
                          end
                      end
                  end
              end
          end
      end
  end.

Lemma BDDuniv_1_lemma :
 forall (bound : nat) (cfg : BDDconfig) (ul : list ad) 
   (u : BDDvar) (node : ad),
 nat_of_N (node_height cfg node) < bound ->
 BDDconfig_OK cfg ->
 used_list_OK cfg ul ->
 used_node' cfg ul node ->
 BDDconfig_OK (fst (BDDuniv_1 cfg ul node u bound)) /\
 config_node_OK (fst (BDDuniv_1 cfg ul node u bound))
   (snd (BDDuniv_1 cfg ul node u bound)) /\
 used_nodes_preserved cfg (fst (BDDuniv_1 cfg ul node u bound)) ul /\
 Nleb
   (node_height (fst (BDDuniv_1 cfg ul node u bound))
      (snd (BDDuniv_1 cfg ul node u bound))) (node_height cfg node) = true /\
 bool_fun_eq
   (bool_fun_of_BDD (fst (BDDuniv_1 cfg ul node u bound))
      (snd (BDDuniv_1 cfg ul node u bound)))
   (bool_fun_forall u (bool_fun_of_BDD cfg node)).
Proof.
(* Goal: forall (bound : nat) (cfg : BDDconfig) (ul : list ad) (u : BDDvar) (node : ad) (_ : lt (N.to_nat (node_height cfg node)) bound) (_ : BDDconfig_OK cfg) (_ : used_list_OK cfg ul) (_ : used_node' cfg ul node), and (BDDconfig_OK (@fst BDDconfig ad (BDDuniv_1 cfg ul node u bound))) (and (config_node_OK (@fst BDDconfig ad (BDDuniv_1 cfg ul node u bound)) (@snd BDDconfig ad (BDDuniv_1 cfg ul node u bound))) (and (used_nodes_preserved cfg (@fst BDDconfig ad (BDDuniv_1 cfg ul node u bound)) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad (BDDuniv_1 cfg ul node u bound)) (@snd BDDconfig ad (BDDuniv_1 cfg ul node u bound))) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (BDDuniv_1 cfg ul node u bound)) (@snd BDDconfig ad (BDDuniv_1 cfg ul node u bound))) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  simple induction bound.  intros.  absurd (nat_of_N (node_height cfg node) < 0).
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply lt_n_O.  assumption.  simpl in |- *.  intros.
(* Goal: and (BDDconfig_OK (@fst BDDconfig ad match MapGet2 ad (um_of_cfg cfg) node u with | Some node' => @pair BDDconfig ad cfg node' | None => match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end end)) (and (config_node_OK (@fst BDDconfig ad match MapGet2 ad (um_of_cfg cfg) node u with | Some node' => @pair BDDconfig ad cfg node' | None => match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end end) (@snd BDDconfig ad match MapGet2 ad (um_of_cfg cfg) node u with | Some node' => @pair BDDconfig ad cfg node' | None => match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet2 ad (um_of_cfg cfg) node u with | Some node' => @pair BDDconfig ad cfg node' | None => match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet2 ad (um_of_cfg cfg) node u with | Some node' => @pair BDDconfig ad cfg node' | None => match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end end) (@snd BDDconfig ad match MapGet2 ad (um_of_cfg cfg) node u with | Some node' => @pair BDDconfig ad cfg node' | None => match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet2 ad (um_of_cfg cfg) node u with | Some node' => @pair BDDconfig ad cfg node' | None => match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end end) (@snd BDDconfig ad match MapGet2 ad (um_of_cfg cfg) node u with | Some node' => @pair BDDconfig ad cfg node' | None => match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  elim (option_sum _ (MapGet2 ad (um_of_cfg cfg) node u)).  intro y.
(* Goal: and (BDDconfig_OK (@fst BDDconfig ad (@pair BDDconfig ad cfg node))) (and (config_node_OK (@fst BDDconfig ad (@pair BDDconfig ad cfg node)) (@snd BDDconfig ad (@pair BDDconfig ad cfg node))) (and (used_nodes_preserved cfg (@fst BDDconfig ad (@pair BDDconfig ad cfg node)) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad (@pair BDDconfig ad cfg node)) (@snd BDDconfig ad (@pair BDDconfig ad cfg node))) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (@pair BDDconfig ad cfg node)) (@snd BDDconfig ad (@pair BDDconfig ad cfg node))) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  elim y; clear y; intros node' H4.  rewrite H4.  simpl in |- *.
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  elim (um_of_cfg_OK _ H1 u node node' H4).  intros.  split.  assumption.  
(* Goal: used_node' cfg ul node *)
  split.  inversion H6.  inversion H8.  assumption.  split.
(* Goal: and (@eq bool (Nleb (node_height cfg node) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node))) *)
  apply used_nodes_preserved_refl.  split.  exact (proj1 (proj2 H6)).
(* Goal: forall _ : @eq (option ad) (MapGet2 ad (um_of_cfg cfg) node u) (@None ad), and (BDDconfig_OK (@fst BDDconfig ad match MapGet2 ad (um_of_cfg cfg) node u with | Some node' => @pair BDDconfig ad cfg node' | None => match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end end)) (and (config_node_OK (@fst BDDconfig ad match MapGet2 ad (um_of_cfg cfg) node u with | Some node' => @pair BDDconfig ad cfg node' | None => match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end end) (@snd BDDconfig ad match MapGet2 ad (um_of_cfg cfg) node u with | Some node' => @pair BDDconfig ad cfg node' | None => match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet2 ad (um_of_cfg cfg) node u with | Some node' => @pair BDDconfig ad cfg node' | None => match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet2 ad (um_of_cfg cfg) node u with | Some node' => @pair BDDconfig ad cfg node' | None => match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end end) (@snd BDDconfig ad match MapGet2 ad (um_of_cfg cfg) node u with | Some node' => @pair BDDconfig ad cfg node' | None => match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet2 ad (um_of_cfg cfg) node u with | Some node' => @pair BDDconfig ad cfg node' | None => match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end end) (@snd BDDconfig ad match MapGet2 ad (um_of_cfg cfg) node u with | Some node' => @pair BDDconfig ad cfg node' | None => match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  exact (proj2 (proj2 H6)).  intro y.  rewrite y.
(* Goal: and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  elim (option_sum _ (MapGet (BDDvar * (ad * ad)) (fst cfg) node)).  intro y0.
(* Goal: forall (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Gt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  elim y0; clear y0.
(* Goal: forall (x : prod BDDvar (prod ad ad)) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@Some (prod BDDvar (prod ad ad)) x)), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x0 (pair l r as p1) as p0) => match BDDcompare x0 u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x0 nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x0 (pair l r as p1) as p0) => match BDDcompare x0 u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x0 nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x0 (pair l r as p1) as p0) => match BDDcompare x0 u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x0 nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x0 (pair l r as p1) as p0) => match BDDcompare x0 u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x0 nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x0 (pair l r as p1) as p0) => match BDDcompare x0 u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x0 nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x0 (pair l r as p1) as p0) => match BDDcompare x0 u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x0 nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x0 (pair l r as p1) as p0) => match BDDcompare x0 u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x0 nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x0 (pair l r as p1) as p0) => match BDDcompare x0 u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x0 nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  intro x; elim x; clear x; intros x x0; elim x0; clear x0; intros l r H4.
(* Goal: @eq N match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => ad_S x | None => N0 end (ad_S x) *)
(* Goal: @eq N (node_height cfgr nodel) (ad_S xl) *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  rewrite H4.  cut (used_node' cfg ul l).  cut (used_node' cfg ul r).
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  elim (relation_sum (BDDcompare x u)).  intro y0.  elim y0; clear y0.
(* Goal: used_node' cfg ul node *)
  intros y0.  rewrite y0.  split.  apply BDDand_config_OK.  assumption.  
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  assumption.  assumption.  split.
(* Goal: used_node' cfg ul node *)
  apply BDDand_node_OK.  assumption.  assumption.  assumption.  assumption.  
(* Goal: used_node' cfg ul node *)
  assumption.  split.  apply BDDand_used_nodes_preserved.  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  assumption.  assumption.  split.
  apply
   Nleb_trans with (b := BDDvar_max (node_height cfg l) (node_height cfg r)).
(* Goal: used_node' cfg ul node *)
  apply BDDand_var_le.  assumption.  assumption.  assumption.  assumption.  
(* Goal: used_node' cfg ul node *)
  assumption.  unfold Nleb in |- *.
(* Goal: @eq bool (Nat.leb (N.to_nat (BDDvar_max (node_height cfg l) (node_height cfg r))) (N.to_nat (node_height cfg node))) true *)
(* Goal: bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (BDDand gc cfg ul l r)) (@snd BDDconfig ad (BDDand gc cfg ul l r))) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Lt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Gt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  rewrite (BDDvar_max_max (node_height cfg l) (node_height cfg r)).
(* Goal: @eq bool (Nat.leb (S (N.to_nat x)) (N.to_nat u)) true *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Gt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply leb_correct.  apply lt_le_weak.  apply
   lt_le_trans
    with
      (m := max (nat_of_N (node_height cfg node))
              (nat_of_N (node_height cfg node))).
(* Goal: lt (max (N.to_nat (node_height cfg l)) (N.to_nat (node_height cfg r))) (max (N.to_nat (node_height cfg node)) (N.to_nat (node_height cfg node))) *)
(* Goal: le (max (N.to_nat (node_height cfg node)) (N.to_nat (node_height cfg node))) (N.to_nat (node_height cfg node)) *)
(* Goal: bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (BDDand gc cfg ul l r)) (@snd BDDconfig ad (BDDand gc cfg ul l r))) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Lt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Gt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply lt_max_1_2.  apply BDDcompare_lt.  unfold node_height in |- *.
(* Goal: used_node' cfg ul node *)
  apply bs_node_height_left with (x := x) (r := r).  exact (proj1 H1).  assumption.
(* Goal: lt (N.to_nat (node_height cfg l)) (N.to_nat (node_height cfg node)) *)
(* Goal: lt (N.to_nat (node_height cfg node)) (S n) *)
(* Goal: BDDconfig_OK cfg *)
(* Goal: used_list_OK cfg ul *)
(* Goal: used_node' cfg ul l *)
(* Goal: @eq ad (@snd BDDconfig ad (BDDuniv_1 cfg ul l u n)) nodel *)
(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n)) cfgl *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply BDDcompare_lt.  unfold node_height in |- *.
(* Goal: used_node' cfg ul node *)
  apply bs_node_height_right with (x := x) (l := l).  exact (proj1 H1).  assumption.
(* Goal: le (max (N.to_nat (node_height cfg node)) (N.to_nat (node_height cfg node))) (N.to_nat (node_height cfg node)) *)
(* Goal: bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (BDDand gc cfg ul l r)) (@snd BDDconfig ad (BDDand gc cfg ul l r))) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Lt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Gt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  rewrite (max_x_x_eq_x (nat_of_N (node_height cfg node))).  apply le_n.  
(* Goal: bool_fun_eq (bool_fun_forall u (bool_fun_if x (bool_fun_of_BDD cfg r) (bool_fun_of_BDD cfg l))) (bool_fun_forall x (bool_fun_of_BDD cfg node)) *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Lt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Gt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  rewrite <- (BDD_EGAL_complete _ _ y0).
  apply
   bool_fun_eq_trans
    with
      (bf2 := bool_fun_forall u
                (bool_fun_if x (bool_fun_of_BDD cfg r)
                   (bool_fun_of_BDD cfg l))).
  apply
   bool_fun_eq_trans
    with
      (bf2 := bool_fun_and (bool_fun_of_BDD cfg r) (bool_fun_of_BDD cfg l)).
  apply
   bool_fun_eq_trans
    with
      (bf2 := bool_fun_and (bool_fun_of_BDD cfg l) (bool_fun_of_BDD cfg r)).
(* Goal: used_node' cfg ul node *)
  apply BDDand_is_and.  assumption.  assumption.  assumption.  assumption.  
(* Goal: used_node' cfg ul node *)
  assumption.  apply bool_fun_and_comm.  apply bool_fun_eq_sym.
(* Goal: bool_fun_eq (bool_fun_forall u (bool_fun_if x (bool_fun_of_BDD cfg r) (bool_fun_of_BDD cfg l))) (bool_fun_and (bool_fun_of_BDD cfg r) (bool_fun_of_BDD cfg l)) *)
(* Goal: bool_fun_eq (bool_fun_forall u (bool_fun_if x (bool_fun_of_BDD cfg r) (bool_fun_of_BDD cfg l))) (bool_fun_forall x (bool_fun_of_BDD cfg node)) *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Lt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Gt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  rewrite (BDD_EGAL_complete _ _ y0).  apply bool_fun_forall_if_egal.
(* Goal: bool_fun_eq (bool_fun_forall u (bool_fun_if x (bool_fun_of_BDD cfg r) (bool_fun_of_BDD cfg l))) (bool_fun_forall x (bool_fun_of_BDD cfg node)) *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Lt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Gt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  unfold bool_fun_of_BDD in |- *.  rewrite <- (BDD_EGAL_complete _ _ y0).
(* Goal: bool_fun_independent (bool_fun_of_BDD_bs (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) r) x *)
(* Goal: bool_fun_independent (bool_fun_of_BDD cfg l) u *)
(* Goal: bool_fun_eq (bool_fun_forall u (bool_fun_if x (bool_fun_of_BDD cfg r) (bool_fun_of_BDD cfg l))) (bool_fun_forall x (bool_fun_of_BDD cfg node)) *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Lt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Gt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply BDDvar_independent_high with (x := x) (l := l) (node := node).
(* Goal: used_node' cfg ul node *)
  exact (proj1 H1).  assumption.  unfold bool_fun_of_BDD in |- *.
(* Goal: bool_fun_eq (bool_fun_forall u (bool_fun_if x (bool_fun_of_BDD cfg r) (bool_fun_of_BDD cfg l))) (bool_fun_forall x (bool_fun_of_BDD cfg node)) *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Lt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Gt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  rewrite <- (BDD_EGAL_complete _ _ y0).
(* Goal: BDDstate_OK (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) *)
(* Goal: @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) x (@pair ad ad l r))) *)
(* Goal: lt (N.to_nat (node_height cfg node)) (S n) *)
(* Goal: BDDconfig_OK cfg *)
(* Goal: used_list_OK cfg ul *)
(* Goal: used_node' cfg ul l *)
(* Goal: @eq ad (@snd BDDconfig ad (BDDuniv_1 cfg ul l u n)) nodel *)
(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n)) cfgl *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply BDDvar_independent_low with (x := x) (r := r) (node := node).  exact (proj1 H1).
(* Goal: used_node' cfg ul node *)
  assumption.  rewrite <- (BDD_EGAL_complete _ _ y0).
(* Goal: bool_fun_eq bool_fun_one (bool_fun_of_BDD cfg BDDone) *)
(* Goal: forall _ : @eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  apply bool_fun_forall_preserves_eq.  apply bool_fun_eq_sym.
(* Goal: used_node' cfg ul node *)
  apply bool_fun_of_BDD_int.  assumption.  assumption.  intros y0.  rewrite y0.
(* Goal: used_node' cfg ul node *)
  split.  assumption.  split.  apply used_node'_OK with (ul := ul).  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  split.  apply used_nodes_preserved_refl.  split.
(* Goal: and (BDDconfig_OK (@fst BDDconfig ad (@pair BDDconfig ad cfg node))) (and (config_node_OK (@fst BDDconfig ad (@pair BDDconfig ad cfg node)) (@snd BDDconfig ad (@pair BDDconfig ad cfg node))) (and (used_nodes_preserved cfg (@fst BDDconfig ad (@pair BDDconfig ad cfg node)) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad (@pair BDDconfig ad cfg node)) (@snd BDDconfig ad (@pair BDDconfig ad cfg node))) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (@pair BDDconfig ad cfg node)) (@snd BDDconfig ad (@pair BDDconfig ad cfg node))) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply Nleb_refl.  simpl in |- *.  apply bool_fun_eq_sym.
(* Goal: bool_fun_independent (bool_fun_of_BDD cfg node) u *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Gt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply bool_fun_forall_independent.  unfold bool_fun_of_BDD in |- *.
(* Goal: BDDstate_OK (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) *)
(* Goal: @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) x (@pair ad ad l r))) *)
(* Goal: lt (N.to_nat (node_height cfg node)) (S n) *)
(* Goal: BDDconfig_OK cfg *)
(* Goal: used_list_OK cfg ul *)
(* Goal: used_node' cfg ul l *)
(* Goal: @eq ad (@snd BDDconfig ad (BDDuniv_1 cfg ul l u n)) nodel *)
(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n)) cfgl *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply BDDvar_independent_bs.  exact (proj1 H1).  
(* Goal: node_OK (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node *)
(* Goal: @eq bool (Nleb (bs_node_height (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) u) true *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Gt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  fold (node_OK (fst cfg) node) in |- *.  fold (config_node_OK cfg node) in |- *.
(* Goal: used_node' cfg ul node *)
  apply used_node'_OK with (ul := ul).  assumption.  assumption.  assumption.
(* Goal: @eq N match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => ad_S x | None => N0 end (ad_S x) *)
(* Goal: @eq N (node_height cfgr nodel) (ad_S xl) *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  unfold bs_node_height in |- *.  rewrite H4.  unfold Nleb in |- *.  rewrite (ad_S_is_S x).
(* Goal: @eq bool (Nat.leb (S (N.to_nat x)) (N.to_nat u)) true *)
(* Goal: forall (_ : @eq comparison (BDDcompare x u) Gt) (_ : used_node' cfg ul r) (_ : used_node' cfg ul l), and (BDDconfig_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (config_node_OK (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end) (@snd BDDconfig ad match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply leb_correct.  fold lt in |- *.  fold (nat_of_N x < nat_of_N u) in |- *.
(* Goal: used_node' cfg ul node *)
  apply BDDcompare_lt.  assumption.  intros y0 H5 H6.  rewrite y0.
(* Goal: and (BDDconfig_OK (@fst BDDconfig ad (let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node'))) (and (config_node_OK (@fst BDDconfig ad (let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node')) (@snd BDDconfig ad (let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node'))) (and (used_nodes_preserved cfg (@fst BDDconfig ad (let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node')) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad (let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node')) (@snd BDDconfig ad (let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node'))) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node')) (@snd BDDconfig ad (let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node'))) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  elim (prod_sum _ _ (BDDuniv_1 cfg ul l u n)).  intros cfgl H7.
(* Goal: and (BDDconfig_OK (@fst BDDconfig ad (let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node'))) (and (config_node_OK (@fst BDDconfig ad (let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node')) (@snd BDDconfig ad (let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node'))) (and (used_nodes_preserved cfg (@fst BDDconfig ad (let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node')) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad (let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node')) (@snd BDDconfig ad (let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node'))) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node')) (@snd BDDconfig ad (let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node'))) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  elim H7; clear H7.  intros nodel H7.  rewrite H7.
(* Goal: and (BDDconfig_OK (@fst BDDconfig ad (let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node'))) (and (config_node_OK (@fst BDDconfig ad (let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node')) (@snd BDDconfig ad (let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node'))) (and (used_nodes_preserved cfg (@fst BDDconfig ad (let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node')) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad (let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node')) (@snd BDDconfig ad (let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node'))) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node')) (@snd BDDconfig ad (let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node'))) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  elim (prod_sum _ _ (BDDuniv_1 cfgl (nodel :: ul) r u n)).  intros cfgr H8.
(* Goal: and (BDDconfig_OK (@fst BDDconfig ad (let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node'))) (and (config_node_OK (@fst BDDconfig ad (let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node')) (@snd BDDconfig ad (let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node'))) (and (used_nodes_preserved cfg (@fst BDDconfig ad (let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node')) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad (let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node')) (@snd BDDconfig ad (let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node'))) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node')) (@snd BDDconfig ad (let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node'))) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  elim H8; clear H8.  intros noder H8.  rewrite H8.  elim (prod_sum _ _ (BDDmake gc cfgr x nodel noder (noder :: nodel :: ul))).
(* Goal: and (BDDconfig_OK (@fst BDDconfig ad (@pair BDDconfig ad cfg node))) (and (config_node_OK (@fst BDDconfig ad (@pair BDDconfig ad cfg node)) (@snd BDDconfig ad (@pair BDDconfig ad cfg node))) (and (used_nodes_preserved cfg (@fst BDDconfig ad (@pair BDDconfig ad cfg node)) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad (@pair BDDconfig ad cfg node)) (@snd BDDconfig ad (@pair BDDconfig ad cfg node))) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (@pair BDDconfig ad cfg node)) (@snd BDDconfig ad (@pair BDDconfig ad cfg node))) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  intros cfg' H9.  elim H9; clear H9.  intros node' H9.  rewrite H9.  simpl in |- *.  
  cut
   (BDDconfig_OK cfgl /\
    config_node_OK cfgl nodel /\
    used_nodes_preserved cfg cfgl ul /\
    Nleb (node_height cfgl nodel) (node_height cfg l) = true /\
    bool_fun_eq (bool_fun_of_BDD cfgl nodel)
      (bool_fun_forall u (bool_fun_of_BDD cfg l))).
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  intro.  elim H10; clear H10; intros.  elim H11; clear H11; intros.
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  elim H12; clear H12; intros.  elim H13; clear H13; intros.
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  cut (config_node_OK cfg l).  cut (config_node_OK cfg r).  intros.
(* Goal: forall _ : @eq ad node BDDone, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: forall _ : @eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  cut (used_list_OK cfgl ul).  intro.  cut (used_list_OK cfgl (nodel :: ul)).
(* Goal: forall _ : @eq ad node BDDone, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: forall _ : @eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  intro.  cut (used_node' cfgl ul r).  intro.
(* Goal: forall _ : @eq ad node BDDone, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: forall _ : @eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  cut (used_node' cfgl (nodel :: ul) r).  intro.  
  cut
   (BDDconfig_OK cfgr /\
    config_node_OK cfgr noder /\
    used_nodes_preserved cfgl cfgr (nodel :: ul) /\
    Nleb (node_height cfgr noder) (node_height cfgl r) = true /\
    bool_fun_eq (bool_fun_of_BDD cfgr noder)
      (bool_fun_forall u (bool_fun_of_BDD cfgl r))).
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  intro.  elim H21; clear H21; intros.  elim H22; clear H22; intros.
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  elim H23; clear H23; intros.  elim H24; clear H24; intros.
(* Goal: forall _ : @eq ad node BDDone, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: forall _ : @eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  cut (used_list_OK cfgr (nodel :: ul)).  intro.
(* Goal: forall _ : @eq ad node BDDone, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: forall _ : @eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  cut (used_list_OK cfgr (noder :: nodel :: ul)).  intro.
(* Goal: and (BDDconfig_OK (BDDuniv_memo_put cfg' u node node')) (and (config_node_OK (BDDuniv_memo_put cfg' u node node') node') (and (used_nodes_preserved cfg (BDDuniv_memo_put cfg' u node node') ul) (and (@eq bool (Nleb (node_height (BDDuniv_memo_put cfg' u node node') node') (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (BDDuniv_memo_put cfg' u node node') node') (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  cut (used_node' cfgr (noder :: nodel :: ul) nodel).
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  cut (used_node' cfgr (noder :: nodel :: ul) noder).  intros.
  cut
   (forall (xl : BDDvar) (ll rl : ad),
    MapGet _ (fst cfgr) nodel = Some (xl, (ll, rl)) ->
    BDDcompare xl x = Datatypes.Lt).
  cut
   (forall (xr : BDDvar) (lr rr : ad),
    MapGet _ (fst cfgr) noder = Some (xr, (lr, rr)) ->
    BDDcompare xr x = Datatypes.Lt).
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  intros.  cut (BDDconfig_OK cfg').
(* Goal: forall _ : BDDconfig_OK cfg', and (BDDconfig_OK (BDDuniv_memo_put cfg' u node node')) (and (config_node_OK (BDDuniv_memo_put cfg' u node node') node') (and (used_nodes_preserved cfg (BDDuniv_memo_put cfg' u node node') ul) (and (@eq bool (Nleb (node_height (BDDuniv_memo_put cfg' u node node') node') (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (BDDuniv_memo_put cfg' u node node') node') (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: BDDconfig_OK cfg' *)
(* Goal: forall (xr : BDDvar) (lr rr : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) noder) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xr (@pair ad ad lr rr)))), @eq comparison (BDDcompare xr x) Lt *)
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  cut (used_nodes_preserved cfgr cfg' (noder :: nodel :: ul)).
(* Goal: forall (_ : used_nodes_preserved cfgr cfg' (@cons ad noder (@cons ad nodel ul))) (_ : BDDconfig_OK cfg'), and (BDDconfig_OK (BDDuniv_memo_put cfg' u node node')) (and (config_node_OK (BDDuniv_memo_put cfg' u node node') node') (and (used_nodes_preserved cfg (BDDuniv_memo_put cfg' u node node') ul) (and (@eq bool (Nleb (node_height (BDDuniv_memo_put cfg' u node node') node') (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (BDDuniv_memo_put cfg' u node node') node') (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
(* Goal: used_nodes_preserved cfgr cfg' (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: BDDconfig_OK cfg' *)
(* Goal: forall (xr : BDDvar) (lr rr : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) noder) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xr (@pair ad ad lr rr)))), @eq comparison (BDDcompare xr x) Lt *)
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  cut (config_node_OK cfg' node').

  cut
   (bool_fun_eq (bool_fun_of_BDD cfg' node')
      (bool_fun_if x (bool_fun_of_BDD cfgr noder)
         (bool_fun_of_BDD cfgr nodel))).
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  cut (Nleb (node_height cfg' node') (ad_S x) = true).  intros.
(* Goal: forall _ : @eq ad node BDDone, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: forall _ : @eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  cut (config_node_OK cfg' node).  intro.
(* Goal: forall _ : @eq ad node BDDone, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: forall _ : @eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  cut (nodes_preserved cfg' (BDDuniv_memo_put cfg' u node node')).  intro.
(* Goal: and (@eq bool (Nleb (node_height cfg node) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node))) *)
  cut (BDDconfig_OK (BDDuniv_memo_put cfg' u node node')).  intro.  split.
(* Goal: used_node' cfg ul node *)
  assumption.  split.  apply nodes_preserved_config_node_OK with (cfg1 := cfg').
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  split.
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved_trans with (cfg2 := cfgr).  assumption.
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved_trans with (cfg2 := cfgl).  assumption.  assumption.
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved_cons with (node := nodel).  assumption.
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved_trans with (cfg2 := cfg').  assumption.
(* Goal: used_nodes_preserved cfgr cfg' ul *)
(* Goal: @eq bool (Nleb (node_height cfg' node') (ad_S x)) true *)
(* Goal: bool_fun_eq (bool_fun_of_BDD cfg' node') (bool_fun_if x (bool_fun_of_BDD cfgr noder) (bool_fun_of_BDD cfgr nodel)) *)
(* Goal: config_node_OK cfg' node' *)
(* Goal: used_nodes_preserved cfgr cfg' (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: BDDconfig_OK cfg' *)
(* Goal: forall (xr : BDDvar) (lr rr : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) noder) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xr (@pair ad ad lr rr)))), @eq comparison (BDDcompare xr x) Lt *)
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply used_nodes_preserved_cons with (node := nodel).
(* Goal: used_nodes_preserved cfgr cfg' (@cons ad nodel ul) *)
(* Goal: @eq bool (Nleb (node_height cfg' node') (ad_S x)) true *)
(* Goal: bool_fun_eq (bool_fun_of_BDD cfg' node') (bool_fun_if x (bool_fun_of_BDD cfgr noder) (bool_fun_of_BDD cfgr nodel)) *)
(* Goal: config_node_OK cfg' node' *)
(* Goal: used_nodes_preserved cfgr cfg' (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: BDDconfig_OK cfg' *)
(* Goal: forall (xr : BDDvar) (lr rr : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) noder) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xr (@pair ad ad lr rr)))), @eq comparison (BDDcompare xr x) Lt *)
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply used_nodes_preserved_cons with (node := noder).
(* Goal: used_node' cfg ul node *)
  assumption.  apply nodes_preserved_used_nodes_preserved.  assumption.
  rewrite
   (Neqb_complete (node_height (BDDuniv_memo_put cfg' u node node') node')
      (node_height cfg' node')).
(* Goal: used_node' cfg ul node *)
  split.  apply Nleb_trans with (b := ad_S x).  assumption.
(* Goal: @eq comparison (BDDcompare (node_height cfg l) (node_height cfg node)) Lt *)
(* Goal: lt (N.to_nat (node_height cfg node)) (S n) *)
(* Goal: BDDconfig_OK cfg *)
(* Goal: used_list_OK cfg ul *)
(* Goal: used_node' cfg ul l *)
(* Goal: @eq ad (@snd BDDconfig ad (BDDuniv_1 cfg ul l u n)) nodel *)
(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n)) cfgl *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  unfold node_height in |- *.  unfold bs_node_height in |- *.
(* Goal: @eq N match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => ad_S x | None => N0 end (ad_S x) *)
(* Goal: @eq N (node_height cfgr nodel) (ad_S xl) *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  rewrite H4.  apply Nleb_refl.
(* Goal: bool_fun_eq (bool_fun_of_BDD (BDDuniv_memo_put cfg' u node node') node') (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: @eq bool (N.eqb (node_height (BDDuniv_memo_put cfg' u node node') node') (node_height cfg' node')) true *)
(* Goal: BDDconfig_OK (BDDuniv_memo_put cfg' u node node') *)
(* Goal: nodes_preserved cfg' (BDDuniv_memo_put cfg' u node node') *)
(* Goal: config_node_OK cfg' node *)
(* Goal: @eq bool (Nleb (node_height cfg' node') (ad_S x)) true *)
(* Goal: bool_fun_eq (bool_fun_of_BDD cfg' node') (bool_fun_if x (bool_fun_of_BDD cfgr noder) (bool_fun_of_BDD cfgr nodel)) *)
(* Goal: config_node_OK cfg' node' *)
(* Goal: used_nodes_preserved cfgr cfg' (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: BDDconfig_OK cfg' *)
(* Goal: forall (xr : BDDvar) (lr rr : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) noder) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xr (@pair ad ad lr rr)))), @eq comparison (BDDcompare xr x) Lt *)
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply bool_fun_eq_trans with (bf2 := bool_fun_of_BDD cfg' node').
(* Goal: used_node' cfg ul node *)
  apply nodes_preserved_bool_fun.  assumption.  assumption.  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  apply
   bool_fun_eq_trans
    with
      (bf2 := bool_fun_if x (bool_fun_of_BDD cfgr noder)
                (bool_fun_of_BDD cfgr nodel)).
(* Goal: used_node' cfg ul node *)
  assumption.
  apply
   bool_fun_eq_trans
    with
      (bf2 := bool_fun_if x (bool_fun_forall u (bool_fun_of_BDD cfg r))
                (bool_fun_forall u (bool_fun_of_BDD cfg l))).
(* Goal: bool_fun_eq (bool_fun_if x (bool_fun_of_BDD cfgr noder) (bool_fun_of_BDD cfgr nodel)) (bool_fun_if x (bool_fun_forall u (bool_fun_of_BDD cfg r)) (bool_fun_forall u (bool_fun_of_BDD cfg l))) *)
(* Goal: bool_fun_eq (bool_fun_if x (bool_fun_forall u (bool_fun_of_BDD cfg r)) (bool_fun_forall u (bool_fun_of_BDD cfg l))) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: bool_fun_eq (bool_fun_forall u (bool_fun_of_BDD cfg node)) (bool_fun_forall u (bool_fun_of_BDD cfg' node)) *)
(* Goal: nodes_preserved cfg' (BDDuniv_memo_put cfg' u node node') *)
(* Goal: config_node_OK cfg' node *)
(* Goal: @eq bool (Nleb (node_height cfg' node') (ad_S x)) true *)
(* Goal: bool_fun_eq (bool_fun_of_BDD cfg' node') (bool_fun_if x (bool_fun_of_BDD cfgr noder) (bool_fun_of_BDD cfgr nodel)) *)
(* Goal: config_node_OK cfg' node' *)
(* Goal: used_nodes_preserved cfgr cfg' (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: BDDconfig_OK cfg' *)
(* Goal: forall (xr : BDDvar) (lr rr : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) noder) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xr (@pair ad ad lr rr)))), @eq comparison (BDDcompare xr x) Lt *)
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply bool_fun_if_preserves_eq.  apply
   bool_fun_eq_trans with (bf2 := bool_fun_forall u (bool_fun_of_BDD cfgl r)).
(* Goal: used_node' cfg ul node *)
  assumption.  apply bool_fun_forall_preserves_eq.
(* Goal: bool_fun_eq (bool_fun_of_BDD cfg' node) (bool_fun_of_BDD cfg node) *)
(* Goal: nodes_preserved cfg' (BDDuniv_memo_put cfg' u node node') *)
(* Goal: config_node_OK cfg' node *)
(* Goal: @eq bool (Nleb (node_height cfg' node') (ad_S x)) true *)
(* Goal: bool_fun_eq (bool_fun_of_BDD cfg' node') (bool_fun_if x (bool_fun_of_BDD cfgr noder) (bool_fun_of_BDD cfgr nodel)) *)
(* Goal: config_node_OK cfg' node' *)
(* Goal: used_nodes_preserved cfgr cfg' (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: BDDconfig_OK cfg' *)
(* Goal: forall (xr : BDDvar) (lr rr : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) noder) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xr (@pair ad ad lr rr)))), @eq comparison (BDDcompare xr x) Lt *)
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply used_nodes_preserved'_bool_fun with (ul := ul).
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  assumption.  assumption.  assumption.
(* Goal: bool_fun_eq (bool_fun_of_BDD cfgr nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)) *)
(* Goal: bool_fun_eq (bool_fun_if x (bool_fun_forall u (bool_fun_of_BDD cfg r)) (bool_fun_forall u (bool_fun_of_BDD cfg l))) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: bool_fun_eq (bool_fun_forall u (bool_fun_of_BDD cfg node)) (bool_fun_forall u (bool_fun_of_BDD cfg' node)) *)
(* Goal: nodes_preserved cfg' (BDDuniv_memo_put cfg' u node node') *)
(* Goal: config_node_OK cfg' node *)
(* Goal: @eq bool (Nleb (node_height cfg' node') (ad_S x)) true *)
(* Goal: bool_fun_eq (bool_fun_of_BDD cfg' node') (bool_fun_if x (bool_fun_of_BDD cfgr noder) (bool_fun_of_BDD cfgr nodel)) *)
(* Goal: config_node_OK cfg' node' *)
(* Goal: used_nodes_preserved cfgr cfg' (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: BDDconfig_OK cfg' *)
(* Goal: forall (xr : BDDvar) (lr rr : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) noder) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xr (@pair ad ad lr rr)))), @eq comparison (BDDcompare xr x) Lt *)
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply bool_fun_eq_trans with (bf2 := bool_fun_of_BDD cfgl nodel).
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved'_bool_fun with (ul := nodel :: ul).  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  assumption.  apply used_node'_cons_node_ul.
(* Goal: used_node' cfg ul node *)
  assumption.  apply bool_fun_eq_sym.
  apply
   bool_fun_eq_trans
    with
      (bf2 := bool_fun_forall u
                (bool_fun_if x (bool_fun_of_BDD cfg r)
                   (bool_fun_of_BDD cfg l))).
(* Goal: used_node' cfg ul node *)
  apply bool_fun_forall_preserves_eq.  apply bool_fun_of_BDD_int.  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  apply bool_fun_forall_orthogonal.  apply not_true_is_false.
(* Goal: forall _ : @eq ad node BDDone, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: forall _ : @eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  unfold not in |- *; intro.  rewrite (Neqb_complete _ _ H40) in y0.
(* Goal: False *)
(* Goal: bool_fun_eq (bool_fun_forall u (bool_fun_if x (bool_fun_of_BDD cfg r) (bool_fun_of_BDD cfg l))) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: bool_fun_eq (bool_fun_forall u (bool_fun_of_BDD cfg node)) (bool_fun_forall u (bool_fun_of_BDD cfg' node)) *)
(* Goal: nodes_preserved cfg' (BDDuniv_memo_put cfg' u node node') *)
(* Goal: config_node_OK cfg' node *)
(* Goal: @eq bool (Nleb (node_height cfg' node') (ad_S x)) true *)
(* Goal: bool_fun_eq (bool_fun_of_BDD cfg' node') (bool_fun_if x (bool_fun_of_BDD cfgr noder) (bool_fun_of_BDD cfgr nodel)) *)
(* Goal: config_node_OK cfg' node' *)
(* Goal: used_nodes_preserved cfgr cfg' (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: BDDconfig_OK cfg' *)
(* Goal: forall (xr : BDDvar) (lr rr : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) noder) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xr (@pair ad ad lr rr)))), @eq comparison (BDDcompare xr x) Lt *)
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  rewrite (BDD_EGAL_correct u) in y0.  discriminate y0.  
(* Goal: @eq bool (N.eqb (node_height (BDDuniv_memo_put cfg' u node node') node') (node_height cfg' node')) true *)
(* Goal: BDDconfig_OK (BDDuniv_memo_put cfg' u node node') *)
(* Goal: nodes_preserved cfg' (BDDuniv_memo_put cfg' u node node') *)
(* Goal: config_node_OK cfg' node *)
(* Goal: @eq bool (Nleb (node_height cfg' node') (ad_S x)) true *)
(* Goal: bool_fun_eq (bool_fun_of_BDD cfg' node') (bool_fun_if x (bool_fun_of_BDD cfgr noder) (bool_fun_of_BDD cfgr nodel)) *)
(* Goal: config_node_OK cfg' node' *)
(* Goal: used_nodes_preserved cfgr cfg' (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: BDDconfig_OK cfg' *)
(* Goal: forall (xr : BDDvar) (lr rr : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) noder) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xr (@pair ad ad lr rr)))), @eq comparison (BDDcompare xr x) Lt *)
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply nodes_preserved_node_height_eq.
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  assumption.  assumption.  apply BDDum_put_OK.
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  assumption.
(* Goal: @eq bool (Nleb (node_height cfg' node') (node_height cfg' node)) true *)
(* Goal: bool_fun_eq (bool_fun_of_BDD cfg' node') (bool_fun_forall u (bool_fun_of_BDD cfg' node)) *)
(* Goal: nodes_preserved cfg' (BDDuniv_memo_put cfg' u node node') *)
(* Goal: config_node_OK cfg' node *)
(* Goal: @eq bool (Nleb (node_height cfg' node') (ad_S x)) true *)
(* Goal: bool_fun_eq (bool_fun_of_BDD cfg' node') (bool_fun_if x (bool_fun_of_BDD cfgr noder) (bool_fun_of_BDD cfgr nodel)) *)
(* Goal: config_node_OK cfg' node' *)
(* Goal: used_nodes_preserved cfgr cfg' (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: BDDconfig_OK cfg' *)
(* Goal: forall (xr : BDDvar) (lr rr : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) noder) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xr (@pair ad ad lr rr)))), @eq comparison (BDDcompare xr x) Lt *)
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  rewrite (Neqb_complete (node_height cfg' node) (node_height cfg node)).
(* Goal: used_node' cfg ul node *)
  unfold node_height at 2 in |- *.  unfold bs_node_height in |- *.  rewrite H4.  assumption.  
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved'_node_height_eq with (ul := ul).  assumption.  
(* Goal: used_node' cfg ul node *)
  assumption.  apply used_nodes_preserved_trans with (cfg2 := cfgl).  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  apply used_nodes_preserved_cons with (node := nodel).
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved_trans with (cfg2 := cfgr).  assumption.  assumption.  
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved_cons with (node := noder).  assumption.  assumption.  
(* Goal: used_node' cfg ul node *)
  assumption.  
  apply
   bool_fun_eq_trans
    with
      (bf2 := bool_fun_if x (bool_fun_of_BDD cfgr noder)
                (bool_fun_of_BDD cfgr nodel)).
(* Goal: used_node' cfg ul node *)
  assumption.
  apply
   bool_fun_eq_trans
    with (bf2 := bool_fun_forall u (bool_fun_of_BDD cfg node)).
  apply
   bool_fun_eq_trans
    with
      (bf2 := bool_fun_if x (bool_fun_forall u (bool_fun_of_BDD cfg r))
                (bool_fun_forall u (bool_fun_of_BDD cfg l))).
(* Goal: bool_fun_eq (bool_fun_if x (bool_fun_of_BDD cfgr noder) (bool_fun_of_BDD cfgr nodel)) (bool_fun_if x (bool_fun_forall u (bool_fun_of_BDD cfg r)) (bool_fun_forall u (bool_fun_of_BDD cfg l))) *)
(* Goal: bool_fun_eq (bool_fun_if x (bool_fun_forall u (bool_fun_of_BDD cfg r)) (bool_fun_forall u (bool_fun_of_BDD cfg l))) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: bool_fun_eq (bool_fun_forall u (bool_fun_of_BDD cfg node)) (bool_fun_forall u (bool_fun_of_BDD cfg' node)) *)
(* Goal: nodes_preserved cfg' (BDDuniv_memo_put cfg' u node node') *)
(* Goal: config_node_OK cfg' node *)
(* Goal: @eq bool (Nleb (node_height cfg' node') (ad_S x)) true *)
(* Goal: bool_fun_eq (bool_fun_of_BDD cfg' node') (bool_fun_if x (bool_fun_of_BDD cfgr noder) (bool_fun_of_BDD cfgr nodel)) *)
(* Goal: config_node_OK cfg' node' *)
(* Goal: used_nodes_preserved cfgr cfg' (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: BDDconfig_OK cfg' *)
(* Goal: forall (xr : BDDvar) (lr rr : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) noder) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xr (@pair ad ad lr rr)))), @eq comparison (BDDcompare xr x) Lt *)
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply bool_fun_if_preserves_eq.
  apply
   bool_fun_eq_trans with (bf2 := bool_fun_forall u (bool_fun_of_BDD cfgl r)).
(* Goal: used_node' cfg ul node *)
  assumption.  apply bool_fun_forall_preserves_eq.  
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved'_bool_fun with (ul := ul).  assumption.  assumption.  
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  assumption.  
(* Goal: bool_fun_eq (bool_fun_of_BDD cfgr nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)) *)
(* Goal: bool_fun_eq (bool_fun_if x (bool_fun_forall u (bool_fun_of_BDD cfg r)) (bool_fun_forall u (bool_fun_of_BDD cfg l))) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: bool_fun_eq (bool_fun_forall u (bool_fun_of_BDD cfg node)) (bool_fun_forall u (bool_fun_of_BDD cfg' node)) *)
(* Goal: nodes_preserved cfg' (BDDuniv_memo_put cfg' u node node') *)
(* Goal: config_node_OK cfg' node *)
(* Goal: @eq bool (Nleb (node_height cfg' node') (ad_S x)) true *)
(* Goal: bool_fun_eq (bool_fun_of_BDD cfg' node') (bool_fun_if x (bool_fun_of_BDD cfgr noder) (bool_fun_of_BDD cfgr nodel)) *)
(* Goal: config_node_OK cfg' node' *)
(* Goal: used_nodes_preserved cfgr cfg' (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: BDDconfig_OK cfg' *)
(* Goal: forall (xr : BDDvar) (lr rr : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) noder) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xr (@pair ad ad lr rr)))), @eq comparison (BDDcompare xr x) Lt *)
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply bool_fun_eq_trans with (bf2 := bool_fun_of_BDD cfgl nodel).
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved'_bool_fun with (ul := nodel :: ul).  assumption.  
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  assumption.  apply used_node'_cons_node_ul.  
(* Goal: used_node' cfg ul node *)
  assumption. 
  apply
   bool_fun_eq_trans
    with
      (bf2 := bool_fun_forall u
                (bool_fun_if x (bool_fun_of_BDD cfg r)
                   (bool_fun_of_BDD cfg l))).
(* Goal: bool_fun_eq bool_fun_one (bool_fun_of_BDD cfg BDDone) *)
(* Goal: forall _ : @eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  apply bool_fun_eq_sym.  apply bool_fun_forall_orthogonal.
(* Goal: forall _ : @eq ad node BDDone, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: forall _ : @eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  apply not_true_is_false.  unfold not in |- *; intro.
(* Goal: False *)
(* Goal: bool_fun_eq (bool_fun_forall u (bool_fun_if x (bool_fun_of_BDD cfg r) (bool_fun_of_BDD cfg l))) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: bool_fun_eq (bool_fun_forall u (bool_fun_of_BDD cfg node)) (bool_fun_forall u (bool_fun_of_BDD cfg' node)) *)
(* Goal: nodes_preserved cfg' (BDDuniv_memo_put cfg' u node node') *)
(* Goal: config_node_OK cfg' node *)
(* Goal: @eq bool (Nleb (node_height cfg' node') (ad_S x)) true *)
(* Goal: bool_fun_eq (bool_fun_of_BDD cfg' node') (bool_fun_if x (bool_fun_of_BDD cfgr noder) (bool_fun_of_BDD cfgr nodel)) *)
(* Goal: config_node_OK cfg' node' *)
(* Goal: used_nodes_preserved cfgr cfg' (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: BDDconfig_OK cfg' *)
(* Goal: forall (xr : BDDvar) (lr rr : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) noder) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xr (@pair ad ad lr rr)))), @eq comparison (BDDcompare xr x) Lt *)
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  rewrite (Neqb_complete _ _ H39) in y0.  rewrite (BDD_EGAL_correct u) in y0.
(* Goal: False *)
(* Goal: bool_fun_eq (bool_fun_forall u (bool_fun_if x (bool_fun_of_BDD cfg r) (bool_fun_of_BDD cfg l))) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: bool_fun_eq (bool_fun_forall u (bool_fun_of_BDD cfg node)) (bool_fun_forall u (bool_fun_of_BDD cfg' node)) *)
(* Goal: nodes_preserved cfg' (BDDuniv_memo_put cfg' u node node') *)
(* Goal: config_node_OK cfg' node *)
(* Goal: @eq bool (Nleb (node_height cfg' node') (ad_S x)) true *)
(* Goal: bool_fun_eq (bool_fun_of_BDD cfg' node') (bool_fun_if x (bool_fun_of_BDD cfgr noder) (bool_fun_of_BDD cfgr nodel)) *)
(* Goal: config_node_OK cfg' node' *)
(* Goal: used_nodes_preserved cfgr cfg' (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: BDDconfig_OK cfg' *)
(* Goal: forall (xr : BDDvar) (lr rr : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) noder) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xr (@pair ad ad lr rr)))), @eq comparison (BDDcompare xr x) Lt *)
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  discriminate y0.
(* Goal: bool_fun_eq bool_fun_one (bool_fun_of_BDD cfg BDDone) *)
(* Goal: forall _ : @eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  apply bool_fun_forall_preserves_eq.  apply bool_fun_eq_sym.
(* Goal: used_node' cfg ul node *)
  apply bool_fun_of_BDD_int.  assumption.  assumption.
(* Goal: bool_fun_eq bool_fun_one (bool_fun_of_BDD cfg BDDone) *)
(* Goal: forall _ : @eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  apply bool_fun_forall_preserves_eq.  apply bool_fun_eq_sym.
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved'_bool_fun with (ul := ul).  assumption.  assumption.
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved_trans with (cfg2 := cfgl).  assumption.  assumption.
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved_trans with (cfg2 := cfgr).  assumption.
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved_cons with (node := nodel).  assumption.
(* Goal: used_nodes_preserved cfgr cfg' ul *)
(* Goal: @eq bool (Nleb (node_height cfg' node') (ad_S x)) true *)
(* Goal: bool_fun_eq (bool_fun_of_BDD cfg' node') (bool_fun_if x (bool_fun_of_BDD cfgr noder) (bool_fun_of_BDD cfgr nodel)) *)
(* Goal: config_node_OK cfg' node' *)
(* Goal: used_nodes_preserved cfgr cfg' (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: BDDconfig_OK cfg' *)
(* Goal: forall (xr : BDDvar) (lr rr : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) noder) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xr (@pair ad ad lr rr)))), @eq comparison (BDDcompare xr x) Lt *)
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply used_nodes_preserved_cons with (node := nodel).
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved_cons with (node := noder).  assumption.  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  apply BDDum_put_nodes_preserved.
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved_node_OK' with (ul := ul) (cfg := cfg).  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  apply used_nodes_preserved_trans with (cfg2 := cfgl).
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  apply used_nodes_preserved_trans with (cfg2 := cfgr).
(* Goal: used_node' cfg ul node *)
  assumption.  apply used_nodes_preserved_cons with (node := nodel).  assumption.
(* Goal: used_nodes_preserved cfgr cfg' ul *)
(* Goal: @eq bool (Nleb (node_height cfg' node') (ad_S x)) true *)
(* Goal: bool_fun_eq (bool_fun_of_BDD cfg' node') (bool_fun_if x (bool_fun_of_BDD cfgr noder) (bool_fun_of_BDD cfgr nodel)) *)
(* Goal: config_node_OK cfg' node' *)
(* Goal: used_nodes_preserved cfgr cfg' (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: BDDconfig_OK cfg' *)
(* Goal: forall (xr : BDDvar) (lr rr : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) noder) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xr (@pair ad ad lr rr)))), @eq comparison (BDDcompare xr x) Lt *)
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply used_nodes_preserved_cons with (node := nodel).
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved_cons with (node := noder).  assumption.
  replace cfg' with
   (fst (BDDmake gc cfgr x nodel noder (noder :: nodel :: ul))).
  replace node' with
   (snd (BDDmake gc cfgr x nodel noder (noder :: nodel :: ul))).
(* Goal: used_node' cfg ul node *)
  apply BDDmake_node_height_le.  assumption. 
(* Goal: used_node' cfg ul node *)
  assumption.  rewrite H9; reflexivity.  rewrite H9; reflexivity.
  replace cfg' with
   (fst (BDDmake gc cfgr x nodel noder (noder :: nodel :: ul))).
  replace node' with
   (snd (BDDmake gc cfgr x nodel noder (noder :: nodel :: ul))).
(* Goal: used_node' cfg ul node *)
  apply BDDmake_bool_fun.  assumption.  assumption.  assumption.  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  assumption.  rewrite H9.  reflexivity.  rewrite H9.
(* Goal: @eq BDDconfig (@fst BDDconfig ad (@pair BDDconfig ad cfgl nodel)) cfgl *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
reflexivity.
  replace cfg' with
   (fst (BDDmake gc cfgr x nodel noder (noder :: nodel :: ul))).
  replace node' with
   (snd (BDDmake gc cfgr x nodel noder (noder :: nodel :: ul))).
(* Goal: used_node' cfg ul node *)
  apply BDDmake_node_OK.  assumption.  assumption.  assumption.  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  assumption.  rewrite H9.  reflexivity.  rewrite H9.
(* Goal: @eq BDDconfig (@fst BDDconfig ad (@pair BDDconfig ad cfgl nodel)) cfgl *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
reflexivity.
 replace cfg' with
  (fst (BDDmake gc cfgr x nodel noder (noder :: nodel :: ul))).
  replace node' with
   (snd (BDDmake gc cfgr x nodel noder (noder :: nodel :: ul))).
(* Goal: used_node' cfg ul node *)
  apply BDDmake_preserves_used_nodes.  assumption.  assumption.  assumption. 

(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)))) cfg' *)
(* Goal: forall (xr : BDDvar) (lr rr : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) noder) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xr (@pair ad ad lr rr)))), @eq comparison (BDDcompare xr x) Lt *)
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  rewrite H9.  reflexivity.  rewrite H9.  reflexivity.
  replace cfg' with
   (fst (BDDmake gc cfgr x nodel noder (noder :: nodel :: ul))).
(* Goal: used_node' cfg ul node *)
  apply BDDmake_keeps_config_OK.  assumption.  assumption.  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  assumption.   assumption.
(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)))) cfg' *)
(* Goal: forall (xr : BDDvar) (lr rr : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) noder) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xr (@pair ad ad lr rr)))), @eq comparison (BDDcompare xr x) Lt *)
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  rewrite H9.  reflexivity.
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  intros.  rewrite (ad_S_compare xr x).
(* Goal: @eq comparison (BDDcompare (ad_S xr) (ad_S x)) Lt *)
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  replace (ad_S xr) with (node_height cfgr noder).
(* Goal: @eq comparison (BDDcompare (node_height cfgr nodel) (ad_S x)) Lt *)
(* Goal: @eq N (node_height cfgr nodel) (ad_S xl) *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  replace (ad_S x) with (node_height cfg node).   (* Unfold node_height in H24.*)
(* Goal: @eq comparison (BDDcompare (node_height cfgl nodel) (node_height cfg node)) Lt *)
(* Goal: @eq bool (N.eqb (node_height cfgr nodel) (node_height cfgl nodel)) true *)
(* Goal: @eq N (node_height cfg node) (ad_S x) *)
(* Goal: @eq N (node_height cfgr nodel) (ad_S xl) *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply BDDlt_compare.  apply le_lt_trans with (m := nat_of_N (node_height cfgl r)).
(* Goal: used_node' cfg ul node *)
  apply leb_complete.  assumption.
(* Goal: lt (N.to_nat (node_height cfgl r)) (N.to_nat (node_height cfg node)) *)
(* Goal: lt (N.to_nat (node_height cfg node)) (S n) *)
(* Goal: BDDconfig_OK cfgl *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: @eq ad (@snd BDDconfig ad (BDDuniv_1 cfgl (@cons ad nodel ul) r u n)) noder *)
(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDuniv_1 cfgl (@cons ad nodel ul) r u n)) cfgr *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  rewrite (Neqb_complete (node_height cfgl r) (node_height cfg r)).
(* Goal: lt (N.to_nat (node_height cfg l)) (N.to_nat (node_height cfg node)) *)
(* Goal: lt (N.to_nat (node_height cfg node)) (S n) *)
(* Goal: BDDconfig_OK cfg *)
(* Goal: used_list_OK cfg ul *)
(* Goal: used_node' cfg ul l *)
(* Goal: @eq ad (@snd BDDconfig ad (BDDuniv_1 cfg ul l u n)) nodel *)
(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n)) cfgl *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply BDDcompare_lt.  unfold node_height in |- *.  apply bs_node_height_right with (x := x) (l := l).
(* Goal: used_node' cfg ul node *)
  exact (proj1 H1).  assumption.
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved'_node_height_eq with (ul := ul).  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  assumption.  assumption.
(* Goal: @eq N match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => ad_S x | None => N0 end (ad_S x) *)
(* Goal: @eq N (node_height cfgr nodel) (ad_S xl) *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  unfold node_height in |- *.  unfold bs_node_height in |- *.  rewrite H4.  reflexivity.
(* Goal: @eq comparison (BDDcompare (node_height cfg l) (node_height cfg node)) Lt *)
(* Goal: lt (N.to_nat (node_height cfg node)) (S n) *)
(* Goal: BDDconfig_OK cfg *)
(* Goal: used_list_OK cfg ul *)
(* Goal: used_node' cfg ul l *)
(* Goal: @eq ad (@snd BDDconfig ad (BDDuniv_1 cfg ul l u n)) nodel *)
(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n)) cfgl *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  unfold node_height in |- *.  unfold bs_node_height in |- *.  rewrite H30.  reflexivity.
(* Goal: forall (xl : BDDvar) (ll rl : ad) (_ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfgr) nodel) (@Some (prod BDDvar (prod ad ad)) (@pair BDDvar (prod ad ad) xl (@pair ad ad ll rl)))), @eq comparison (BDDcompare xl x) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  intros.  rewrite (ad_S_compare xl x).
(* Goal: @eq comparison (BDDcompare (ad_S xl) (ad_S x)) Lt *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  replace (ad_S xl) with (node_height cfgr nodel).
(* Goal: @eq comparison (BDDcompare (node_height cfgr nodel) (ad_S x)) Lt *)
(* Goal: @eq N (node_height cfgr nodel) (ad_S xl) *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  replace (ad_S x) with (node_height cfg node). (*  Unfold node_height in H24.*)
(* Goal: @eq comparison (BDDcompare (node_height cfgr nodel) (node_height cfg node)) Lt *)
(* Goal: @eq N (node_height cfg node) (ad_S x) *)
(* Goal: @eq N (node_height cfgr nodel) (ad_S xl) *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  rewrite (Neqb_complete (node_height cfgr nodel) (node_height cfgl nodel)).
(* Goal: @eq comparison (BDDcompare (node_height cfgl nodel) (node_height cfg node)) Lt *)
(* Goal: @eq bool (N.eqb (node_height cfgr nodel) (node_height cfgl nodel)) true *)
(* Goal: @eq N (node_height cfg node) (ad_S x) *)
(* Goal: @eq N (node_height cfgr nodel) (ad_S xl) *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply BDDlt_compare.  apply le_lt_trans with (m := nat_of_N (node_height cfg l)).
(* Goal: used_node' cfg ul node *)
  apply leb_complete.  assumption.
(* Goal: lt (N.to_nat (node_height cfg l)) (N.to_nat (node_height cfg node)) *)
(* Goal: lt (N.to_nat (node_height cfg node)) (S n) *)
(* Goal: BDDconfig_OK cfg *)
(* Goal: used_list_OK cfg ul *)
(* Goal: used_node' cfg ul l *)
(* Goal: @eq ad (@snd BDDconfig ad (BDDuniv_1 cfg ul l u n)) nodel *)
(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n)) cfgl *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply BDDcompare_lt.  unfold node_height in |- *.  apply bs_node_height_left with (x := x) (r := r).
(* Goal: used_node' cfg ul node *)
  exact (proj1 H1).  assumption.
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved'_node_height_eq with (ul := nodel :: ul).  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  assumption.
(* Goal: used_node' cfgr (@cons ad nodel ul) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply used_node'_cons_node_ul.
(* Goal: @eq N match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => ad_S x | None => N0 end (ad_S x) *)
(* Goal: @eq N (node_height cfgr nodel) (ad_S xl) *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) noder *)
(* Goal: used_node' cfgr (@cons ad noder (@cons ad nodel ul)) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  unfold node_height in |- *.  unfold bs_node_height in |- *.  rewrite H4.  reflexivity.
(* Goal: @eq comparison (BDDcompare (node_height cfg l) (node_height cfg node)) Lt *)
(* Goal: lt (N.to_nat (node_height cfg node)) (S n) *)
(* Goal: BDDconfig_OK cfg *)
(* Goal: used_list_OK cfg ul *)
(* Goal: used_node' cfg ul l *)
(* Goal: @eq ad (@snd BDDconfig ad (BDDuniv_1 cfg ul l u n)) nodel *)
(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n)) cfgl *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  unfold node_height in |- *.  unfold bs_node_height in |- *.  rewrite H30.  reflexivity.
(* Goal: used_node' cfgr (@cons ad nodel ul) nodel *)
(* Goal: used_list_OK cfgr (@cons ad noder (@cons ad nodel ul)) *)
(* Goal: used_list_OK cfgr (@cons ad nodel ul) *)
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply used_node'_cons_node_ul.  apply used_node'_cons_node'_ul.
(* Goal: used_node' cfg ul node *)
  apply used_node'_cons_node_ul.  apply node_OK_list_OK.  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  apply used_nodes_preserved_list_OK with (cfg := cfgl).  assumption.
(* Goal: used_node' cfg ul node *)
  assumption. 
(* Goal: and (BDDconfig_OK cfgr) (and (config_node_OK cfgr noder) (and (used_nodes_preserved cfgl cfgr (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height cfgr noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD cfgr noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  replace cfgr with (fst (BDDuniv_1 cfgl (nodel :: ul) r u n)).
(* Goal: and (BDDconfig_OK (@fst BDDconfig ad (BDDuniv_1 cfgl (@cons ad nodel ul) r u n))) (and (config_node_OK (@fst BDDconfig ad (BDDuniv_1 cfgl (@cons ad nodel ul) r u n)) noder) (and (used_nodes_preserved cfgl (@fst BDDconfig ad (BDDuniv_1 cfgl (@cons ad nodel ul) r u n)) (@cons ad nodel ul)) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad (BDDuniv_1 cfgl (@cons ad nodel ul) r u n)) noder) (node_height cfgl r)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (BDDuniv_1 cfgl (@cons ad nodel ul) r u n)) noder) (bool_fun_forall u (bool_fun_of_BDD cfgl r)))))) *)
(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDuniv_1 cfgl (@cons ad nodel ul) r u n)) cfgr *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  replace noder with (snd (BDDuniv_1 cfgl (nodel :: ul) r u n)).  apply H.
(* Goal: lt (N.to_nat (node_height cfg l)) n *)
(* Goal: BDDconfig_OK cfg *)
(* Goal: used_list_OK cfg ul *)
(* Goal: used_node' cfg ul l *)
(* Goal: @eq ad (@snd BDDconfig ad (BDDuniv_1 cfg ul l u n)) nodel *)
(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n)) cfgl *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply lt_trans_1 with (y := nat_of_N (node_height cfg node)).
(* Goal: lt (N.to_nat (node_height cfg l)) (N.to_nat (node_height cfg node)) *)
(* Goal: lt (N.to_nat (node_height cfg node)) (S n) *)
(* Goal: BDDconfig_OK cfg *)
(* Goal: used_list_OK cfg ul *)
(* Goal: used_node' cfg ul l *)
(* Goal: @eq ad (@snd BDDconfig ad (BDDuniv_1 cfg ul l u n)) nodel *)
(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n)) cfgl *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  rewrite (Neqb_complete (node_height cfgl r) (node_height cfg r)).  apply BDDcompare_lt.
(* Goal: @eq comparison (BDDcompare (node_height cfg l) (node_height cfg node)) Lt *)
(* Goal: lt (N.to_nat (node_height cfg node)) (S n) *)
(* Goal: BDDconfig_OK cfg *)
(* Goal: used_list_OK cfg ul *)
(* Goal: used_node' cfg ul l *)
(* Goal: @eq ad (@snd BDDconfig ad (BDDuniv_1 cfg ul l u n)) nodel *)
(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n)) cfgl *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  unfold node_height in |- *.  apply bs_node_height_right with (x := x) (l := l).  exact (proj1 H1).
(* Goal: used_node' cfg ul node *)
  assumption.  apply used_nodes_preserved'_node_height_eq with (ul := ul).  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  assumption.  assumption.  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  assumption.  rewrite H8.  reflexivity.
(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDuniv_1 cfgl (@cons ad nodel ul) r u n)) cfgr *)
(* Goal: used_node' cfgl (@cons ad nodel ul) r *)
(* Goal: used_node' cfgl ul r *)
(* Goal: used_list_OK cfgl (@cons ad nodel ul) *)
(* Goal: used_list_OK cfgl ul *)
(* Goal: config_node_OK cfg r *)
(* Goal: config_node_OK cfg l *)
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  rewrite H8.  reflexivity.  apply used_node'_cons_node'_ul.
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved_used_node' with (cfg := cfg).  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  apply high_used' with (node := node) (x := x) (l := l).  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved_used_node' with (cfg := cfg).  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  apply node_OK_list_OK.  assumption.  assumption.
(* Goal: used_node' cfg ul node *)
  apply used_nodes_preserved_list_OK with (cfg := cfg).  assumption.  assumption.
(* Goal: used_node' cfg ul node *)
  apply used_node'_OK with (ul := ul).  assumption.  assumption.  assumption.
(* Goal: used_node' cfg ul node *)
  apply used_node'_OK with (ul := ul).  assumption.  assumption.  assumption.
(* Goal: and (BDDconfig_OK cfgl) (and (config_node_OK cfgl nodel) (and (used_nodes_preserved cfg cfgl ul) (and (@eq bool (Nleb (node_height cfgl nodel) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD cfgl nodel) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  replace cfgl with (fst (BDDuniv_1 cfg ul l u n)).
(* Goal: and (BDDconfig_OK (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n))) (and (config_node_OK (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n)) (@snd BDDconfig ad (BDDuniv_1 cfg ul l u n))) (and (used_nodes_preserved cfg (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n)) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n)) (@snd BDDconfig ad (BDDuniv_1 cfg ul l u n))) (node_height cfg l)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n)) (@snd BDDconfig ad (BDDuniv_1 cfg ul l u n))) (bool_fun_forall u (bool_fun_of_BDD cfg l)))))) *)
(* Goal: @eq ad (@snd BDDconfig ad (BDDuniv_1 cfg ul l u n)) nodel *)
(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n)) cfgl *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  replace nodel with (snd (BDDuniv_1 cfg ul l u n)).  apply H.
(* Goal: lt (N.to_nat (node_height cfg l)) n *)
(* Goal: BDDconfig_OK cfg *)
(* Goal: used_list_OK cfg ul *)
(* Goal: used_node' cfg ul l *)
(* Goal: @eq ad (@snd BDDconfig ad (BDDuniv_1 cfg ul l u n)) nodel *)
(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n)) cfgl *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply lt_trans_1 with (y := nat_of_N (node_height cfg node)).
(* Goal: lt (N.to_nat (node_height cfg l)) (N.to_nat (node_height cfg node)) *)
(* Goal: lt (N.to_nat (node_height cfg node)) (S n) *)
(* Goal: BDDconfig_OK cfg *)
(* Goal: used_list_OK cfg ul *)
(* Goal: used_node' cfg ul l *)
(* Goal: @eq ad (@snd BDDconfig ad (BDDuniv_1 cfg ul l u n)) nodel *)
(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n)) cfgl *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply BDDcompare_lt.  unfold node_height in |- *.
(* Goal: @eq comparison (BDDcompare (bs_node_height (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) l) (bs_node_height (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node)) Lt *)
(* Goal: lt (N.to_nat (node_height cfg node)) (S n) *)
(* Goal: BDDconfig_OK cfg *)
(* Goal: used_list_OK cfg ul *)
(* Goal: used_node' cfg ul l *)
(* Goal: @eq ad (@snd BDDconfig ad (BDDuniv_1 cfg ul l u n)) nodel *)
(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n)) cfgl *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  apply bs_node_height_left with (x := x) (r := r).  exact (proj1 H1).
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  assumption.  assumption.  assumption.
(* Goal: @eq BDDconfig (@fst BDDconfig ad (BDDuniv_1 cfg ul l u n)) cfgl *)
(* Goal: used_node' cfg ul r *)
(* Goal: used_node' cfg ul l *)
(* Goal: forall _ : @eq (option (prod BDDvar (prod ad ad))) (MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node) (@None (prod BDDvar (prod ad ad))), and (BDDconfig_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (config_node_OK (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (and (used_nodes_preserved cfg (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) ul) (and (@eq bool (Nleb (node_height (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (node_height cfg node)) true) (bool_fun_eq (bool_fun_of_BDD (@fst BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end) (@snd BDDconfig ad match MapGet (prod BDDvar (prod ad ad)) (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg) node with | Some (pair x (pair l r as p0) as p) => match BDDcompare x u with | Eq => BDDand gc cfg ul l r | Lt => @pair BDDconfig ad cfg node | Gt => let (cfgl, nodel) := BDDuniv_1 cfg ul l u n in let (cfgr, noder) := BDDuniv_1 cfgl (@cons ad nodel ul) r u n in let (cfg', node') := BDDmake gc cfgr x nodel noder (@cons ad noder (@cons ad nodel ul)) in @pair (prod BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo (Map (Map ad)))))))) ad (BDDuniv_memo_put cfg' u node node') node' end | None => @pair BDDconfig ad cfg node end)) (bool_fun_forall u (bool_fun_of_BDD cfg node)))))) *)
  rewrite H7.  reflexivity.  rewrite H7.  reflexivity.  
(* Goal: used_node' cfg ul node *)
  apply high_used' with (node := node) (x := x) (l := l).  assumption.  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  apply low_used' with (node := node) (x := x) (r := r).  assumption.
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  intro y0.  rewrite y0.  simpl in |- *.  split.  assumption.
(* Goal: used_node' cfg ul node *)
  split.  apply used_node'_OK with (ul := ul).  assumption.  assumption.  
(* Goal: used_node' cfg ul node *)
  assumption.  split.  apply used_nodes_preserved_refl.  split.
(* Goal: @eq bool (Nleb (node_height cfg node) (node_height cfg node)) true *)
(* Goal: bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
  apply Nleb_refl.  cut (config_node_OK cfg node).  intro.
(* Goal: forall _ : @eq ad node BDDone, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: forall _ : @eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  unfold config_node_OK in H4.  elim H4.  intro.  rewrite H5.
(* Goal: bool_fun_eq (bool_fun_of_BDD cfg BDDzero) (bool_fun_forall u (bool_fun_of_BDD cfg BDDzero)) *)
(* Goal: forall _ : or (@eq ad node BDDone) (@eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true), bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  apply bool_fun_eq_trans with bool_fun_zero.  apply bool_fun_of_BDD_zero.
(* Goal: used_node' cfg ul node *)
  assumption.  
(* Goal: bool_fun_eq bool_fun_zero (bool_fun_forall u (bool_fun_of_BDD cfg BDDzero)) *)
(* Goal: forall _ : or (@eq ad node BDDone) (@eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true), bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  apply bool_fun_eq_trans with (bf2 := bool_fun_forall u bool_fun_zero).
(* Goal: bool_fun_eq bool_fun_one (bool_fun_of_BDD cfg BDDone) *)
(* Goal: forall _ : @eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  apply bool_fun_eq_sym.  apply bool_fun_forall_zero.  
(* Goal: bool_fun_eq bool_fun_one (bool_fun_of_BDD cfg BDDone) *)
(* Goal: forall _ : @eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  apply bool_fun_forall_preserves_eq.  apply bool_fun_eq_sym.
(* Goal: used_node' cfg ul node *)
  apply bool_fun_of_BDD_zero.  assumption.  intro.  elim H5.  intro.
(* Goal: bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: forall _ : @eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  rewrite H6.  apply bool_fun_eq_trans with bool_fun_one.
(* Goal: used_node' cfg ul node *)
  apply bool_fun_of_BDD_one.  assumption.  
(* Goal: bool_fun_eq bool_fun_one (bool_fun_forall u (bool_fun_of_BDD cfg BDDone)) *)
(* Goal: forall _ : @eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  apply bool_fun_eq_trans with (bf2 := bool_fun_forall u bool_fun_one).
(* Goal: bool_fun_eq bool_fun_one (bool_fun_of_BDD cfg BDDone) *)
(* Goal: forall _ : @eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  apply bool_fun_eq_sym.  apply bool_fun_forall_one.  
(* Goal: bool_fun_eq bool_fun_one (bool_fun_of_BDD cfg BDDone) *)
(* Goal: forall _ : @eq bool (in_dom (prod BDDvar (prod ad ad)) node (@fst BDDstate (prod BDDsharing_map (prod BDDfree_list (prod ad (prod BDDneg_memo (prod BDDor_memo BDDuniv_memo))))) cfg)) true, bool_fun_eq (bool_fun_of_BDD cfg node) (bool_fun_forall u (bool_fun_of_BDD cfg node)) *)
(* Goal: config_node_OK cfg node *)
  apply bool_fun_forall_preserves_eq.  apply bool_fun_eq_sym.
(* Goal: used_node' cfg ul node *)
  apply bool_fun_of_BDD_one.  assumption.  unfold in_dom in |- *.  rewrite y0.
(* Goal: used_node' cfg ul node *)
  intro; discriminate.  apply used_node'_OK with (ul := ul).  assumption.  
(* Goal: used_node' cfg ul node *)
  assumption.  assumption.  
Qed.

End BDDuniv_sec.
