Section Loop.
Variable (A : Type) (f : A -> A) (p : A -> bool).
Fixpoint loop (a : A) (k : nat) {struct k} :=
if p a then Some a else
match k with
| O => None
| S k' => loop (f a) k'
end.

Lemma loop_fulfills k a b :
loop a k = Some b ->
p b = true.