Require Export FcEtt.tactics.
Require Export FcEtt.ett_inf.
Set Bullet Behavior "Strict Subproofs".
Set Implicit Arguments.
(* --------------------------------------------------------------------------- *)
(* --------------------------------------------------------------------------- *)
(* --------------------------------------------------------------------------- *)
Ltac solve_binds :=
match goal with
| [ b : binds ?v _ ?G
, H : forall v' _, binds v' _ ?G -> _ [<=] dom ?G ∧ _ [<=] dom ?G
|- _ ] =>
apply H in b; simpl in b; split_hyp; (done || fsetdec)
end.
(* Definition tm_context_fv_statement G a A (H: Typing G a A) :=  Definition PropWff_context_fv_statement G phi (H : PropWff G phi) := fv_tm_tm_constraint phi [<=] dom G. Definition  Iso_context_fv_statement G D p1 p2 (H : Iso G D p1 p2) := fv_tm_tm_constraint p1 [<=] dom G /\ fv_tm_tm_constraint p2 [<=] dom G. Definition DefEq_context_fv_statement G D A B T (H : DefEq G D A B T) := fv_tm_tm_tm A [<=] dom G /\ fv_tm_tm_tm B [<=] dom G. Definition Ctx_context_fv_statement G (H : Ctx G) := forall x A, binds x (Tm A) G -> fv_tm_tm_tm A [<=] dom G. *)
(* FIXME: ? *)
Hint Unfold AtomSetImpl.Subset.
Hint Resolve binds_In AtomSetImpl.singleton_1 in_singleton_subset.
(* *)

Theorem context_fv_mutual :
(forall G (a : tm) A (H: Typing G a A),
fv_tm_tm_tm a [<=] dom G /\ fv_co_co_tm a [<=] dom G /\
fv_tm_tm_tm A [<=] dom G /\ fv_co_co_tm A [<=] dom G)
/\
(forall G phi (H : PropWff G phi),
fv_tm_tm_constraint phi [<=] dom G /\ fv_co_co_constraint phi [<=] dom G)
/\
(forall G D p1 p2 (H : Iso G D p1 p2),
fv_tm_tm_constraint p1 [<=] dom G /\ fv_co_co_constraint p1 [<=] dom G /\
fv_tm_tm_constraint p2 [<=] dom G /\ fv_co_co_constraint p2 [<=] dom G)
/\
(forall G D A B T (H : DefEq G D A B T),
(fv_tm_tm_tm A [<=] dom G /\ fv_co_co_tm A [<=] dom G /\
fv_tm_tm_tm B [<=] dom G /\ fv_co_co_tm B [<=] dom G /\
fv_tm_tm_tm T [<=] dom G /\ fv_co_co_tm T [<=] dom G))
/\
(forall G (H : Ctx G),
(forall x A,
binds x (Tm A)   G ->
fv_tm_tm_tm         A   [<=] dom G /\ fv_co_co_tm         A   [<=] dom G) /\
(forall c phi,
binds c (Co phi) G ->
fv_tm_tm_constraint phi [<=] dom G /\ fv_co_co_constraint phi [<=] dom G)).