]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/equivalence/cpcs_cpcs.ma
basic_2: stronger supclosure allows better inversion lemmas
[helm.git] / matita / matita / contribs / lambdadelta / 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/lprs_cprs.ma".
16 include "basic_2/conversion/cpc_cpc.ma".
17 include "basic_2/equivalence/cpcs_cprs.ma".
18
19 (* CONTEXT-SENSITIVE PARALLEL EQUIVALENCE ON TERMS **************************)
20
21 (* Advanced inversion lemmas ************************************************)
22
23 lemma cpcs_inv_cprs: ∀G,L,T1,T2. ⦃G, L⦄ ⊢ T1 ⬌* T2 →
24                      ∃∃T. ⦃G, L⦄ ⊢ T1 ➡* T & ⦃G, L⦄ ⊢ T2 ➡* T.
25 #G #L #T1 #T2 #H @(cpcs_ind … H) -T2
26 [ /3 width=3 by ex2_intro/
27 | #T #T2 #_ #HT2 * #T0 #HT10 elim HT2 -HT2 #HT2 #HT0
28   [ elim (cprs_strip … HT0 … HT2) -T /3 width=3 by cprs_strap1, ex2_intro/
29   | /3 width=5 by cprs_strap2, ex2_intro/
30   ]
31 ]
32 qed-.
33
34 (* Basic_1: was: pc3_gen_sort *)
35 lemma cpcs_inv_sort: ∀G,L,s1,s2. ⦃G, L⦄ ⊢ ⋆s1 ⬌* ⋆s2 → s1 = s2.
36 #G #L #s1 #s2 #H elim (cpcs_inv_cprs … H) -H
37 #T #H1 >(cprs_inv_sort1 … H1) -T #H2
38 lapply (cprs_inv_sort1 … H2) -L #H destruct //
39 qed-.
40
41 lemma cpcs_inv_abst1: ∀a,G,L,W1,T1,T. ⦃G, L⦄ ⊢ ⓛ{a}W1.T1 ⬌* T →
42                       ∃∃W2,T2. ⦃G, L⦄ ⊢ T ➡* ⓛ{a}W2.T2 & ⦃G, L⦄ ⊢ ⓛ{a}W1.T1 ➡* ⓛ{a}W2.T2.
43 #a #G #L #W1 #T1 #T #H
44 elim (cpcs_inv_cprs … H) -H #X #H1 #H2
45 elim (cprs_inv_abst1 … H1) -H1 #W2 #T2 #HW12 #HT12 #H destruct
46 /3 width=6 by cprs_bind, ex2_2_intro/
47 qed-.
48
49 lemma cpcs_inv_abst2: ∀a,G,L,W1,T1,T. ⦃G, L⦄ ⊢ T ⬌* ⓛ{a}W1.T1 →
50                       ∃∃W2,T2. ⦃G, L⦄ ⊢ T ➡* ⓛ{a}W2.T2 & ⦃G, L⦄ ⊢ ⓛ{a}W1.T1 ➡* ⓛ{a}W2.T2.
51 /3 width=1 by cpcs_inv_abst1, cpcs_sym/ qed-.
52
53 (* Basic_1: was: pc3_gen_sort_abst *)
54 lemma cpcs_inv_sort_abst: ∀a,G,L,W,T,s. ⦃G, L⦄ ⊢ ⋆s ⬌* ⓛ{a}W.T → ⊥.
55 #a #G #L #W #T #s #H
56 elim (cpcs_inv_cprs … H) -H #X #H1
57 >(cprs_inv_sort1 … H1) -X #H2
58 elim (cprs_inv_abst1 … H2) -H2 #W0 #T0 #_ #_ #H destruct
59 qed-.
60
61 (* Basic_1: was: pc3_gen_lift *)
62 lemma cpcs_inv_lift: ∀G,L,K,b,l,k. ⬇[b, l, k] L ≡ K →
63                      ∀T1,U1. ⬆[l, k] T1 ≡ U1 → ∀T2,U2. ⬆[l, k] T2 ≡ U2 →
64                      ⦃G, L⦄ ⊢ U1 ⬌* U2 → ⦃G, K⦄ ⊢ T1 ⬌* T2.
65 #G #L #K #b #l #k #HLK #T1 #U1 #HTU1 #T2 #U2 #HTU2 #HU12
66 elim (cpcs_inv_cprs … HU12) -HU12 #U #HU1 #HU2
67 elim (cprs_inv_lift1 … HU1 … HLK … HTU1) -U1 #T #HTU #HT1
68 elim (cprs_inv_lift1 … HU2 … HLK … HTU2) -L -U2 #X #HXU
69 >(lift_inj … HXU … HTU) -X -U -l -k /2 width=3 by cprs_div/
70 qed-.
71
72 (* Advanced properties ******************************************************)
73
74 lemma lpr_cpcs_trans: ∀G,L1,L2. ⦃G, L1⦄ ⊢ ➡ L2 →
75                       ∀T1,T2. ⦃G, L2⦄ ⊢ T1 ⬌* T2 → ⦃G, L1⦄ ⊢ T1 ⬌* T2.
76 #G #L1 #L2 #HL12 #T1 #T2 #H elim (cpcs_inv_cprs … H) -H
77 /4 width=5 by cprs_div, lpr_cprs_trans/
78 qed-.
79
80 lemma lprs_cpcs_trans: ∀G,L1,L2. ⦃G, L1⦄ ⊢ ➡* L2 →
81                        ∀T1,T2. ⦃G, L2⦄ ⊢ T1 ⬌* T2 → ⦃G, L1⦄ ⊢ T1 ⬌* T2.
82 #G #L1 #L2 #HL12 #T1 #T2 #H elim (cpcs_inv_cprs … H) -H
83 /4 width=5 by cprs_div, lprs_cprs_trans/
84 qed-.
85
86 lemma cpr_cprs_conf_cpcs: ∀G,L,T,T1,T2. ⦃G, L⦄ ⊢ T ➡* T1 → ⦃G, L⦄ ⊢ T ➡ T2 → ⦃G, L⦄ ⊢ T1 ⬌* T2.
87 #G #L #T #T1 #T2 #HT1 #HT2 elim (cprs_strip … HT1 … HT2) -HT1 -HT2
88 /2 width=3 by cpr_cprs_div/
89 qed-.
90
91 lemma cprs_cpr_conf_cpcs: ∀G,L,T,T1,T2. ⦃G, L⦄ ⊢ T ➡* T1 → ⦃G, L⦄ ⊢ T ➡ T2 → ⦃G, L⦄ ⊢ T2 ⬌* T1.
92 #G #L #T #T1 #T2 #HT1 #HT2 elim (cprs_strip … HT1 … HT2) -HT1 -HT2
93 /2 width=3 by cprs_cpr_div/
94 qed-.
95
96 lemma cprs_conf_cpcs: ∀G,L,T,T1,T2. ⦃G, L⦄ ⊢ T ➡* T1 → ⦃G, L⦄ ⊢ T ➡* T2 → ⦃G, L⦄ ⊢ T1 ⬌* T2.
97 #G #L #T #T1 #T2 #HT1 #HT2 elim (cprs_conf … HT1 … HT2) -HT1 -HT2
98 /2 width=3 by cprs_div/
99 qed-.
100
101 lemma lprs_cprs_conf: ∀G,L1,L2. ⦃G, L1⦄ ⊢ ➡* L2 →
102                       ∀T1,T2. ⦃G, L1⦄ ⊢ T1 ➡* T2 → ⦃G, L2⦄ ⊢ T1 ⬌* T2.
103 #G #L1 #L2 #HL12 #T1 #T2 #HT12 elim (lprs_cprs_conf_dx … HT12 … HL12) -L1
104 /2 width=3 by cprs_div/
105 qed-.
106
107 (* Basic_1: was: pc3_wcpr0_t *)
108 (* Basic_1: note: pc3_wcpr0_t should be renamed *)
109 (* Note: alternative proof /3 width=5 by lprs_cprs_conf, lpr_lprs/ *)
110 lemma lpr_cprs_conf: ∀G,L1,L2. ⦃G, L1⦄ ⊢ ➡ L2 →
111                      ∀T1,T2. ⦃G, L1⦄ ⊢ T1 ➡* T2 → ⦃G, L2⦄ ⊢ T1 ⬌* T2.
112 #G #L1 #L2 #HL12 #T1 #T2 #HT12 elim (cprs_lpr_conf_dx … HT12 … HL12) -L1
113 /2 width=3 by cprs_div/
114 qed-.
115
116 (* Basic_1: was only: pc3_pr0_pr2_t *)
117 (* Basic_1: note: pc3_pr0_pr2_t should be renamed *)
118 lemma lpr_cpr_conf: ∀G,L1,L2. ⦃G, L1⦄ ⊢ ➡ L2 →
119                     ∀T1,T2. ⦃G, L1⦄ ⊢ T1 ➡ T2 → ⦃G, L2⦄ ⊢ T1 ⬌* T2.
120 /3 width=5 by lpr_cprs_conf, cpr_cprs/ qed-.
121
122 (* Basic_1: was only: pc3_thin_dx *)
123 lemma cpcs_flat: ∀G,L,V1,V2. ⦃G, L⦄ ⊢ V1 ⬌* V2 → ∀T1,T2. ⦃G, L⦄ ⊢ T1 ⬌* T2 →
124                  ∀I. ⦃G, L⦄ ⊢ ⓕ{I}V1.T1 ⬌* ⓕ{I}V2.T2.
125 #G #L #V1 #V2 #HV12 #T1 #T2 #HT12
126 elim (cpcs_inv_cprs … HV12) -HV12
127 elim (cpcs_inv_cprs … HT12) -HT12
128 /3 width=5 by cprs_flat, cprs_div/
129 qed.
130
131 lemma cpcs_flat_dx_cpr_rev: ∀G,L,V1,V2. ⦃G, L⦄ ⊢ V2 ➡ V1 → ∀T1,T2. ⦃G, L⦄ ⊢ T1 ⬌* T2 →
132                             ∀I. ⦃G, L⦄ ⊢ ⓕ{I}V1.T1 ⬌* ⓕ{I}V2.T2.
133 /3 width=1 by cpr_cpcs_sn, cpcs_flat/ qed.
134
135 lemma cpcs_bind_dx: ∀a,I,G,L,V,T1,T2. ⦃G, L.ⓑ{I}V⦄ ⊢ T1 ⬌* T2 →
136                     ⦃G, L⦄ ⊢ ⓑ{a,I}V.T1 ⬌* ⓑ{a,I}V.T2.
137 #a #I #G #L #V #T1 #T2 #HT12 elim (cpcs_inv_cprs … HT12) -HT12
138 /3 width=5 by cprs_div, cprs_bind/
139 qed.
140
141 lemma cpcs_bind_sn: ∀a,I,G,L,V1,V2,T. ⦃G, L⦄ ⊢ V1 ⬌* V2 → ⦃G, L⦄ ⊢ ⓑ{a,I}V1. T ⬌* ⓑ{a,I}V2. T.
142 #a #I #G #L #V1 #V2 #T #HV12 elim (cpcs_inv_cprs … HV12) -HV12
143 /3 width=5 by cprs_div, cprs_bind/
144 qed.
145
146 lemma lsubr_cpcs_trans: ∀G,L1,T1,T2. ⦃G, L1⦄ ⊢ T1 ⬌* T2 →
147                         ∀L2. L2 ⫃ L1 → ⦃G, L2⦄ ⊢ T1 ⬌* T2.
148 #G #L1 #T1 #T2 #HT12 elim (cpcs_inv_cprs … HT12) -HT12
149 /3 width=5 by cprs_div, lsubr_cprs_trans/
150 qed-.
151
152 (* Basic_1: was: pc3_lift *)
153 lemma cpcs_lift: ∀G,L,K,b,l,k. ⬇[b, l, k] L ≡ K →
154                  ∀T1,U1. ⬆[l, k] T1 ≡ U1 → ∀T2,U2. ⬆[l, k] T2 ≡ U2 →
155                  ⦃G, K⦄ ⊢ T1 ⬌* T2 → ⦃G, L⦄ ⊢ U1 ⬌* U2.
156 #G #L #K #b #l #k #HLK #T1 #U1 #HTU1 #T2 #U2 #HTU2 #HT12
157 elim (cpcs_inv_cprs … HT12) -HT12 #T #HT1 #HT2
158 elim (lift_total T l k) /3 width=12 by cprs_div, cprs_lift/
159 qed.
160
161 lemma cpcs_strip: ∀G,L,T1,T. ⦃G, L⦄ ⊢ T ⬌* T1 → ∀T2. ⦃G, L⦄ ⊢ T ⬌ T2 →
162                   ∃∃T0. ⦃G, L⦄ ⊢ T1 ⬌ T0 & ⦃G, L⦄ ⊢ T2 ⬌* T0.
163 #G #L #T1 #T @TC_strip1 /2 width=3 by cpc_conf/ qed-.
164
165 (* More inversion lemmas ****************************************************)
166
167 (* Note: there must be a proof suitable for llpr *)
168 lemma cpcs_inv_abst_sn: ∀a1,a2,G,L,W1,W2,T1,T2. ⦃G, L⦄ ⊢ ⓛ{a1}W1.T1 ⬌* ⓛ{a2}W2.T2 →
169                         ∧∧ ⦃G, L⦄ ⊢ W1 ⬌* W2 & ⦃G, L.ⓛW1⦄ ⊢ T1 ⬌* T2 & a1 = a2.
170 #a1 #a2 #G #L #W1 #W2 #T1 #T2 #H
171 elim (cpcs_inv_cprs … H) -H #T #H1 #H2
172 elim (cprs_inv_abst1 … H1) -H1 #W0 #T0 #HW10 #HT10 #H destruct
173 elim (cprs_inv_abst1 … H2) -H2 #W #T #HW2 #HT2 #H destruct
174 lapply (lprs_cprs_conf … (L.ⓛW) … HT2) /2 width=1 by lprs_pair/ -HT2 #HT2
175 lapply (lprs_cpcs_trans … (L.ⓛW1) … HT2) /2 width=1 by lprs_pair/ -HT2 #HT2
176 /4 width=3 by and3_intro, cprs_div, cpcs_cprs_div, cpcs_sym/
177 qed-.
178
179 lemma cpcs_inv_abst_dx: ∀a1,a2,G,L,W1,W2,T1,T2. ⦃G, L⦄ ⊢ ⓛ{a1}W1.T1 ⬌* ⓛ{a2}W2.T2 →
180                         ∧∧ ⦃G, L⦄ ⊢ W1 ⬌* W2 & ⦃G, L.ⓛW2⦄ ⊢ T1 ⬌* T2 & a1 = a2.
181 #a1 #a2 #G #L #W1 #W2 #T1 #T2 #HT12 lapply (cpcs_sym … HT12) -HT12
182 #HT12 elim (cpcs_inv_abst_sn … HT12) -HT12 /3 width=1 by cpcs_sym, and3_intro/
183 qed-.
184
185 (* Main properties **********************************************************)
186
187 (* Basic_1: was pc3_t *)
188 theorem cpcs_trans: ∀G,L,T1,T. ⦃G, L⦄ ⊢ T1 ⬌* T → ∀T2. ⦃G, L⦄ ⊢ T ⬌* T2 → ⦃G, L⦄ ⊢ T1 ⬌* T2.
189 #G #L #T1 #T #HT1 #T2 @(trans_TC … HT1) qed-.
190
191 theorem cpcs_canc_sn: ∀G,L,T,T1,T2. ⦃G, L⦄ ⊢ T ⬌* T1 → ⦃G, L⦄ ⊢ T ⬌* T2 → ⦃G, L⦄ ⊢ T1 ⬌* T2.
192 /3 width=3 by cpcs_trans, cpcs_sym/ qed-.
193
194 theorem cpcs_canc_dx: ∀G,L,T,T1,T2. ⦃G, L⦄ ⊢ T1 ⬌* T → ⦃G, L⦄ ⊢ T2 ⬌* T → ⦃G, L⦄ ⊢ T1 ⬌* T2.
195 /3 width=3 by cpcs_trans, cpcs_sym/ qed-.
196
197 lemma cpcs_bind1: ∀a,I,G,L,V1,V2. ⦃G, L⦄ ⊢ V1 ⬌* V2 →
198                   ∀T1,T2. ⦃G, L.ⓑ{I}V1⦄ ⊢ T1 ⬌* T2 →
199                   ⦃G, L⦄ ⊢ ⓑ{a,I}V1. T1 ⬌* ⓑ{a,I}V2. T2.
200 /3 width=3 by cpcs_trans, cpcs_bind_sn, cpcs_bind_dx/ qed.
201
202 lemma cpcs_bind2: ∀a,I,G,L,V1,V2. ⦃G, L⦄ ⊢ V1 ⬌* V2 →
203                   ∀T1,T2. ⦃G, L.ⓑ{I}V2⦄ ⊢ T1 ⬌* T2 →
204                   ⦃G, L⦄ ⊢ ⓑ{a,I}V1. T1 ⬌* ⓑ{a,I}V2. T2.
205 /3 width=3 by cpcs_trans, cpcs_bind_sn, cpcs_bind_dx/ qed.
206
207 (* Basic_1: was: pc3_wcpr0 *)
208 lemma lpr_cpcs_conf: ∀G,L1,L2. ⦃G, L1⦄ ⊢ ➡ L2 →
209                      ∀T1,T2. ⦃G, L1⦄ ⊢ T1 ⬌* T2 → ⦃G, L2⦄ ⊢ T1 ⬌* T2.
210 #G #L1 #L2 #HL12 #T1 #T2 #H elim (cpcs_inv_cprs … H) -H
211 /3 width=5 by cpcs_canc_dx, lpr_cprs_conf/
212 qed-.