Definition Typing_weakening  := first  typing_weakening_mutual.
Definition PropWff_weakening := second typing_weakening_mutual.
Definition Iso_weakening     := third  typing_weakening_mutual.
Definition DefEq_weakening   := fourth typing_weakening_mutual.
End ext_weak_sig.
(**************** Ext Substitution ****************)
Module Type ext_subst_sig.
Include ext_weak_sig.

(* Specifications: *)
Axiom Ctx_strengthen : forall G1 G2, Ctx (G2 ++ G1) -> Ctx G1.
Axiom binds_to_PropWff: forall G0 A B T c,
Ctx G0 ->
binds c (Co (Eq A B T)) G0 -> PropWff G0 (Eq A B T).
Axiom tm_subst_tm_tm_dom_invariance: forall x a F,
dom F = dom (map (tm_subst_tm_sort a x) F).
Axiom tm_subst_fresh_1 :
forall G a A a0 x s,
Typing G a A -> Ctx ((x ~ s) ++ G) -> tm_subst_tm_tm a0 x A = A.
Axiom tm_subst_fresh_2 :
forall G a A a0 x s,
Typing G a A -> Ctx ((x ~ s) ++ G) -> tm_subst_tm_tm a0 x a = a.
Axiom tm_subst_co_fresh_1 :
forall G a A a0 c s,
Typing G a A -> Ctx ((c ~ s) ++ G) -> co_subst_co_tm a0 c A = A.
Axiom tm_substitution_mutual :  (forall G0 b B (H : Typing G0 b B),
forall G a A, Typing G a A ->
forall F x, G0 = (F ++ (x ~ Tm A) ++ G) ->
Typing (map (tm_subst_tm_sort a x) F ++ G)
(tm_subst_tm_tm a x b)
(tm_subst_tm_tm a x B)) /\
(forall G0 phi (H : PropWff G0 phi),
forall G a A, Typing G a A ->
forall F x, G0 = (F ++ (x ~ Tm A) ++ G) ->
PropWff (map (tm_subst_tm_sort a x) F ++ G)
(tm_subst_tm_constraint a x phi)) /\
(forall G0 D p1 p2 (H : Iso G0 D p1 p2),
forall G a A, Typing G a A ->
forall F x, G0 = (F ++ (x ~ Tm A) ++ G) ->
Iso (map (tm_subst_tm_sort a x) F ++ G) D
(tm_subst_tm_constraint a x p1)
(tm_subst_tm_constraint a x p2)) /\
(forall G0 D A B T (H : DefEq G0 D A B T),
forall G a A0, Typing G a A0 ->
forall F x, G0 = (F ++ (x ~ Tm A0) ++ G) ->
DefEq (map (tm_subst_tm_sort a x) F ++ G) D
(tm_subst_tm_tm a x A)
(tm_subst_tm_tm a x B) (tm_subst_tm_tm a x T)) /\
(forall G0 (H : Ctx G0),
forall G a A, Typing G a A ->
forall F x, G0 = (F ++ (x ~ Tm A) ++ G) ->
Ctx (map (tm_subst_tm_sort a x) F ++ G)).
Axiom Typing_tm_subst : forall G x A b B (H : Typing ((x ~ Tm A) ++ G) b B),
forall a, Typing G a A ->
Typing G (tm_subst_tm_tm a x b) (tm_subst_tm_tm a x B).
Axiom co_substitution_mutual :
(forall G0 b B (H : Typing G0 b B),
forall G D A1 A2 T F c ,
G0 = (F ++ (c ~ Co (Eq A1 A2 T) ) ++ G)
-> DefEq G D A1 A2 T
-> Typing (map (co_subst_co_sort g_Triv c) F ++ G) (co_subst_co_tm g_Triv c b) (co_subst_co_tm g_Triv c B)) /\
(forall G0 phi (H : PropWff G0 phi),
forall G D A1 A2 T F c,
G0 = (F ++ (c ~ Co (Eq A1 A2 T) ) ++ G)
-> DefEq G D A1 A2 T
-> PropWff (map (co_subst_co_sort g_Triv c) F ++ G) (co_subst_co_constraint g_Triv c phi)) /\
(forall G0 D0 p1 p2 (H : Iso G0 D0 p1 p2),
forall G D A1 A2 T F c,
G0 = (F ++ (c ~ Co (Eq A1 A2 T) ) ++ G)
-> DefEq G D A1 A2 T
-> Iso (map (co_subst_co_sort g_Triv c) F ++ G) (union D (remove c D0))
(co_subst_co_constraint g_Triv c p1)
(co_subst_co_constraint g_Triv c p2)) /\
(forall G0 D0 A B T (H : DefEq G0 D0 A B T),
forall G D F c A1 A2 T1,
G0 = (F ++ (c ~ Co (Eq A1 A2 T1) ) ++ G)
-> DefEq G D A1 A2 T1
-> DefEq (map (co_subst_co_sort g_Triv c) F ++ G) (union D (remove c D0))
(co_subst_co_tm g_Triv c A) (co_subst_co_tm g_Triv c B)
(co_subst_co_tm g_Triv c T)) /\
(forall G0 (H : Ctx G0),
forall G D F c A1 A2 T,
G0 = (F ++ (c ~ Co (Eq A1 A2 T) ) ++ G)
-> DefEq G D A1 A2 T
-> Ctx (map (co_subst_co_sort g_Triv c) F ++ G)).
Axiom Typing_co_subst:
forall G D c a1 a2 A b B (H : Typing (c ~ (Co (Eq a1 a2 A)) ++ G) b B),
DefEq G D a1 a2 A ->
Typing G (co_subst_co_tm g_Triv c b) (co_subst_co_tm g_Triv c B).
Axiom Typing_swap : forall x1 x G a A B,
x1 `notin` fv_tm_tm_tm a \u fv_tm_tm_tm B
-> x `notin` dom G \u {{ x1 }}
-> Typing ([(x1, Tm A)] ++ G) (open_tm_wrt_tm a (a_Var_f x1))
(open_tm_wrt_tm B (a_Var_f x1))
-> Typing ([(x, Tm A)] ++ G) (open_tm_wrt_tm a (a_Var_f x))
(open_tm_wrt_tm B (a_Var_f x)).
Axiom E_Pi_exists : forall x (G : context) (rho : relflag) (A B : tm),
x `notin` dom G \u fv_tm_tm_tm B
-> Typing ([(x, Tm A)] ++ G) (open_tm_wrt_tm B (a_Var_f x)) a_Star
-> Typing G A a_Star -> Typing G (a_Pi rho A B) a_Star.
Axiom E_Abs_exists :  forall x (G : context) (rho : relflag) (a A B : tm),
x `notin` fv_tm_tm_tm a \u fv_tm_tm_tm B
-> Typing ([(x, Tm A)] ++ G) (open_tm_wrt_tm a (a_Var_f x)) (open_tm_wrt_tm B (a_Var_f x))
-> Typing G A a_Star
-> RhoCheck rho x (open_tm_wrt_tm a (a_Var_f x))
-> Typing G (a_UAbs rho a) (a_Pi rho A B).