red in |- *.
simple induction 1; simpl in |- *; intros.
elim (le_gt_dec k n); intros.
unfold lift in |- *.
rewrite simpl_lift_rec; simpl in |- *; auto with arith pts.
change (delta f (Ref (S n)) (lift (S (S n)) d)) in |- *.
apply delta_intro with T; auto with arith pts.
apply ins_item_ge with (1 := H1); auto with arith pts.
unfold lift in |- *.
replace k with (S n + (k - S n)); auto with arith pts.
elim permute_lift_rec with d 1 (k - S n) (S n) 0; auto with arith pts.
change (delta f (Ref n) (lift (S n) (lift_rec 1 d (k - S n)))) in |- *.
apply delta_intro with (lift_rec 1 T (k - S n)).
change (item (lift_decl 1 (Def d T) (k - S n)) f n) in |- *.
apply ins_item_lt with (1 := H1); auto with arith pts.
red in |- *.
simple induction 1; simpl in |- *; intros.
elim (lt_eq_lt_dec n0 n); intros.
red in |- *.
elim a.
generalize H0.
clear H0.
case n; simpl in |- *; intros.
inversion_clear a0.
rewrite simpl_subst; auto with arith pts.
apply rt_step.
apply delta_intro with T.
apply nth_sub_sup with (1 := H1); auto with arith pts.
intro.
rewrite b.
rewrite simpl_subst.
rewrite b in H1.
generalize H1.
rewrite nth_sub_eq with (1 := H1) (2 := H0).
intro.
elim sub_decl_eq_def with (1 := H2).
auto with arith pts.
auto with arith pts.
red in |- *; apply rt_step.
replace n0 with (S n + (n0 - S n)); auto with arith pts.
unfold lift in |- *.
elim commut_lift_subst_rec with d s (S n) (n0 - S n) 0; auto with arith pts.
change (delta f (Ref n) (lift (S n) (subst_rec s d (n0 - S n)))) in |- *.
apply delta_intro with (subst_rec s T (n0 - S n)).
change (item (subst_decl s (Def d T) (n0 - S n)) f n) in |- *.
apply nth_sub_inf with (1 := H1); auto with arith pts.
red in |- *; intros.
inversion_clear H.
elim red_item with R' n (Def d T) e f; intros; auto with arith pts.
apply delta_intro with T; auto with arith pts.
elim item_trunc with decl n e (Def d T); intros; auto with arith pts.
elim H with x0; intros; auto with arith pts.
inversion_clear H3.
generalize H6.
inversion_clear H5; intros.
apply delta_intro with U; auto with arith pts.
Defined.

(* Specifications: *)
Lemma delta_reduce :
forall (n : nat) (e : env),
{def : term | delta e (Ref n) def} +
{(forall x : term, ~ delta e (Ref n) x)}.