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/tpr_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_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_1_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_bind … HV1 HT1 … HTT1) -T1 #U1 #TTU1 #HTU1
128 elim (tpr_tps_bind … HV2 HT2 … HTT2) -T2 #U2 #TTU2 #HTU2
129 elim (tps_conf_eq … HTU1 … HTU2) -T #U #HU1 #HU2
130 @ex2_1_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_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_1_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 ***************************************************************)
201 ∀X0:term. #{X0} < #{Y0} →
202 ∀X1,X2. X0 ➡ X1 → X0 ➡ X2 →
205 ∀X0,X1,X2. X0 ➡ X1 → X0 ➡ X2 → X0 = Y0 →
206 ∃∃X. X1 ➡ X & X2 ➡ X.
207 #Y0 #IH #X0 #X1 #X2 * -X0 -X1
208 [ #I1 #H1 #H2 destruct
209 lapply (tpr_inv_atom1 … H1) -H1
210 (* case 1: atom, atom *)
212 | #I #V0 #V1 #T0 #T1 #HV01 #HT01 #H1 #H2 destruct
213 elim (tpr_inv_flat1 … H1) -H1 *
214 (* case 2: flat, flat *)
215 [ #V2 #T2 #HV02 #HT02 #H destruct
216 /3 width=7 by tpr_conf_flat_flat/ (**) (* /3 width=7/ is too slow *)
217 (* case 3: flat, beta *)
218 | #b #V2 #W #U0 #T2 #HV02 #HT02 #H1 #H2 #H3 destruct
219 /3 width=8 by tpr_conf_flat_beta/ (**) (* /3 width=8/ is too slow *)
220 (* case 4: flat, theta *)
221 | #b #V2 #V #W0 #W2 #U0 #U2 #HV02 #HW02 #HT02 #HV2 #H1 #H2 #H3 destruct
222 /3 width=11 by tpr_conf_flat_theta/ (**) (* /3 width=11/ is too slow *)
223 (* case 5: flat, tau *)
225 /3 width=6 by tpr_conf_flat_cast/ (**) (* /3 width=6/ is too slow *)
227 | #a #V0 #V1 #W0 #T0 #T1 #HV01 #HT01 #H1 #H2 destruct
228 elim (tpr_inv_appl1 … H1) -H1 *
229 (* case 6: beta, flat (repeated) *)
230 [ #V2 #T2 #HV02 #HT02 #H destruct
231 @ex2_1_comm /3 width=8 by tpr_conf_flat_beta/
232 (* case 7: beta, beta *)
233 | #b #V2 #WW0 #TT0 #T2 #HV02 #HT02 #H1 #H2 destruct
234 /3 width=8 by tpr_conf_beta_beta/ (**) (* /3 width=8/ is too slow *)
235 (* case 8, beta, theta (excluded) *)
236 | #b #V2 #VV2 #WW0 #W2 #TT0 #T2 #_ #_ #_ #_ #H destruct
238 | #a #I1 #V0 #V1 #T0 #T1 #TT1 #HV01 #HT01 #HTT1 #H1 #H2 destruct
239 elim (tpr_inv_bind1 … H1) -H1 *
240 (* case 9: delta, delta *)
241 [ #V2 #T2 #TT2 #HV02 #HT02 #HTT2 #H destruct
242 /3 width=11 by tpr_conf_delta_delta/ (**) (* /3 width=11/ is too slow *)
243 (* case 10: delta, zeta *)
244 | #T2 #HT20 #HTX2 #H1 #H2 destruct
245 /3 width=10 by tpr_conf_delta_zeta/ (**) (* /3 width=10/ is too slow *)
247 | #a #VV1 #V0 #V1 #W0 #W1 #T0 #T1 #HV01 #HVV1 #HW01 #HT01 #H1 #H2 destruct
248 elim (tpr_inv_appl1 … H1) -H1 *
249 (* case 11: theta, flat (repeated) *)
250 [ #V2 #T2 #HV02 #HT02 #H destruct
251 @ex2_1_comm /3 width=11 by tpr_conf_flat_theta/
252 (* case 12: theta, beta (repeated) *)
253 | #b #V2 #WW0 #TT0 #T2 #_ #_ #H destruct
254 (* case 13: theta, theta *)
255 | #b #V2 #VV2 #WW0 #W2 #TT0 #T2 #V02 #HW02 #HT02 #HVV2 #H1 #H2 destruct
256 /3 width=14 by tpr_conf_theta_theta/ (**) (* /3 width=14/ is too slow *)
258 | #V0 #TT0 #T0 #T1 #HTT0 #HT01 #H1 #H2 destruct
259 elim (tpr_inv_abbr1 … H1) -H1 *
260 (* case 14: zeta, delta (repeated) *)
261 [ #V2 #TT2 #T2 #HV02 #HTT02 #HTT2 #H destruct
262 @ex2_1_comm /3 width=10 by tpr_conf_delta_zeta/
263 (* case 15: zeta, zeta *)
265 /3 width=9 by tpr_conf_zeta_zeta/ (**) (* /3 width=9/ is too slow *)
267 | #V0 #T0 #T1 #HT01 #H1 #H2 destruct
268 elim (tpr_inv_cast1 … H1) -H1
269 (* case 16: tau, flat (repeated) *)
270 [ * #V2 #T2 #HV02 #HT02 #H destruct
271 @ex2_1_comm /3 width=6 by tpr_conf_flat_cast/
272 (* case 17: tau, tau *)
274 /3 width=5 by tpr_conf_tau_tau/
279 (* Basic_1: was: pr0_confluence *)
280 theorem tpr_conf: ∀T0:term. ∀T1,T2. T0 ➡ T1 → T0 ➡ T2 →
281 ∃∃T. T1 ➡ T & T2 ➡ T.
282 #T @(tw_wf_ind … T) -T /3 width=6 by tpr_conf_aux/