1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "basic_2/unfold/lsstas_lsstas.ma".
16 include "basic_2/computation/fpbs_lift.ma".
17 include "basic_2/computation/fpbg.ma".
18 include "basic_2/equivalence/cpes_cpds.ma".
19 include "basic_2/dynamic/snv.ma".
21 (* STRATIFIED NATIVE VALIDITY FOR TERMS *************************************)
23 (* Inductive premises for the preservation results **************************)
25 definition IH_snv_cpr_lpr: ∀h:sh. sd h → relation3 genv lenv term ≝
26 λh,g,G,L1,T1. ⦃G, L1⦄ ⊢ T1 ¡[h, g] →
27 ∀T2. ⦃G, L1⦄ ⊢ T1 ➡ T2 → ∀L2. ⦃G, L1⦄ ⊢ ➡ L2 → ⦃G, L2⦄ ⊢ T2 ¡[h, g].
29 definition IH_da_cpr_lpr: ∀h:sh. sd h → relation3 genv lenv term ≝
30 λh,g,G,L1,T1. ⦃G, L1⦄ ⊢ T1 ¡[h, g] →
31 ∀l. ⦃G, L1⦄ ⊢ T1 ▪[h, g] l →
32 ∀T2. ⦃G, L1⦄ ⊢ T1 ➡ T2 → ∀L2. ⦃G, L1⦄ ⊢ ➡ L2 →
33 ⦃G, L2⦄ ⊢ T2 ▪[h, g] l.
35 definition IH_lsstas_cpr_lpr: ∀h:sh. sd h → relation3 genv lenv term ≝
36 λh,g,G,L1,T1. ⦃G, L1⦄ ⊢ T1 ¡[h, g] →
37 ∀l1,l2. l2 ≤ l1 → ⦃G, L1⦄ ⊢ T1 ▪[h, g] l1 →
38 ∀U1. ⦃G, L1⦄ ⊢ T1 •*[h, g, l2] U1 →
39 ∀T2. ⦃G, L1⦄ ⊢ T1 ➡ T2 → ∀L2. ⦃G, L1⦄ ⊢ ➡ L2 →
40 ∃∃U2. ⦃G, L2⦄ ⊢ T2 •*[h, g, l2] U2 & ⦃G, L2⦄ ⊢ U1 ⬌* U2.
42 definition IH_snv_lsstas: ∀h:sh. sd h → relation3 genv lenv term ≝
43 λh,g,G,L,T. ⦃G, L⦄ ⊢ T ¡[h, g] →
44 ∀l1,l2. l2 ≤ l1 → ⦃G, L⦄ ⊢ T ▪[h, g] l1 →
45 ∀U. ⦃G, L⦄ ⊢ T •*[h, g, l2] U → ⦃G, L⦄ ⊢ U ¡[h, g].
47 (* Properties for the preservation results **********************************)
49 fact snv_cprs_lpr_aux: ∀h,g,G0,L0,T0.
50 (∀G1,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G1, L1, T1⦄ → IH_snv_cpr_lpr h g G1 L1 T1) →
51 ∀G,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G, L1, T1⦄ → ⦃G, L1⦄ ⊢ T1 ¡[h, g] →
52 ∀T2. ⦃G, L1⦄ ⊢ T1 ➡* T2 → ∀L2. ⦃G, L1⦄ ⊢ ➡ L2 → ⦃G, L2⦄ ⊢ T2 ¡[h, g].
53 #h #g #G0 #L0 #T0 #IH #G #L1 #T1 #HLT0 #HT1 #T2 #H
54 @(cprs_ind … H) -T2 /4 width=6 by fpbg_fpbs_trans, cprs_fpbs/
57 fact da_cprs_lpr_aux: ∀h,g,G0,L0,T0.
58 (∀G1,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G1, L1, T1⦄ → IH_snv_cpr_lpr h g G1 L1 T1) →
59 (∀G1,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G1, L1, T1⦄ → IH_da_cpr_lpr h g G1 L1 T1) →
60 ∀G,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G, L1, T1⦄ → ⦃G, L1⦄ ⊢ T1 ¡[h, g] →
61 ∀l. ⦃G, L1⦄ ⊢ T1 ▪[h, g] l →
62 ∀T2. ⦃G, L1⦄ ⊢ T1 ➡* T2 → ∀L2. ⦃G, L1⦄ ⊢ ➡ L2 → ⦃G, L2⦄ ⊢ T2 ▪[h, g] l.
63 #h #g #G0 #L0 #T0 #IH2 #IH1 #G #L1 #T1 #HLT0 #HT1 #l #Hl #T2 #H
64 @(cprs_ind … H) -T2 /4 width=10 by snv_cprs_lpr_aux, fpbg_fpbs_trans, cprs_fpbs/
67 fact da_cpcs_aux: ∀h,g,G0,L0,T0.
68 (∀G1,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G1, L1, T1⦄ → IH_snv_cpr_lpr h g G1 L1 T1) →
69 (∀G1,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G1, L1, T1⦄ → IH_da_cpr_lpr h g G1 L1 T1) →
70 ∀G,L,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G, L, T1⦄ → ⦃G, L⦄ ⊢ T1 ¡[h, g] →
71 ∀T2. ⦃G0, L0, T0⦄ >[h, g] ⦃G, L, T2⦄ → ⦃G, L⦄ ⊢ T2 ¡[h, g] →
72 ∀l1. ⦃G, L⦄ ⊢ T1 ▪[h, g] l1 → ∀l2. ⦃G, L⦄ ⊢ T2 ▪[h, g] l2 →
73 ⦃G, L⦄ ⊢ T1 ⬌* T2 → l1 = l2.
74 #h #g #G0 #L0 #T0 #IH2 #IH1 #G #L #T1 #HLT01 #HT1 #T2 #HLT02 #HT2 #l1 #Hl1 #l2 #Hl2 #H
75 elim (cpcs_inv_cprs … H) -H /4 width=18 by da_cprs_lpr_aux, da_mono/
78 fact ssta_cpr_lpr_aux: ∀h,g,G0,L0,T0.
79 (∀G1,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G1, L1, T1⦄ → IH_lsstas_cpr_lpr h g G1 L1 T1) →
80 ∀G,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G, L1, T1⦄ → ⦃G, L1⦄ ⊢ T1 ¡[h, g] →
81 ∀l. ⦃G, L1⦄ ⊢ T1 ▪[h, g] l+1 →
82 ∀U1. ⦃G, L1⦄ ⊢ T1 •[h, g] U1 →
83 ∀T2. ⦃G, L1⦄ ⊢ T1 ➡ T2 → ∀L2. ⦃G, L1⦄ ⊢ ➡ L2 →
84 ∃∃U2. ⦃G, L2⦄ ⊢ T2 •[h, g] U2 & ⦃G, L2⦄ ⊢ U1 ⬌* U2.
85 #h #g #G0 #L0 #T0 #IH #G #L1 #T1 #H01 #HT1 #l #Hl #U1 #HTU1 #T2 #HT12 #L2 #HL12
86 elim (IH … H01 … 1 … Hl U1 … HT12 … HL12)
87 /3 width=3 by lsstas_inv_SO, ssta_lsstas, ex2_intro/
90 fact lsstas_cprs_lpr_aux: ∀h,g,G0,L0,T0.
91 (∀G1,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G1, L1, T1⦄ → IH_snv_cpr_lpr h g G1 L1 T1) →
92 (∀G1,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G1, L1, T1⦄ → IH_da_cpr_lpr h g G1 L1 T1) →
93 (∀G1,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G1, L1, T1⦄ → IH_lsstas_cpr_lpr h g G1 L1 T1) →
94 ∀G,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G, L1, T1⦄ → ⦃G, L1⦄ ⊢ T1 ¡[h, g] →
95 ∀l1,l2. l2 ≤ l1 → ⦃G, L1⦄ ⊢ T1 ▪[h, g] l1 →
96 ∀U1. ⦃G, L1⦄ ⊢ T1 •*[h, g, l2] U1 →
97 ∀T2. ⦃G, L1⦄ ⊢ T1 ➡* T2 → ∀L2. ⦃G, L1⦄ ⊢ ➡ L2 →
98 ∃∃U2. ⦃G, L2⦄ ⊢ T2 •*[h, g, l2] U2 & ⦃G, L2⦄ ⊢ U1 ⬌* U2.
99 #h #g #G0 #L0 #T0 #IH3 #IH2 #IH1 #G #L1 #T1 #H01 #HT1 #l1 #l2 #Hl21 #Hl1 #U1 #HTU1 #T2 #H
100 @(cprs_ind … H) -T2 [ /2 width=10/ ]
101 #T #T2 #HT1T #HTT2 #IHT1 #L2 #HL12
102 elim (IHT1 L1) // -IHT1 #U #HTU #HU1
103 elim (IH1 … Hl21 … HTU … HTT2 … HL12) -IH1 -HTU -HTT2
104 [2: /3 width=12 by da_cprs_lpr_aux/
105 |3: /3 width=10 by snv_cprs_lpr_aux/
106 |4: /3 width=5 by fpbg_fpbs_trans, cprs_fpbs/
107 ] -G0 -L0 -T0 -T1 -T -l1 #U2 #HTU2 #HU2
108 /4 width=5 by lpr_cpcs_conf, cpcs_trans, ex2_intro/
111 fact lsstas_cpcs_lpr_aux: ∀h,g,G0,L0,T0.
112 (∀G1,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G1, L1, T1⦄ → IH_snv_cpr_lpr h g G1 L1 T1) →
113 (∀G1,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G1, L1, T1⦄ → IH_da_cpr_lpr h g G1 L1 T1) →
114 (∀G1,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G1, L1, T1⦄ → IH_lsstas_cpr_lpr h g G1 L1 T1) →
115 ∀G,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G, L1, T1⦄ → ⦃G, L1⦄ ⊢ T1 ¡[h, g] →
116 ∀l,l1. l ≤ l1 → ⦃G, L1⦄ ⊢ T1 ▪[h, g] l1 → ∀U1. ⦃G, L1⦄ ⊢ T1 •*[h, g, l] U1 →
117 ∀T2. ⦃G0, L0, T0⦄ >[h, g] ⦃G, L1, T2⦄ → ⦃G, L1⦄ ⊢ T2 ¡[h, g] →
118 ∀l2. l ≤ l2 → ⦃G, L1⦄ ⊢ T2 ▪[h, g] l2 → ∀U2. ⦃G, L1⦄ ⊢ T2 •*[h, g, l] U2 →
119 ⦃G, L1⦄ ⊢ T1 ⬌* T2 → ∀L2. ⦃G, L1⦄ ⊢ ➡ L2 → ⦃G, L2⦄ ⊢ U1 ⬌* U2.
120 #h #g #G0 #L0 #T0 #IH3 #IH2 #IH1 #G #L1 #T1 #H01 #HT1 #l #l1 #Hl1 #HTl1 #U1 #HTU1 #T2 #H02 #HT2 #l2 #Hl2 #HTl2 #U2 #HTU2 #H #L2 #HL12
121 elim (cpcs_inv_cprs … H) -H #T #H1 #H2
122 elim (lsstas_cprs_lpr_aux … H01 HT1 … Hl1 HTl1 … HTU1 … H1 … HL12) -T1 /2 width=1/ #W1 #H1 #HUW1
123 elim (lsstas_cprs_lpr_aux … H02 HT2 … Hl2 HTl2 … HTU2 … H2 … HL12) -T2 /2 width=1/ #W2 #H2 #HUW2 -L0 -T0
124 lapply (lsstas_mono … H1 … H2) -h -T -l #H destruct /2 width=3 by cpcs_canc_dx/
127 fact snv_ssta_aux: ∀h,g,G0,L0,T0.
128 (∀G1,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G1, L1, T1⦄ → IH_snv_lsstas h g G1 L1 T1) →
129 ∀G,L,T. ⦃G0, L0, T0⦄ >[h, g] ⦃G, L, T⦄ → ⦃G, L⦄ ⊢ T ¡[h, g] →
130 ∀l. ⦃G, L⦄ ⊢ T ▪[h, g] l+1 →
131 ∀U. ⦃G, L⦄ ⊢ T •[h, g] U → ⦃G, L⦄ ⊢ U ¡[h, g].
132 /3 width=8 by lsstas_inv_SO, ssta_lsstas/ qed-.
134 fact lsstas_cpds_aux: ∀h,g,G0,L0,T0.
135 (∀G1,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G1, L1, T1⦄ → IH_snv_lsstas h g G1 L1 T1) →
136 (∀G1,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G1, L1, T1⦄ → IH_snv_cpr_lpr h g G1 L1 T1) →
137 (∀G1,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G1, L1, T1⦄ → IH_da_cpr_lpr h g G1 L1 T1) →
138 (∀G1,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G1, L1, T1⦄ → IH_lsstas_cpr_lpr h g G1 L1 T1) →
139 ∀G,L,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G, L, T1⦄ → ⦃G, L⦄ ⊢ T1 ¡[h, g] →
140 ∀l1,l2. l2 ≤ l1 → ⦃G, L⦄ ⊢ T1 ▪[h, g] l1 →
141 ∀U1. ⦃G, L⦄ ⊢ T1 •*[h, g, l2] U1 → ∀T2. ⦃G, L⦄ ⊢ T1 •*➡*[h, g] T2 →
142 ∃∃U2,l. l ≤ l2 & ⦃G, L⦄ ⊢ T2 •*[h, g, l] U2 & ⦃G, L⦄ ⊢ U1 •*⬌*[h, g] U2.
143 #h #g #G0 #L0 #T0 #IH4 #IH3 #IH2 #IH1 #G #L #T1 #H01 #HT1 #l1 #l2 #Hl21 #Hl1 #U1 #HTU1 #T2 * #T #l0 #l #Hl0 #H #HT1T #HTT2
144 lapply (da_mono … H … Hl1) -H #H destruct
145 lapply (lsstas_da_conf … HTU1 … Hl1) #Hl12
146 elim (le_or_ge l2 l) #Hl2
147 [ lapply (lsstas_conf_le … HTU1 … HT1T) -HT1T // #HU1T
148 /5 width=11 by cpds_cpes_dx, monotonic_le_minus_l, ex3_2_intro, ex4_3_intro/
149 | lapply (lsstas_da_conf … HT1T … Hl1) #Hl1l
150 lapply (lsstas_conf_le … HT1T … HTU1) -HTU1 // #HTU1
151 elim (lsstas_cprs_lpr_aux … IH3 IH2 IH1 … Hl1l … HTU1 … HTT2 L)
152 /3 width=8 by fpbg_fpbs_trans, lsstas_fpbs, monotonic_le_minus_l/ -T #U2 #HTU2 #HU12
153 /3 width=5 by cpcs_cpes, ex3_2_intro/
157 fact cpds_cpr_lpr_aux: ∀h,g,G0,L0,T0.
158 (∀G1,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G1, L1, T1⦄ → IH_da_cpr_lpr h g G1 L1 T1) →
159 (∀G1,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G1, L1, T1⦄ → IH_lsstas_cpr_lpr h g G1 L1 T1) →
160 ∀G,L1,T1. ⦃G0, L0, T0⦄ >[h, g] ⦃G, L1, T1⦄ → ⦃G, L1⦄ ⊢ T1 ¡[h, g] →
161 ∀U1. ⦃G, L1⦄ ⊢ T1 •*➡*[h, g] U1 →
162 ∀T2. ⦃G, L1⦄ ⊢ T1 ➡ T2 → ∀L2. ⦃G, L1⦄ ⊢ ➡ L2 →
163 ∃∃U2. ⦃G, L2⦄ ⊢ T2 •*➡*[h, g] U2 & ⦃G, L2⦄ ⊢ U1 ➡* U2.
164 #h #g #G0 #L0 #T0 #IH2 #IH1 #G #L1 #T1 #H01 #HT1 #U1 * #W1 #l1 #l2 #Hl21 #Hl1 #HTW1 #HWU1 #T2 #HT12 #L2 #HL12
165 elim (IH1 … H01 … HTW1 … HT12 … HL12) -IH1 // #W2 #HTW2 #HW12
166 lapply (IH2 … H01 … Hl1 … HT12 … HL12) -L0 -T0 // -T1 #Hl1
167 lapply (lpr_cprs_conf … HL12 … HWU1) -L1 #HWU1
168 lapply (cpcs_canc_sn … HW12 HWU1) -W1 #H
169 elim (cpcs_inv_cprs … H) -H /3 width=7 by ex4_3_intro, ex2_intro/