(* --------------------------------------------------------------------- *)
(* This is the place for "smart constructors" and "smart inversion" lemmas. They are especialy useful for constructing derivations from a particular variable and avoiding the co-finite quantification stuff.  *)
(* In a locally nameless development, these should be stated and immediately proven after substitution. *)

Lemma An_Abs_inversion :
∀ (G:context) rho (a:tm) A A1,
AnnTyping G (a_Abs rho A a) A1 ->
(exists B, A1 = a_Pi rho A B /\
AnnTyping G A a_Star /\
∀ x, x \notin dom G ->
RhoCheck rho x (erase_tm (open_tm_wrt_tm a (a_Var_f x))) /\
AnnTyping (( x ~ Tm  A) ++ G)
(open_tm_wrt_tm a (a_Var_f x))
(open_tm_wrt_tm B (a_Var_f x))).