Proof with auto.
induction T; simpl; intro H; f_equal...
Case "typ_fvar".
destruct (a == Z)...
contradict H; fsetdec.
Qed.
(** Substitution commutes with opening under certain conditions.  This lemma depends on the fact that opening a locally closed term is the identity. *)

Lemma subst_tt_open_tt_rec : forall T1 T2 X P k,
type P ->
subst_tt X P (open_tt_rec k T2 T1) =
open_tt_rec k (subst_tt X P T2) (subst_tt X P T1).