]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambda_delta/basic_2/equivalence/cpcs_cpcs.ma
- star.ma: constructor inj of star conflicts with previous constructor
[helm.git] / matita / matita / contribs / lambda_delta / basic_2 / equivalence / cpcs_cpcs.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "basic_2/computation/cprs_lift.ma".
16 include "basic_2/computation/cprs_cprs.ma".
17 include "basic_2/conversion/cpc_cpc.ma".
18 include "basic_2/equivalence/cpcs_cprs.ma".
19
20 (* CONTEXT-SENSITIVE PARALLEL EQUIVALENCE ON TERMS **************************)
21
22 (* Advanced inversion lemmas ************************************************)
23
24 lemma cpcs_inv_cprs: ∀L,T1,T2. L ⊢ T1 ⬌* T2 →
25                      ∃∃T. L ⊢ T1 ➡* T & L ⊢ T2 ➡* T.
26 #L #T1 #T2 #H @(cpcs_ind … H) -T2
27 [ /3 width=3/
28 | #T #T2 #_ #HT2 * #T0 #HT10 elim HT2 -HT2 #HT2 #HT0
29   [ elim (cprs_strip … HT0 … HT2) -T #T #HT0 #HT2
30     lapply (cprs_strap1 … HT10 … HT0) -T0 /2 width=3/
31   | lapply (cprs_strap2 … HT2 … HT0) -T /2 width=3/
32   ]
33 ]
34 qed-.
35
36 (* Basic_1: was: pc3_gen_sort *)
37 lemma cpcs_inv_sort: ∀L,k1,k2. L ⊢ ⋆k1 ⬌* ⋆k2 → k1 = k2.
38 #L #k1 #k2 #H
39 elim (cpcs_inv_cprs … H) -H #T #H1
40 >(cprs_inv_sort1 … H1) -T #H2
41 lapply (cprs_inv_sort1 … H2) -L #H destruct //
42 qed-.
43
44 (* Basic_1: was: pc3_gen_sort_abst *)
45 lemma cpcs_inv_sort_abst: ∀L,W,T,k. L ⊢ ⋆k ⬌* ⓛW.T → ⊥.
46 #L #W #T #k #H
47 elim (cpcs_inv_cprs … H) -H #X #H1
48 >(cprs_inv_sort1 … H1) -X #H2
49 elim (cprs_inv_abst1 Abst W … H2) -H2 #W0 #T0 #_ #_ #H destruct
50 qed-.
51
52 (* Basic_1: was: pc3_gen_abst *)
53 lemma cpcs_inv_abst: ∀L,W1,W2,T1,T2. L ⊢ ⓛW1.T1 ⬌* ⓛW2.T2 → ∀I,V.
54                      L ⊢ W1 ⬌* W2 ∧ L. ②{I}V ⊢ T1 ⬌* T2.
55 #L #W1 #W2 #T1 #T2 #H #I #V
56 elim (cpcs_inv_cprs … H) -H #T #H1 #H2
57 elim (cprs_inv_abst1 I V … H1) -H1 #W0 #T0 #HW10 #HT10 #H destruct
58 elim (cprs_inv_abst1 I V … H2) -H2 #W #T #HW2 #HT2 #H destruct /3 width=3/
59 qed-.
60
61 (* Basic_1: was: pc3_gen_abst_shift *)
62 lemma cpcs_inv_abst_shift: ∀L,W1,W2,T1,T2. L ⊢ ⓛW1.T1 ⬌* ⓛW2.T2 → ∀W.
63                            L ⊢ W1 ⬌* W2 ∧ L. ⓛW ⊢ T1 ⬌* T2.
64 #L #W1 #W2 #T1 #T2 #H #W
65 lapply (cpcs_inv_abst … H Abst W) -H //
66 qed.
67
68 lemma cpcs_inv_abst1: ∀L,W1,T1,T. L ⊢ ⓛW1.T1 ⬌* T →
69                       ∃∃W2,T2. L ⊢ T ➡* ⓛW2.T2 & L ⊢ ⓛW1.T1 ➡* ⓛW2.T2.
70 #L #W1 #T1 #T #H
71 elim (cpcs_inv_cprs … H) -H #X #H1 #H2
72 elim (cprs_inv_abst1 Abst W1 … H1) -H1 #W2 #T2 #HW12 #HT12 #H destruct
73 @(ex2_2_intro … H2) -H2 /2 width=2/ (**) (* explicit constructor, /3 width=6/ is slow *)
74 qed-.
75
76 lemma cpcs_inv_abst2: ∀L,W1,T1,T. L ⊢ T ⬌* ⓛW1.T1 →
77                       ∃∃W2,T2. L ⊢ T ➡* ⓛW2.T2 & L ⊢ ⓛW1.T1 ➡* ⓛW2.T2.
78 /3 width=1 by cpcs_inv_abst1, cpcs_sym/ qed-.
79
80 (* Basic_1: was: pc3_gen_lift *)
81 lemma cpcs_inv_lift: ∀L,K,d,e. ⇩[d, e] L ≡ K →
82                      ∀T1,U1. ⇧[d, e] T1 ≡ U1 → ∀T2,U2. ⇧[d, e] T2 ≡ U2 →
83                      L ⊢ U1 ⬌* U2 → K ⊢ T1 ⬌* T2.
84 #L #K #d #e #HLK #T1 #U1 #HTU1 #T2 #U2 #HTU2 #HU12
85 elim (cpcs_inv_cprs … HU12) -HU12 #U #HU1 #HU2
86 elim (cprs_inv_lift … HLK … HTU1 … HU1) -U1 #T #HTU #HT1
87 elim (cprs_inv_lift … HLK … HTU2 … HU2) -L -U2 #X #HXU
88 >(lift_inj … HXU … HTU) -X -U -d -e /2 width=3/
89 qed-.
90
91 (* Advanced properties ******************************************************)
92
93 (* Basic_1: was only: pc3_thin_dx *)
94 lemma cpcs_flat: ∀L,V1,V2. L ⊢ V1 ⬌* V2 → ∀T1,T2. L ⊢ T1 ⬌* T2 →
95                  ∀I. L ⊢ ⓕ{I}V1. T1 ⬌* ⓕ{I}V2. T2.
96 #L #V1 #V2 #HV12 #T1 #T2 #HT12 #I
97 elim (cpcs_inv_cprs … HV12) -HV12 #V #HV1 #HV2
98 elim (cpcs_inv_cprs … HT12) -HT12 /3 width=5 by cprs_flat, cprs_div/ (**) (* /3 width=5/ is too slow *)
99 qed.
100
101 lemma cpcs_flat_dx_tpr_rev: ∀L,V1,V2. V2 ➡ V1 → ∀T1,T2. L ⊢ T1 ⬌* T2 →
102                             ∀I. L ⊢ ⓕ{I}V1. T1 ⬌* ⓕ{I}V2. T2.
103 /3 width=1/ qed.
104
105 lemma cpcs_abst: ∀L,V1,V2. L ⊢ V1 ⬌* V2 →
106                  ∀V,T1,T2. L.ⓛV ⊢ T1 ⬌* T2 → L ⊢ ⓛV1. T1 ⬌* ⓛV2. T2.
107 #L #V1 #V2 #HV12 #V #T1 #T2 #HT12
108 elim (cpcs_inv_cprs … HV12) -HV12
109 elim (cpcs_inv_cprs … HT12) -HT12
110 /3 width=6 by cprs_div, cprs_abst/ (**) (* /3 width=6/ is a bit slow *)
111 qed.
112
113 lemma cpcs_abbr_dx: ∀L,V,T1,T2. L.ⓓV ⊢ T1 ⬌* T2 → L ⊢ ⓓV. T1 ⬌* ⓓV. T2.
114 #L #V #T1 #T2 #HT12
115 elim (cpcs_inv_cprs … HT12) -HT12 /3 width=5 by cprs_div, cprs_abbr1/ (**) (* /3 width=5/ is a bit slow *)
116 qed.
117
118 lemma cpcs_bind_dx: ∀I,L,V,T1,T2. L.ⓑ{I}V ⊢ T1 ⬌* T2 →
119                     L ⊢ ⓑ{I}V. T1 ⬌* ⓑ{I}V. T2.
120 * /2 width=1/ /2 width=2/ qed.
121
122 lemma cpcs_abbr_sn: ∀L,V1,V2,T. L ⊢ V1 ⬌* V2 → L ⊢ ⓓV1. T ⬌* ⓓV2. T.
123 #L #V1 #V2 #T #HV12
124 elim (cpcs_inv_cprs … HV12) -HV12 /3 width=5 by cprs_div, cprs_abbr1/ (**) (* /3 width=5/ is a bit slow *)
125 qed.
126
127 lemma cpcs_bind_sn: ∀I,L,V1,V2,T. L ⊢ V1 ⬌* V2 → L ⊢ ⓑ{I}V1. T ⬌* ⓑ{I}V2. T.
128 * /2 width=1/ /2 width=2/ qed.
129
130 lemma cpcs_beta_dx: ∀L,V1,V2,W,T1,T2.
131                     L ⊢ V1 ➡ V2 → L.ⓛW ⊢ T1 ⬌* T2 → L ⊢ ⓐV1.ⓛW.T1 ⬌* ⓓV2.T2.
132 #L #V1 #V2 #W #T1 #T2 #HV12 #HT12
133 elim (cpcs_inv_cprs … HT12) -HT12 #T #HT1 #HT2
134 lapply (cprs_beta_dx … HV12 HT1) -HV12 -HT1 #HT1
135 lapply (cprs_lsubs_trans … HT2 (L.ⓓV2) ?) -HT2 /2 width=1/ #HT2
136 @(cprs_div … HT1) /2 width=1/
137 qed.
138
139 lemma cpcs_beta_dx_tpr_rev: ∀L,V1,V2,W,T1,T2.
140                             V1 ➡ V2 → L.ⓛW ⊢ T2 ⬌* T1 →
141                             L ⊢ ⓓV2.T2 ⬌* ⓐV1.ⓛW.T1.
142 /4 width=1/ qed.
143
144 (* Note: it does not hold replacing |L1| with |L2| *)
145 lemma cpcs_lsubs_trans: ∀L1,T1,T2. L1 ⊢ T1 ⬌* T2 →
146                         ∀L2. L2 ≼ [0, |L1|] L1 → L2 ⊢ T1 ⬌* T2.
147 #L1 #T1 #T2 #HT12
148 elim (cpcs_inv_cprs … HT12) -HT12
149 /3 width=5 by cprs_div, cprs_lsubs_trans/ (**) (* /3 width=5/ is a bit slow *)
150 qed.
151
152
153 (* Basic_1: was: pc3_lift *)
154 lemma cpcs_lift: ∀L,K,d,e. ⇩[d, e] L ≡ K →
155                  ∀T1,U1. ⇧[d, e] T1 ≡ U1 → ∀T2,U2. ⇧[d, e] T2 ≡ U2 →
156                  K ⊢ T1 ⬌* T2 → L ⊢ U1 ⬌* U2.
157 #L #K #d #e #HLK #T1 #U1 #HTU1 #T2 #U2 #HTU2 #HT12
158 elim (cpcs_inv_cprs … HT12) -HT12 #T #HT1 #HT2
159 elim (lift_total T d e) #U #HTU
160 lapply (cprs_lift … HLK … HTU1 … HT1 … HTU) -T1 #HU1
161 lapply (cprs_lift … HLK … HTU2 … HT2 … HTU) -K -T2 -T -d -e /2 width=3/
162 qed.
163
164 lemma cpcs_strip: ∀L,T1,T. L ⊢ T ⬌* T1 → ∀T2. L ⊢ T ⬌ T2 →
165                   ∃∃T0. L ⊢ T1 ⬌ T0 & L ⊢ T2 ⬌* T0.
166 /3 width=3/ qed.
167
168 (* Main properties **********************************************************)
169
170 (* Basic_1: was pc3_t *)
171 theorem cpcs_trans: ∀L,T1,T. L ⊢ T1 ⬌* T → ∀T2. L ⊢ T ⬌* T2 → L ⊢ T1 ⬌* T2.
172 /2 width=3/ qed.
173
174 theorem cpcs_canc_sn: ∀L,T,T1,T2. L ⊢ T ⬌* T1 → L ⊢ T ⬌* T2 → L ⊢ T1 ⬌* T2.
175 /3 width=3 by cpcs_trans, cprs_comm/ qed. (**) (* /3 width=3/ is too slow *)
176
177 theorem cpcs_canc_dx: ∀L,T,T1,T2. L ⊢ T1 ⬌* T → L ⊢ T2 ⬌* T → L ⊢ T1 ⬌* T2.
178 /3 width=3 by cpcs_trans, cprs_comm/ qed. (**) (* /3 width=3/ is too slow *)
179
180 lemma cpcs_abbr1: ∀L,V1,V2. L ⊢ V1 ⬌* V2 → ∀T1,T2. L.ⓓV1 ⊢ T1 ⬌* T2 →
181                   L ⊢ ⓓV1. T1 ⬌* ⓓV2. T2.
182 #L #V1 #V2 #HV12 #T1 #T2 #HT12
183 @(cpcs_trans … (ⓓV1.T2)) /2 width=1/
184 qed.
185
186 lemma cpcs_abbr2: ∀L,V1,V2. L ⊢ V1 ⬌* V2 → ∀T1,T2. L.ⓓV2 ⊢ T1 ⬌* T2 →
187                   L ⊢ ⓓV1. T1 ⬌* ⓓV2. T2.
188 #L #V1 #V2 #HV12 #T1 #T2 #HT12
189 @(cpcs_trans … (ⓓV2.T1)) /2 width=1/
190 qed.