(* 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                                                     *)
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.

(* Specifications: *)
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)).