(* 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                                                     *)
Fixpoint ad_list_neq (l1 l2 : list ad) {struct l2} : bool :=
match l1, l2 with
| nil, _ => true
| _, nil => true
| a1 :: l1', a2 :: l2' => negb (Neqb a1 a2) && ad_list_neq l1' l2'
end.
Definition bool_to_be (b : bool) :=
match b with
| true => One
| false => Zero
end.
Definition bool_to_bf (b : bool) :=
match b with
| true => bool_fun_one
| false => bool_fun_zero
end.
Definition bool_fun_subst (x : BDDvar) (bfx bf : bool_fun) : bool_fun :=
fun ve : var_env => bf (augment ve x (bfx ve)).
Definition bool_fun_subst1 (x : BDDvar) (bfx bf : bool_fun) : bool_fun :=
bool_fun_forall x (bool_fun_impl (bool_fun_iff (bool_fun_var x) bfx) bf).
Definition bool_fun_replace (x y : BDDvar) (bf : bool_fun) :=
bool_fun_subst x (bool_fun_var y) bf.
Definition bool_fun_restrict1 (x : BDDvar) (b : bool)
(bf : bool_fun) := bool_fun_subst x (bool_to_bf b) bf.

Lemma bool_fun_restrict1_eq_restrict :
forall (bf : bool_fun) (x : BDDvar) (b : bool),
bool_fun_eq (bool_fun_restrict1 x b bf) (bool_fun_restrict bf x b).