intros e t T P inv_P j.
generalize P inv_P; clear inv_P P.
elim j; simpl in |- *; intros.
apply inv_P with s2; trivial with arith pts.
inversion_clear H0.
apply inv_P with x; trivial with arith pts.
elim H1; trivial with arith pts.
apply inv_P with s U; auto with arith pts.
apply inv_P with Ur V; auto with arith pts.
apply inv_P with s1 s2 s3; auto with arith pts.
apply H0.
apply inv_typ_conv with V; auto with arith pts.
apply H0.
apply inv_typ_conv with (Srt s); auto with arith pts.
Qed.
Ltac Inversion_typ T :=
let INVTYP := fresh "INVTYP" in
(generalize T; intro INVTYP; inversion INVTYP using inversion_lemma;
unfold inv_typ in |- *; clear INVTYP; intros).

Lemma wft_free_db :
forall (e : env) (t : term), wf_type e t -> free_db (length e) t.