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).

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).