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 "basic_2/rt_computation/cpms_drops.ma".
16 include "basic_2/rt_computation/cprs.ma".
18 (* T-BOUND CONTEXT-SENSITIVE PARALLEL RT-COMPUTATION FOR TERMS **************)
20 (* Main properties **********************************************************)
22 (* Basic_2A1: uses: lstas_scpds_trans scpds_strap2 *)
23 theorem cpms_trans (h) (G) (L):
24 ∀n1,T1,T. ⦃G, L⦄ ⊢ T1 ➡*[n1, h] T →
25 ∀n2,T2. ⦃G, L⦄ ⊢ T ➡*[n2, h] T2 → ⦃G, L⦄ ⊢ T1 ➡*[n1+n2, h] T2.
26 /2 width=3 by ltc_trans/ qed-.
28 (* Basic_2A1: uses: scpds_cprs_trans *)
29 theorem cpms_cprs_trans (n) (h) (G) (L):
30 ∀T1,T. ⦃G, L⦄ ⊢ T1 ➡*[n, h] T →
31 ∀T2. ⦃G, L⦄ ⊢ T ➡*[h] T2 → ⦃G, L⦄ ⊢ T1 ➡*[n, h] T2.
32 #n #h #G #L #T1 #T #HT1 #T2 #HT2 >(plus_n_O … n)
33 /2 width=3 by cpms_trans/ qed-.
35 (* Basic_2A1: includes: cprs_bind *)
36 theorem cpms_bind (n) (h) (G) (L):
37 ∀I,V1,T1,T2. ⦃G, L.ⓑ{I}V1⦄ ⊢ T1 ➡*[n, h] T2 →
38 ∀V2. ⦃G, L⦄ ⊢ V1 ➡*[h] V2 →
39 ∀p. ⦃G, L⦄ ⊢ ⓑ{p,I}V1.T1 ➡*[n, h] ⓑ{p,I}V2.T2.
40 #n #h #G #L #I #V1 #T1 #T2 #HT12 #V2 #H @(cprs_ind_dx … H) -V2
41 [ /2 width=1 by cpms_bind_dx/
42 | #V #V2 #_ #HV2 #IH #p >(plus_n_O … n) -HT12
43 /3 width=3 by cpr_pair_sn, cpms_step_dx/
47 theorem cpms_appl (n) (h) (G) (L):
48 ∀T1,T2. ⦃G, L⦄ ⊢ T1 ➡*[n, h] T2 →
49 ∀V1,V2. ⦃G, L⦄ ⊢ V1 ➡*[h] V2 →
50 ⦃G, L⦄ ⊢ ⓐV1.T1 ➡*[n, h] ⓐV2.T2.
51 #n #h #G #L #T1 #T2 #HT12 #V1 #V2 #H @(cprs_ind_dx … H) -V2
52 [ /2 width=1 by cpms_appl_dx/
53 | #V #V2 #_ #HV2 #IH >(plus_n_O … n) -HT12
54 /3 width=3 by cpr_pair_sn, cpms_step_dx/
58 lemma cpms_inv_plus (h) (G) (L): ∀n1,n2,T1,T2. ⦃G, L⦄ ⊢ T1 ➡*[n1+n2, h] T2 →
59 ∃∃T. ⦃G, L⦄ ⊢ T1 ➡*[n1, h] T & ⦃G, L⦄ ⊢ T ➡*[n2, h] T2.
60 #h #G #L #n1 elim n1 -n1 /2 width=3 by ex2_intro/
61 #n1 #IH #n2 #T1 #T2 <plus_S1 #H
62 elim (cpms_inv_succ_sn … H) -H #T0 #HT10 #HT02
63 elim (IH … HT02) -IH -HT02 #T #HT0 #HT2
64 lapply (cpms_trans … HT10 … HT0) -T0 #HT1
65 /2 width=3 by ex2_intro/
68 lemma cpms_cast (n) (h) (G) (L):
69 ∀T1,T2. ⦃G, L⦄ ⊢ T1 ➡*[n, h] T2 →
70 ∀U1,U2. ⦃G, L⦄ ⊢ U1 ➡*[n, h] U2 →
71 ⦃G, L⦄ ⊢ ⓝU1.T1 ➡*[n, h] ⓝU2.T2.
72 #n #h #G #L #T1 #T2 #H @(cpms_ind_sn … H) -T1 -n
73 [ /3 width=3 by cpms_cast_sn/
74 | #n1 #n2 #T1 #T #HT1 #_ #IH #U1 #U2 #H
75 elim (cpms_inv_plus … H) -H #U #HU1 #HU2
76 /3 width=3 by cpms_trans, cpms_cast_sn/
80 (* Basic_2A1: includes: cprs_beta_rc *)
81 theorem cpms_beta_rc (n) (h) (G) (L):
82 ∀V1,V2. ⦃G, L⦄ ⊢ V1 ➡[h] V2 →
83 ∀W1,T1,T2. ⦃G, L.ⓛW1⦄ ⊢ T1 ➡*[n, h] T2 →
84 ∀W2. ⦃G, L⦄ ⊢ W1 ➡*[h] W2 →
85 ∀p. ⦃G, L⦄ ⊢ ⓐV1.ⓛ{p}W1.T1 ➡*[n, h] ⓓ{p}ⓝW2.V2.T2.
86 #n #h #G #L #V1 #V2 #HV12 #W1 #T1 #T2 #HT12 #W2 #H @(cprs_ind_dx … H) -W2
87 [ /2 width=1 by cpms_beta_dx/
88 | #W #W2 #_ #HW2 #IH #p >(plus_n_O … n) -HT12
89 /4 width=3 by cpr_pair_sn, cpms_step_dx/
93 (* Basic_2A1: includes: cprs_beta *)
94 theorem cpms_beta (n) (h) (G) (L):
95 ∀W1,T1,T2. ⦃G, L.ⓛW1⦄ ⊢ T1 ➡*[n, h] T2 →
96 ∀W2. ⦃G, L⦄ ⊢ W1 ➡*[h] W2 →
97 ∀V1,V2. ⦃G, L⦄ ⊢ V1 ➡*[h] V2 →
98 ∀p. ⦃G, L⦄ ⊢ ⓐV1.ⓛ{p}W1.T1 ➡*[n, h] ⓓ{p}ⓝW2.V2.T2.
99 #n #h #G #L #W1 #T1 #T2 #HT12 #W2 #HW12 #V1 #V2 #H @(cprs_ind_dx … H) -V2
100 [ /2 width=1 by cpms_beta_rc/
101 | #V #V2 #_ #HV2 #IH #p >(plus_n_O … n) -HT12
102 /4 width=5 by cpms_step_dx, cpr_pair_sn, cpm_cast/
106 (* Basic_2A1: includes: cprs_theta_rc *)
107 theorem cpms_theta_rc (n) (h) (G) (L):
108 ∀V1,V. ⦃G, L⦄ ⊢ V1 ➡[h] V → ∀V2. ⬆*[1] V ≘ V2 →
109 ∀W1,T1,T2. ⦃G, L.ⓓW1⦄ ⊢ T1 ➡*[n, h] T2 →
110 ∀W2. ⦃G, L⦄ ⊢ W1 ➡*[h] W2 →
111 ∀p. ⦃G, L⦄ ⊢ ⓐV1.ⓓ{p}W1.T1 ➡*[n, h] ⓓ{p}W2.ⓐV2.T2.
112 #n #h #G #L #V1 #V #HV1 #V2 #HV2 #W1 #T1 #T2 #HT12 #W2 #H @(cprs_ind_dx … H) -W2
113 [ /2 width=3 by cpms_theta_dx/
114 | #W #W2 #_ #HW2 #IH #p >(plus_n_O … n) -HT12
115 /3 width=3 by cpr_pair_sn, cpms_step_dx/
119 (* Basic_2A1: includes: cprs_theta *)
120 theorem cpms_theta (n) (h) (G) (L):
121 ∀V,V2. ⬆*[1] V ≘ V2 → ∀W1,W2. ⦃G, L⦄ ⊢ W1 ➡*[h] W2 →
122 ∀T1,T2. ⦃G, L.ⓓW1⦄ ⊢ T1 ➡*[n, h] T2 →
123 ∀V1. ⦃G, L⦄ ⊢ V1 ➡*[h] V →
124 ∀p. ⦃G, L⦄ ⊢ ⓐV1.ⓓ{p}W1.T1 ➡*[n, h] ⓓ{p}W2.ⓐV2.T2.
125 #n #h #G #L #V #V2 #HV2 #W1 #W2 #HW12 #T1 #T2 #HT12 #V1 #H @(cprs_ind_sn … H) -V1
126 [ /2 width=3 by cpms_theta_rc/
127 | #V1 #V0 #HV10 #_ #IH #p >(plus_O_n … n) -HT12
128 /3 width=3 by cpr_pair_sn, cpms_step_sn/
132 (* Advanced inversion lemmas ************************************************)
134 (* Basic_1: was pr3_gen_appl *)
135 lemma cprs_inv_appl1: ∀G,L,V1,T1,U2. ⦃G, L⦄ ⊢ ⓐV1.T1 ➡* U2 →
136 ∨∨ ∃∃V2,T2. ⦃G, L⦄ ⊢ V1 ➡* V2 & ⦃G, L⦄ ⊢ T1 ➡* T2 &
138 | ∃∃a,W,T. ⦃G, L⦄ ⊢ T1 ➡* ⓛ{a}W.T &
139 ⦃G, L⦄ ⊢ ⓓ{a}ⓝW.V1.T ➡* U2
140 | ∃∃a,V0,V2,V,T. ⦃G, L⦄ ⊢ V1 ➡* V0 & ⬆[0,1] V0 ≘ V2 &
141 ⦃G, L⦄ ⊢ T1 ➡* ⓓ{a}V.T &
142 ⦃G, L⦄ ⊢ ⓓ{a}V.ⓐV2.T ➡* U2.
143 #G #L #V1 #T1 #U2 #H @(cprs_ind … H) -U2 /3 width=5 by or3_intro0, ex3_2_intro/
145 [ #V0 #T0 #HV10 #HT10 #H destruct
146 elim (cpr_inv_appl1 … HU2) -HU2 *
147 [ #V2 #T2 #HV02 #HT02 #H destruct /4 width=5 by cprs_strap1, or3_intro0, ex3_2_intro/
148 | #a #V2 #W #W2 #T #T2 #HV02 #HW2 #HT2 #H1 #H2 destruct
149 lapply (cprs_strap1 … HV10 … HV02) -V0 #HV12
150 lapply (lsubr_cpr_trans … HT2 (L.ⓓⓝW.V1) ?) -HT2
151 /5 width=5 by cprs_bind, cprs_flat_dx, cpr_cprs, lsubr_beta, ex2_3_intro, or3_intro1/
152 | #a #V #V2 #W0 #W2 #T #T2 #HV0 #HV2 #HW02 #HT2 #H1 #H2 destruct
153 /5 width=10 by cprs_flat_sn, cprs_bind_dx, cprs_strap1, ex4_5_intro, or3_intro2/
155 | /4 width=9 by cprs_strap1, or3_intro1, ex2_3_intro/
156 | /4 width=11 by cprs_strap1, or3_intro2, ex4_5_intro/
160 (* Advanced inversion lemmas ************************************************)
162 lemma scpds_inv_abst1: ∀h,o,a,G,L,V1,T1,U2,d. ⦃G, L⦄ ⊢ ⓛ{a}V1.T1 •*➡*[h, o, d] U2 →
163 ∃∃V2,T2. ⦃G, L⦄ ⊢ V1 ➡* V2 & ⦃G, L.ⓛV1⦄ ⊢ T1 •*➡*[h, o, d] T2 &
165 #h #o #a #G #L #V1 #T1 #U2 #d2 * #X #d1 #Hd21 #Hd1 #H1 #H2
166 lapply (da_inv_bind … Hd1) -Hd1 #Hd1
167 elim (lstas_inv_bind1 … H1) -H1 #U #HTU1 #H destruct
168 elim (cprs_inv_abst1 … H2) -H2 #V2 #T2 #HV12 #HUT2 #H destruct
169 /3 width=6 by ex4_2_intro, ex3_2_intro/
172 lemma scpds_inv_abbr_abst: ∀h,o,a1,a2,G,L,V1,W2,T1,T2,d. ⦃G, L⦄ ⊢ ⓓ{a1}V1.T1 •*➡*[h, o, d] ⓛ{a2}W2.T2 →
173 ∃∃T. ⦃G, L.ⓓV1⦄ ⊢ T1 •*➡*[h, o, d] T & ⬆[0, 1] ⓛ{a2}W2.T2 ≘ T & a1 = true.
174 #h #o #a1 #a2 #G #L #V1 #W2 #T1 #T2 #d2 * #X #d1 #Hd21 #Hd1 #H1 #H2
175 lapply (da_inv_bind … Hd1) -Hd1 #Hd1
176 elim (lstas_inv_bind1 … H1) -H1 #U1 #HTU1 #H destruct
177 elim (cprs_inv_abbr1 … H2) -H2 *
178 [ #V2 #U2 #HV12 #HU12 #H destruct
179 | /3 width=6 by ex4_2_intro, ex3_intro/
183 lemma scpds_inv_lstas_eq: ∀h,o,G,L,T1,T2,d. ⦃G, L⦄ ⊢ T1 •*➡*[h, o, d] T2 →
184 ∀T. ⦃G, L⦄ ⊢ T1 •*[h, d] T → ⦃G, L⦄ ⊢ T ➡* T2.
185 #h #o #G #L #T1 #T2 #d2 *
186 #T0 #d1 #_ #_ #HT10 #HT02 #T #HT1
187 lapply (lstas_mono … HT10 … HT1) #H destruct //
190 (* Main properties **********************************************************)
192 theorem scpds_conf_eq: ∀h,o,G,L,T0,T1,d. ⦃G, L⦄ ⊢ T0 •*➡*[h, o, d] T1 →
193 ∀T2. ⦃G, L⦄ ⊢ T0 •*➡*[h, o, d] T2 →
194 ∃∃T. ⦃G, L⦄ ⊢ T1 ➡* T & ⦃G, L⦄ ⊢ T2 ➡* T.
195 #h #o #G #L #T0 #T1 #d0 * #U1 #d1 #_ #_ #H1 #HUT1 #T2 * #U2 #d2 #_ #_ #H2 #HUT2 -d1 -d2
196 lapply (lstas_mono … H1 … H2) #H destruct -h -d0 /2 width=3 by cprs_conf/