(* *)
(**************************************************************************)
-include "basic_2/static/ssta_ssta.ma".
+include "basic_2/unwind/sstas_sstas.ma".
include "basic_2/computation/ygt.ma".
include "basic_2/equivalence/cpcs_ltpr.ma".
include "basic_2/dynamic/snv_ltpss_dx.ma".
lapply (cpcs_canc_sn … HW12 HWU1) -W1 #H
elim (cpcs_inv_cprs … H) -H /3 width=3/
qed-.
-(*
-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
-*)
+
+fact ssta_dxprs_aux: ∀h,g,L0,T0.
+ (∀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] →
+ ∀l,U1. ⦃h, L1⦄ ⊢ T1 •[g, l+1] U1 → ∀T2. ⦃h, L1⦄ ⊢ T1 •*➡*[g] T2 →
+ ∃∃U,U2. ⦃h, L1⦄ ⊢ U1 •*[g] U & ⦃h, L1⦄ ⊢ T2 •*[g] U2 & L1 ⊢ U ⬌* U2.
+#h #g #L0 #T0 #IH2 #IH1 #L1 #T1 #H01 #HT1 #l #U1 #HTU1 #T2 * #T #HT1T #HTT2
+elim (sstas_strip … HT1T … HTU1) #HU1T destruct [ -HT1T | -L0 -T0 -T1 ]
+[ elim (ssta_ltpr_cprs_aux … IH2 IH1 … HTU1 L1 … HTT2) // -L0 -T0 -T /3 width=5/
+| @(ex3_2_intro …T2 HU1T) // /2 width=1/
+]
+qed-.
(* Properties on stratified static type assignment for terms ****************)
-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
-[
-|
-|
-| #a #L0 #V #W #W0 #T0 #V0 #l0 #HV #HT0 #HVW #HW0 #HTV0 #X #l #H #H1 #H2 destruct
- elim (ssta_inv_appl1 … H) -H #U0 #HTU0 #H destruct
- lapply (IH1 … HT0 … HTU0 ?) // #HU0
- @(snv_appl … HV HU0 HVW HW0) -HV -HU0 -HVW -HW0
-| #L0 #W #T0 #W0 #l0 #_ #HT0 #_ #_ #U0 #l #H #H1 #H2 destruct -W0
- lapply (ssta_inv_cast1 … H) -H /2 width=5/
+fact snv_ssta_aux: ∀h,g,L0,T0.
+ (∀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⦄ → IH_snv_ssta h g L1 T1) →
+ ∀L1,T1. L0 = L1 → T0 = T1 → IH_snv_ssta h g L1 T1.
+#h #g #L0 #T0 #IH3 #IH2 #IH1 #L1 * * [||||*]
+[ #k #HL0 #HT0 #_ #X #l #H2 destruct -IH3 -IH2 -IH1
+ elim (ssta_inv_sort1 … H2) -H2 #_ #H destruct //
+| #i #HL0 #HT0 #H1 #X #l #H2 destruct -IH3 -IH2
+ elim (snv_inv_lref … H1) -H1 #I #K1 #V1 #HLK1 #HV1
+ elim (ssta_inv_lref1 … H2) -H2 * #K0 #V0 #W1 [| #l ] #H #HVW1 #HX [| #_ ]
+ lapply (ldrop_mono … H … HLK1) -H #H destruct
+ lapply (ldrop_pair2_fwd_fw … HLK1 (#i)) #H
+ lapply (ldrop_fwd_ldrop2 … HLK1) -HLK1 /4 width=7/
+| #p #HL0 #HT0 #H1 #X #l #H2 destruct -IH3 -IH2 -IH1
+ elim (snv_inv_gref … H1)
+| #a #I #V1 #T1 #HL0 #HT0 #H1 #X #l #H2 destruct -IH3 -IH2
+ elim (snv_inv_bind … H1) -H1 #HV1 #HT1
+ elim (ssta_inv_bind1 … H2) -H2 #U1 #HTU1 #H destruct /4 width=5/
+| #V1 #T1 #HL0 #HT0 #H1 #X #l #H2 destruct
+ elim (snv_inv_appl … H1) -H1 #a #W1 #W0 #T0 #l0 #HV1 #HT1 #HVW1 #HW10 #HT10
+ elim (ssta_inv_appl1 … H2) -H2 #U1 #HTU1 #H destruct
+ lapply (IH1 … HT1 … HTU1) -IH1 /2 width=1/ #HU1
+ elim (ssta_dxprs_aux … IH3 IH2 … HTU1 … HT10) -IH3 -IH2 // /2 width=2/ -T1 #U #X #HU1U #H #HU0
+ elim (sstas_inv_bind1 … H) -H #U0 #HTU0 #H destruct
+ elim (cpcs_inv_abst2 … HU0) -HU0 #W2 #U2 #HU2 #HU02
+ elim (cprs_inv_abst … HU02 Abst W0) -HU02 #HW02 #_
+ lapply (cprs_trans … HW10 … HW02) -W0 /3 width=10 by snv_appl, ex2_intro/ (**) (* auto is too slow without trace *)
+| #W1 #T1 #HL0 #HT0 #H1 #X #l #H2 destruct -IH3 -IH2
+ elim (snv_inv_cast … H1) -H1 #U1 #l0 #HW1 #HT1 #HTU1 #HUW1
+ lapply (ssta_inv_cast1 … H2) -H2 /3 width=5/
+]
+qed-.
lemma sstas_strip: ∀h,g,L,T,U1. ⦃h, L⦄ ⊢ T •*[g] U1 →
∀U2,l. ⦃h, L⦄ ⊢ T •[g, l] U2 →
- ⦃h, L⦄ ⊢ U1 •[g, l] U2 ∨ ⦃h, L⦄ ⊢ U2 •*[g] U1.
+ T = U1 ∨ ⦃h, L⦄ ⊢ U2 •*[g] U1.
#h #g #L #T #U1 #H1 @(sstas_ind_dx … H1) -T /2 width=1/
#T #U #l0 #HTU #HU1 #_ #U2 #l #H2
elim (ssta_mono … H2 … HTU) -H2 -HTU #H1 #H2 destruct /2 width=1/
⦃h, L⦄ ⊢ U1 •*[g] U2 ∨ ⦃h, L⦄ ⊢ U2 •*[g] U1.
#h #g #L #T #U1 #H1 @(sstas_ind_dx … H1) -T /2 width=1/
#T #U #l #HTU #HU1 #IHU1 #U2 #H2
-elim (sstas_strip … H2 … HTU) -T /2 width=1/ -IHU1 /3 width=4/
+elim (sstas_strip … H2 … HTU) #H destruct
+[ -H2 -IHU1 /3 width=4/
+| -T /2 width=1/
+]
qed-.