(* --------------------------------------- *)
(* Convenience lemmas for working with substitution. *)

(* Specifications: *)
Lemma AnnTyping_tm_subst : forall G x A b B (H : AnnTyping ((x ~ Tm A) ++ G) b B),
forall a, AnnTyping G a A ->
AnnTyping G (tm_subst_tm_tm a x b) (tm_subst_tm_tm a x B).
Lemma AnnTyping_tm_subst_nondep : forall L G a A b B,
AnnTyping G a A ->
(forall x, x `notin` L -> AnnTyping ([(x,Tm A)] ++ G) (open_tm_wrt_tm b (a_Var_f x)) B) ->
AnnTyping G (open_tm_wrt_tm b a) B.
Lemma AnnTyping_co_subst : forall G x A1 A2 A3 b B (H : AnnTyping ((x ~ Co (Eq A1 A2 A3)) ++ G) b B),
forall D a, AnnDefEq G D a A1 A2 ->
AnnTyping G (co_subst_co_tm a x b) (co_subst_co_tm a x B).
Lemma AnnTyping_co_subst_nondep : forall L G D g A1 A2 A3 b B,
AnnDefEq G D g A1 A2 ->
(forall x, x `notin` L -> AnnTyping ([(x,Co (Eq A1 A2 A3))] ++ G) (open_tm_wrt_co b (g_Var_f x)) B) ->
AnnTyping G (open_tm_wrt_co b g) B.