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/reducibility/ltpr_tpss.ma".
17 (* CONTEXT-FREE PARALLEL REDUCTION ON TERMS *********************************)
19 (* Confluence lemmas ********************************************************)
21 fact tpr_conf_atom_atom: ∀I. ∃∃X. ⓪{I} ➡ X & ⓪{I} ➡ X.
24 fact tpr_conf_flat_flat:
25 ∀I,V0,V1,T0,T1,V2,T2. (
26 ∀X0:term. ♯{X0} < ♯{V0} + ♯{T0} + 1 →
27 ∀X1,X2. X0 ➡ X1 → X0 ➡ X2 →
30 V0 ➡ V1 → V0 ➡ V2 → T0 ➡ T1 → T0 ➡ T2 →
31 ∃∃T0. ⓕ{I} V1. T1 ➡ T0 & ⓕ{I} V2. T2 ➡ T0.
32 #I #V0 #V1 #T0 #T1 #V2 #T2 #IH #HV01 #HV02 #HT01 #HT02
33 elim (IH … HV01 … HV02) -HV01 -HV02 // #V #HV1 #HV2
34 elim (IH … HT01 … HT02) -HT01 -HT02 -IH // /3 width=5/
37 fact tpr_conf_flat_beta:
38 ∀a,V0,V1,T1,V2,W0,U0,T2. (
39 ∀X0:term. ♯{X0} < ♯{V0} + (♯{W0} + ♯{U0} + 1) + 1 →
40 ∀X1,X2. X0 ➡ X1 → X0 ➡ X2 →
44 U0 ➡ T2 → ⓛ{a}W0. U0 ➡ T1 →
45 ∃∃X. ⓐV1. T1 ➡ X & ⓓ{a}V2. T2 ➡ X.
46 #a #V0 #V1 #T1 #V2 #W0 #U0 #T2 #IH #HV01 #HV02 #HT02 #H
47 elim (tpr_inv_abst1 … H) -H #W1 #U1 #HW01 #HU01 #H destruct
48 elim (IH … HV01 … HV02) -HV01 -HV02 /2 width=1/ #V #HV1 #HV2
49 elim (IH … HT02 … HU01) -HT02 -HU01 -IH /2 width=1/ /3 width=5/
53 pr0_cong_upsilon_refl pr0_cong_upsilon_zeta
54 pr0_cong_upsilon_cong pr0_cong_upsilon_delta
56 fact tpr_conf_flat_theta:
57 ∀a,V0,V1,T1,V2,V,W0,W2,U0,U2. (
58 ∀X0:term. ♯{X0} < ♯{V0} + (♯{W0} + ♯{U0} + 1) + 1 →
59 ∀X1,X2. X0 ➡ X1 → X0 ➡ X2 →
62 V0 ➡ V1 → V0 ➡ V2 → ⇧[O,1] V2 ≡ V →
63 W0 ➡ W2 → U0 ➡ U2 → ⓓ{a}W0. U0 ➡ T1 →
64 ∃∃X. ⓐV1. T1 ➡ X & ⓓ{a}W2. ⓐV. U2 ➡ X.
65 #a #V0 #V1 #T1 #V2 #V #W0 #W2 #U0 #U2 #IH #HV01 #HV02 #HV2 #HW02 #HU02 #H
66 elim (IH … HV01 … HV02) -HV01 -HV02 /2 width=1/ #VV #HVV1 #HVV2
67 elim (lift_total VV 0 1) #VVV #HVV
68 lapply (tpr_lift … HVV2 … HV2 … HVV) #HVVV
69 elim (tpr_inv_abbr1 … H) -H *
71 [ -HV2 -HVV2 #WW2 #UU2 #UU #HWW2 #HUU02 #HUU2 #H destruct
72 elim (IH … HW02 … HWW2) -HW02 -HWW2 /2 width=1/ #W #HW02 #HWW2
73 elim (IH … HU02 … HUU02) -HU02 -HUU02 -IH /2 width=1/ #U #HU2 #HUUU2
74 elim (tpr_tps_conf_bind … HWW2 HUUU2 … HUU2) -UU2 #UUU #HUUU2 #HUUU1
76 [2: @tpr_theta [6: @HVV |7: @HWW2 |8: @HUUU2 |1,2,3,4: skip | // ]
78 |3: @tpr_delta [3: @tpr_flat |1: skip ] /2 width=5/
79 ] (**) (* /5 width=14/ is too slow *)
81 | -HV2 -HW02 -HVV2 #U1 #HU01 #HTU1
82 elim (IH … HU01 … HU02) -HU01 -HU02 -IH // -U0 #U #HU1 #HU2
83 elim (tpr_inv_lift1 … HU1 … HTU1) -U1 #UU #HUU #HT1UU #H destruct
84 @(ex2_intro … (ⓐVV.UU)) /2 width=1/ /3 width=5/ (**) (* /4 width=9/ is too slow *)
88 fact tpr_conf_flat_cast:
90 ∀X0:term. ♯{X0} < ♯{V0} + ♯{T0} + 1 →
91 ∀X1,X2. X0 ➡ X1 → X0 ➡ X2 →
94 V0 ➡ V1 → T0 ➡ T1 → T0 ➡ X2 →
95 ∃∃X. ⓝV1. T1 ➡ X & X2 ➡ X.
96 #X2 #V0 #V1 #T0 #T1 #IH #_ #HT01 #HT02
97 elim (IH … HT01 … HT02) -HT01 -HT02 -IH // /3 width=3/
100 fact tpr_conf_beta_beta:
101 ∀a. ∀W0:term. ∀V0,V1,T0,T1,V2,T2. (
102 ∀X0:term. ♯{X0} < ♯{V0} + (♯{W0} + ♯{T0} + 1) + 1 →
103 ∀X1,X2. X0 ➡ X1 → X0 ➡ X2 →
106 V0 ➡ V1 → V0 ➡ V2 → T0 ➡ T1 → T0 ➡ T2 →
107 ∃∃X. ⓓ{a}V1. T1 ➡X & ⓓ{a}V2. T2 ➡ X.
108 #a #W0 #V0 #V1 #T0 #T1 #V2 #T2 #IH #HV01 #HV02 #HT01 #HT02
109 elim (IH … HV01 … HV02) -HV01 -HV02 /2 width=1/
110 elim (IH … HT01 … HT02) -HT01 -HT02 -IH /2 width=1/ /3 width=5/
113 (* Basic_1: was: pr0_cong_delta pr0_delta_delta *)
114 fact tpr_conf_delta_delta:
115 ∀a,I1,V0,V1,T0,T1,TT1,V2,T2,TT2. (
116 ∀X0:term. ♯{X0} < ♯{V0} + ♯{T0} + 1 →
117 ∀X1,X2. X0 ➡ X1 → X0 ➡ X2 →
120 V0 ➡ V1 → V0 ➡ V2 → T0 ➡ T1 → T0 ➡ T2 →
121 ⋆. ⓑ{I1} V1 ⊢ T1 ▶ [O, 1] TT1 →
122 ⋆. ⓑ{I1} V2 ⊢ T2 ▶ [O, 1] TT2 →
123 ∃∃X. ⓑ{a,I1} V1. TT1 ➡ X & ⓑ{a,I1} V2. TT2 ➡ X.
124 #a #I1 #V0 #V1 #T0 #T1 #TT1 #V2 #T2 #TT2 #IH #HV01 #HV02 #HT01 #HT02 #HTT1 #HTT2
125 elim (IH … HV01 … HV02) -HV01 -HV02 // #V #HV1 #HV2
126 elim (IH … HT01 … HT02) -HT01 -HT02 -IH // #T #HT1 #HT2
127 elim (tpr_tps_conf_bind … HV1 HT1 … HTT1) -T1 #U1 #TTU1 #HTU1
128 elim (tpr_tps_conf_bind … HV2 HT2 … HTT2) -T2 #U2 #TTU2 #HTU2
129 elim (tps_conf_eq … HTU1 … HTU2) -T #U #HU1 #HU2
130 @ex2_intro [2,3: @tpr_delta |1: skip ] /width=10/ (**) (* /3 width=10/ is too slow *)
133 fact tpr_conf_delta_zeta:
134 ∀X2,V0,V1,T0,T1,TT1,T2. (
135 ∀X0:term. ♯{X0} < ♯{V0} + ♯{T0} + 1 →
136 ∀X1,X2. X0 ➡ X1 → X0 ➡ X2 →
139 V0 ➡ V1 → T0 ➡ T1 → ⋆. ⓓV1 ⊢ T1 ▶ [O,1] TT1 →
140 T0 ➡ T2 → ⇧[O, 1] X2 ≡ T2 →
141 ∃∃X. +ⓓV1. TT1 ➡ X & X2 ➡ X.
142 #X2 #V0 #V1 #T0 #T1 #TT1 #T2 #IH #_ #HT01 #HTT1 #HT02 #HXT2
143 elim (IH … HT01 … HT02) -IH -HT01 -HT02 // -V0 -T0 #T #HT1 #HT2
144 elim (tpr_tps_conf_bind ? ? V1 … HT1 HTT1) -T1 // #TT #HTT1 #HTT
145 elim (tpr_inv_lift1 … HT2 … HXT2) -T2 #X #HXT #HX2
146 lapply (tps_inv_lift1_eq … HTT … HXT) -HTT #H destruct /3 width=3/
149 (* Basic_1: was: pr0_upsilon_upsilon *)
150 fact tpr_conf_theta_theta:
151 ∀a,VV1,V0,V1,W0,W1,T0,T1,V2,VV2,W2,T2. (
152 ∀X0:term. ♯{X0} < ♯{V0} + (♯{W0} + ♯{T0} + 1) + 1 →
153 ∀X1,X2. X0 ➡ X1 → X0 ➡ X2 →
156 V0 ➡ V1 → V0 ➡ V2 → W0 ➡ W1 → W0 ➡ W2 → T0 ➡ T1 → T0 ➡ T2 →
157 ⇧[O, 1] V1 ≡ VV1 → ⇧[O, 1] V2 ≡ VV2 →
158 ∃∃X. ⓓ{a}W1. ⓐVV1. T1 ➡ X & ⓓ{a}W2. ⓐVV2. T2 ➡ X.
159 #a #VV1 #V0 #V1 #W0 #W1 #T0 #T1 #V2 #VV2 #W2 #T2 #IH #HV01 #HV02 #HW01 #HW02 #HT01 #HT02 #HVV1 #HVV2
160 elim (IH … HV01 … HV02) -HV01 -HV02 /2 width=1/ #V #HV1 #HV2
161 elim (IH … HW01 … HW02) -HW01 -HW02 /2 width=1/ #W #HW1 #HW2
162 elim (IH … HT01 … HT02) -HT01 -HT02 -IH /2 width=1/ #T #HT1 #HT2
163 elim (lift_total V 0 1) #VV #HVV
164 lapply (tpr_lift … HV1 … HVV1 … HVV) -V1 #HVV1
165 lapply (tpr_lift … HV2 … HVV2 … HVV) -V2 -HVV #HVV2
166 @ex2_intro [2,3: @tpr_bind |1:skip ] /2 width=5/ (**) (* /4 width=5/ is too slow *)
169 fact tpr_conf_zeta_zeta:
170 ∀V0:term. ∀X2,TT0,T0,T1,TT2. (
171 ∀X0:term. ♯{X0} < ♯{V0} + ♯{TT0} + 1 →
172 ∀X1,X2. X0 ➡ X1 → X0 ➡ X2 →
175 TT0 ➡ T0 → ⇧[O, 1] T1 ≡ T0 →
176 TT0 ➡ TT2 → ⇧[O, 1] X2 ≡ TT2 →
177 ∃∃X. T1 ➡ X & X2 ➡ X.
178 #V0 #X2 #TT0 #T0 #T1 #TT2 #IH #HTT0 #HT10 #HTT02 #HXTT2
179 elim (IH … HTT0 … HTT02) -IH -HTT0 -HTT02 // -V0 -TT0 #T #HT0 #HTT2
180 elim (tpr_inv_lift1 … HT0 … HT10) -T0 #T0 #HT0 #HT10
181 elim (tpr_inv_lift1 … HTT2 … HXTT2) -TT2 #TT2 #HTT2 #HXTT2
182 lapply (lift_inj … HTT2 … HT0) -HTT2 #H destruct /2 width=3/
185 fact tpr_conf_tau_tau:
186 ∀V0,T0:term. ∀X2,T1. (
187 ∀X0:term. ♯{X0} < ♯{V0} + ♯{T0} + 1 →
188 ∀X1,X2. X0 ➡ X1 → X0 ➡ X2 →
192 ∃∃X. T1 ➡ X & X2 ➡ X.
193 #V0 #T0 #X2 #T1 #IH #HT01 #HT02
194 elim (IH … HT01 … HT02) -HT01 -HT02 -IH // /2 width=3/
197 (* Confluence ***************************************************************)
199 (* Basic_1: was: pr0_confluence *)
200 theorem tpr_conf: ∀T0:term. ∀T1,T2. T0 ➡ T1 → T0 ➡ T2 →
201 ∃∃T. T1 ➡ T & T2 ➡ T.
202 #T0 @(f_ind … tw … T0) -T0 #n #IH *
203 [ #I #_ #X1 #X2 #H1 #H2 -n
204 >(tpr_inv_atom1 … H1) -X1
205 >(tpr_inv_atom1 … H2) -X2
206 (* case 1: atom, atom *)
208 | * [ #a ] #I #V0 #T0 #Hn #X1 #X2 #H1 #H2
209 [ elim (tpr_inv_bind1 … H1) -H1 *
210 [ #V1 #T1 #U1 #HV01 #HT01 #HTU1 #H1
211 | #T1 #HT01 #HXT1 #H11 #H12
213 elim (tpr_inv_bind1 … H2) -H2 *
214 [1,3: #V2 #T2 #U2 #HV02 #HT02 #HTU2 #H2
215 |2,4: #T2 #HT02 #HXT2 #H21 #H22
217 (* case 2: delta, delta *)
218 [ /3 width=11 by tpr_conf_delta_delta/ (**) (* /3 width=11/ is too slow *)
219 (* case 3: zeta, delta (repeated) *)
220 | @ex2_commute /3 width=10 by tpr_conf_delta_zeta/
221 (* case 4: delta, zeta *)
222 | /3 width=10 by tpr_conf_delta_zeta/ (**) (* /3 width=10/ is too slow *)
223 (* case 5: zeta, zeta *)
224 | /3 width=9 by tpr_conf_zeta_zeta/ (**) (* /3 width=9/ is too slow *)
226 | elim (tpr_inv_flat1 … H1) -H1 *
227 [ #V1 #T1 #HV01 #HT01 #H1
228 | #b1 #V1 #W1 #U1 #T1 #HV01 #HUT1 #H11 #H12 #H13
229 | #b1 #V1 #Y1 #W1 #Z1 #U1 #T1 #HV01 #HWZ1 #HUT1 #HVY1 #H11 #H12 #H13
232 elim (tpr_inv_flat1 … H2) -H2 *
233 [1,5,9,13: #V2 #T2 #HV02 #HT02 #H2
234 |2,6,10,14: #b2 #V2 #W2 #U2 #T2 #HV02 #HUT2 #H21 #H22 #H23
235 |3,7,11,15: #b2 #V2 #Y2 #W2 #Z2 #U2 #T2 #HV02 #HWZ2 #HUT2 #HVY2 #H21 #H22 #H23
238 (* case 6: flat, flat *)
239 [ /3 width=7 by tpr_conf_flat_flat/ (**) (* /3 width=7/ is too slow *)
240 (* case 7: beta, flat (repeated) *)
241 | @ex2_commute /3 width=8 by tpr_conf_flat_beta/
242 (* case 8: theta, flat (repeated) *)
243 | @ex2_commute /3 width=11 by tpr_conf_flat_theta/
244 (* case 9: tau, flat (repeated) *)
245 | @ex2_commute /3 width=6 by tpr_conf_flat_cast/
246 (* case 10: flat, beta *)
247 | /3 width=8 by tpr_conf_flat_beta/ (**) (* /3 width=8/ is too slow *)
248 (* case 11: beta, beta *)
249 | /3 width=8 by tpr_conf_beta_beta/ (**) (* /3 width=8/ is too slow *)
250 (* case 12: flat, theta *)
251 | /3 width=11 by tpr_conf_flat_theta/ (**) (* /3 width=11/ is too slow *)
252 (* case 13: theta, theta *)
253 | /3 width=14 by tpr_conf_theta_theta/ (**) (* /3 width=14/ is too slow *)
254 (* case 14: flat, tau *)
255 | /3 width=6 by tpr_conf_flat_cast/ (**) (* /3 width=6/ is too slow *)
256 (* case 15: tau, tau *)
257 | /3 width=5 by tpr_conf_tau_tau/