]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/etc/lsubr/cpqs.etc
- extended multiple substitutions now uses bounds in ynat (ie. they
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / etc / lsubr / cpqs.etc
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 notation "hvbox( L ⊢ break term 46 T1 ➤ * break term 46 T2 )"
16    non associative with precedence 45
17    for @{ 'PRestStar $L $T1 $T2 }.
18
19 include "basic_2/substitution/cpss.ma".
20
21 (* CONTEXT-SENSITIVE RESTRICTED PARALLEL COMPUTATION FOR TERMS **************)
22
23 inductive cpqs: lenv → relation term ≝
24 | cpqs_atom : ∀I,L. cpqs L (⓪{I}) (⓪{I})
25 | cpqs_delta: ∀L,K,V,V2,W2,i.
26               ⇩[0, i] L ≡ K. ⓓV → cpqs K V V2 →
27               ⇧[0, i + 1] V2 ≡ W2 → cpqs L (#i) W2
28 | cpqs_bind : ∀a,I,L,V1,V2,T1,T2.
29               cpqs L V1 V2 → cpqs (L. ⓑ{I} V1) T1 T2 →
30               cpqs L (ⓑ{a,I} V1. T1) (ⓑ{a,I} V2. T2)
31 | cpqs_flat : ∀I,L,V1,V2,T1,T2.
32               cpqs L V1 V2 → cpqs L T1 T2 →
33               cpqs L (ⓕ{I} V1. T1) (ⓕ{I} V2. T2)
34 | cpqs_zeta : ∀L,V,T1,T,T2. cpqs (L.ⓓV) T1 T →
35               ⇧[0, 1] T2 ≡ T → cpqs L (+ⓓV. T1) T2
36 | cpqs_tau  : ∀L,V,T1,T2. cpqs L T1 T2 → cpqs L (ⓝV. T1) T2
37 .
38
39 interpretation "context-sensitive restricted parallel computation (term)"
40    'PRestStar L T1 T2 = (cpqs L T1 T2).
41
42 (* Basic properties *********************************************************)
43
44 lemma cpqs_lsubr_trans: lsub_trans … cpqs lsubr.
45 #L1 #T1 #T2 #H elim H -L1 -T1 -T2
46 [ //
47 | #L1 #K1 #V1 #V2 #W2 #i #HLK1 #_ #HVW2 #IHV12 #L2 #HL12
48   elim (lsubr_fwd_ldrop2_abbr … HL12 … HLK1) -HL12 -HLK1 /3 width=6/
49 | /4 width=1/
50 |4,6: /3 width=1/
51 | /4 width=3/
52 ]
53 qed-.
54
55 lemma cpss_cpqs: ∀L,T1,T2. L ⊢ T1 ▶* T2 → L ⊢ T1 ➤* T2.
56 #L #T1 #T2 #H elim H -L -T1 -T2 // /2 width=1/ /2 width=6/
57 qed.
58
59 lemma cpqs_refl: ∀T,L. L ⊢ T ➤* T.
60 /2 width=1/ qed.
61
62 lemma cpqs_delift: ∀L,K,V,T1,d. ⇩[0, d] L ≡ (K. ⓓV) →
63                    ∃∃T2,T. L ⊢ T1 ➤* T2 & ⇧[d, 1] T ≡ T2.
64 #L #K #V #T1 #d #HLK
65 elim (cpss_delift … T1 … HLK) -HLK /3 width=4/
66 qed-.
67
68 lemma cpqs_append: l_appendable_sn … cpqs.
69 #K #T1 #T2 #H elim H -K -T1 -T2 // /2 width=1/ /2 width=3/
70 #K #K0 #V1 #V2 #W2 #i #HK0 #_ #HVW2 #IHV12 #L
71 lapply (ldrop_fwd_length_lt2 … HK0) #H
72 @(cpqs_delta … (L@@K0) V1 … HVW2) //
73 @(ldrop_O1_append_sn_le … HK0) /2 width=2/ (**) (* /3/ does not work *)
74 qed.
75
76 (* Basic inversion lemmas ***************************************************)
77
78 fact cpqs_inv_atom1_aux: ∀L,T1,T2. L ⊢ T1 ➤* T2 → ∀I. T1 = ⓪{I} →
79                          T2 = ⓪{I} ∨
80                          ∃∃K,V,V2,i. ⇩[O, i] L ≡ K. ⓓV &
81                                      K ⊢ V ➤* V2 &
82                                      ⇧[O, i + 1] V2 ≡ T2 &
83                                      I = LRef i.
84 #L #T1 #T2 * -L -T1 -T2
85 [ #I #L #J #H destruct /2 width=1/
86 | #L #K #V #V2 #T2 #i #HLK #HV2 #HVT2 #J #H destruct /3 width=8/
87 | #a #I #L #V1 #V2 #T1 #T2 #_ #_ #J #H destruct
88 | #I #L #V1 #V2 #T1 #T2 #_ #_ #J #H destruct
89 | #L #V #T1 #T #T2 #_ #_ #J #H destruct
90 | #L #V #T1 #T2 #_ #J #H destruct
91 ]
92 qed-.
93
94 lemma cpqs_inv_atom1: ∀I,L,T2. L ⊢ ⓪{I} ➤* T2 →
95                       T2 = ⓪{I} ∨
96                       ∃∃K,V,V2,i. ⇩[O, i] L ≡ K. ⓓV &
97                                   K ⊢ V ➤* V2 &
98                                   ⇧[O, i + 1] V2 ≡ T2 &
99                                   I = LRef i.
100 /2 width=3 by cpqs_inv_atom1_aux/ qed-.
101
102 lemma cpqs_inv_sort1: ∀L,T2,k. L ⊢ ⋆k ➤* T2 → T2 = ⋆k.
103 #L #T2 #k #H
104 elim (cpqs_inv_atom1 … H) -H //
105 * #K #V #V2 #i #_ #_ #_ #H destruct
106 qed-.
107
108 lemma cpqs_inv_lref1: ∀L,T2,i. L ⊢ #i ➤* T2 →
109                       T2 = #i ∨
110                       ∃∃K,V,V2. ⇩[O, i] L ≡ K. ⓓV &
111                                 K ⊢ V ➤* V2 &
112                                 ⇧[O, i + 1] V2 ≡ T2.
113 #L #T2 #i #H
114 elim (cpqs_inv_atom1 … H) -H /2 width=1/
115 * #K #V #V2 #j #HLK #HV2 #HVT2 #H destruct /3 width=6/
116 qed-.
117
118 lemma cpqs_inv_gref1: ∀L,T2,p. L ⊢ §p ➤* T2 → T2 = §p.
119 #L #T2 #p #H
120 elim (cpqs_inv_atom1 … H) -H //
121 * #K #V #V2 #i #_ #_ #_ #H destruct
122 qed-.
123
124 fact cpqs_inv_bind1_aux: ∀L,U1,U2. L ⊢ U1 ➤* U2 →
125                          ∀a,I,V1,T1. U1 = ⓑ{a,I} V1. T1 → (
126                          ∃∃V2,T2. L ⊢ V1 ➤* V2 &
127                                   L. ⓑ{I} V1 ⊢ T1 ➤* T2 &
128                                   U2 = ⓑ{a,I} V2. T2
129                          ) ∨
130                          ∃∃T. L.ⓓV1 ⊢ T1 ➤* T & ⇧[0, 1] U2 ≡ T & a = true & I = Abbr.
131 #L #U1 #U2 * -L -U1 -U2
132 [ #I #L #b #J #W1 #U1 #H destruct
133 | #L #K #V #V2 #W2 #i #_ #_ #_ #b #J #W1 #U1 #H destruct
134 | #a #I #L #V1 #V2 #T1 #T2 #HV12 #HT12 #b #J #W1 #U1 #H destruct /3 width=5/
135 | #I #L #V1 #V2 #T1 #T2 #_ #_ #b #J #W1 #U1 #H destruct
136 | #L #V #T1 #T #T2 #HT1 #HT2 #b #J #W1 #U1 #H destruct /3 width=3/
137 | #L #V #T1 #T2 #_ #b #J #W1 #U1 #H destruct
138 ]
139 qed-.
140
141 lemma cpqs_inv_bind1: ∀a,I,L,V1,T1,U2. L ⊢ ⓑ{a,I} V1. T1 ➤* U2 → (
142                       ∃∃V2,T2. L ⊢ V1 ➤* V2 &
143                                L. ⓑ{I} V1 ⊢ T1 ➤* T2 &
144                                U2 = ⓑ{a,I} V2. T2
145                       ) ∨
146                       ∃∃T. L.ⓓV1 ⊢ T1 ➤* T & ⇧[0, 1] U2 ≡ T & a = true & I = Abbr.
147 /2 width=3 by cpqs_inv_bind1_aux/ qed-.
148
149 lemma cpqs_inv_abbr1: ∀a,L,V1,T1,U2. L ⊢ ⓓ{a} V1. T1 ➤* U2 → (
150                       ∃∃V2,T2. L ⊢ V1 ➤* V2 &
151                                L. ⓓ V1 ⊢ T1 ➤* T2 &
152                                U2 = ⓓ{a} V2. T2
153                       ) ∨
154                       ∃∃T. L.ⓓV1 ⊢ T1 ➤* T & ⇧[0, 1] U2 ≡ T & a = true.
155 #a #L #V1 #T1 #U2 #H
156 elim (cpqs_inv_bind1 … H) -H * /3 width=3/ /3 width=5/
157 qed-.
158
159 lemma cpqs_inv_abst1: ∀a,L,V1,T1,U2. L ⊢ ⓛ{a} V1. T1 ➤* U2 →
160                       ∃∃V2,T2. L ⊢ V1 ➤* V2 &
161                                L. ⓛ V1 ⊢ T1 ➤* T2 &
162                                U2 = ⓛ{a} V2. T2.
163 #a #L #V1 #T1 #U2 #H
164 elim (cpqs_inv_bind1 … H) -H *
165 [ /3 width=5/
166 | #T #_ #_ #_ #H destruct
167 ]
168 qed-.
169
170 fact cpqs_inv_flat1_aux: ∀L,U1,U2. L ⊢ U1 ➤* U2 →
171                          ∀I,V1,T1. U1 = ⓕ{I} V1. T1 → (
172                          ∃∃V2,T2. L ⊢ V1 ➤* V2 & L ⊢ T1 ➤* T2 &
173                                   U2 = ⓕ{I} V2. T2
174                          ) ∨
175                          (L ⊢ T1 ➤* U2 ∧ I = Cast).
176 #L #U1 #U2 * -L -U1 -U2
177 [ #I #L #J #W1 #U1 #H destruct
178 | #L #K #V #V2 #W2 #i #_ #_ #_ #J #W1 #U1 #H destruct
179 | #a #I #L #V1 #V2 #T1 #T2 #_ #_ #J #W1 #U1 #H destruct
180 | #I #L #V1 #V2 #T1 #T2 #HV12 #HT12 #J #W1 #U1 #H destruct /3 width=5/
181 | #L #V #T1 #T #T2 #_ #_ #J #W1 #U1 #H destruct
182 | #L #V #T1 #T2 #HT12 #J #W1 #U1 #H destruct /3 width=1/
183 ]
184 qed-.
185
186 lemma cpqs_inv_flat1: ∀I,L,V1,T1,U2. L ⊢ ⓕ{I} V1. T1 ➤* U2 → (
187                       ∃∃V2,T2. L ⊢ V1 ➤* V2 & L ⊢ T1 ➤* T2 &
188                                U2 = ⓕ{I} V2. T2
189                       ) ∨
190                       (L ⊢ T1 ➤* U2 ∧ I = Cast).
191 /2 width=3 by cpqs_inv_flat1_aux/ qed-.
192
193 lemma cpqs_inv_appl1: ∀L,V1,T1,U2. L ⊢ ⓐ V1. T1 ➤* U2 →
194                       ∃∃V2,T2. L ⊢ V1 ➤* V2 & L ⊢ T1 ➤* T2 &
195                                U2 = ⓐ V2. T2.
196 #L #V1 #T1 #U2 #H elim (cpqs_inv_flat1 … H) -H *
197 [ /3 width=5/
198 | #_ #H destruct
199 ]
200 qed-.
201
202 lemma cpqs_inv_cast1: ∀L,V1,T1,U2. L ⊢ ⓝ V1. T1 ➤* U2 → (
203                       ∃∃V2,T2. L ⊢ V1 ➤* V2 & L ⊢ T1 ➤* T2 &
204                                U2 = ⓝ V2. T2
205                       ) ∨
206                       L ⊢ T1 ➤* U2.
207 #L #V1 #T1 #U2 #H elim (cpqs_inv_flat1 … H) -H * /2 width=1/ /3 width=5/
208 qed-.
209
210 (* Basic forward lemmas *****************************************************)
211
212 lemma cpqs_fwd_shift1: ∀L1,L,T1,T. L ⊢ L1 @@ T1 ➤* T →
213                        ∃∃L2,T2. |L1| = |L2| & T = L2 @@ T2.
214 #L1 @(lenv_ind_dx … L1) -L1 normalize
215 [ #L #T1 #T #HT1
216   @(ex2_2_intro … (⋆)) // (**) (* explicit constructor *)
217 | #I #L1 #V1 #IH #L #T1 #X
218   >shift_append_assoc normalize #H
219   elim (cpqs_inv_bind1 … H) -H *
220   [ #V0 #T0 #_ #HT10 #H destruct
221     elim (IH … HT10) -IH -HT10 #L2 #T2 #HL12 #H destruct
222     >append_length >HL12 -HL12
223     @(ex2_2_intro … (⋆.ⓑ{I}V0@@L2) T2) [ >append_length ] // /2 width=3/ (**) (* explicit constructor *)
224   | #T #_ #_ #H destruct
225   ]
226 ]
227 qed-.