Module unique := fc_unique wf subst.
Set Implicit Arguments.
Set Bullet Behavior "Strict Subproofs".
Hint Constructors Typing PropWff Iso DefEq Ctx.
Ltac dispatch_rho  :=
match goal with
|  H11 : ∀ x : atom,
¬ x `in` ?L0 →
RhoCheck ?rho x (erase_tm (open_tm_wrt_tm ?b1 (a_Var_f x)))
|-
∀ x : atom,
¬ x `in` ?LL → RhoCheck ?rho x (open_tm_wrt_tm (erase_tm ?b1) (a_Var_f x))
=>
let Fr := fresh in
let r' := fresh in
intros x; intros;
assert (FrL0 : x `notin` L0); eauto;
move: (H11 x FrL0) => r';
autorewcshyp r';
rewrite -open_tm_erase_tm in r'; eapply r'
end.
(* ------------------------------------------ *)
Definition AnnTyping_erase :
(forall G a A, AnnTyping G a A ->
Typing (erase_context G) (erase a) (erase A)) := first erase_mutual.
Definition AnnPropWff_erase :
(forall G phi, AnnPropWff G phi ->
PropWff (erase_context G) (erase phi)) := second erase_mutual.
Definition AnnIso_erase :
(forall G D g p1 p2, AnnIso G D g p1 p2 ->
Iso (erase_context G) D
(erase_constraint p1) (erase_constraint p2)) := third erase_mutual.
Definition AnnDefEq_erase :
(forall G D g a b,
AnnDefEq G D g a b ->
forall A, AnnTyping G a A ->
DefEq (erase_context G) D (erase a) (erase b) (erase A)) := fourth erase_mutual.
Definition AnnCtx_erase :
(forall G, AnnCtx G -> Ctx (erase_context G) /\
forall c t, binds c t G -> binds c (erase_sort t) (erase_context G)) := fifth erase_mutual.

Lemma AnnDefEq_invertb : forall G D g a b, AnnDefEq G D g a b ->
exists A b' g, AnnTyping G a A /\ AnnTyping G b' A /\ erase b' = erase b /\ AnnDefEq G D g b b'.