]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/rt_computation/cpms_cpms.ma
update in ground_2, static_2, basic_2
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / rt_computation / cpms_cpms.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 "ground_2/xoa/ex_3_5.ma".
16 include "ground_2/xoa/ex_5_7.ma".
17 include "basic_2/rt_transition/cpm_lsubr.ma".
18 include "basic_2/rt_computation/cpms_drops.ma".
19 include "basic_2/rt_computation/cprs.ma".
20
21 (* T-BOUND CONTEXT-SENSITIVE PARALLEL RT-COMPUTATION FOR TERMS **************)
22
23 (* Main properties **********************************************************)
24
25 (* Basic_2A1: includes: cprs_bind *)
26 theorem cpms_bind (n) (h) (G) (L):
27                   ∀I,V1,T1,T2. ⦃G,L.ⓑ{I}V1⦄ ⊢ T1 ➡*[n,h] T2 →
28                   ∀V2. ⦃G,L⦄ ⊢ V1 ➡*[h] V2 →
29                   ∀p. ⦃G,L⦄ ⊢ ⓑ{p,I}V1.T1 ➡*[n,h] ⓑ{p,I}V2.T2.
30 #n #h #G #L #I #V1 #T1 #T2 #HT12 #V2 #H @(cprs_ind_dx … H) -V2
31 [ /2 width=1 by cpms_bind_dx/
32 | #V #V2 #_ #HV2 #IH #p >(plus_n_O … n) -HT12
33   /3 width=3 by cpr_pair_sn, cpms_step_dx/
34 ]
35 qed.
36
37 theorem cpms_appl (n) (h) (G) (L):
38                   ∀T1,T2. ⦃G,L⦄ ⊢ T1 ➡*[n,h] T2 →
39                   ∀V1,V2. ⦃G,L⦄ ⊢ V1 ➡*[h] V2 →
40                   ⦃G,L⦄ ⊢ ⓐV1.T1 ➡*[n,h] ⓐV2.T2.
41 #n #h #G #L #T1 #T2 #HT12 #V1 #V2 #H @(cprs_ind_dx … H) -V2
42 [ /2 width=1 by cpms_appl_dx/
43 | #V #V2 #_ #HV2 #IH >(plus_n_O … n) -HT12
44   /3 width=3 by cpr_pair_sn, cpms_step_dx/
45 ]
46 qed.
47
48 (* Basic_2A1: includes: cprs_beta_rc *)
49 theorem cpms_beta_rc (n) (h) (G) (L):
50                      ∀V1,V2. ⦃G,L⦄ ⊢ V1 ➡[h] V2 →
51                      ∀W1,T1,T2. ⦃G,L.ⓛW1⦄ ⊢ T1 ➡*[n,h] T2 →
52                      ∀W2. ⦃G,L⦄ ⊢ W1 ➡*[h] W2 →
53                      ∀p. ⦃G,L⦄ ⊢ ⓐV1.ⓛ{p}W1.T1 ➡*[n,h] ⓓ{p}ⓝW2.V2.T2.
54 #n #h #G #L #V1 #V2 #HV12 #W1 #T1 #T2 #HT12 #W2 #H @(cprs_ind_dx … H) -W2
55 [ /2 width=1 by cpms_beta_dx/
56 | #W #W2 #_ #HW2 #IH #p >(plus_n_O … n) -HT12
57   /4 width=3 by cpr_pair_sn, cpms_step_dx/
58 ]
59 qed.
60
61 (* Basic_2A1: includes: cprs_beta *)
62 theorem cpms_beta (n) (h) (G) (L):
63                   ∀W1,T1,T2. ⦃G,L.ⓛW1⦄ ⊢ T1 ➡*[n,h] T2 →
64                   ∀W2. ⦃G,L⦄ ⊢ W1 ➡*[h] W2 →
65                   ∀V1,V2. ⦃G,L⦄ ⊢ V1 ➡*[h] V2 →
66                   ∀p. ⦃G,L⦄ ⊢ ⓐV1.ⓛ{p}W1.T1 ➡*[n,h] ⓓ{p}ⓝW2.V2.T2.
67 #n #h #G #L #W1 #T1 #T2 #HT12 #W2 #HW12 #V1 #V2 #H @(cprs_ind_dx … H) -V2
68 [ /2 width=1 by cpms_beta_rc/
69 | #V #V2 #_ #HV2 #IH #p >(plus_n_O … n) -HT12
70   /4 width=5 by cpms_step_dx, cpr_pair_sn, cpm_cast/
71 ]
72 qed.
73
74 (* Basic_2A1: includes: cprs_theta_rc *)
75 theorem cpms_theta_rc (n) (h) (G) (L):
76                       ∀V1,V. ⦃G,L⦄ ⊢ V1 ➡[h] V → ∀V2. ⇧*[1] V ≘ V2 →
77                       ∀W1,T1,T2. ⦃G,L.ⓓW1⦄ ⊢ T1 ➡*[n,h] T2 →
78                       ∀W2. ⦃G,L⦄ ⊢ W1 ➡*[h] W2 →
79                       ∀p. ⦃G,L⦄ ⊢ ⓐV1.ⓓ{p}W1.T1 ➡*[n,h] ⓓ{p}W2.ⓐV2.T2.
80 #n #h #G #L #V1 #V #HV1 #V2 #HV2 #W1 #T1 #T2 #HT12 #W2 #H @(cprs_ind_dx … H) -W2
81 [ /2 width=3 by cpms_theta_dx/
82 | #W #W2 #_ #HW2 #IH #p >(plus_n_O … n) -HT12
83   /3 width=3 by cpr_pair_sn, cpms_step_dx/
84 ]
85 qed.
86
87 (* Basic_2A1: includes: cprs_theta *)
88 theorem cpms_theta (n) (h) (G) (L):
89                    ∀V,V2. ⇧*[1] V ≘ V2 → ∀W1,W2. ⦃G,L⦄ ⊢ W1 ➡*[h] W2 →
90                    ∀T1,T2. ⦃G,L.ⓓW1⦄ ⊢ T1 ➡*[n,h] T2 →
91                    ∀V1. ⦃G,L⦄ ⊢ V1 ➡*[h] V →
92                    ∀p. ⦃G,L⦄ ⊢ ⓐV1.ⓓ{p}W1.T1 ➡*[n,h] ⓓ{p}W2.ⓐV2.T2.
93 #n #h #G #L #V #V2 #HV2 #W1 #W2 #HW12 #T1 #T2 #HT12 #V1 #H @(cprs_ind_sn … H) -V1
94 [ /2 width=3 by cpms_theta_rc/
95 | #V1 #V0 #HV10 #_ #IH #p >(plus_O_n … n) -HT12
96   /3 width=3 by cpr_pair_sn, cpms_step_sn/
97 ]
98 qed.
99
100 (* Basic_2A1: uses: lstas_scpds_trans scpds_strap2 *)
101 theorem cpms_trans (h) (G) (L):
102                    ∀n1,T1,T. ⦃G,L⦄ ⊢ T1 ➡*[n1,h] T →
103                    ∀n2,T2. ⦃G,L⦄ ⊢ T ➡*[n2,h] T2 → ⦃G,L⦄ ⊢ T1 ➡*[n1+n2,h] T2.
104 /2 width=3 by ltc_trans/ qed-.
105
106 (* Basic_2A1: uses: scpds_cprs_trans *)
107 theorem cpms_cprs_trans (n) (h) (G) (L):
108                         ∀T1,T. ⦃G,L⦄ ⊢ T1 ➡*[n,h] T →
109                         ∀T2. ⦃G,L⦄ ⊢ T ➡*[h] T2 → ⦃G,L⦄ ⊢ T1 ➡*[n,h] T2.
110 #n #h #G #L #T1 #T #HT1 #T2 #HT2 >(plus_n_O … n)
111 /2 width=3 by cpms_trans/ qed-.
112
113 (* Advanced inversion lemmas ************************************************)
114
115 lemma cpms_inv_appl_sn (n) (h) (G) (L):
116                        ∀V1,T1,X2. ⦃G,L⦄ ⊢ ⓐV1.T1 ➡*[n,h] X2 →
117                        ∨∨ ∃∃V2,T2.
118                             ⦃G,L⦄ ⊢ V1 ➡*[h] V2 & ⦃G,L⦄ ⊢ T1 ➡*[n,h] T2 &
119                             X2 = ⓐV2.T2
120                         | ∃∃n1,n2,p,W,T.
121                             ⦃G,L⦄ ⊢ T1 ➡*[n1,h] ⓛ{p}W.T & ⦃G,L⦄ ⊢ ⓓ{p}ⓝW.V1.T ➡*[n2,h] X2 &
122                             n1 + n2 = n
123                         | ∃∃n1,n2,p,V0,V2,V,T.
124                             ⦃G,L⦄ ⊢ V1 ➡*[h] V0 & ⇧*[1] V0 ≘ V2 &
125                             ⦃G,L⦄ ⊢ T1 ➡*[n1,h] ⓓ{p}V.T & ⦃G,L⦄ ⊢ ⓓ{p}V.ⓐV2.T ➡*[n2,h] X2 &
126                             n1 + n2 = n.
127 #n #h #G #L #V1 #T1 #U2 #H
128 @(cpms_ind_dx … H) -U2 /3 width=5 by or3_intro0, ex3_2_intro/
129 #n1 #n2 #U #U2 #_ * *
130 [ #V0 #T0 #HV10 #HT10 #H #HU2 destruct
131   elim (cpm_inv_appl1 … HU2) -HU2 *
132   [ #V2 #T2 #HV02 #HT02 #H destruct /4 width=5 by cpms_step_dx, or3_intro0, ex3_2_intro/
133   | #p #V2 #W #W2 #T #T2 #HV02 #HW2 #HT2 #H1 #H2 destruct
134     lapply (cprs_step_dx … HV10 … HV02) -V0 #HV12
135     lapply (lsubr_cpm_trans … HT2 (L.ⓓⓝW.V1) ?) -HT2
136     /5 width=8 by cprs_flat_dx, cpms_bind, cpm_cpms, lsubr_beta, ex3_5_intro, or3_intro1/
137   | #p #V #V2 #W0 #W2 #T #T2 #HV0 #HV2 #HW02 #HT2 #H1 #H2 destruct
138     /6 width=12 by cprs_step_dx, cpm_cpms, cpm_appl, cpm_bind, ex5_7_intro, or3_intro2/
139   ]
140 | #m1 #m2 #p #W #T #HT1 #HTU #H #HU2 destruct
141   lapply (cpms_step_dx … HTU … HU2) -U #H
142   @or3_intro1 @(ex3_5_intro … HT1 H) // (**) (* auto fails *)
143 | #m1 #m2 #p #V2 #W2 #V #T #HV12 #HVW2 #HT1 #HTU #H #HU2 destruct
144   lapply (cpms_step_dx … HTU … HU2) -U #H
145   @or3_intro2 @(ex5_7_intro … HV12 HVW2 HT1 H) // (**) (* auto fails *)
146 ]
147 qed-.
148
149 lemma cpms_inv_plus (h) (G) (L): ∀n1,n2,T1,T2. ⦃G,L⦄ ⊢ T1 ➡*[n1+n2,h] T2 →
150                                  ∃∃T. ⦃G,L⦄ ⊢ T1 ➡*[n1,h] T & ⦃G,L⦄ ⊢ T ➡*[n2,h] T2.
151 #h #G #L #n1 elim n1 -n1 /2 width=3 by ex2_intro/
152 #n1 #IH #n2 #T1 #T2 <plus_S1 #H
153 elim (cpms_inv_succ_sn … H) -H #T0 #HT10 #HT02
154 elim (IH … HT02) -IH -HT02 #T #HT0 #HT2
155 lapply (cpms_trans … HT10 … HT0) -T0 #HT1
156 /2 width=3 by ex2_intro/
157 qed-.
158
159 (* Advanced main properties *************************************************)
160
161 theorem cpms_cast (n) (h) (G) (L):
162                   ∀T1,T2. ⦃G,L⦄ ⊢ T1 ➡*[n,h] T2 →
163                   ∀U1,U2. ⦃G,L⦄ ⊢ U1 ➡*[n,h] U2 →
164                   ⦃G,L⦄ ⊢ ⓝU1.T1 ➡*[n,h] ⓝU2.T2.
165 #n #h #G #L #T1 #T2 #H @(cpms_ind_sn … H) -T1 -n
166 [ /3 width=3 by cpms_cast_sn/
167 | #n1 #n2 #T1 #T #HT1 #_ #IH #U1 #U2 #H
168   elim (cpms_inv_plus … H) -H #U #HU1 #HU2
169   /3 width=3 by cpms_trans, cpms_cast_sn/
170 ]
171 qed.
172
173 theorem cpms_trans_swap (h) (G) (L) (T1):
174         ∀n1,T. ⦃G,L⦄ ⊢ T1 ➡*[n1,h] T → ∀n2,T2. ⦃G,L⦄ ⊢ T ➡*[n2,h] T2 →
175         ∃∃T0. ⦃G,L⦄ ⊢ T1 ➡*[n2,h] T0 & ⦃G,L⦄ ⊢ T0 ➡*[n1,h] T2.
176 #h #G #L #T1 #n1 #T #HT1 #n2 #T2 #HT2
177 lapply (cpms_trans … HT1 … HT2) -T <commutative_plus #HT12
178 /2 width=1 by cpms_inv_plus/
179 qed-.