From Undecidability.L Require Export L.
(** * Step-indexed interpreter and modesty *)
(** ** Step-indexed interpreter *)
Fixpoint eval (n : nat) (u : term) :=
match u with
| var n => None
| lambda s => Some (lambda s)
| app s t => match n with
| 0   => None
| S n => match eval n s, eval n t with
| Some (lambda s), Some t => eval n (subst s 0 t)
|   _ , _ => None
end
end
end.

(* Specifications: *)
Lemma eval_S n s t : eval n s = Some t -> eval (S n) s = Some t.
Lemma eval_step s s' t n : s ≻ s' -> eval n s' = Some t -> eval (S n) s = Some t.
Lemma evaluates_eval s t : evaluates s t -> exists n, eval n s = Some t.
Lemma eval_evaluates n s t : eval n s = Some t -> evaluates s t.
Lemma equiv_eval s t : lam t -> s ≡ t -> exists n, eval n s = Some t.
Lemma eval_equiv s s' n : eval n s = Some s' -> s ≡ s'.
Lemma eval_lambda n s t : eval n s = Some t -> lam t.
Definition cChoice := constructive_indefinite_ground_description_nat_Acc.
(** ** Modesty *)
Lemma computable_eva s : eva s -> { v | s ▷ v }.
Lemma decidable_dec p : decidable p -> exists f, forall s, f s = true <-> p s.
Proof with try tauto; try (eexists; reflexivity).