]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/computation/cpxs.ma
- partial commit :(
[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/reduction/cpx.ma".
16 include "basic_2/computation/cprs.ma".
17
18 (* EXTENDED CONTEXT-SENSITIVE PARALLEL COMPUTATION ON TERMS *****************)
19
20 definition cpxs: ∀h. sd h → lenv → relation term ≝
21                  λh,g. LTC … (cpx h g).
22
23 interpretation "extended context-sensitive parallel computation (term)"
24    'PRedStar h g L T1 T2 = (cpxs h g L T1 T2).
25
26 (* Basic eliminators ********************************************************)
27
28 lemma cpxs_ind: ∀h,g,L,T1. ∀R:predicate term. R T1 →
29                 (∀T,T2. ⦃h, L⦄ ⊢ T1 ➡*[g] T → ⦃h, L⦄ ⊢ T ➡[g] T2 → R T → R T2) →
30                 ∀T2. ⦃h, L⦄ ⊢ T1 ➡*[g] T2 → R T2.
31 #h #g #L #T1 #R #HT1 #IHT1 #T2 #HT12
32 @(TC_star_ind … HT1 IHT1 … HT12) //
33 qed-.
34
35 lemma cpxs_ind_dx: ∀h,g,L,T2. ∀R:predicate term. R T2 →
36                    (∀T1,T. ⦃h, L⦄ ⊢ T1 ➡[g] T → ⦃h, L⦄ ⊢ T ➡*[g] T2 → R T → R T1) →
37                    ∀T1. ⦃h, L⦄ ⊢ T1 ➡*[g] T2 → R T1.
38 #h #g #L #T2 #R #HT2 #IHT2 #T1 #HT12
39 @(TC_star_ind_dx … HT2 IHT2 … HT12) //
40 qed-.
41
42 (* Basic properties *********************************************************)
43
44 lemma cpxs_refl: ∀h,g,L,T. ⦃h, L⦄ ⊢ T ➡*[g] T.
45 /2 width=1/ qed.
46
47 lemma cpx_cpxs: ∀h,g,L,T1,T2. ⦃h, L⦄ ⊢ T1 ➡[g] T2 → ⦃h, L⦄ ⊢ T1 ➡*[g] T2.
48 /2 width=1/ qed.
49
50 lemma cpxs_strap1: ∀h,g,L,T1,T. ⦃h, L⦄ ⊢ T1 ➡*[g] T →
51                    ∀T2. ⦃h, L⦄ ⊢ T ➡[g] T2 → ⦃h, L⦄ ⊢ T1 ➡*[g] T2.
52 normalize /2 width=3/ qed.
53
54 lemma cpxs_strap2: ∀h,g,L,T1,T. ⦃h, L⦄ ⊢ T1 ➡[g] T →
55                    ∀T2. ⦃h, L⦄ ⊢ T ➡*[g] T2 → ⦃h, L⦄ ⊢ T1 ➡*[g] T2.
56 normalize /2 width=3/ qed.
57
58 lemma cprs_cpxs: ∀h,g,L,T1,T2. L ⊢ T1 ➡* T2 → ⦃h, L⦄ ⊢ T1 ➡*[g] T2.
59 #h #g #L #T1 #T2 #H @(cprs_ind … H) -T2 // /3 width=3/
60 qed.
61
62 lemma cpxs_bind_dx: ∀h,g,L,V1,V2. ⦃h, L⦄ ⊢ V1 ➡[g] V2 →
63                     ∀I,T1,T2. ⦃h, L. ⓑ{I}V1⦄ ⊢ T1 ➡*[g] T2 →
64                     ∀a. ⦃h, L⦄ ⊢ ⓑ{a,I}V1.T1 ➡*[g] ⓑ{a,I}V2.T2.
65 #h #g #L #V1 #V2 #HV12 #I #T1 #T2 #HT12 #a @(cpxs_ind_dx … HT12) -T1
66 /3 width=1/ /3 width=3/
67 qed.
68
69 lemma cpxs_flat_dx: ∀h,g,L,V1,V2. ⦃h, L⦄ ⊢ V1 ➡[g] V2 →
70                     ∀T1,T2. ⦃h, L⦄ ⊢ T1 ➡*[g] T2 →
71                     ∀I. ⦃h, L⦄ ⊢ ⓕ{I} V1. T1 ➡*[g] ⓕ{I} V2. T2.
72 #h #g #L #V1 #V2 #HV12 #T1 #T2 #HT12 @(cpxs_ind … HT12) -T2 /3 width=1/ /3 width=5/
73 qed.
74
75 lemma cpxs_flat_sn: ∀h,g,L,T1,T2. ⦃h, L⦄ ⊢ T1 ➡[g] T2 →
76                     ∀V1,V2. ⦃h, L⦄ ⊢ V1 ➡*[g] V2 →
77                     ∀I. ⦃h, L⦄ ⊢ ⓕ{I} V1. T1 ➡*[g] ⓕ{I} V2. T2.
78 #h #g #L #T1 #T2 #HT12 #V1 #V2 #H @(cpxs_ind … H) -V2 /3 width=1/ /3 width=5/
79 qed.
80
81 lemma cpxs_zeta: ∀h,g,L,V,T1,T,T2. ⇧[0, 1] T2 ≡ T →
82                  ⦃h, L.ⓓV⦄ ⊢ T1 ➡*[g] T → ⦃h, L⦄ ⊢ +ⓓV.T1 ➡*[g] T2.
83 #h #g #L #V #T1 #T #T2 #HT2 #H @(TC_ind_dx … T1 H) -T1 /3 width=3/
84 qed.
85
86 lemma cpxs_tau: ∀h,g,L,T1,T2. ⦃h, L⦄ ⊢ T1 ➡*[g] T2 → ∀V. ⦃h, L⦄ ⊢ ⓝV.T1 ➡*[g] T2.
87 #h #g #L #T1 #T2 #H elim H -T2 /2 width=3/ /3 width=1/
88 qed.
89
90 lemma cpxs_beta_dx: ∀h,g,a,L,V1,V2,W,T1,T2.
91                     ⦃h, L⦄ ⊢ V1 ➡[g] V2 → ⦃h, L.ⓛW⦄ ⊢ T1 ➡*[g] T2 →
92                     ⦃h, L⦄ ⊢ ⓐV1.ⓛ{a}W.T1 ➡*[g] ⓓ{a}V2.T2.
93 #h #g #a #L #V1 #V2 #W #T1 #T2 #HV12 * -T2 /3 width=1/
94 /4 width=6 by cpxs_strap1, cpxs_bind_dx, cpxs_flat_dx, cpx_beta/ (**) (* auto too slow without trace *)
95 qed.
96
97 lemma cpxs_theta_dx: ∀h,g,a,L,V1,V,V2,W1,W2,T1,T2.
98                      ⦃h, L⦄ ⊢ V1 ➡[g] V → ⇧[0, 1] V ≡ V2 → ⦃h, L.ⓓW1⦄ ⊢ T1 ➡*[g] T2 →
99                      ⦃h, L⦄ ⊢ W1 ➡[g] W2 → ⦃h, L⦄ ⊢ ⓐV1.ⓓ{a}W1.T1 ➡*[g] ⓓ{a}W2.ⓐV2.T2.
100 #h #g #a #L #V1 #V #V2 #W1 #W2 #T1 #T2 #HV1 #HV2 * -T2 [ /3 width=3/ ]
101 /4 width=9 by cpxs_strap1, cpxs_bind_dx, cpxs_flat_dx, cpx_theta/ (**) (* auto too slow without trace *)
102 qed.
103
104 (* Basic inversion lemmas ***************************************************)
105
106 lemma cpxs_inv_sort1: ∀h,g,L,U2,k. ⦃h, L⦄ ⊢ ⋆k ➡*[g] U2 →
107                       ∃∃n,l. deg h g k (n+l) & U2 = ⋆((next h)^n k).
108 #h #g #L #U2 #k #H @(cpxs_ind … H) -U2
109 [ elim (deg_total h g k) #l #Hkl
110   @(ex2_2_intro … 0 … Hkl) -Hkl //
111 | #U #U2 #_ #HU2 * #n #l #Hknl #H destruct
112   elim (cpx_inv_sort1 … HU2) -HU2
113   [ #H destruct /2 width=4/
114   | * #l0 #Hkl0 #H destruct -l
115     @(ex2_2_intro … (n+1) l0) /2 width=1/ >iter_SO //
116   ]
117 ]
118 qed-.
119
120 lemma cpxs_inv_appl1: ∀h,g,L,V1,T1,U2. ⦃h, L⦄ ⊢ ⓐV1.T1 ➡*[g] U2 →
121                       ∨∨ ∃∃V2,T2.       ⦃h, L⦄ ⊢ V1 ➡*[g] V2 & ⦃h, L⦄ ⊢ T1 ➡*[g] T2 &
122                                         U2 = ⓐV2. T2
123                        | ∃∃a,V2,W,T.    ⦃h, L⦄ ⊢ V1 ➡*[g] V2 &
124                                         ⦃h, L⦄ ⊢ T1 ➡*[g] ⓛ{a}W.T & ⦃h, L⦄ ⊢ ⓓ{a}V2.T ➡*[g] U2
125                        | ∃∃a,V0,V2,V,T. ⦃h, L⦄ ⊢ V1 ➡*[g] V0 & ⇧[0,1] V0 ≡ V2 &
126                                         ⦃h, L⦄ ⊢ T1 ➡*[g] ⓓ{a}V.T & ⦃h, L⦄ ⊢ ⓓ{a}V.ⓐV2.T ➡*[g] U2.
127 #h #g #L #V1 #T1 #U2 #H @(cpxs_ind … H) -U2 [ /3 width=5/ ]
128 #U #U2 #_ #HU2 * *
129 [ #V0 #T0 #HV10 #HT10 #H destruct
130   elim (cpx_inv_appl1 … HU2) -HU2 *
131   [ #V2 #T2 #HV02 #HT02 #H destruct /4 width=5/
132   | #a #V2 #W2 #T #T2 #HV02 #HT2 #H1 #H2 destruct
133     lapply (cpxs_strap1 … HV10 … HV02) -V0 /5 width=7/
134   | #a #V #V2 #W0 #W2 #T #T2 #HV0 #HV2 #HW02 #HT2 #H1 #H2 destruct
135     @or3_intro2 @(ex4_5_intro … HV2 HT10) /2 width=3/ /3 width=1/ (**) (* explicit constructor. /5 width=8/ is too slow because TC_transitive gets in the way *)
136   ]
137 | /4 width=9/
138 | /4 width=11/
139 ]
140 qed-.
141
142 lemma cpxs_inv_cast1: ∀h,g,L,W1,T1,U2. ⦃h, L⦄ ⊢ ⓝW1.T1 ➡*[g] U2 → ⦃h, L⦄ ⊢ T1 ➡*[g] U2 ∨
143                       ∃∃W2,T2. ⦃h, L⦄ ⊢ W1 ➡*[g] W2 & ⦃h, L⦄ ⊢ T1 ➡*[g] T2 & U2 = ⓝW2.T2.
144 #h #g #L #W1 #T1 #U2 #H @(cpxs_ind … H) -U2 /3 width=5/
145 #U2 #U #_ #HU2 * /3 width=3/ *
146 #W #T #HW1 #HT1 #H destruct
147 elim (cpx_inv_cast1 … HU2) -HU2 /3 width=3/ *
148 #W2 #T2 #HW2 #HT2 #H destruct /4 width=5/
149 qed-.