Require Export FcEtt.imports.
Require Export FcEtt.tactics.
Require Export FcEtt.ett_ott.
Require Export FcEtt.ett_inf.
Require Export FcEtt.ett_ind.
Require Export FcEtt.ett_par.
Require Export FcEtt.erase_syntax.
Module ext_consist (invert : ext_invert_sig)(fc_wf: fc_wf_sig).
Module red_one := ext_red_one invert.
Export red_one.
Module red := ext_red invert.
Export red.
Set Implicit Arguments.
Set Bullet Behavior "Strict Subproofs".
Definition Good (G : context) (D : available_props):=
erased_context G /\
forall c1 A B1 T1,
binds c1 (Co (Eq A B1 T1)) G
-> c1 `in` D
-> exists C, Par G D A C /\ Par G D B1 C.
(* ---------------------------------------- *)

(* Specifications: *)
Lemma open2 :
forall x b b' S D a a',
x `notin` fv_tm_tm_tm a' \u fv_tm_tm_tm a ->
erased_tm b ->
erased_tm (open_tm_wrt_tm a (a_Var_f x)) ->
Par S D (open_tm_wrt_tm a (a_Var_f x)) (open_tm_wrt_tm a' (a_Var_f x)) ->
Par S D b b' ->
Par S D (open_tm_wrt_tm a b) (open_tm_wrt_tm a' b').
Lemma a_Pi_head : forall S G b A rho B,
Par S G (a_Pi rho A B) b -> exists A' B' L,
b = a_Pi rho A' B' /\ Par S G A A' /\
(forall x, x `notin` L -> Par S G (open_tm_wrt_tm B (a_Var_f x)) (open_tm_wrt_tm B' (a_Var_f x))).
Lemma Par_Abs_inversion : forall G D a b rho,
Par G D (a_UAbs rho a) b ->
(exists a', b = (a_UAbs rho a') /\
forall x, x `notin` fv_tm_tm_tm a \u fv_tm_tm_tm a' ->
Par G D (open_tm_wrt_tm a (a_Var_f x)) (open_tm_wrt_tm a' (a_Var_f x)))
\/
(exists a', Par G D a' b /\ (forall x, x `notin`  fv_tm_tm_tm a ->
open_tm_wrt_tm a (a_Var_f x) = a_App a' rho (a_Var_f x)) /\ rho = Rel)
\/ (exists a', Par G D a' b /\ (forall x, x `notin`  fv_tm_tm_tm a ->
open_tm_wrt_tm a (a_Var_f x) = a_App a' rho a_Bullet) /\ rho = Irrel).
Lemma Par_Abs_inversion_Rel : forall G D a b,
Par G D (a_UAbs Rel a) b ->
(exists a', b = (a_UAbs Rel a') /\
forall x, x `notin` fv_tm_tm_tm a \u fv_tm_tm_tm a' ->
Par G D (open_tm_wrt_tm a (a_Var_f x)) (open_tm_wrt_tm a' (a_Var_f x)))
\/
(exists a', Par G D a' b /\ (forall x, x `notin`  fv_tm_tm_tm a ->
open_tm_wrt_tm a (a_Var_f x) = a_App a' Rel (a_Var_f x))).
Lemma Par_Abs_inversion_Irrel : forall G D a b,
Par G D (a_UAbs Irrel a) b ->
(exists a', b = (a_UAbs Irrel a') /\
forall x, x `notin` fv_tm_tm_tm a \u fv_tm_tm_tm a' ->
Par G D (open_tm_wrt_tm a (a_Var_f x)) (open_tm_wrt_tm a' (a_Var_f x)))
\/ (exists a', Par G D a' b /\ (forall x, x `notin`  fv_tm_tm_tm a ->
open_tm_wrt_tm a (a_Var_f x) = a_App a' Irrel a_Bullet)).