Fixpoint BDDreplacel (cfg : BDDconfig) (ul : list ad) 
 (node : ad) (lx ly : list BDDvar) {struct ly} : BDDconfig * ad :=
  match lx, ly with
  | nil, _ => (cfg, node)
  | _ :: _, nil => (cfg, node)
  | x :: lx', y :: ly' =>
      match BDDreplacel cfg ul node lx' ly' with
      | (cfg1, node1) => BDDreplace cfg1 (node1 :: ul) node1 x y
      end
  end.

Lemma BDDreplacel_is_replacel : bool_fun_eq (bool_fun_of_BDD (fst (BDDreplacel cfg ul node lx ly)) (snd (BDDreplacel cfg ul node lx ly))) (bool_fun_replacel (bool_fun_of_BDD cfg node) lx ly).