Module congruence
(ext_weak : ext_weak_sig)
(wf : fc_wf_sig)
(weak : fc_weak_sig)
(subst : fc_subst_sig)
(ext_invert : ext_invert_sig).
Module unique := fc_unique wf subst.
Module invert := fc_invert wf weak subst.
Module erasem := erase wf weak subst ext_invert.
Set Bullet Behavior "Strict Subproofs".
Set Implicit Arguments.
(* ------------------------------------------------------------- *)

(* Specifications: *)
Lemma congruence :
(forall G a A, Typing G a A ->
forall G1 G2 x A1 a1 a2 D,
G = G2 ++ [(x, Tm A1)] ++ G1 ->
Typing G1 a1 A1 ->
DefEq G1 D a1 a2 A1 ->
DefEq (map (tm_subst_tm_sort a1 x) G2 ++ G1)
D (tm_subst_tm_tm a1 x a) (tm_subst_tm_tm a2 x a)
(tm_subst_tm_tm a1 x A)) /\
(forall G phi,     PropWff G phi       ->
forall G1 G2 x A1 a1 a2 D,
G = G2 ++ [(x, Tm A1)] ++ G1 ->
Typing G1 a1 A1 ->
DefEq G1 D a1 a2 A1 ->
Iso (map (tm_subst_tm_sort a1 x) G2 ++ G1)
D (tm_subst_tm_constraint a1 x phi) (tm_subst_tm_constraint a2 x phi) ) /\
(forall G D p1 p2, Iso G D p1 p2      -> True) /\
(forall G D A B T,   DefEq G D A B T  -> True) /\
(forall G,           Ctx G            -> True).
Lemma map_map : forall a1 x G2,
map erase_sort (map (tm_subst_tm_sort a1 x) G2) =
map (tm_subst_tm_sort (erase a1) x) (map erase_sort G2).
Lemma an_congruence :
forall G a A, AnnTyping G a A ->
forall G1 x A1 g a1 a2 D,
G = [(x, Tm A1)] ++ G1 ->
AnnTyping G1 a1 A1 ->
AnnTyping G1 a2 A1 ->
AnnDefEq G1 D g a1 a2 ->
exists g', AnnDefEq G1 D g'
(tm_subst_tm_tm a1 x a) (tm_subst_tm_tm a2 x a).