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/computation/cprs_cprs.ma".
16 include "basic_2/conversion/cpc_cpc.ma".
17 include "basic_2/equivalence/cpcs_cprs.ma".
19 (* CONTEXT-SENSITIVE PARALLEL EQUIVALENCE ON TERMS **************************)
21 (* Advanced inversion lemmas ************************************************)
23 lemma cpcs_inv_cprs: ∀L,T1,T2. L ⊢ T1 ⬌* T2 →
24 ∃∃T. L ⊢ T1 ➡* T & L ⊢ T2 ➡* T.
25 #L #T1 #T2 #H @(cpcs_ind … H) -T2
27 | #T #T2 #_ #HT2 * #T0 #HT10 elim HT2 -HT2 #HT2 #HT0
28 [ elim (cprs_strip … HT0 … HT2) -T #T #HT0 #HT2
29 lapply (cprs_strap1 … HT10 … HT0) -T0 /2 width=3/
30 | lapply (cprs_strap2 … HT2 … HT0) -T /2 width=3/
35 (* Basic_1: was: pc3_gen_sort *)
36 lemma cpcs_inv_sort: ∀L,k1,k2. L ⊢ ⋆k1 ⬌* ⋆k2 → k1 = k2.
38 elim (cpcs_inv_cprs … H) -H #T #H1
39 >(cprs_inv_sort1 … H1) -T #H2
40 lapply (cprs_inv_sort1 … H2) -L #H destruct //
43 (* Basic_1: was: pc3_gen_sort_abst *)
44 lemma cpcs_inv_sort_abst: ∀a,L,W,T,k. L ⊢ ⋆k ⬌* ⓛ{a}W.T → ⊥.
46 elim (cpcs_inv_cprs … H) -H #X #H1
47 >(cprs_inv_sort1 … H1) -X #H2
48 elim (cprs_fwd_abst1 … H2 Abst W) -H2 #W0 #T0 #_ #_ #H destruct
51 (* Basic_1: was: pc3_gen_abst *)
52 lemma cpcs_inv_abst: ∀a1,a2,L,W1,W2,T1,T2. L ⊢ ⓛ{a1}W1.T1 ⬌* ⓛ{a2}W2.T2 → ∀I,V.
53 ∧∧ L ⊢ W1 ⬌* W2 & L. ②{I}V ⊢ T1 ⬌* T2 & a1 = a2.
54 #a1 #a2 #L #W1 #W2 #T1 #T2 #H #I #V
55 elim (cpcs_inv_cprs … H) -H #T #H1 #H2
56 elim (cprs_fwd_abst1 … H1 I V) -H1 #W0 #T0 #HW10 #HT10 #H destruct
57 elim (cprs_fwd_abst1… H2 I V) -H2 #W #T #HW2 #HT2 #H destruct /3 width=3/
60 (* Basic_1: was: pc3_gen_abst_shift *)
61 lemma cpcs_inv_abst_shift: ∀a1,a2,L,W1,W2,T1,T2. L ⊢ ⓛ{a1}W1.T1 ⬌* ⓛ{a2}W2.T2 → ∀W.
62 ∧∧ L ⊢ W1 ⬌* W2 & L. ⓛW ⊢ T1 ⬌* T2 & a1 = a2.
63 #a1 #a2 #L #W1 #W2 #T1 #T2 #H #W
64 lapply (cpcs_inv_abst … H Abst W) -H //
67 lemma cpcs_inv_abst1: ∀a,L,W1,T1,T. L ⊢ ⓛ{a}W1.T1 ⬌* T →
68 ∃∃W2,T2. L ⊢ T ➡* ⓛ{a}W2.T2 & L ⊢ ⓛ{a}W1.T1 ➡* ⓛ{a}W2.T2.
70 elim (cpcs_inv_cprs … H) -H #X #H1 #H2
71 elim (cprs_fwd_abst1 … H1 Abst W1) -H1 #W2 #T2 #HW12 #HT12 #H destruct
72 @(ex2_2_intro … H2) -H2 /2 width=2/ (**) (* explicit constructor, /3 width=6/ is slow *)
75 lemma cpcs_inv_abst2: ∀a,L,W1,T1,T. L ⊢ T ⬌* ⓛ{a}W1.T1 →
76 ∃∃W2,T2. L ⊢ T ➡* ⓛ{a}W2.T2 & L ⊢ ⓛ{a}W1.T1 ➡* ⓛ{a}W2.T2.
77 /3 width=1 by cpcs_inv_abst1, cpcs_sym/ qed-.
79 (* Basic_1: was: pc3_gen_lift *)
80 lemma cpcs_inv_lift: ∀L,K,d,e. ⇩[d, e] L ≡ K →
81 ∀T1,U1. ⇧[d, e] T1 ≡ U1 → ∀T2,U2. ⇧[d, e] T2 ≡ U2 →
82 L ⊢ U1 ⬌* U2 → K ⊢ T1 ⬌* T2.
83 #L #K #d #e #HLK #T1 #U1 #HTU1 #T2 #U2 #HTU2 #HU12
84 elim (cpcs_inv_cprs … HU12) -HU12 #U #HU1 #HU2
85 elim (cprs_inv_lift1 … HU1 … HLK … HTU1) -U1 #T #HTU #HT1
86 elim (cprs_inv_lift1 … HU2 … HLK … HTU2) -L -U2 #X #HXU
87 >(lift_inj … HXU … HTU) -X -U -d -e /2 width=3/
90 (* Advanced properties ******************************************************)
92 lemma lpr_cpcs_trans: ∀L1,L2. L1 ⊢ ➡ L2 → ∀T1,T2. L2 ⊢ T1 ⬌* T2 → L1 ⊢ T1 ⬌* T2.
93 #L1 #L2 #HL12 #T1 #T2 #H
94 elim (cpcs_inv_cprs … H) -H #T #HT1 #HT2
95 lapply (lpr_cprs_trans … HT1 … HL12) -HT1
96 lapply (lpr_cprs_trans … HT2 … HL12) -L2 /2 width=3/
99 lemma cpr_cprs_conf_cpcs: ∀L,T,T1,T2. L ⊢ T ➡* T1 → L ⊢ T ➡ T2 → L ⊢ T1 ⬌* T2.
100 #L #T #T1 #T2 #HT1 #HT2
101 elim (cprs_strip … HT1 … HT2) /2 width=3 by cpr_cprs_div/
104 lemma cprs_cpr_conf_cpcs: ∀L,T,T1,T2. L ⊢ T ➡* T1 → L ⊢ T ➡ T2 → L ⊢ T2 ⬌* T1.
105 #L #T #T1 #T2 #HT1 #HT2
106 elim (cprs_strip … HT1 … HT2) /2 width=3 by cprs_cpr_div/
109 lemma cprs_conf_cpcs: ∀L,T,T1,T2. L ⊢ T ➡* T1 → L ⊢ T ➡* T2 → L ⊢ T1 ⬌* T2.
110 #L #T #T1 #T2 #HT1 #HT2
111 elim (cprs_conf … HT1 … HT2) /2 width=3/
114 (* Basic_1: was only: pc3_pr0_pr2_t *)
115 (* Basic_1: note: pc3_pr0_pr2_t should be renamed *)
116 lemma lpr_cpr_conf: ∀L1,L2. L1 ⊢ ➡ L2 → ∀T1,T2. L1 ⊢ T1 ➡ T2 → L2 ⊢ T1 ⬌* T2.
117 #L1 #L2 #HL12 #T1 #T2 #HT12
118 elim (lpr_cpr_conf_dx … HT12 … HL12) -L1 /3 width=3/
121 (* Basic_1: was only: pc3_thin_dx *)
122 lemma cpcs_flat: ∀L,V1,V2. L ⊢ V1 ⬌* V2 → ∀T1,T2. L ⊢ T1 ⬌* T2 →
123 ∀I. L ⊢ ⓕ{I}V1. T1 ⬌* ⓕ{I}V2. T2.
124 #L #V1 #V2 #HV12 #T1 #T2 #HT12 #I
125 elim (cpcs_inv_cprs … HV12) -HV12 #V #HV1 #HV2
126 elim (cpcs_inv_cprs … HT12) -HT12 /3 width=5 by cprs_flat, cprs_div/ (**) (* /3 width=5/ is too slow *)
129 lemma cpcs_flat_dx_cpr_rev: ∀L,V1,V2. L ⊢ V2 ➡ V1 → ∀T1,T2. L ⊢ T1 ⬌* T2 →
130 ∀I. L ⊢ ⓕ{I}V1. T1 ⬌* ⓕ{I}V2. T2.
133 lemma cpcs_ext_bind: ∀L,V1,V2. L ⊢ V1 ⬌* V2 → ∀V,T1,T2. L.ⓛV ⊢ T1 ⬌* T2 →
134 ∀a,I. L ⊢ ⓑ{a,I}V1.T1 ⬌* ⓑ{a,I}V2.T2.
135 #L #V1 #V2 #HV12 #V #T1 #T2 #HT12 #a #I
136 elim (cpcs_inv_cprs … HV12) -HV12
137 elim (cpcs_inv_cprs … HT12) -HT12
138 /3 width=6 by cprs_div, cprs_ext_bind/ (**) (* /3 width=6/ is a bit slow *)
141 lemma cpcs_bind_dx: ∀a,I,L,V,T1,T2. L.ⓑ{I}V ⊢ T1 ⬌* T2 →
142 L ⊢ ⓑ{a,I}V. T1 ⬌* ⓑ{a,I}V. T2.
143 #a #I #L #V #T1 #T2 #HT12
144 elim (cpcs_inv_cprs … HT12) -HT12 /3 width=5 by cprs_div, cprs_bind/ (**) (* /3 width=5/ is a bit slow *)
147 lemma cpcs_bind_sn: ∀a,I,L,V1,V2,T. L ⊢ V1 ⬌* V2 → L ⊢ ⓑ{a,I}V1. T ⬌* ⓑ{a,I}V2. T.
148 #a #I #L #V1 #V2 #T #HV12
149 elim (cpcs_inv_cprs … HV12) -HV12 /3 width=5 by cprs_div, cprs_bind/ (**) (* /3 width=5/ is a bit slow *)
152 lemma cpcs_beta_dx_cpr: ∀a,L,V1,V2,W,T1,T2.
153 L ⊢ V1 ➡ V2 → L.ⓛW ⊢ T1 ⬌* T2 → L ⊢ ⓐV1.ⓛ{a}W.T1 ⬌* ⓓ{a}V2.T2.
154 #a #L #V1 #V2 #W #T1 #T2 #HV12 #HT12
155 elim (cpcs_inv_cprs … HT12) -HT12 #T #HT1 #HT2
156 lapply (cprs_beta_dx a … HV12 HT1) -HV12 -HT1 #HT1
157 lapply (cprs_lsubr_trans … HT2 (L.ⓓV2) ?) -HT2 /2 width=1/ #HT2
158 @(cprs_div … HT1) /2 width=1/
161 lemma cpcs_beta_dx_rev_cpr: ∀a,L,V1,V2,W,T1,T2.
162 L ⊢ V1 ➡ V2 → L.ⓛW ⊢ T2 ⬌* T1 →
163 L ⊢ ⓓ{a}V2.T2 ⬌* ⓐV1.ⓛ{a}W.T1.
166 lemma cpcs_lsubr_trans: ∀L1,T1,T2. L1 ⊢ T1 ⬌* T2 →
167 ∀L2. L2 ⊑ L1 → L2 ⊢ T1 ⬌* T2.
169 elim (cpcs_inv_cprs … HT12) -HT12
170 /3 width=5 by cprs_div, cprs_lsubr_trans/ (**) (* /3 width=5/ is a bit slow *)
173 (* Basic_1: was: pc3_lift *)
174 lemma cpcs_lift: ∀L,K,d,e. ⇩[d, e] L ≡ K →
175 ∀T1,U1. ⇧[d, e] T1 ≡ U1 → ∀T2,U2. ⇧[d, e] T2 ≡ U2 →
176 K ⊢ T1 ⬌* T2 → L ⊢ U1 ⬌* U2.
177 #L #K #d #e #HLK #T1 #U1 #HTU1 #T2 #U2 #HTU2 #HT12
178 elim (cpcs_inv_cprs … HT12) -HT12 #T #HT1 #HT2
179 elim (lift_total T d e) #U #HTU
180 lapply (cprs_lift … HT1 … HLK … HTU1 … HTU) -T1 #HU1
181 lapply (cprs_lift … HT2 … HLK … HTU2 … HTU) -K -T2 -T -d -e /2 width=3/
184 lemma cpcs_strip: ∀L,T1,T. L ⊢ T ⬌* T1 → ∀T2. L ⊢ T ⬌ T2 →
185 ∃∃T0. L ⊢ T1 ⬌ T0 & L ⊢ T2 ⬌* T0.
186 #L #T1 #T @TC_strip1 /2 width=3/ qed-.
188 (* Main properties **********************************************************)
190 (* Basic_1: was pc3_t *)
191 theorem cpcs_trans: ∀L,T1,T. L ⊢ T1 ⬌* T → ∀T2. L ⊢ T ⬌* T2 → L ⊢ T1 ⬌* T2.
192 #L #T1 #T #HT1 #T2 @(trans_TC … HT1) qed-.
194 theorem cpcs_canc_sn: ∀L,T,T1,T2. L ⊢ T ⬌* T1 → L ⊢ T ⬌* T2 → L ⊢ T1 ⬌* T2.
195 /3 width=3 by cpcs_trans, cpcs_sym/ qed-. (**) (* /3 width=3/ is too slow *)
197 theorem cpcs_canc_dx: ∀L,T,T1,T2. L ⊢ T1 ⬌* T → L ⊢ T2 ⬌* T → L ⊢ T1 ⬌* T2.
198 /3 width=3 by cpcs_trans, cpcs_sym/ qed-. (**) (* /3 width=3/ is too slow *)
200 lemma cpcs_bind1: ∀a,I,L,V1,V2. L ⊢ V1 ⬌* V2 → ∀T1,T2. L.ⓑ{I}V1 ⊢ T1 ⬌* T2 →
201 L ⊢ ⓑ{a,I}V1. T1 ⬌* ⓑ{a,I}V2. T2.
202 #a #I #L #V1 #V2 #HV12 #T1 #T2 #HT12
203 @(cpcs_trans … (ⓑ{a,I}V1.T2)) /2 width=1/
206 lemma cpcs_bind2: ∀a,I,L,V1,V2. L ⊢ V1 ⬌* V2 → ∀T1,T2. L.ⓑ{I}V2 ⊢ T1 ⬌* T2 →
207 L ⊢ ⓑ{a,I}V1. T1 ⬌* ⓑ{a,I}V2. T2.
208 #a #I #L #V1 #V2 #HV12 #T1 #T2 #HT12
209 @(cpcs_trans … (ⓑ{a,I}V2.T1)) /2 width=1/
212 (* Basic_1: was: pc3_wcpr0_t *)
213 (* Basic_1: note: pc3_wcpr0_t should be renamed *)
214 lemma cprs_lpr_conf: ∀L1,L2. L1 ⊢ ➡ L2 → ∀T1,T2. L1 ⊢ T1 ➡* T2 → L2 ⊢ T1 ⬌* T2.
215 #L1 #L2 #HL12 #T1 #T2 #H @(cprs_ind … H) -T2 //
216 /3 width=5 by cpcs_trans, lpr_cpr_conf/
219 (* Basic_1: was: pc3_wcpr0 *)
220 lemma cpcs_lpr_conf: ∀L1,L2. L1 ⊢ ➡ L2 → ∀T1,T2. L1 ⊢ T1 ⬌* T2 → L2 ⊢ T1 ⬌* T2.
221 #L1 #L2 #HL12 #T1 #T2 #H
222 elim (cpcs_inv_cprs … H) -H /3 width=5 by cpcs_canc_dx, cprs_lpr_conf/