Fixpoint BDDiter (f : BDDconfig -> ad -> BDDconfig * ad)
(cfg : BDDconfig) (node : ad) (n : nat) {struct n} :
BDDconfig * ad :=
match n with
| O => (cfg, node)
| S m =>
match f cfg node with
| (cfg1, node1) =>
if Neqb node node1 then (cfg1, node1) else BDDiter f cfg1 node1 m
end
end.
Fixpoint BDDiter2n (f : BDDconfig -> ad -> BDDconfig * ad)
(cfg : BDDconfig) (node : ad) (n : nat) {struct n} :
BDDconfig * ad * bool :=
match n with
| O =>
match f cfg node with
| (cfg1, node1) => (cfg1, node1, Neqb node node1)
end
| S m =>
match BDDiter2n f cfg node m with
| ((cfg1, node1), true) => (cfg1, node1, true)
| ((cfg1, node1), false) => BDDiter2n f cfg1 node1 m
end
end.
Definition cfgnode_eq (cfgnode1 cfgnode2 : BDDconfig * ad) :=
Neqb (snd cfgnode1) (snd cfgnode2).

Lemma BDDiter_as_iter :
forall (n : nat) (cfg : BDDconfig) (node : ad)
(f : BDDconfig -> ad -> BDDconfig * ad),
BDDiter f cfg node n =
iter _ cfgnode_eq (fun x => f (fst x) (snd x)) (cfg, node) n.