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

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