]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/computation/cpxs.ma
- name changes in the rediction rules
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / computation / cpxs.ma
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 include "basic_2/notation/relations/predstar_6.ma".
16 include "basic_2/reduction/cnx.ma".
17 include "basic_2/computation/cprs.ma".
18
19 (* CONTEXT-SENSITIVE EXTENDED PARALLEL COMPUTATION ON TERMS *****************)
20
21 definition cpxs: ∀h. sd h → relation4 genv lenv term term ≝
22                  λh,g,G. LTC … (cpx h g G).
23
24 interpretation "extended context-sensitive parallel computation (term)"
25    'PRedStar h g G L T1 T2 = (cpxs h g G L T1 T2).
26
27 (* Basic eliminators ********************************************************)
28
29 lemma cpxs_ind: ∀h,g,G,L,T1. ∀R:predicate term. R T1 →
30                 (∀T,T2. ⦃G, L⦄ ⊢ T1 ➡*[h, g] T → ⦃G, L⦄ ⊢ T ➡[h, g] T2 → R T → R T2) →
31                 ∀T2. ⦃G, L⦄ ⊢ T1 ➡*[h, g] T2 → R T2.
32 #h #g #L #G #T1 #R #HT1 #IHT1 #T2 #HT12
33 @(TC_star_ind … HT1 IHT1 … HT12) //
34 qed-.
35
36 lemma cpxs_ind_dx: ∀h,g,G,L,T2. ∀R:predicate term. R T2 →
37                    (∀T1,T. ⦃G, L⦄ ⊢ T1 ➡[h, g] T → ⦃G, L⦄ ⊢ T ➡*[h, g] T2 → R T → R T1) →
38                    ∀T1. ⦃G, L⦄ ⊢ T1 ➡*[h, g] T2 → R T1.
39 #h #g #G #L #T2 #R #HT2 #IHT2 #T1 #HT12
40 @(TC_star_ind_dx … HT2 IHT2 … HT12) //
41 qed-.
42
43 (* Basic properties *********************************************************)
44
45 lemma cpxs_refl: ∀h,g,G,L,T. ⦃G, L⦄ ⊢ T ➡*[h, g] T.
46 /2 width=1 by inj/ qed.
47
48 lemma cpx_cpxs: ∀h,g,G,L,T1,T2. ⦃G, L⦄ ⊢ T1 ➡[h, g] T2 → ⦃G, L⦄ ⊢ T1 ➡*[h, g] T2.
49 /2 width=1 by inj/ qed.
50
51 lemma cpxs_strap1: ∀h,g,G,L,T1,T. ⦃G, L⦄ ⊢ T1 ➡*[h, g] T →
52                    ∀T2. ⦃G, L⦄ ⊢ T ➡[h, g] T2 → ⦃G, L⦄ ⊢ T1 ➡*[h, g] T2.
53 normalize /2 width=3 by step/ qed.
54
55 lemma cpxs_strap2: ∀h,g,G,L,T1,T. ⦃G, L⦄ ⊢ T1 ➡[h, g] T →
56                    ∀T2. ⦃G, L⦄ ⊢ T ➡*[h, g] T2 → ⦃G, L⦄ ⊢ T1 ➡*[h, g] T2.
57 normalize /2 width=3 by TC_strap/ qed.
58
59 lemma lsubr_cpxs_trans: ∀h,g,G. lsub_trans … (cpxs h g G) lsubr.
60 /3 width=5 by lsubr_cpx_trans, LTC_lsub_trans/
61 qed-.
62
63 lemma cprs_cpxs: ∀h,g,G,L,T1,T2. ⦃G, L⦄ ⊢ T1 ➡* T2 → ⦃G, L⦄ ⊢ T1 ➡*[h, g] T2.
64 #h #g #G #L #T1 #T2 #H @(cprs_ind … H) -T2 /3 width=3 by cpxs_strap1, cpr_cpx/
65 qed.
66
67 lemma cpxs_bind_dx: ∀h,g,G,L,V1,V2. ⦃G, L⦄ ⊢ V1 ➡[h, g] V2 →
68                     ∀I,T1,T2. ⦃G, L. ⓑ{I}V1⦄ ⊢ T1 ➡*[h, g] T2 →
69                     ∀a. ⦃G, L⦄ ⊢ ⓑ{a,I}V1.T1 ➡*[h, g] ⓑ{a,I}V2.T2.
70 #h #g #G #L #V1 #V2 #HV12 #I #T1 #T2 #HT12 #a @(cpxs_ind_dx … HT12) -T1
71 /3 width=3 by cpxs_strap2, cpx_cpxs, cpx_pair_sn, cpx_bind/
72 qed.
73
74 lemma cpxs_flat_dx: ∀h,g,G,L,V1,V2. ⦃G, L⦄ ⊢ V1 ➡[h, g] V2 →
75                     ∀T1,T2. ⦃G, L⦄ ⊢ T1 ➡*[h, g] T2 →
76                     ∀I. ⦃G, L⦄ ⊢ ⓕ{I}V1.T1 ➡*[h, g] ⓕ{I}V2.T2.
77 #h #g #G #L #V1 #V2 #HV12 #T1 #T2 #HT12 @(cpxs_ind … HT12) -T2
78 /3 width=5 by cpxs_strap1, cpx_cpxs, cpx_pair_sn, cpx_flat/
79 qed.
80
81 lemma cpxs_flat_sn: ∀h,g,G,L,T1,T2. ⦃G, L⦄ ⊢ T1 ➡[h, g] T2 →
82                     ∀V1,V2. ⦃G, L⦄ ⊢ V1 ➡*[h, g] V2 →
83                     ∀I. ⦃G, L⦄ ⊢ ⓕ{I}V1.T1 ➡*[h, g] ⓕ{I}V2.T2.
84 #h #g #G #L #T1 #T2 #HT12 #V1 #V2 #H @(cpxs_ind … H) -V2
85 /3 width=5 by cpxs_strap1, cpx_cpxs, cpx_pair_sn, cpx_flat/
86 qed.
87
88 lemma cpxs_pair_sn: ∀h,g,I,G,L,V1,V2. ⦃G, L⦄ ⊢ V1 ➡*[h, g] V2 →
89                     ∀T. ⦃G, L⦄ ⊢ ②{I}V1.T ➡*[h, g] ②{I}V2.T.
90 #h #g #I #G #L #V1 #V2 #H @(cpxs_ind … H) -V2
91 /3 width=3 by cpxs_strap1, cpx_pair_sn/
92 qed.
93
94 lemma cpxs_zeta: ∀h,g,G,L,V,T1,T,T2. ⇧[0, 1] T2 ≡ T →
95                  ⦃G, L.ⓓV⦄ ⊢ T1 ➡*[h, g] T → ⦃G, L⦄ ⊢ +ⓓV.T1 ➡*[h, g] T2.
96 #h #g #G #L #V #T1 #T #T2 #HT2 #H @(cpxs_ind_dx … H) -T1
97 /3 width=3 by cpxs_strap2, cpx_cpxs, cpx_bind, cpx_zeta/
98 qed.
99
100 lemma cpxs_eps: ∀h,g,G,L,T1,T2. ⦃G, L⦄ ⊢ T1 ➡*[h, g] T2 →
101                 ∀V. ⦃G, L⦄ ⊢ ⓝV.T1 ➡*[h, g] T2.
102 #h #g #G #L #T1 #T2 #H @(cpxs_ind … H) -T2
103 /3 width=3 by cpxs_strap1, cpx_cpxs, cpx_eps/
104 qed.
105
106 lemma cpxs_ct: ∀h,g,G,L,V1,V2. ⦃G, L⦄ ⊢ V1 ➡*[h, g] V2 →
107                ∀T. ⦃G, L⦄ ⊢ ⓝV1.T ➡*[h, g] V2.
108 #h #g #G #L #V1 #V2 #H @(cpxs_ind … H) -V2
109 /3 width=3 by cpxs_strap1, cpx_cpxs, cpx_ct/
110 qed.
111
112 lemma cpxs_beta_dx: ∀h,g,a,G,L,V1,V2,W1,W2,T1,T2.
113                     ⦃G, L⦄ ⊢ V1 ➡[h, g] V2 → ⦃G, L.ⓛW1⦄ ⊢ T1 ➡*[h, g] T2 → ⦃G, L⦄ ⊢ W1 ➡[h, g] W2 →
114                     ⦃G, L⦄ ⊢ ⓐV1.ⓛ{a}W1.T1 ➡*[h, g] ⓓ{a}ⓝW2.V2.T2.
115 #h #g #a #G #L #V1 #V2 #W1 #W2 #T1 #T2 #HV12 * -T2
116 /4 width=7 by cpx_cpxs, cpxs_strap1, cpxs_bind_dx, cpxs_flat_dx, cpx_beta/
117 qed.
118
119 lemma cpxs_theta_dx: ∀h,g,a,G,L,V1,V,V2,W1,W2,T1,T2.
120                      ⦃G, L⦄ ⊢ V1 ➡[h, g] V → ⇧[0, 1] V ≡ V2 → ⦃G, L.ⓓW1⦄ ⊢ T1 ➡*[h, g] T2 →
121                      ⦃G, L⦄ ⊢ W1 ➡[h, g] W2 → ⦃G, L⦄ ⊢ ⓐV1.ⓓ{a}W1.T1 ➡*[h, g] ⓓ{a}W2.ⓐV2.T2.
122 #h #g #a #G #L #V1 #V #V2 #W1 #W2 #T1 #T2 #HV1 #HV2 * -T2 
123 /4 width=9 by cpx_cpxs, cpxs_strap1, cpxs_bind_dx, cpxs_flat_dx, cpx_theta/
124 qed.
125
126 (* Basic inversion lemmas ***************************************************)
127
128 lemma cpxs_inv_sort1: ∀h,g,G,L,U2,k. ⦃G, L⦄ ⊢ ⋆k ➡*[h, g] U2 →
129                       ∃∃n,l. deg h g k (n+l) & U2 = ⋆((next h)^n k).
130 #h #g #G #L #U2 #k #H @(cpxs_ind … H) -U2
131 [ elim (deg_total h g k) #l #Hkl
132   @(ex2_2_intro … 0 … Hkl) -Hkl //
133 | #U #U2 #_ #HU2 * #n #l #Hknl #H destruct
134   elim (cpx_inv_sort1 … HU2) -HU2
135   [ #H destruct /2 width=4 by ex2_2_intro/
136   | * #l0 #Hkl0 #H destruct -l
137     @(ex2_2_intro … (n+1) l0) /2 width=1 by deg_inv_prec/ >iter_SO //
138   ]
139 ]
140 qed-.
141
142 lemma cpxs_inv_cast1: ∀h,g,G,L,W1,T1,U2. ⦃G, L⦄ ⊢ ⓝW1.T1 ➡*[h, g] U2 →
143                       ∨∨ ∃∃W2,T2. ⦃G, L⦄ ⊢ W1 ➡*[h, g] W2 & ⦃G, L⦄ ⊢ T1 ➡*[h, g] T2 & U2 = ⓝW2.T2
144                        | ⦃G, L⦄ ⊢ T1 ➡*[h, g] U2
145                        | ⦃G, L⦄ ⊢ W1 ➡*[h, g] U2.
146 #h #g #G #L #W1 #T1 #U2 #H @(cpxs_ind … H) -U2 /3 width=5 by or3_intro0, ex3_2_intro/
147 #U2 #U #_ #HU2 * /3 width=3 by cpxs_strap1, or3_intro1, or3_intro2/ *
148 #W #T #HW1 #HT1 #H destruct
149 elim (cpx_inv_cast1 … HU2) -HU2 /3 width=3 by cpxs_strap1, or3_intro1, or3_intro2/ *
150 #W2 #T2 #HW2 #HT2 #H destruct
151 lapply (cpxs_strap1 … HW1 … HW2) -W
152 lapply (cpxs_strap1 … HT1 … HT2) -T /3 width=5 by or3_intro0, ex3_2_intro/
153 qed-.
154
155 lemma cpxs_inv_cnx1: ∀h,g,G,L,T,U. ⦃G, L⦄ ⊢ T ➡*[h, g] U → ⦃G, L⦄ ⊢ ➡[h, g] 𝐍⦃T⦄ → T = U.
156 #h #g #G #L #T #U #H @(cpxs_ind_dx … H) -T //
157 #T0 #T #H1T0 #_ #IHT #H2T0
158 lapply (H2T0 … H1T0) -H1T0 #H destruct /2 width=1 by/
159 qed-.
160
161 lemma cpxs_neq_inv_step_sn: ∀h,g,G,L,T1,T2. ⦃G, L⦄ ⊢ T1 ➡*[h, g] T2 → (T1 = T2 → ⊥) →
162                             ∃∃T. ⦃G, L⦄ ⊢ T1 ➡[h, g] T & T1 = T → ⊥ & ⦃G, L⦄ ⊢ T ➡*[h, g] T2.
163 #h #g #G #L #T1 #T2 #H @(cpxs_ind_dx … H) -T1
164 [ #H elim H -H //
165 | #T1 #T #H1 #H2 #IH2 #H12 elim (eq_term_dec T1 T) #H destruct
166   [ -H1 -H2 /3 width=1 by/
167   | -IH2 /3 width=4 by ex3_intro/ (**) (* auto fails without clear *)
168   ]
169 ]
170 qed-.