Definition bool_fun_if (x : BDDvar) (bf bf' : bool_fun) : bool_fun :=
fun vb : var_binding => ifb (vb x) (bf vb) (bf' vb).

(* Specifications: *)
Lemma nodes_preserved_internal :
forall (cfg cfg' : BDDconfig) (node : ad),
BDDconfig_OK cfg ->
BDDconfig_OK cfg' ->
config_node_OK cfg node ->
is_internal_node cfg' node -> is_internal_node cfg node.
Lemma bool_fun_if_preserves_eq :
forall (x : BDDvar) (bf1 bf2 bf1' bf2' : bool_fun),
bool_fun_eq bf1 bf1' ->
bool_fun_eq bf2 bf2' ->
bool_fun_eq (bool_fun_if x bf1 bf2) (bool_fun_if x bf1' bf2').
Lemma BDDmake_var_order :
forall (cfg : BDDconfig) (l r : ad) (x : BDDvar),
BDDconfig_OK cfg ->
config_node_OK cfg l ->
config_node_OK cfg r ->
(is_internal_node cfg l -> BDDcompare (var cfg l) x = Datatypes.Lt) ->
(is_internal_node cfg r -> BDDcompare (var cfg r) x = Datatypes.Lt) ->
BDDvar_le (var (fst (BDDmake cfg x l r)) (snd (BDDmake cfg x l r))) x = true.
Lemma BDDmake_bool_fun :
forall (cfg : BDDconfig) (l r : ad) (x : BDDvar),
BDDconfig_OK cfg ->
config_node_OK cfg l ->
config_node_OK cfg r ->
(is_internal_node cfg l -> BDDcompare (var cfg l) x = Datatypes.Lt) ->
(is_internal_node cfg r -> BDDcompare (var cfg r) x = Datatypes.Lt) ->
bool_fun_eq
(bool_fun_of_BDD (fst (BDDmake cfg x l r)) (snd (BDDmake cfg x l r)))
(bool_fun_if x (bool_fun_of_BDD cfg r) (bool_fun_of_BDD cfg l)).
Lemma bool_fun_or_commute :
forall bf bf' : bool_fun,
bool_fun_eq (bool_fun_or bf bf') (bool_fun_or bf' bf).
Lemma bool_fun_or_zero :
forall bf : bool_fun, bool_fun_eq (bool_fun_or bf bool_fun_zero) bf.
Lemma bool_fun_or_one :
forall bf : bool_fun, bool_fun_eq (bool_fun_or bf bool_fun_one) bool_fun_one.
Lemma bool_fun_if_lemma_1 :
forall (x : BDDvar) (bfl1 bfl2 bfr1 bfr2 : bool_fun),
bool_fun_eq (bool_fun_if x (bool_fun_or bfr1 bfr2) (bool_fun_or bfl1 bfl2))
(bool_fun_or (bool_fun_if x bfr1 bfl1) (bool_fun_if x bfr2 bfl2)).
Lemma bool_fun_if_lemma_3 :
forall (x : BDDvar) (bf1 bfl2 bfr2 : bool_fun),
bool_fun_eq (bool_fun_if x (bool_fun_or bf1 bfr2) (bool_fun_or bf1 bfl2))
(bool_fun_or bf1 (bool_fun_if x bfr2 bfl2)).
Lemma bool_fun_if_lemma_4 :
forall (x : BDDvar) (bfl1 bfr1 bf2 : bool_fun),
bool_fun_eq (bool_fun_if x (bool_fun_or bfr1 bf2) (bool_fun_or bfl1 bf2))
(bool_fun_or (bool_fun_if x bfr1 bfl1) bf2).
Lemma bool_fun_if_lemma_2 :
forall (cfg : BDDconfig) (node : ad),
BDDconfig_OK cfg ->
is_internal_node cfg node ->
bool_fun_eq (bool_fun_of_BDD cfg node)
(bool_fun_if (var cfg node) (bool_fun_of_BDD cfg (high cfg node))
(bool_fun_of_BDD cfg (low cfg node))).