Module ext_weak (wf: ext_wf_sig).
Include wf.
Set Bullet Behavior "Strict Subproofs".
Set Implicit Arguments.
(* TODO: this tactic is not so "automated" (e.g. has to link a_Pi to E_Pi), but it is hard to make it more "searchy" without trying extensively all the lemmas. We could probably work something out, though *)
(* Ltac E_pick_fresh x := match goal with | [ |- Typing _ ?shape _ ] => let v := match shape with | a_Pi _ _ _ => E_Pi | a_UAbs _ _ => E_Abs | a_CPi _ _  => E_CPi | a_CAbs _ _ => E_CAbs | a_UCAbs _  => E_CAbs end in pick fresh x and apply v | [ |- DefEq _ _ ?shape _ _ ] => let v := match shape with | a_Pi _ _ _ => E_PiCong | a_UAbs _ _ => E_AbsCong | a_CPi _ _  => E_CPiCong | a_CAbs _ _ => E_CAbsCong | a_UCAbs _  => E_CAbsCong end in pick fresh x and apply v | [ |- Par _ _ ?shape _ ] => let v := match shape with | a_Pi _ _ _ => Par_Pi | a_UAbs _ _ => Par_Abs | a_CPi _ _  => Par_CPi | a_CAbs _ _ => Par_CAbs | a_UCAbs _  => Par_CAbs end in pick fresh x and apply v end. *)
(* ------------------------------------------------------------------- *)
(* Weakening Lemmas for the available set *)
Definition Iso_respects_atoms_eq   := third  respects_atoms_eq_mutual.
Definition DefEq_respects_atoms_eq := fourth respects_atoms_eq_mutual.
(* Instance Iso_atoms_eq_mor : Morphisms.Proper (eq ==> AtomSetImpl.Equal ==> eq ==> eq ==> iff) Iso.  Instance DefEq_atoms_eq_mor : Morphisms.Proper (eq ==> AtomSetImpl.Equal ==> eq ==> eq ==> eq ==> iff) DefEq.  *)
(* ----- *)
Ltac binds_cons :=
let H5 := fresh in
match goal with
[
H4 : (∃ phi : constraint, binds ?x (Co phi) ?G) → False
|- ((exists phi, binds ?x (Co phi) ([(?y, ?s)] ++ ?G)) -> False) ] =>
intro H5; destruct H5; apply H4; simpl in H5;
destruct (binds_cons_1 _ x y _ s G H5); split_hyp; subst;
try done; eauto
end.

Lemma DefEq_strengthen_available_tmvar :
forall G D g A B, DefEq G D g A B ->  forall x A', binds x (Tm A') G ->
forall D', D' [=] remove x D ->
DefEq G D' g A B.