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