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_replace_preserves_eq : forall (bf1 bf2 : bool_fun) (x y : BDDvar), bool_fun_eq bf1 bf2 -> bool_fun_eq (bool_fun_replace x y bf1) (bool_fun_replace x y bf2).