(* The derivation that is plugged in is usually canonical, i.e., [m] is zero, but we do not require this. *)
(* In the worst case, the height of the new derivation is the sum of the heights of the original derivations, due to the way the derivations are plugged in at variables. *)

(* Specifications: *)
Lemma type_substitution:
forall n E t T,
j n E t T ->
forall U x E' T',
map (subst U x) E = E' ->
subst U x T = T' ->
j n E' t T'.
Lemma inversion_JAbs:
forall E t T1 T2,
j 0 E (TAbs t) (TyArrow T1 T2) ->
exists m,
j m (insert 0 T1 E) t T2.
Lemma inversion_JTyAbs:
forall E t T,
j 0 E (TAbs t) (TyForall T) ->
j 0 (map (shift 0) E) (TAbs t) T.