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 annotation_mutual :
(forall G a A, Typing G a A ->
forall G0, erase_context G0 = G -> AnnCtx G0 ->
exists a0 A0,
(erase a0) = a /\
(erase A0) = A /\
AnnTyping G0 a0 A0) /\
(forall G phi, PropWff G phi ->
forall G0, erase_context G0 = G -> AnnCtx G0 ->
exists phi0,
erase_constraint phi0 = phi /\
AnnPropWff G0 phi0) /\
(forall G D p1 p2, Iso G D p1 p2 ->
forall G0, erase_context G0 = G -> AnnCtx G0 ->
exists g0 p1' p2',
(erase_constraint p1') = p1 /\
(erase_constraint p2') = p2 /\
AnnIso G0 D g0 p1' p2') /\
(forall G D a b A, DefEq G D a b A ->
forall G0, erase_context G0 = G -> AnnCtx G0 ->
exists g a0 b0 A0,
(erase a0) = a /\
(erase b0) = b /\
(erase A0) = A /\
AnnDefEq G0 D g a0 b0 /\ AnnTyping G0 a0 A0 /\ AnnTyping G0 b0 A0) /\
(forall G, Ctx G -> True).