(* -------------------------------------------------------------- *)
(*  Interlude: some lemmas about how erasure and typing interact. *)
(* -------------------------------------------------------------- *)

(* Specifications: *)
Lemma erase_pi : forall G AB0 rho A B S, erase AB0 = (a_Pi rho A B) -> AnnTyping G AB0 S ->
exists A1 B0, erase AB0 = erase (a_Pi rho A1 B0) /\ erase A1 = A /\ erase B0 = B /\ AnnTyping G (a_Pi rho A1 B0) a_Star.
Lemma erase_cpi : forall AB0 A B G S,
erase AB0 = (a_CPi A B) -> AnnTyping G AB0 S ->
exists A1 B0, erase AB0 = erase (a_CPi A1 B0) /\ erase_constraint A1 = A /\ erase B0 = B
/\ AnnTyping G (a_CPi A1 B0) a_Star.
Lemma erase_app_Rel :
forall AB0 A B C G, erase AB0 = (a_App A Rel B) -> AnnTyping G AB0 C ->
exists A1 B0 g D, erase AB0 = erase (a_App A1 Rel B0) /\ erase A1 = A /\ erase B0 = B /\
AnnTyping G (a_App A1 Rel B0) D /\ AnnDefEq G (dom G) g C D.
Lemma erase_app_Irrel :
forall AB0 A C G, erase AB0 = (a_App A Irrel a_Bullet) -> AnnTyping G AB0 C ->
exists A1 B0 g D, erase AB0 = erase (a_App A1 Irrel B0) /\ erase A1 = A /\
AnnTyping G (a_App A1 Irrel B0) D /\ AnnDefEq G (dom G) g C D.