(*! Indexed version of safety (not needed here) *)

Inductive iter {X} (R : Rel X) : nat -> Rel X :=
  | iter_O x : iter R O x x
  | iter_S n x y z : R x y -> iter R n y z -> iter R (S n) x z.(*! Indexed version of safety (not needed here) *)

Inductive iter {X} (R : Rel X) : nat -> Rel X :=
  | iter_O x : iter R O x x
  | iter_S n x y z : R x y -> iter R n y z -> iter R (S n) x z.(*! Indexed version of safety (not needed here) *)

Inductive iter {X} (R : Rel X) : nat -> Rel X :=
  | iter_O x : iter R O x x
  | iter_S n x y z : R x y -> iter R n y z -> iter R (S n) x z.Definition safe_ n {X} (R : Rel X) x := forall y m, m < n -> iter R m x y -> exists z, R y z.

(* Specifications: *)
Lemma safe_safe_ {X} (R : Rel X) x : safe R x <-> forall n, safe_ n R x.
Lemma safe__det {X} (R : Rel X) n x y : safe_ n R y -> R x y -> (forall y', R x y' -> y = y') -> safe_ (S n) R x.
Lemma safe__R {X} (R : Rel X) n x y : safe_ (S n) R x -> R x y -> safe_ n R y.
Lemma safe_S {X} (R : Rel X) n x : safe_ (S n) R x -> safe_ n R x.
Lemma safe_safe_ {X} (R : Rel X) x : safe R x <-> forall n, safe_ n R x.
Lemma safe__det {X} (R : Rel X) n x y : safe_ n R y -> R x y -> (forall y', R x y' -> y = y') -> safe_ (S n) R x.
Lemma safe__R {X} (R : Rel X) n x y : safe_ (S n) R x -> R x y -> safe_ n R y.
Lemma safe_S {X} (R : Rel X) n x : safe_ (S n) R x -> safe_ n R x.