(*! Indexed version of safety (not needed here) *)
Definition safe_ n {X} (R : Rel X) x := forall y m, m < n -> iter R m x y -> exists z, R y z.

Lemma safe_S {X} (R : Rel X) n x : safe_ (S n) R x -> safe_ n R x.
Fixpoint nth {A} (l : list A) i :=
match l with
| nil => None
| x :: l =>
match i with
| O => Some x
| S i => nth l i
end
end.