let graph = Hashtbl.create 503
+let rec purge dname bdeps = match bdeps with
+ | [] -> bdeps
+ | hd :: tl -> if hd = dname then bdeps else purge dname tl
+
let add fname =
if Hashtbl.mem graph fname then () else
Hashtbl.add graph fname {ddeps = []; rdeps = None}
let init fname dname =
add fname; add dname; add_ddep fname dname
-let rec compute fname file = match file.rdeps with
+let rec compute bdeps fname file = match file.rdeps with
| Some rdeps -> rdeps
| None ->
- let rdeps = List.fold_left (iter fname) StringSet.empty file.ddeps in
+ let bdeps = fname :: bdeps in
+ let rdeps = List.fold_left (iter fname bdeps) StringSet.empty file.ddeps in
Hashtbl.replace graph fname {file with rdeps = Some rdeps};
rdeps
-and iter fname rdeps dname =
- if StringSet.mem dname rdeps then
- begin Printf.printf "%s: redundant %s\n" fname dname; rdeps end
- else
+and iter fname bdeps rdeps dname =
+ if StringSet.mem dname rdeps then begin
+ Printf.printf "%s: redundant %s\n" fname dname;
+ rdeps
+ end else if List.mem dname bdeps then begin
+ let loop = purge dname (List.rev bdeps) in
+ Printf.printf "circular: %s\n" (String.concat " " loop);
+ StringSet.add dname rdeps
+ end else
let file = Hashtbl.find graph dname in
- StringSet.add dname (StringSet.union (compute dname file) rdeps)
+ StringSet.add dname (StringSet.union (compute bdeps dname file) rdeps)
let check () =
- let iter fname file =
- if StringSet.mem fname (compute fname file) then
- Printf.printf "%s: circular\n" fname
- in
+ let iter fname file = ignore (compute [] fname file) in
Hashtbl.iter iter graph
let rec read ich =
(* Advanced properties ******************************************************)
-lemma cprs_abst_dx: ∀L,V1,V2. L ⊢ V1 ➡ V2 → ∀V,T1,T2.
- L.ⓛV ⊢ T1 ➡* T2 → ∀a. L ⊢ ⓛ{a}V1. T1 ➡* ⓛ{a}V2. T2.
+lemma cprs_abst_dx: ∀L,V1,V2. L ⊢ V1 ➡ V2 → ∀V,T1,T2. L.ⓛV ⊢ T1 ➡* T2 →
+ ∀a,I. L ⊢ ⓑ{a,I}V1. T1 ➡* ⓑ{a,I}V2. T2.
#L #V1 #V2 #HV12 #V #T1 #T2 #HT12 #a @(cprs_ind … HT12) -T2
[ /3 width=2/
| /3 width=6 by cprs_strap1, cpr_abst/ (**) (* /3 width=6/ is too slow *)
@(cprs_trans … IHV1) -IHV1 /2 width=1/
qed.
-lemma cprs_abst: ∀L,V1,V2. L ⊢ V1 ➡* V2 → ∀V,T1,T2.
- L.ⓛV ⊢ T1 ➡* T2 → ∀a. L ⊢ ⓛ{a}V1. T1 ➡* ⓛ{a}V2. T2.
-#L #V1 #V2 #HV12 #V #T1 #T2 #HT12 #a @(cprs_ind … HV12) -V2
+lemma cprs_abst: ∀L,V1,V2. L ⊢ V1 ➡* V2 → ∀V,T1,T2. L.ⓛV ⊢ T1 ➡* T2 →
+ ∀a,I. L ⊢ ⓑ{a,I}V1. T1 ➡* ⓑ{a,I}V2. T2.
+#L #V1 #V2 #HV12 #V #T1 #T2 #HT12 #a #I @(cprs_ind … HV12) -V2
[ lapply (cprs_lsubs_trans … HT12 (L.ⓛV1) ?) -HT12 /2 width=2/
| #V0 #V2 #_ #HV02 #IHV01
@(cprs_trans … IHV01) -V1 /2 width=2/
@(cprs_trans … IHV1) -IHV1 /2 width=1/
qed.
+lemma cprs_bind1: ∀I,L,V1,T1,T2. L. ⓑ{I}V1 ⊢ T1 ➡* T2 → ∀V2. L ⊢ V1 ➡* V2 →
+ ∀a. L ⊢ ⓑ{a,I}V1. T1 ➡* ⓑ{a,I}V2. T2.
+* /2 width=1/ /2 width=2/
+qed.
+
lemma cprs_abbr2_dx: ∀L,V1,V2. L ⊢ V1 ➡ V2 → ∀T1,T2. L. ⓓV2 ⊢ T1 ➡* T2 →
∀a. L ⊢ ⓓ{a}V1. T1 ➡* ⓓ{a}V2. T2.
#L #V1 #V2 #HV12 #T1 #T2 #HT12 #a @(cprs_ind_dx … HT12) -T1
@(cprs_trans … HV1) -HV1 /2 width=1/
qed.
+lemma cprs_bind2: ∀L,V1,V2. L ⊢ V1 ➡* V2 → ∀I,T1,T2. L. ⓑ{I}V2 ⊢ T1 ➡* T2 →
+ ∀a. L ⊢ ⓑ{a,I}V1. T1 ➡* ⓑ{a,I}V2. T2.
+#L #V1 #V2 #HV12 * /2 width=1/ /2 width=2/
+qed.
+
lemma cprs_beta_dx: ∀L,V1,V2,W,T1,T2.
L ⊢ V1 ➡ V2 → L.ⓛW ⊢ T1 ➡* T2 →
∀a.L ⊢ ⓐV1.ⓛ{a}W.T1 ➡* ⓓ{a}V2.T2.
]
qed.
+lemma ltpr_cprs_trans: ∀L1,L2. L1 ➡ L2 →
+ ∀T1,T2. L2 ⊢ T1 ➡* T2 → L1 ⊢ T1 ➡* T2.
+#L1 #L2 #HL12 #T1 #T2 #H @(cprs_ind … H) -T2 //
+#T #T2 #_ #HT2 #IHT2
+@(cprs_trans … IHT2) /2 width=3/
+qed.
+
(* Basic_1: was only: pr3_pr2_pr3_t pr3_wcpr0_t *)
lemma lcpr_cprs_trans: ∀L1,L2. ⦃L1⦄ ➡ ⦃L2⦄ →
∀T1,T2. L2 ⊢ T1 ➡* T2 → L1 ⊢ T1 ➡* T2.
(* Advanced properties ******************************************************)
lemma dxprs_cprs_trans: ∀h,g,L,T1,T,T2.
- ⦃h, L⦄ ⊢ T1 •*➡*[g] T → L ⊢ T ➡* T2 → ⦃h, L⦄ ⊢ T1 •*➡*[g] T2.
+ ⦃h, L⦄ ⊢ T1 •*➡*[g] T → L ⊢ T ➡* T2 → ⦃h, L⦄ ⊢ T1 •*➡*[g] T2.
#h #g #L #T1 #T #T2 * #T0 #HT10 #HT0 #HT2
lapply (cprs_trans … HT0 … HT2) -T /2 width=3/
qed-.
∃∃U,l. ⦃h, L⦄ ⊩ W :[g] & ⦃h, L⦄ ⊩ T :[g] &
⦃h, L⦄ ⊢ T •[g, l + 1] U & L ⊢ U ⬌* W.
/2 width=3/ qed-.
+
+(* Basic forward lemmas *****************************************************)
+
+lemma snv_fwd_ssta: ∀h,g,L,T. ⦃h, L⦄ ⊩ T :[g] → ∃∃U,l. ⦃h, L⦄ ⊢ T •[g, l] U.
+#h #g #L #T #H elim H -L -T
+[ #L #k elim (deg_total h g k) /3 width=3/
+| * #L #K #V #i #HLK #_ * #W #l0 #HVW
+ [ elim (lift_total W 0 (i+1)) /3 width=8/
+ | elim (lift_total V 0 (i+1)) /3 width=8/
+ ]
+| #a #I #L #V #T #_ #_ #_ * /3 width=3/
+| #a #L #V #W #W1 #T0 #T1 #l #_ #_ #_ #_ #_ #_ * /3 width=3/
+| #L #W #T #U #l #_ #_ #HTU #_ #_ #_ /3 width=3/ (**) (* auto fails without the last #_ *)
+]
+qed-.
(* STRATIFIED NATIVE VALIDITY FOR TERMS *************************************)
-(* Properties on atomic arity assignment for terms **************************)
+(* Forward lemmas on atomic arity assignment for terms **********************)
-lemma snv_aaa: ∀h,g,L,T. ⦃h, L⦄ ⊩ T :[g] → ∃A. L ⊢ T ⁝ A.
+lemma snv_fwd_aaa: ∀h,g,L,T. ⦃h, L⦄ ⊩ T :[g] → ∃A. L ⊢ T ⁝ A.
#h #g #L #T #H elim H -L -T
[ /2 width=2/
| #I #L #K #V #i #HLK #_ * /3 width=6/
]
qed-.
-lemma snv_csn: ∀h,g,L,T. ⦃h, L⦄ ⊩ T :[g] → L ⊢ ⬊* T.
-#h #g #L #T #H elim (snv_aaa … H) -H /2 width=2/
+lemma snv_fwd_csn: ∀h,g,L,T. ⦃h, L⦄ ⊩ T :[g] → L ⊢ ⬊* T.
+#h #g #L #T #H elim (snv_fwd_aaa … H) -H /2 width=2/
qed-.
include "basic_2/static/ssta_ssta.ma".
include "basic_2/computation/ygt.ma".
-include "basic_2/equivalence/fpcs_cpcs.ma".
include "basic_2/dynamic/snv_ltpss_dx.ma".
+include "basic_2/dynamic/snv_sstas.ma".
(* STRATIFIED NATIVE VALIDITY FOR TERMS *************************************)
(* Inductive premises for the preservation results **************************)
(*
-definition IH_ssta_cprs: ∀h:sh. sd h → relation2 lenv term ≝
- λh,g,L1,T1. ⦃h, L1⦄ ⊩ T1 :[g] →
- ∀U1,l. ⦃h, L1⦄ ⊢ T1 •[g, l] U1 →
- ∀L2. L1 ➡ L2 → ∀T2. L2 ⊢ T1 ➡* T2 →
- ∃∃U2. ⦃h, L2⦄ ⊢ T2 •[g, l] U2 & ⦃L1, U1⦄ ⬌* ⦃L2, U2⦄.
-
definition IH_snv_dxprs: ∀h:sh. sd h → relation2 lenv term ≝
λh,g,L1,T1. ⦃h, L1⦄ ⊩ T1 :[g] →
∀L2. L1 ➡ L2 → ∀T2. ⦃h, L2⦄ ⊢ T1 •*➡*[g] T2 → ⦃h, L2⦄ ⊩ T2 :[g].
-
-fact ssta_cpcs_aux: ∀h,g,L,T1,T2. IH_ssta_cprs h g L T1 → IH_ssta_cprs h g L T2 →
- ⦃h, L⦄ ⊩ T1 :[g] → ⦃h, L⦄ ⊩ T2 :[g] →
- ∀U1,l1. ⦃h, L⦄ ⊢ T1 •[g, l1] U1 →
- ∀U2,l2. ⦃h, L⦄ ⊢ T2 •[g, l2] U2 →
- L ⊢ T1 ⬌* T2 →
- l1 = l2 ∧ L ⊢ U1 ⬌* U2.
-#h #g #L #T1 #T2 #IH1 #IH2 #HT1 #HT2 #U1 #l1 #HTU1 #U2 #l2 #HTU2 #H
-elim (cpcs_inv_cprs … H) -H #T #H1 #H2
-elim (IH1 … HT1 … HTU1 … H1) -T1 // #W1 #H1 #HUW1
-elim (IH2 … HT2 … HTU2 … H2) -T2 // #W2 #H2 #HUW2
-elim (ssta_mono … H1 … H2) -T #H1 #H2 destruct
-lapply (fpcs_canc_dx … HUW1 … HUW2) -W2 #HU12
-lapply (fpcs_inv_cpcs … HU12) -HU12 /2 width=1/
-qed-.
*)
definition IH_ssta_ltpr_tpr: ∀h:sh. sd h → relation2 lenv term ≝
λh,g,L1,T1. ⦃h, L1⦄ ⊩ T1 :[g] →
∀U1,l. ⦃h, L1⦄ ⊢ T1 •[g, l] U1 →
∀L2. L1 ➡ L2 → ∀T2. T1 ➡ T2 →
- ∃∃U2. ⦃h, L2⦄ ⊢ T2 •[g, l] U2 & ⦃L1, U1⦄ ⬌* ⦃L2, U2⦄.
+ ∃∃U2. ⦃h, L2⦄ ⊢ T2 •[g, l] U2 & L1 ⊢ U1 ⬌* U2.
definition IH_snv_ltpr_tpr: ∀h:sh. sd h → relation2 lenv term ≝
λh,g,L1,T1. ⦃h, L1⦄ ⊩ T1 :[g] →
⦃h, L1⦄ ⊩ T1 :[g] →
∀U1,l. ⦃h, L1⦄ ⊢ T1 •[g, l] U1 →
∀L2. L1 ➡ L2 → ∀T2. L2 ⊢ T1 ➡ T2 →
- ∃∃U2. ⦃h, L2⦄ ⊢ T2 •[g, l] U2 & ⦃L1, U1⦄ ⬌* ⦃L2, U2⦄.
+ ∃∃U2. ⦃h, L2⦄ ⊢ T2 •[g, l] U2 & L1 ⊢ U1 ⬌* U2.
#h #g #L1 #T1 #IH #HT1 #U1 #l #HTU1 #L2 #HL12 #T2 * #T #HT1T #HTT2
-elim (IH … HTU1 … HL12 … HT1T) // -HL12 -T1 #U #HTU #HU1
+elim (IH … HTU1 … HL12 … HT1T) // -T1 #U #HTU #HU1
elim (ssta_tpss_conf … HTU … HTT2) -T #U2 #HTU2 #HU2
-lapply (fpcs_fpr_strap1 … HU1 L2 U2 ?) -HU1 /2 width=3/ /3 width=3/
+lapply (ltpr_cpr_trans … HL12 U U2 ?) -HL12 /2 width=3/ -HU2 #HU2
+lapply (cpcs_cprs_strap1 … HU1 … HU2) -U /2 width=3/
qed-.
fact snv_ltpr_cpr_aux: ∀h,g,L1,T1. IH_snv_ltpr_tpr h g L1 T1 →
[2: /3 width=7 by snv_cprs_aux, ygt_cprs_trans/
|3: /3 width=3 by ygt_cprs_trans/
] -L0 -T0 -T1 -T #U2 #HTU2 #HU2
-lapply (fpcs_inv_cpcs … HU2) -HU2 #HU2
lapply (cpcs_trans … HU1 … HU2) -U /2 width=3/
qed-.
elim (ssta_mono … H1 … H2) -h -T #H1 #H2 destruct
lapply (cpcs_canc_dx … HUW1 … HUW2) -W2 /2 width=1/
qed-.
+
+fact snv_sstas_aux: ∀h,g,L0,T0.
+ (∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_snv_ssta h g L1 T1) →
+ ∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → ⦃h, L1⦄ ⊩ T1 :[g] →
+ ∀U1. ⦃h, L1⦄ ⊢ T1 •*[g] U1 → ⦃h, L1⦄ ⊩ U1 :[g].
+#h #g #L0 #T0 #IH #L1 #T1 #HLT0 #HT1 #U1 #H
+@(sstas_ind … H) -U1 // -HT1 /3 width=5 by ygt_sstas_trans/
+qed-.
+
+fact sstas_cprs_aux: ∀h,g,L0,T0.
+ (∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_snv_ssta h g L1 T1) →
+ (∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_snv_ltpr_tpr h g L1 T1) →
+ (∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_ssta_ltpr_tpr h g L1 T1) →
+ ∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → ⦃h, L1⦄ ⊩ T1 :[g] →
+ ∀T2. L1 ⊢ T1 ➡* T2 → ∀U1. ⦃h, L1⦄ ⊢ T1 •*[g] U1 →
+ ∃∃U2. ⦃h, L1⦄ ⊢ T2 •*[g] U2 & L1 ⊢ U1 ⬌* U2.
+#h #g #L0 #T0 #IH3 #IH2 #IH1 #L1 #T1 #H01 #HT1 #T2 #HT12 #U1 #H
+@(sstas_ind … H) -U1 [ /3 width=3/ ]
+#U1 #W1 #l1 #HTU1 #HUW1 * #U2 #HTU2 #HU12
+lapply (snv_cprs_aux … IH2 … HT1 … HT12) // #HT2
+elim (snv_sstas_fwd_correct … HTU2) // #W2 #l2 #HUW2
+elim (ssta_cpcs_aux … IH2 IH1 … HUW1 … HUW2 … HU12) -IH2 -IH1 -HUW1 -HU12
+[2,3: /3 width=7 by snv_sstas_aux, ygt_cprs_trans/
+|4,5: /3 width=3 by ygt_sstas_trans, ygt_cprs_trans/
+] -L0 -T0 -T1 -HT2 #H #HW12 destruct /3 width=4/
+qed-.
+
+fact dxprs_cprs_aux: ∀h,g,L0,T0.
+ (∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_snv_ssta h g L1 T1) →
+ (∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_snv_ltpr_tpr h g L1 T1) →
+ (∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_ssta_ltpr_tpr h g L1 T1) →
+ ∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → ⦃h, L1⦄ ⊩ T1 :[g] →
+ ∀T2. L1 ⊢ T1 ➡* T2 → ∀U1. ⦃h, L1⦄ ⊢ T1 •*➡*[g] U1 →
+ ∃∃U2. ⦃h, L1⦄ ⊢ T2 •*➡*[g] U2 & L1 ⊢ U1 ➡* U2.
+#h #g #L0 #T0 #IH3 #IH2 #IH1 #L1 #T1 #H01 #HT1 #T2 #HT12 #U1 * #W1 #HTW1 #HWU1
+elim (sstas_cprs_aux … IH3 IH2 IH1 … H01 … HT12 … HTW1) // -L0 -T0 -T1 #W2 #HTW2 #HW12
+lapply (cpcs_cprs_conf … HWU1 … HW12) -W1 #H
+elim (cpcs_inv_cprs … H) -H /3 width=3/
+qed-.
+
+fact sstas_ltpr_aux: ∀h,g,L0,T0.
+ (∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_snv_ssta h g L1 T1) →
+ (∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_ssta_ltpr_tpr h g L1 T1) →
+ ∀L1,T. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T⦄ → ⦃h, L1⦄ ⊩ T :[g] →
+ ∀L2. L1 ➡ L2 → ∀U1. ⦃h, L1⦄ ⊢ T •*[g] U1 →
+ ∃∃U2. ⦃h, L2⦄ ⊢ T •*[g] U2 & L1 ⊢ U1 ⬌* U2.
+#h #g #L0 #T0 #IH2 #IH1 #L1 #T #H01 #HT #L2 #HL12 #U1 #H
+@(sstas_ind … H) -U1 [ /4 width=3/ ]
+#W1 #U1 #l1 #HTW1 #HWU1 * #W2 #HTW2 #HW12
+lapply (snv_sstas_aux … IH2 … HTW1) // -IH2 -HT #HW1
+
+(*
+elim (IH1 … HWU1 … HL12 W1) // -IH1 -HW1 -HWU1 -HL12
+[2: /2 width=3 by ygt_sstas_trans/ ] #U2
+*)
+(*
+fact sstas_dxprs_aux: ∀h,g,L0,T0.
+ (∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_snv_ssta h g L1 T1) →
+ (∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_snv_ltpr_tpr h g L1 T1) →
+ (∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_ssta_ltpr_tpr h g L1 T1) →
+ ∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → ⦃h, L1⦄ ⊩ T1 :[g] →
+ ∀U1. ⦃h, L1⦄ ⊢ T1 •*[g] U1 → ∀T2. ⦃h, L1⦄ ⊢ T1 •*➡*[g] T2 →
+ ∃∃U2. ⦃h, L1⦄ ⊢ T2 •*[g] U2 & L1 ⊢ U1 ⬌* U2.
+#h #g #L0 #T0 #IH3 #IH2 #IH1 #L1 #T1 #H01 #HT1 #U1 #HTU1 #T2 * #T #HT1T #HTT2
+*)
\ No newline at end of file
(* *)
(**************************************************************************)
-include "basic_2/dynamic/snv_ltpr_ssta.ma".
+include "basic_2/dynamic/snv_cpcs.ma".
(* STRATIFIED NATIVE VALIDITY FOR TERMS *************************************)
fact snv_ltpr_tpr_aux: ∀h,g,L0,T0.
(∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_ssta_ltpr_tpr h g L1 T1) →
+ (∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_snv_ssta h g L1 T1) →
(∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_snv_ltpr_tpr h g L1 T1) →
∀L1,T1. L0 = L1 → T0 = T1 → IH_snv_ltpr_tpr h g L1 T1.
-#h #g #L0 #T0 #IH2 #IH1 #L1 * * [||||*]
-[ #k #HL0 #HT0 #H1 #L2 #_ #X #H2 destruct -IH2 -IH1 -L1
+#h #g #L0 #T0 #IH3 #IH2 #IH1 #L1 * * [||||*]
+[ #k #HL0 #HT0 #H1 #L2 #_ #X #H2 destruct -IH3 -IH2 -IH1 -L1
>(tpr_inv_atom1 … H2) -X //
-| #i #HL0 #HT0 #H1 #L2 #HL12 #X #H2 destruct -IH2
+| #i #HL0 #HT0 #H1 #L2 #HL12 #X #H2 destruct -IH3 -IH2
elim (snv_inv_lref … H1) -H1 #I #K1 #V1 #HLK1 #HV1
>(tpr_inv_atom1 … H2) -X
elim (ltpr_ldrop_conf … HLK1 … HL12) -HL12 #X #H #HLK2
elim (ltpr_inv_pair1 … H) -H #K2 #V2 #HK12 #HV12 #H destruct
lapply (ldrop_pair2_fwd_fw … HLK1 (#i)) -HLK1 #HLK1
lapply (IH1 … HK12 … HV12) -IH1 -HV12 -HK12 // -HV1 [ /2 width=1/ ] -HLK1 /2 width=5/
-| #p #HL0 #HT0 #H1 #L2 #HL12 #X #H2 destruct -IH2 -IH1
+| #p #HL0 #HT0 #H1 #L2 #HL12 #X #H2 destruct -IH3 -IH2 -IH1
elim (snv_inv_gref … H1)
-| #a #I #V1 #T1 #HL0 #HT0 #H1 #L2 #HL12 #X #H2 destruct -IH2
+| #a #I #V1 #T1 #HL0 #HT0 #H1 #L2 #HL12 #X #H2 destruct -IH3 -IH2
elim (snv_inv_bind … H1) -H1 #HV1 #HT1
elim (tpr_inv_bind1 … H2) -H2 *
[ #V2 #T0 #T2 #HV12 #HT10 #HT02 #H destruct
[ #V2 #T2 #HV12 #HT12 #H destruct
lapply (IH1 … HV1 … HL12 … HV12) [ /2 width=1/ ] #HV2
lapply (IH1 … HT1 … HL12 … HT12) [ /2 width=1/ ] #HT2
- elim (IH2 … HVW1 … HL12 … HV12) -IH2 -HVW1 -HV12 // -HV1 [2: /2 width=1/ ] #W2 #HVW2 #HW12
- lapply (fpcs_canc_sn L1 L1 … W10 W1 … HW12) -HW12 /3 width=1/ -W10 #HW12
+ elim (IH3 … HVW1 … HL12 … HV12) -HVW1 -HV12 // -HV1 [2: /2 width=1/ ] #W2 #HVW2 #HW12
+ lapply (cpcs_cprs_conf … HW10 … HW12) -W10 #HW12
+ elim (dxprs_cprs_aux … IH2 IH1 IH3 … T2 … HTU1) // [2: /3 width=1/ |3: /2 width=1/ ] -IH2 -IH1 -IH3 -HT1 -HT12 -HTU1 #U2 #HTU2 #HU12
@(snv_appl … HV2 HT2 HVW2)
(*
lapply (IH1 … HT1 … HTU1) -IH1 // #H
+++ /dev/null
-(**************************************************************************)
-(* ___ *)
-(* ||M|| *)
-(* ||A|| A project by Andrea Asperti *)
-(* ||T|| *)
-(* ||I|| Developers: *)
-(* ||T|| The HELM team. *)
-(* ||A|| http://helm.cs.unibo.it *)
-(* \ / *)
-(* \ / This file is distributed under the terms of the *)
-(* v GNU General Public License Version 2 *)
-(* *)
-(**************************************************************************)
-
-include "basic_2/static/ssta_ltpss_sn.ma".
-include "basic_2/equivalence/lsubse_ssta.ma".
-include "basic_2/equivalence/lfpcs_fpcs.ma".
-include "basic_2/dynamic/snv_ssta.ma".
-include "basic_2/dynamic/snv_cpcs.ma".
-
-(* STRATIFIED NATIVE VALIDITY FOR TERMS *************************************)
-
-(* Properties on context-free parallel reduction for local environments *****)
-
-fact ssta_ltpr_tpr_aux: ∀h,g,L0,T0.
- (∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_snv_ssta h g L1 T1) →
- (∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_snv_ltpr_tpr h g L1 T1) →
- (∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_ssta_ltpr_tpr h g L1 T1) →
- ∀L1,T1. L0 = L1 → T0 = T1 → IH_ssta_ltpr_tpr h g L1 T1.
-#h #g #L0 #T0 #IH3 #IH2 #IH1 #L1 * * [|||| *]
-[ #k #_ #_ #_ #X2 #l #H2 #L2 #HL12 #X3 #H3 -IH3 -IH2 -IH1
- elim (ssta_inv_sort1 … H2) -H2 #Hkl #H destruct
- >(tpr_inv_atom1 … H3) -X3 /4 width=6/
-| #i #HL0 #HT0 #H1 #X2 #l #H2 #L2 #HL12 #X3 #H3 destruct -IH3 -IH2
- elim (snv_inv_lref … H1) -H1 #I0 #K0 #V0 #H #HV1
- elim (ssta_inv_lref1 … H2) -H2 * #K1
- >(tpr_inv_atom1 … H3) -X3
- [ #V1 #W1 #HLK1 #HVW1 #HWU1
- lapply (ldrop_mono … H … HLK1) -H #H destruct
- lapply (ldrop_pair2_fwd_fw … HLK1 (#i)) #HKV1
- elim (ltpr_ldrop_conf … HLK1 … HL12) #X #H #HLK2
- elim (ltpr_inv_pair1 … H) -H #K2 #V2 #HK12 #HV12 #H destruct
- elim (IH1 … HVW1 … HK12 … HV12) -IH1 -HVW1 -HV12 // [2: /2 width=1/ ] -HV1 -HKV1 #W2 #HVW2 #HW12
- lapply (ldrop_fwd_ldrop2 … HLK1) -V1 #H1
- lapply (ldrop_fwd_ldrop2 … HLK2) #H2
- elim (lift_total W2 0 (i+1)) #U2 #HWU2
- lapply (fpcs_lift … HW12 … H1 H2 … HWU1 … HWU2) -H1 -H2 -W1 [ /3 width=1/ ] /3 width=6/
- | #V1 #W1 #l0 #HLK1 #HVW1 #HVU1 #H destruct
- lapply (ldrop_mono … H … HLK1) -H #H destruct
- lapply (ldrop_pair2_fwd_fw … HLK1 (#i)) #HKV1
- elim (ltpr_ldrop_conf … HLK1 … HL12) -HLK1 #X #H #HLK2
- elim (ltpr_inv_pair1 … H) -H #K2 #V2 #HK12 #HV12 #H destruct
- elim (IH1 … HVW1 … HK12 … HV12) -IH1 -HVW1 -HK12 // [2: /2 width=1/ ] -HV1 -HKV1 #W2 #HVW2 #_ -W1
- elim (lift_total V2 0 (i+1)) #U2 #HVU2
- lapply (tpr_lift … HV12 … HVU1 … HVU2) -V1 /4 width=6/
- ]
-| #p #_ #HT0 #H1 destruct -IH3 -IH2 -IH1
- elim (snv_inv_gref … H1)
-| #a #I #V1 #T1 #HL0 #HT0 #H1 #X2 #l #H2 #L2 #HL12 #X3 #H3 destruct -IH3 -IH2
- elim (snv_inv_bind … H1) -H1 #_ #HT1
- elim (ssta_inv_bind1 … H2) -H2 #U1 #HTU1 #H destruct
- elim (tpr_inv_bind1 … H3) -H3 *
- [ #V2 #T0 #T2 #HV12 #HT10 #HT02 #H destruct
- lapply (tps_lsubs_trans … HT02 (L2.ⓑ{I}V2) ?) -HT02 [ /2 width=1/ ] #HT02
- elim (ssta_ltpr_cpr_aux … HT1 … HTU1 (L2.ⓑ{I}V2) … T2) -HT1 -HTU1
- [2: /3 width=5 by cpr_intro, tps_tpss/ |3: /2 width=1/ |4: /3 width=1/ ] -IH1 -T0 -HL12 -HV12 #U2 #HTU2 #HU12
- lapply (fpcs_fwd_shift … HU12 a) -HU12 /3 width=3/
- | #T2 #HT12 #HT2 #H1 #H2 destruct
- elim (IH1 … HTU1 (L2.ⓓV1) … T2) -IH1 -HTU1 // [2,3: /2 width=1/ ] -T1 -HL12 #U2 #HTU2 #HU12
- lapply (fpcs_fwd_shift … HU12 true) -HU12 #HU12
- elim (ssta_inv_lift1 … HTU2 … HT2) -T2 [3: /2 width=1/ |2: skip ] #U #HXU #HU2
- lapply (fpcs_fpr_strap1 … HU12 L2 U ?) -HU12 [ /3 width=3/ ] -U2 /2 width=3/
- ]
-| #V1 #T1 #HL0 #HT0 #H1 #X2 #l #H2 #L2 #HL12 #X3 #H3 destruct
- elim (snv_inv_appl … H1) -H1 #a #W1 #W10 #U10 #l0 #HV1 #HT1 #HVW1 #HW10 #HTU10
- elim (ssta_inv_appl1 … H2) -H2 #U1 #HTU1 #H destruct
- elim (tpr_inv_appl1 … H3) -H3 *
- [ #V2 #T2 #HV12 #HT12 #H destruct -a -l0 -W1 -W10 -U10 -HV1 -IH3 -IH2
- elim (IH1 … HTU1 … HL12 … HT12) -IH1 -HTU1 -HL12 // [2: /2 width=1/ ] -T1 /3 width=5/
- | #b #V2 #W #T2 #T20 #HV12 #HT20 #H1 #H2 destruct
- elim (snv_inv_bind … HT1) -HT1 #HW #HT2
- elim (ssta_inv_bind1 … HTU1) -HTU1 #U2 #HTU2 #H destruct
- elim (dxprs_inv_abst1 … HTU10) -HTU10 #W0 #U0 #HW0 #_ #H destruct
- lapply (cprs_div … HW10 … HW0) -W0 #HW1W
- elim (ssta_fwd_correct … HVW1) <minus_plus_m_m #X1 #HWX1
- elim (snv_ssta … HW) #V #l1 #HWV
- lapply (IH3 … HVW1) -IH3 // [ /2 width=1/ ] #HW1
- elim (ssta_cpcs_aux … IH2 IH1 … HWX1 … HWV …) -IH2 -HWX1 //
- [2: /2 width=1/ |3: /4 width=4 by fw_ygt, ysc_ssta, bi_step/ ] #H #_ destruct -X1
- elim (IH1 … HVW1 … HL12 … HV12) -HVW1 // -HV1 [2: /2 width=1/ ] #W2 #HVW2 #HW12
- elim (IH1 … HWV … HL12 W) -HWV // -HW [2: /2 width=1/ ] #V0 #HWV0 #_
- elim (IH1 … HTU2 (L2.ⓛW) … HT20) -IH1 -HTU2 -HT20 // [2,3: /2 width=1/ ] -HT2 #U20 #HTU20 #HU20
- lapply (lfpr_inv_fpr L1 L2 … W) [ /2 width=1/ ] -HL12 #HL12
- elim (lsubse_ssta_trans … HTU20 (L2.ⓓV2) ?) -HTU20
- [ #U #HTU20 #HU20 -HWV0 -HL12 -W1 -W2
- @(ex2_intro … (ⓓ{b}V2.U)) [ /2 width=1/ ] -h -l -l1 -V -V0 -T2 -T20 -U0
- @(fpcs_fprs_strap2 ? L1 … (ⓓ{b}V2.U2)) [ /4 width=1/ ] -V1
- /4 width=4 by fpcs_fwd_shift, fpcs_canc_dx, cpcs_fpcs, fpcs_fwd_abst13/
- | -b -l -V -V1 -T2 -T20 -U0 -U2 -U20
- /6 width=6 by lsubse_abbr, fpcs_inv_cpcs, fpcs_canc_sn, fpcs_fprs_strap1, cpcs_fpcs, bi_inj/
- ]
- | #b #V0 #V2 #W0 #W2 #T0 #T2 #HV10 #HW02 #HT02 #HV02 #H1 #H2 destruct -a -l0 -W1 -W10 -HV1 -IH3 -IH2
- elim (ssta_inv_bind1 … HTU1) -HTU1 #U0 #HTU0 #H destruct
- elim (snv_inv_bind … HT1) -HT1 #_ #HT0
- elim (IH1 … HTU0 (L2.ⓓW2) … HT02) -IH1 -HTU0 // [2,3: /2 width=1/ ] -T0 -HL12 -HW02 #U2 #HTU2 #HU02
- lapply (fpcs_fwd_shift … HU02 b) -HU02 #HU02
- lapply (fpcs_flat_dx_tpr … HU02 … HV10 Appl) -HV10 -HU02 #HU02
- lapply (fpcs_fpr_strap1 … HU02 L2 (ⓓ{b}W2.ⓐV2.U2) ?) -HU02 [ @ltpr_tpr_fpr // /2 width=3/ ] -V0 /4 width=3/
- ]
-| #U0 #T1 #HL0 #HT0 #H1 #X2 #l #H2 #L2 #HL12 #X3 #H3 destruct -IH3 -IH2
- elim (snv_inv_cast … H1) -H1 #T0 #l0 #_ #HT1 #HT10 #_
- lapply (ssta_inv_cast1 … H2) -H2 #HTU1
- elim (ssta_mono … HT10 … HTU1) -HT10 #H1 #H2 destruct
- elim (tpr_inv_cast1 … H3) -H3
- [ * #U2 #T2 #_ #HT12 #H destruct
- elim (IH1 … HTU1 … HL12 … HT12) -IH1 -HTU1 -HL12 // [2: /2 width=1/ ] -T1 -U0 /3 width=3/
- | #HT1X3
- elim (IH1 … HTU1 … HL12 … HT1X3) -IH1 -HTU1 -HL12 // [2: /2 width=1/ ] -U0 -T1 /2 width=3/
- ]
-]
-qed-.
(* *)
(**************************************************************************)
-include "basic_2/dynamic/snv.ma".
+include "basic_2/dynamic/snv_cpcs.ma".
(* STRATIFIED NATIVE VALIDITY FOR TERMS *************************************)
(* Properties on stratified static type assignment for terms ****************)
-lemma snv_ssta: ∀h,g,L,T. ⦃h, L⦄ ⊩ T :[g] → ∃∃U,l. ⦃h, L⦄ ⊢ T •[g, l] U.
-#h #g #L #T #H elim H -L -T
-[ #L #k elim (deg_total h g k) /3 width=3/
-| * #L #K #V #i #HLK #_ * #W #l0 #HVW
- [ elim (lift_total W 0 (i+1)) /3 width=8/
- | elim (lift_total V 0 (i+1)) /3 width=8/
- ]
-| #a #I #L #V #T #_ #_ #_ * /3 width=3/
-| #a #L #V #W #W1 #T0 #T1 #l #_ #_ #_ #_ #_ #_ * /3 width=3/
-| #L #W #T #U #l #_ #_ #HTU #_ #_ #_ /3 width=3/ (**) (* auto fails without the last #_ *)
-]
-qed-.
-
-fact snv_ssta_conf_aux: ∀h,g,L,T. (
- ∀L0,T0. ⦃h, L0⦄ ⊩ T0 :[g] →
- ∀U0,l. ⦃h, L0⦄ ⊢ T0 •[g, l + 1] U0 →
- ♯{L0, T0} < ♯{L, T} → ⦃h, L0⦄ ⊩ U0 :[g]
- ) →
- ∀L0,T0. ⦃h, L0⦄ ⊩ T0 :[g] →
- ∀U0,l. ⦃h, L0⦄ ⊢ T0 •[g, l + 1] U0 →
- L0 = L → T0 = T → ⦃h, L0⦄ ⊩ U0 :[g].
+fact snv_ssta_aux: ∀h,g,L,T. (
+ ∀L0,T0. ⦃h, L0⦄ ⊩ T0 :[g] →
+ ∀U0,l. ⦃h, L0⦄ ⊢ T0 •[g, l + 1] U0 →
+ ♯{L0, T0} < ♯{L, T} → ⦃h, L0⦄ ⊩ U0 :[g]
+ ) →
+ ∀L0,T0. ⦃h, L0⦄ ⊩ T0 :[g] →
+ ∀U0,l. ⦃h, L0⦄ ⊢ T0 •[g, l + 1] U0 →
+ L0 = L → T0 = T → ⦃h, L0⦄ ⊩ U0 :[g].
#h #g #L #T #IH1 #L0 #T0 * -L0 -T0
[
|
--- /dev/null
+(**************************************************************************)
+(* ___ *)
+(* ||M|| *)
+(* ||A|| A project by Andrea Asperti *)
+(* ||T|| *)
+(* ||I|| Developers: *)
+(* ||T|| The HELM team. *)
+(* ||A|| http://helm.cs.unibo.it *)
+(* \ / *)
+(* \ / This file is distributed under the terms of the *)
+(* v GNU General Public License Version 2 *)
+(* *)
+(**************************************************************************)
+
+include "basic_2/equivalence/cpcs_ltpr.ma".
+include "basic_2/equivalence/lsubse_ssta.ma".
+include "basic_2/dynamic/snv_cpcs.ma".
+
+(* STRATIFIED NATIVE VALIDITY FOR TERMS *************************************)
+
+(* Properties on context-free parallel reduction for local environments *****)
+
+fact ssta_ltpr_tpr_aux: ∀h,g,L0,T0.
+ (∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_snv_ssta h g L1 T1) →
+ (∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_snv_ltpr_tpr h g L1 T1) →
+ (∀L1,T1. h ⊢ ⦃L0, T0⦄ >[g] ⦃L1, T1⦄ → IH_ssta_ltpr_tpr h g L1 T1) →
+ ∀L1,T1. L0 = L1 → T0 = T1 → IH_ssta_ltpr_tpr h g L1 T1.
+#h #g #L0 #T0 #IH3 #IH2 #IH1 #L1 * * [|||| *]
+[ #k #_ #_ #_ #X2 #l #H2 #L2 #HL12 #X3 #H3 -IH3 -IH2 -IH1
+ elim (ssta_inv_sort1 … H2) -H2 #Hkl #H destruct
+ >(tpr_inv_atom1 … H3) -X3 /4 width=6/
+| #i #HL0 #HT0 #H1 #X2 #l #H2 #L2 #HL12 #X3 #H3 destruct -IH3 -IH2
+ elim (snv_inv_lref … H1) -H1 #I0 #K0 #V0 #H #HV1
+ elim (ssta_inv_lref1 … H2) -H2 * #K1
+ >(tpr_inv_atom1 … H3) -X3
+ [ #V1 #W1 #HLK1 #HVW1 #HWU1
+ lapply (ldrop_mono … H … HLK1) -H #H destruct
+ lapply (ldrop_pair2_fwd_fw … HLK1 (#i)) #HKV1
+ elim (ltpr_ldrop_conf … HLK1 … HL12) #X #H #HLK2
+ elim (ltpr_inv_pair1 … H) -H #K2 #V2 #HK12 #HV12 #H destruct
+ elim (IH1 … HVW1 … HK12 … HV12) -IH1 -HVW1 -HV12 // [2: /2 width=1/ ] -HV1 -HKV1 #W2 #HVW2 #HW12
+ lapply (ldrop_fwd_ldrop2 … HLK1) -V1 #H1
+ elim (lift_total W2 0 (i+1)) #U2 #HWU2
+ lapply (cpcs_lift … H1 … HWU1 … HWU2 HW12) -H1 -W1 /3 width=6/
+ | #V1 #W1 #l0 #HLK1 #HVW1 #HVU1 #H destruct
+ lapply (ldrop_mono … H … HLK1) -H #H destruct
+ lapply (ldrop_pair2_fwd_fw … HLK1 (#i)) #HKV1
+ elim (ltpr_ldrop_conf … HLK1 … HL12) -HLK1 #X #H #HLK2
+ elim (ltpr_inv_pair1 … H) -H #K2 #V2 #HK12 #HV12 #H destruct
+ elim (IH1 … HVW1 … HK12 … HV12) -IH1 -HVW1 -HK12 // [2: /2 width=1/ ] -HV1 -HKV1 #W2 #HVW2 #_ -W1
+ elim (lift_total V2 0 (i+1)) #U2 #HVU2
+ lapply (tpr_lift … HV12 … HVU1 … HVU2) -V1 /4 width=6/
+ ]
+| #p #_ #HT0 #H1 destruct -IH3 -IH2 -IH1
+ elim (snv_inv_gref … H1)
+| #a #I #V1 #T1 #HL0 #HT0 #H1 #X2 #l #H2 #L2 #HL12 #X3 #H3 destruct -IH3 -IH2
+ elim (snv_inv_bind … H1) -H1 #_ #HT1
+ elim (ssta_inv_bind1 … H2) -H2 #U1 #HTU1 #H destruct
+ elim (tpr_inv_bind1 … H3) -H3 *
+ [ #V2 #T0 #T2 #HV12 #HT10 #HT02 #H destruct
+ lapply (tps_lsubs_trans … HT02 (L2.ⓑ{I}V2) ?) -HT02 [ /2 width=1/ ] #HT02
+ elim (ssta_ltpr_cpr_aux … HT1 … HTU1 (L2.ⓑ{I}V2) … T2) -HT1 -HTU1
+ [2: /3 width=5 by cpr_intro, tps_tpss/ |3: /2 width=1/ |4: /3 width=1/ ] -IH1 -T0 -HL12 #U2 #HTU2 #HU12
+ lapply (cpcs_bind1 … HU12 … V2 … a) -HU12 [ /2 width=1/ ] -HV12 /3 width=3/
+ | #T2 #HT12 #HT2 #H1 #H2 destruct
+ elim (IH1 … HTU1 (L2.ⓓV1) … T2) -IH1 -HTU1 // [2,3: /2 width=1/ ] -T1 -HL12 #U2 #HTU2 #HU12
+ lapply (cpcs_bind1 … HU12 … V1 … true) // -HU12 #HU12
+ elim (ssta_inv_lift1 … HTU2 … HT2) -T2 [3: /2 width=1/ |2: skip ] #U #HXU #HU2
+ lapply (cpcs_cpr_strap1 … HU12 U ?) -HU12 [ /3 width=3/ ] -U2 /2 width=3/
+ ]
+| #V1 #T1 #HL0 #HT0 #H1 #X2 #l #H2 #L2 #HL12 #X3 #H3 destruct
+ elim (snv_inv_appl … H1) -H1 #a #W1 #W10 #U10 #l0 #HV1 #HT1 #HVW1 #HW10 #HTU10
+ elim (ssta_inv_appl1 … H2) -H2 #U1 #HTU1 #H destruct
+ elim (tpr_inv_appl1 … H3) -H3 *
+ [ #V2 #T2 #HV12 #HT12 #H destruct -a -l0 -W1 -W10 -U10 -HV1 -IH3 -IH2
+ elim (IH1 … HTU1 … HL12 … HT12) -IH1 -HTU1 -HL12 // [2: /2 width=1/ ] -T1 #U2 #HTU2 #HU12
+ lapply (cpcs_flat … V1 V2 … HU12) -HU12 [ /2 width=1/ ] -HV12 /3 width=3/
+ | #b #V2 #W #T2 #T20 #HV12 #HT20 #H1 #H2 destruct
+ elim (snv_inv_bind … HT1) -HT1 #HW #HT2
+ elim (ssta_inv_bind1 … HTU1) -HTU1 #U2 #HTU2 #H destruct
+ elim (dxprs_inv_abst1 … HTU10) -HTU10 #W0 #U0 #HW0 #_ #H destruct
+ lapply (cprs_div … HW10 … HW0) -W0 #HW1W
+ elim (ssta_fwd_correct … HVW1) <minus_plus_m_m #X1 #HWX1
+ elim (snv_fwd_ssta … HW) #V #l1 #HWV
+ lapply (IH3 … HVW1) -IH3 // [ /2 width=1/ ] #HW1
+ elim (ssta_cpcs_aux … IH2 IH1 … HWX1 … HWV …) -IH2 -HWX1 //
+ [2: /2 width=1/ |3: /4 width=4 by fw_ygt, ysc_ssta, bi_step/ ] #H #_ destruct -X1
+ elim (IH1 … HVW1 … HL12 … HV12) -HVW1 // -HV1 [2: /2 width=1/ ] #W2 #HVW2 #HW12
+ elim (IH1 … HWV … HL12 W) -HWV // -HW [2: /2 width=1/ ] #V0 #HWV0 #_
+ elim (IH1 … HTU2 (L2.ⓛW) … HT20) -IH1 -HTU2 -HT20 // [2,3: /2 width=1/ ] -HT2 #U20 #HTU20 #HU20
+ elim (lsubse_ssta_trans … HTU20 (L2.ⓓV2) ?) -HTU20
+ [ #U #HTU20 #HUU20 -HWV0 -W1 -W2
+ lapply (ltpr_cpcs_trans (L1.ⓓV2) … HUU20) -HUU20 [ /2 width=1/ ] -HL12 #HUU20
+ @(ex2_intro … (ⓓ{b}V2.U)) [ /2 width=1/ ] -h -l -l1 -V -V0 -T2 -T20 -U0
+ @(cpcs_cprs_strap2 … (ⓓ{b}V2.U2)) [ /4 width=1/ ] -V1
+ @(cpcs_canc_dx … (ⓓ{b}V2.U20)) /2 width=2/
+ | -b -l -V -V1 -T2 -T20 -U0 -U2 -U20 -HW1
+ lapply (cpcs_canc_sn … HW12 … HW1W) -HW1W -HW12 #HW2
+ lapply (ltpr_cpcs_conf … HL12 … HW2) -L1 /2 width=6/
+ ]
+ | #b #V0 #V2 #W0 #W2 #T0 #T2 #HV10 #HW02 #HT02 #HV02 #H1 #H2 destruct -a -l0 -W1 -W10 -HV1 -IH3 -IH2
+ elim (ssta_inv_bind1 … HTU1) -HTU1 #U0 #HTU0 #H destruct
+ elim (snv_inv_bind … HT1) -HT1 #_ #HT0
+ elim (IH1 … HTU0 (L2.ⓓW2) … HT02) -IH1 -HTU0 // [2,3: /2 width=1/ ] -T0 -HL12 #U2 #HTU2 #HU02
+ lapply (cpcs_bind1 … HU02 … W0 … b) -HU02 // #HU02
+ lapply (cpcs_flat … V1 V0 … HU02 Appl) [ /2 width=1/ ] -HV10 -HU02 #HU02
+ lapply (cpcs_cpr_strap1 … HU02 (ⓓ{b}W2.ⓐV2.U2) ?) -HU02 [ /3 width=3/ ] -V0 -HW02 /4 width=3/
+ ]
+| #U0 #T1 #HL0 #HT0 #H1 #X2 #l #H2 #L2 #HL12 #X3 #H3 destruct -IH3 -IH2
+ elim (snv_inv_cast … H1) -H1 #T0 #l0 #_ #HT1 #HT10 #_
+ lapply (ssta_inv_cast1 … H2) -H2 #HTU1
+ elim (ssta_mono … HT10 … HTU1) -HT10 #H1 #H2 destruct
+ elim (tpr_inv_cast1 … H3) -H3
+ [ * #U2 #T2 #_ #HT12 #H destruct
+ elim (IH1 … HTU1 … HL12 … HT12) -IH1 -HTU1 -HL12 // [2: /2 width=1/ ] -T1 -U0 /3 width=3/
+ | #HT1X3
+ elim (IH1 … HTU1 … HL12 … HT1X3) -IH1 -HTU1 -HL12 // [2: /2 width=1/ ] -U0 -T1 /2 width=3/
+ ]
+]
+qed-.
--- /dev/null
+(**************************************************************************)
+(* ___ *)
+(* ||M|| *)
+(* ||A|| A project by Andrea Asperti *)
+(* ||T|| *)
+(* ||I|| Developers: *)
+(* ||T|| The HELM team. *)
+(* ||A|| http://helm.cs.unibo.it *)
+(* \ / *)
+(* \ / This file is distributed under the terms of the *)
+(* v GNU General Public License Version 2 *)
+(* *)
+(**************************************************************************)
+
+include "basic_2/unwind/sstas_lift.ma".
+include "basic_2/dynamic/snv.ma".
+
+(* STRATIFIED NATIVE VALIDITY FOR TERMS *************************************)
+
+(* Forward_lemmas on iterated stratified static type assignment for terms ***)
+
+lemma snv_sstas_fwd_correct: ∀h,g,L,T1,T2. ⦃h, L⦄ ⊩ T1 :[g] → ⦃h, L⦄ ⊢ T1 •* [g] T2 →
+ ∃∃U2,l. ⦃h, L⦄ ⊢ T2 •[g, l] U2.
+#h #g #L #T1 #T2 #HT1 #HT12
+elim (snv_fwd_ssta … HT1) -HT1 /2 width=5 by sstas_fwd_correct/
+qed-.
(* Advanced properties ******************************************************)
-lemma cpr_cprs_conf: ∀L,T,T1,T2. L ⊢ T ➡* T1 → L ⊢ T ➡ T2 → L ⊢ T1 ⬌* T2.
+lemma ltpr_cpcs_trans: ∀L1,L2. L1 ➡ L2 → ∀T1,T2. L2 ⊢ T1 ⬌* T2 → L1 ⊢ T1 ⬌* T2.
+#L1 #L2 #HL12 #T1 #T2 #H
+elim (cpcs_inv_cprs … H) -H #T #HT1 #HT2
+lapply (ltpr_cprs_trans … HL12 … HT1) -HT1
+lapply (ltpr_cprs_trans … HL12 … HT2) -L2 /2 width=3/
+qed-.
+
+lemma cpr_cprs_conf_cpcs: ∀L,T,T1,T2. L ⊢ T ➡* T1 → L ⊢ T ➡ T2 → L ⊢ T1 ⬌* T2.
#L #T #T1 #T2 #HT1 #HT2
elim (cprs_strip … HT1 … HT2) /2 width=3 by cpr_cprs_div/
qed-.
-lemma cprs_cpr_conf: ∀L,T,T1,T2. L ⊢ T ➡* T1 → L ⊢ T ➡ T2 → L ⊢ T2 ⬌* T1.
+lemma cprs_cpr_conf_cpcs: ∀L,T,T1,T2. L ⊢ T ➡* T1 → L ⊢ T ➡ T2 → L ⊢ T2 ⬌* T1.
#L #T #T1 #T2 #HT1 #HT2
elim (cprs_strip … HT1 … HT2) /2 width=3 by cprs_cpr_div/
qed-.
-lemma cprs_conf: ∀L,T,T1,T2. L ⊢ T ➡* T1 → L ⊢ T ➡* T2 → L ⊢ T1 ⬌* T2.
+lemma cprs_conf_cpcs: ∀L,T,T1,T2. L ⊢ T ➡* T1 → L ⊢ T ➡* T2 → L ⊢ T1 ⬌* T2.
#L #T #T1 #T2 #HT1 #HT2
elim (cprs_conf … HT1 … HT2) /2 width=3/
qed-.
∀I. L ⊢ ⓕ{I}V1. T1 ⬌* ⓕ{I}V2. T2.
/3 width=1/ qed.
-lemma cpcs_abst: ∀a,L,V1,V2. L ⊢ V1 ⬌* V2 →
- ∀V,T1,T2. L.ⓛV ⊢ T1 ⬌* T2 → L ⊢ ⓛ{a}V1. T1 ⬌* ⓛ{a}V2. T2.
-#a #L #V1 #V2 #HV12 #V #T1 #T2 #HT12
+lemma cpcs_abst: ∀L,V1,V2. L ⊢ V1 ⬌* V2 → ∀V,T1,T2. L.ⓛV ⊢ T1 ⬌* T2 →
+ ∀a,I. L ⊢ ⓑ{a,I}V1. T1 ⬌* ⓑ{a,I}V2. T2.
+#L #V1 #V2 #HV12 #V #T1 #T2 #HT12 #a #I
elim (cpcs_inv_cprs … HV12) -HV12
elim (cpcs_inv_cprs … HT12) -HT12
/3 width=6 by cprs_div, cprs_abst/ (**) (* /3 width=6/ is a bit slow *)
#a #L #V1 #V2 #HV12 #T1 #T2 #HT12
@(cpcs_trans … (ⓓ{a}V2.T1)) /2 width=1/
qed.
+
+lemma cpcs_bind1: ∀I,L,V1,T1,T2. L.ⓑ{I}V1 ⊢ T1 ⬌* T2 → ∀V2. L ⊢ V1 ⬌* V2 →
+ ∀a. L ⊢ ⓑ{a,I}V1. T1 ⬌* ⓑ{a,I}V2. T2.
+* /2 width=1/ /2 width=2/
+qed.
+
+lemma cpcs_bind2: ∀L,V1,V2. L ⊢ V1 ⬌* V2 → ∀I,T1,T2. L.ⓑ{I}V2 ⊢ T1 ⬌* T2 →
+ ∀a. L ⊢ ⓑ{a,I}V1. T1 ⬌* ⓑ{a,I}V2. T2.
+#L #V1 #V2 #HV12 * /2 width=1/ /2 width=2/
+qed.
@ex2_intro [2: // | skip | @tpss_subst /width=6/ ] (**) (* /3 width=6/ is too slow *)
qed.
-lemma cpr_abst: ∀L,V1,V2. L ⊢ V1 ➡ V2 → ∀V,T1,T2.
- L.ⓛV ⊢ T1 ➡ T2 → ∀a. L ⊢ ⓛ{a}V1. T1 ➡ ⓛ{a}V2. T2.
-#L #V1 #V2 * #V0 #HV10 #HV02 #V #T1 #T2 * #T0 #HT10 #HT02 #a
+lemma cpr_abst: ∀L,V1,V2. L ⊢ V1 ➡ V2 → ∀V,T1,T2. L.ⓛV ⊢ T1 ➡ T2 →
+ ∀a,I. L ⊢ ⓑ{a,I}V1. T1 ➡ ⓑ{a,I}V2. T2.
+#L #V1 #V2 * #V0 #HV10 #HV02 #V #T1 #T2 * #T0 #HT10 #HT02 #a #I
lapply (tpss_inv_S2 … HT02 L V ?) -HT02 // #HT02
-lapply (tpss_lsubs_trans â\80¦ HT02 (L.â\93\9bV2) ?) -HT02 /2 width=1/ #HT02
-@(ex2_intro â\80¦ (â\93\9b{a}V0.T0)) /2 width=1/ (* explicit constructors *)
+lapply (tpss_lsubs_trans â\80¦ HT02 (L.â\93\91{I}V2) ?) -HT02 /2 width=1/ #HT02
+@(ex2_intro â\80¦ (â\93\91{a,I}V0.T0)) /2 width=1/ (* explicit constructors *)
qed.
lemma cpr_beta: ∀a,L,V1,V2,W,T1,T2.
(* Basic properties *********************************************************)
+lemma sstas_refl: ∀h,g,L. reflexive … (sstas h g L).
+// qed.
+
lemma ssta_sstas: ∀h,g,L,T,U,l. ⦃h, L⦄ ⊢ T •[g, l+1] U → ⦃h, L⦄ ⊢ T •*[g] U.
/3 width=2 by R_to_star, ex_intro/ qed. (**) (* auto fails without trace *)
(* ITERATED STRATIFIED STATIC TYPE ASSIGNMENT FOR TERMS *********************)
+(* Advanced forward lemmas **************************************************)
+
+lemma sstas_fwd_correct: ∀h,g,L,T1,U1,l1. ⦃h, L⦄ ⊢ T1 •[g, l1] U1 →
+ ∀T2. ⦃h, L⦄ ⊢ T1 •*[g] T2 →
+ ∃∃U2,l2. ⦃h, L⦄ ⊢ T2 •[g, l2] U2.
+#h #g #L #T1 #U1 #l1 #HTU1 #T2 #H @(sstas_ind … H) -T2 [ /2 width=3/ ] -HTU1
+#T #T2 #l #_ #HT2 * #U #l0 #_ -l0
+elim (ssta_fwd_correct … HT2) -T /2 width=3/
+qed-.
+
(* Properties on relocation *************************************************)
lemma sstas_lift: ∀h,g,L1,T1,U1. ⦃h, L1⦄ ⊢ T1 •*[g] U1 →