simple induction 2; simpl in |- *; intros; auto with arith pts.
elim (lt_eq_lt_dec n v); intros.
elim H2.
elim a.
case v; intros.
inversion_clear a0.
simpl in |- *.
rewrite H5.
rewrite simpl_subst; auto with arith pts.
apply type_var; auto with arith pts.
exists x0; auto with arith pts.
apply nth_sub_sup with (1 := H3); auto with arith pts.
intros.
rewrite H5.
elim b.
rewrite simpl_subst; auto with arith pts.
apply thinning_n with g; auto with arith pts.
elim H3; intros; auto with arith pts.
rewrite <- b in H6.
elim nth_sub_eq with (1 := H3) (2 := H6).
trivial with arith pts.
apply type_var; auto with arith pts.
apply nth_sub_item_inf with (1 := H3); auto with arith pts.
cut (wf (subst_decl x (Ax T) n :: f)); intros.
apply type_abs with s; auto with arith pts.
replace (Ax (subst_rec x T n)) with (subst_decl x (Ax T) n);
auto with arith pts.
apply
inversion_lemma
with f (Prod (subst_rec x T n) (subst_rec x U0 (S n))) (Srt s);
simpl in |- *; intros; auto with arith pts.
apply wf_var with s1; auto with arith pts.
rewrite distr_subst.
apply type_app with (subst_rec x V n); auto with arith pts.
cut (wf (Ax (subst_rec x T n) :: f)); intros; auto with arith pts.
apply type_prod with s1 s2; auto with arith pts.
replace (Ax (subst_rec x T n)) with (subst_decl x (Ax T) n);
auto with arith pts.
apply wf_var with s1; auto with arith pts.
apply type_conv with (subst_rec x U0 n) s; auto with arith pts.
apply le_type_subst with g d e0; auto with arith pts.
apply type_conv_srt with (subst_rec x U0 n); auto with arith pts.
fold (subst_rec x (Srt s) n) in |- *.
apply le_type_subst with g d e0; auto with arith pts.
Qed.

(* Specifications: *)
Theorem substitution :
forall (e : env) (d t u U : term),
typ (Ax t :: e) u U -> typ e d t -> typ e (subst d u) (subst d U).
Theorem substitution :
forall (e : env) (d t u U : term),
typ (Ax t :: e) u U -> typ e d t -> typ e (subst d u) (subst d U).