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 "ground/xoa/ex_3_5.ma".
16 include "ground/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".
21 (* T-BOUND CONTEXT-SENSITIVE PARALLEL RT-COMPUTATION FOR TERMS **************)
23 (* Main properties **********************************************************)
25 (* Basic_2A1: includes: cprs_bind *)
26 theorem cpms_bind (h) (n) (G) (L):
27 ∀I,V1,T1,T2. ❪G,L.ⓑ[I]V1❫ ⊢ T1 ➡*[h,n] T2 →
28 ∀V2. ❪G,L❫ ⊢ V1 ➡*[h,0] V2 →
29 ∀p. ❪G,L❫ ⊢ ⓑ[p,I]V1.T1 ➡*[h,n] ⓑ[p,I]V2.T2.
30 #h #n #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/
37 theorem cpms_appl (h) (n) (G) (L):
38 ∀T1,T2. ❪G,L❫ ⊢ T1 ➡*[h,n] T2 →
39 ∀V1,V2. ❪G,L❫ ⊢ V1 ➡*[h,0] V2 →
40 ❪G,L❫ ⊢ ⓐV1.T1 ➡*[h,n] ⓐV2.T2.
41 #h #n #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/
48 (* Basic_2A1: includes: cprs_beta_rc *)
49 theorem cpms_beta_rc (h) (n) (G) (L):
50 ∀V1,V2. ❪G,L❫ ⊢ V1 ➡[h,0] V2 →
51 ∀W1,T1,T2. ❪G,L.ⓛW1❫ ⊢ T1 ➡*[h,n] T2 →
52 ∀W2. ❪G,L❫ ⊢ W1 ➡*[h,0] W2 →
53 ∀p. ❪G,L❫ ⊢ ⓐV1.ⓛ[p]W1.T1 ➡*[h,n] ⓓ[p]ⓝW2.V2.T2.
54 #h #n #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/
61 (* Basic_2A1: includes: cprs_beta *)
62 theorem cpms_beta (h) (n) (G) (L):
63 ∀W1,T1,T2. ❪G,L.ⓛW1❫ ⊢ T1 ➡*[h,n] T2 →
64 ∀W2. ❪G,L❫ ⊢ W1 ➡*[h,0] W2 →
65 ∀V1,V2. ❪G,L❫ ⊢ V1 ➡*[h,0] V2 →
66 ∀p. ❪G,L❫ ⊢ ⓐV1.ⓛ[p]W1.T1 ➡*[h,n] ⓓ[p]ⓝW2.V2.T2.
67 #h #n #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/
74 (* Basic_2A1: includes: cprs_theta_rc *)
75 theorem cpms_theta_rc (h) (n) (G) (L):
76 ∀V1,V. ❪G,L❫ ⊢ V1 ➡[h,0] V → ∀V2. ⇧[1] V ≘ V2 →
77 ∀W1,T1,T2. ❪G,L.ⓓW1❫ ⊢ T1 ➡*[h,n] T2 →
78 ∀W2. ❪G,L❫ ⊢ W1 ➡*[h,0] W2 →
79 ∀p. ❪G,L❫ ⊢ ⓐV1.ⓓ[p]W1.T1 ➡*[h,n] ⓓ[p]W2.ⓐV2.T2.
80 #h #n #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/
87 (* Basic_2A1: includes: cprs_theta *)
88 theorem cpms_theta (h) (n) (G) (L):
89 ∀V,V2. ⇧[1] V ≘ V2 → ∀W1,W2. ❪G,L❫ ⊢ W1 ➡*[h,0] W2 →
90 ∀T1,T2. ❪G,L.ⓓW1❫ ⊢ T1 ➡*[h,n] T2 →
91 ∀V1. ❪G,L❫ ⊢ V1 ➡*[h,0] V →
92 ∀p. ❪G,L❫ ⊢ ⓐV1.ⓓ[p]W1.T1 ➡*[h,n] ⓓ[p]W2.ⓐV2.T2.
93 #h #n #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/
100 (* Basic_2A1: uses: lstas_scpds_trans scpds_strap2 *)
101 theorem cpms_trans (h) (G) (L):
102 ∀n1,T1,T. ❪G,L❫ ⊢ T1 ➡*[h,n1] T →
103 ∀n2,T2. ❪G,L❫ ⊢ T ➡*[h,n2] T2 → ❪G,L❫ ⊢ T1 ➡*[h,n1+n2] T2.
104 /2 width=3 by ltc_trans/ qed-.
106 (* Basic_2A1: uses: scpds_cprs_trans *)
107 theorem cpms_cprs_trans (h) (n) (G) (L):
108 ∀T1,T. ❪G,L❫ ⊢ T1 ➡*[h,n] T →
109 ∀T2. ❪G,L❫ ⊢ T ➡*[h,0] T2 → ❪G,L❫ ⊢ T1 ➡*[h,n] T2.
110 #h #n #G #L #T1 #T #HT1 #T2 #HT2 >(plus_n_O … n)
111 /2 width=3 by cpms_trans/ qed-.
113 (* Advanced inversion lemmas ************************************************)
115 lemma cpms_inv_appl_sn (h) (n) (G) (L):
116 ∀V1,T1,X2. ❪G,L❫ ⊢ ⓐV1.T1 ➡*[h,n] X2 →
117 ∨∨ ∃∃V2,T2. ❪G,L❫ ⊢ V1 ➡*[h,0] V2 & ❪G,L❫ ⊢ T1 ➡*[h,n] T2 & X2 = ⓐV2.T2
118 | ∃∃n1,n2,p,W,T. ❪G,L❫ ⊢ T1 ➡*[h,n1] ⓛ[p]W.T & ❪G,L❫ ⊢ ⓓ[p]ⓝW.V1.T ➡*[h,n2] X2 & n1 + n2 = n
119 | ∃∃n1,n2,p,V0,V2,V,T. ❪G,L❫ ⊢ V1 ➡*[h,0] V0 & ⇧[1] V0 ≘ V2 & ❪G,L❫ ⊢ T1 ➡*[h,n1] ⓓ[p]V.T & ❪G,L❫ ⊢ ⓓ[p]V.ⓐV2.T ➡*[h,n2] X2 & n1 + n2 = n.
120 #h #n #G #L #V1 #T1 #U2 #H
121 @(cpms_ind_dx … H) -U2 /3 width=5 by or3_intro0, ex3_2_intro/
122 #n1 #n2 #U #U2 #_ * *
123 [ #V0 #T0 #HV10 #HT10 #H #HU2 destruct
124 elim (cpm_inv_appl1 … HU2) -HU2 *
125 [ #V2 #T2 #HV02 #HT02 #H destruct /4 width=5 by cpms_step_dx, or3_intro0, ex3_2_intro/
126 | #p #V2 #W #W2 #T #T2 #HV02 #HW2 #HT2 #H1 #H2 destruct
127 lapply (cprs_step_dx … HV10 … HV02) -V0 #HV12
128 lapply (lsubr_cpm_trans … HT2 (L.ⓓⓝW.V1) ?) -HT2
129 /5 width=8 by cprs_flat_dx, cpms_bind, cpm_cpms, lsubr_beta, ex3_5_intro, or3_intro1/
130 | #p #V #V2 #W0 #W2 #T #T2 #HV0 #HV2 #HW02 #HT2 #H1 #H2 destruct
131 /6 width=12 by cprs_step_dx, cpm_cpms, cpm_appl, cpm_bind, ex5_7_intro, or3_intro2/
133 | #m1 #m2 #p #W #T #HT1 #HTU #H #HU2 destruct
134 lapply (cpms_step_dx … HTU … HU2) -U #H
135 @or3_intro1 @(ex3_5_intro … HT1 H) // (**) (* auto fails *)
136 | #m1 #m2 #p #V2 #W2 #V #T #HV12 #HVW2 #HT1 #HTU #H #HU2 destruct
137 lapply (cpms_step_dx … HTU … HU2) -U #H
138 @or3_intro2 @(ex5_7_intro … HV12 HVW2 HT1 H) // (**) (* auto fails *)
142 lemma cpms_inv_plus (h) (G) (L):
143 ∀n1,n2,T1,T2. ❪G,L❫ ⊢ T1 ➡*[h,n1+n2] T2 →
144 ∃∃T. ❪G,L❫ ⊢ T1 ➡*[h,n1] T & ❪G,L❫ ⊢ T ➡*[h,n2] T2.
145 #h #G #L #n1 elim n1 -n1 /2 width=3 by ex2_intro/
146 #n1 #IH #n2 #T1 #T2 <plus_S1 #H
147 elim (cpms_inv_succ_sn … H) -H #T0 #HT10 #HT02
148 elim (IH … HT02) -IH -HT02 #T #HT0 #HT2
149 lapply (cpms_trans … HT10 … HT0) -T0 #HT1
150 /2 width=3 by ex2_intro/
153 (* Advanced main properties *************************************************)
155 theorem cpms_cast (h) (n) (G) (L):
156 ∀T1,T2. ❪G,L❫ ⊢ T1 ➡*[h,n] T2 →
157 ∀U1,U2. ❪G,L❫ ⊢ U1 ➡*[h,n] U2 →
158 ❪G,L❫ ⊢ ⓝU1.T1 ➡*[h,n] ⓝU2.T2.
159 #h #n #G #L #T1 #T2 #H @(cpms_ind_sn … H) -T1 -n
160 [ /3 width=3 by cpms_cast_sn/
161 | #n1 #n2 #T1 #T #HT1 #_ #IH #U1 #U2 #H
162 elim (cpms_inv_plus … H) -H #U #HU1 #HU2
163 /3 width=3 by cpms_trans, cpms_cast_sn/
167 theorem cpms_trans_swap (h) (G) (L) (T1):
168 ∀n1,T. ❪G,L❫ ⊢ T1 ➡*[h,n1] T → ∀n2,T2. ❪G,L❫ ⊢ T ➡*[h,n2] T2 →
169 ∃∃T0. ❪G,L❫ ⊢ T1 ➡*[h,n2] T0 & ❪G,L❫ ⊢ T0 ➡*[h,n1] T2.
170 #h #G #L #T1 #n1 #T #HT1 #n2 #T2 #HT2
171 lapply (cpms_trans … HT1 … HT2) -T <commutative_plus #HT12
172 /2 width=1 by cpms_inv_plus/