]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/ground_2/lib/star.ma
- ground_2: some additions
[helm.git] / matita / matita / contribs / lambdadelta / ground_2 / lib / star.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 "basics/star1.ma".
16 include "ground_2/xoa/xoa_props.ma".
17
18 (* PROPERTIES OF RELATIONS **************************************************)
19
20 definition Decidable: Prop → Prop ≝ λR. R ∨ (R → ⊥).
21
22 definition Transitive: ∀A. ∀R: relation A. Prop ≝ λA,R.
23                        ∀a1,a0. R a1 a0 → ∀a2. R a0 a2 → R a1 a2.
24                        
25 definition left_cancellable: ∀A. ∀R: relation A. Prop ≝ λA,R.
26                              ∀a0,a1. R a0 a1 → ∀a2. R a0 a2 → R a1 a2.
27
28 definition right_cancellable: ∀A. ∀R: relation A. Prop ≝ λA,R.
29                               ∀a1,a0. R a1 a0 → ∀a2. R a2 a0 → R a1 a2.
30
31 definition confluent2: ∀A. ∀R1,R2: relation A. Prop ≝ λA,R1,R2.
32                        ∀a0,a1. R1 a0 a1 → ∀a2. R2 a0 a2 →
33                        ∃∃a. R2 a1 a & R1 a2 a.
34
35 definition transitive2: ∀A. ∀R1,R2: relation A. Prop ≝ λA,R1,R2.
36                         ∀a1,a0. R1 a1 a0 → ∀a2. R2 a0 a2 →
37                         ∃∃a. R2 a1 a & R1 a a2.
38
39 definition bi_confluent:  ∀A,B. ∀R: bi_relation A B. Prop ≝ λA,B,R.
40                           ∀a0,a1,b0,b1. R a0 b0 a1 b1 → ∀a2,b2. R a0 b0 a2 b2 →
41                           ∃∃a,b. R a1 b1 a b & R a2 b2 a b.
42
43 definition LTC: ∀A:Type[0]. ∀B. (A→relation B) → (A→relation B) ≝
44                 λA,B,R,a. TC … (R a).
45
46 definition lsub_trans: ∀A,B. relation2 (A→relation B) (relation A) ≝ λA,B,R1,R2.
47                        ∀L2,T1,T2. R1 L2 T1 T2 → ∀L1. R2 L1 L2 → R1 L1 T1 T2.
48
49 definition s_r_transitive: ∀A,B. relation2 (A→relation B) (B→relation A) ≝ λA,B,R1,R2.
50                            ∀L2,T1,T2. R1 L2 T1 T2 → ∀L1. R2 T1 L1 L2 → LTC … R1 L1 T1 T2.
51
52 definition s_rs_transitive: ∀A,B. relation2 (A→relation B) (B→relation A) ≝ λA,B,R1,R2.
53                             ∀L2,T1,T2. LTC … R1 L2 T1 T2 → ∀L1. R2 T1 L1 L2 → LTC … R1 L1 T1 T2.
54
55 definition s_r_confluent1: ∀A,B. relation2 (A→relation B) (B→relation A) ≝ λA,B,R1,R2.
56                            ∀L1,T1,T2. R1 L1 T1 T2 → ∀L2. R2 T1 L1 L2 → R2 T2 L1 L2.
57
58 lemma TC_strip1: ∀A,R1,R2. confluent2 A R1 R2 →
59                  ∀a0,a1. TC … R1 a0 a1 → ∀a2. R2 a0 a2 →
60                  ∃∃a. R2 a1 a & TC … R1 a2 a.
61 #A #R1 #R2 #HR12 #a0 #a1 #H elim H -a1
62 [ #a1 #Ha01 #a2 #Ha02
63   elim (HR12 … Ha01 … Ha02) -HR12 -a0 /3 width=3 by inj, ex2_intro/
64 | #a #a1 #_ #Ha1 #IHa0 #a2 #Ha02
65   elim (IHa0 … Ha02) -a0 #a0 #Ha0 #Ha20
66   elim (HR12 … Ha1 … Ha0) -HR12 -a /4 width=5 by step, ex2_intro/
67 ]
68 qed.
69
70 lemma TC_strip2: ∀A,R1,R2. confluent2 A R1 R2 →
71                  ∀a0,a2. TC … R2 a0 a2 → ∀a1. R1 a0 a1 →
72                  ∃∃a. TC … R2 a1 a & R1 a2 a.
73 #A #R1 #R2 #HR12 #a0 #a2 #H elim H -a2
74 [ #a2 #Ha02 #a1 #Ha01
75   elim (HR12 … Ha01 … Ha02) -HR12 -a0 /3 width=3 by inj, ex2_intro/
76 | #a #a2 #_ #Ha2 #IHa0 #a1 #Ha01
77   elim (IHa0 … Ha01) -a0 #a0 #Ha10 #Ha0
78   elim (HR12 … Ha0 … Ha2) -HR12 -a /4 width=3 by step, ex2_intro/
79 ]
80 qed.
81
82 lemma TC_confluent2: ∀A,R1,R2.
83                      confluent2 A R1 R2 → confluent2 A (TC … R1) (TC … R2).
84 #A #R1 #R2 #HR12 #a0 #a1 #H elim H -a1
85 [ #a1 #Ha01 #a2 #Ha02
86   elim (TC_strip2 … HR12 … Ha02 … Ha01) -HR12 -a0 /3 width=3 by inj, ex2_intro/
87 | #a #a1 #_ #Ha1 #IHa0 #a2 #Ha02
88   elim (IHa0 … Ha02) -a0 #a0 #Ha0 #Ha20
89   elim (TC_strip2 … HR12 … Ha0 … Ha1) -HR12 -a /4 width=5 by step, ex2_intro/
90 ]
91 qed.
92
93 lemma TC_strap1: ∀A,R1,R2. transitive2 A R1 R2 →
94                  ∀a1,a0. TC … R1 a1 a0 → ∀a2. R2 a0 a2 →
95                  ∃∃a. R2 a1 a & TC … R1 a a2.
96 #A #R1 #R2 #HR12 #a1 #a0 #H elim H -a0
97 [ #a0 #Ha10 #a2 #Ha02
98   elim (HR12 … Ha10 … Ha02) -HR12 -a0 /3 width=3 by inj, ex2_intro/
99 | #a #a0 #_ #Ha0 #IHa #a2 #Ha02
100   elim (HR12 … Ha0 … Ha02) -HR12 -a0 #a0 #Ha0 #Ha02
101   elim (IHa … Ha0) -a /4 width=5 by step, ex2_intro/
102 ]
103 qed.
104
105 lemma TC_strap2: ∀A,R1,R2. transitive2 A R1 R2 →
106                  ∀a0,a2. TC … R2 a0 a2 → ∀a1. R1 a1 a0 →
107                  ∃∃a. TC … R2 a1 a & R1 a a2.
108 #A #R1 #R2 #HR12 #a0 #a2 #H elim H -a2
109 [ #a2 #Ha02 #a1 #Ha10
110   elim (HR12 … Ha10 … Ha02) -HR12 -a0 /3 width=3 by inj, ex2_intro/
111 | #a #a2 #_ #Ha02 #IHa #a1 #Ha10
112   elim (IHa … Ha10) -a0 #a0 #Ha10 #Ha0
113   elim (HR12 … Ha0 … Ha02) -HR12 -a /4 width=3 by step, ex2_intro/
114 ]
115 qed.
116
117 lemma TC_transitive2: ∀A,R1,R2.
118                       transitive2 A R1 R2 → transitive2 A (TC … R1) (TC … R2).
119 #A #R1 #R2 #HR12 #a1 #a0 #H elim H -a0
120 [ #a0 #Ha10 #a2 #Ha02
121   elim (TC_strap2 … HR12 … Ha02 … Ha10) -HR12 -a0 /3 width=3 by inj, ex2_intro/
122 | #a #a0 #_ #Ha0 #IHa #a2 #Ha02
123   elim (TC_strap2 … HR12 … Ha02 … Ha0) -HR12 -a0 #a0 #Ha0 #Ha02
124   elim (IHa … Ha0) -a /4 width=5 by step, ex2_intro/
125 ]
126 qed.
127
128 definition NF: ∀A. relation A → relation A → predicate A ≝
129    λA,R,S,a1. ∀a2. R a1 a2 → S a2 a1.
130
131 definition NF_dec: ∀A. relation A → relation A → Prop ≝
132                    λA,R,S. ∀a1. NF A R S a1 ∨
133                    ∃∃a2. R … a1 a2 & (S a2 a1 → ⊥).
134
135 inductive SN (A) (R,S:relation A): predicate A ≝
136 | SN_intro: ∀a1. (∀a2. R a1 a2 → (S a2 a1 → ⊥) → SN A R S a2) → SN A R S a1
137 .
138
139 lemma NF_to_SN: ∀A,R,S,a. NF A R S a → SN A R S a.
140 #A #R #S #a1 #Ha1
141 @SN_intro #a2 #HRa12 #HSa12
142 elim HSa12 -HSa12 /2 width=1 by/
143 qed.
144
145 lemma SN_to_NF: ∀A,R,S. NF_dec A R S →
146                 ∀a1. SN A R S a1 →
147                 ∃∃a2. star … R a1 a2 & NF A R S a2.
148 #A #R #S #HRS #a1 #H elim H -a1
149 #a1 #_ #IHa1 elim (HRS a1) -HRS /2 width=3 by srefl, ex2_intro/
150 * #a0 #Ha10 #Ha01 elim (IHa1 … Ha10 Ha01) -IHa1 -Ha01 /3 width=3 by star_compl, ex2_intro/
151 qed-.
152
153 definition NF_sn: ∀A. relation A → relation A → predicate A ≝
154    λA,R,S,a2. ∀a1. R a1 a2 → S a2 a1.
155
156 inductive SN_sn (A) (R,S:relation A): predicate A ≝
157 | SN_sn_intro: ∀a2. (∀a1. R a1 a2 → (S a2 a1 → ⊥) → SN_sn A R S a1) → SN_sn A R S a2
158 .
159
160 lemma NF_to_SN_sn: ∀A,R,S,a. NF_sn A R S a → SN_sn A R S a.
161 #A #R #S #a2 #Ha2
162 @SN_sn_intro #a1 #HRa12 #HSa12
163 elim HSa12 -HSa12 /2 width=1 by/
164 qed.
165
166 lemma LTC_lsub_trans: ∀A,B,R,S. lsub_trans A B R S → lsub_trans A B (LTC … R) S.
167 #A #B #R #S #HRS #L2 #T1 #T2 #H elim H -T2 /3 width=3 by inj/
168 #T #T2 #_ #HT2 #IHT1 #L1 #HL12
169 lapply (HRS … HT2 … HL12) -HRS -HT2 /3 width=3 by step/
170 qed-.
171
172 lemma s_r_conf1_LTC1: ∀A,B,S,R. s_r_confluent1 A B S R → s_r_confluent1 A B (LTC … S) R.
173 #A #B #S #R #HSR #L1 #T1 #T2 #H @(TC_ind_dx … T1 H) -T1 /3 width=3 by/
174 qed-.
175
176 lemma s_r_trans_LTC1: ∀A,B,S,R. s_r_confluent1 A B S R →
177                       s_r_transitive A B S R → s_rs_transitive A B S R.
178 #A #B #S #R #H1SR #H2SR #L2 #T1 #T2 #H @(TC_ind_dx … T1 H) -T1 /2 width=3 by/
179 #T1 #T #HT1 #_ #IHT2 #L1 #HL12 lapply (H2SR … HT1 … HL12) -H2SR -HT1
180 /4 width=5 by s_r_conf1_LTC1, trans_TC/
181 qed-.
182
183 lemma s_r_trans_LTC2: ∀A,B,S,R. s_rs_transitive A B S R → s_r_transitive A B S (LTC … R).
184 #A #B #S #R #HSR #L2 #T1 #T2 #HT12 #L1 #H @(TC_ind_dx … L1 H) -L1 /3 width=3 by inj/
185 qed-.
186
187 lemma s_r_to_s_rs_trans: ∀A,B,S,R. s_r_transitive A B (LTC … S) R →
188                          s_rs_transitive A B S R.
189 #A #B #S #R #HSR #L2 #T1 #T2 #HL2 #L1 #HT1
190 elim (TC_idem … (S L1) …  T1 T2)
191 #_ #H @H @HSR //
192 qed-.
193
194 lemma s_rs_to_s_r_trans: ∀A,B,S,R. s_rs_transitive A B S R →
195                          s_r_transitive A B (LTC … S) R.
196 #A #B #S #R #HSR #L2 #T1 #T2 #HL2 #L1 #HT1
197 elim (TC_idem … (S L1) …  T1 T2)
198 #H #_ @H @HSR //
199 qed-.
200
201 lemma s_rs_trans_TC1: ∀A,B,S,R. s_rs_transitive A B S R →
202                       s_rs_transitive A B (LTC … S) R.
203 #A #B #S #R #HSR #L2 #T1 #T2 #HL2 #L1 #HT1
204 elim (TC_idem … (S L1) …  T1 T2)
205 elim (TC_idem … (S L2) …  T1 T2)
206 #_ #H1 #H2 #_ @H2 @HSR /3 width=3 by/
207 qed-.
208
209 (* relations on unboxed pairs ***********************************************)
210
211 lemma bi_TC_strip: ∀A,B,R. bi_confluent A B R →
212                    ∀a0,a1,b0,b1. R a0 b0 a1 b1 → ∀a2,b2. bi_TC … R a0 b0 a2 b2 →
213                    ∃∃a,b. bi_TC … R a1 b1 a b & R a2 b2 a b.
214 #A #B #R #HR #a0 #a1 #b0 #b1 #H01 #a2 #b2 #H elim H -a2 -b2
215 [ #a2 #b2 #H02
216   elim (HR … H01 … H02) -HR -a0 -b0 /3 width=4 by ex2_2_intro, bi_inj/
217 | #a2 #b2 #a3 #b3 #_ #H23 * #a #b #H1 #H2
218   elim (HR … H23 … H2) -HR -a0 -b0 -a2 -b2 /3 width=4 by ex2_2_intro, bi_step/
219 ]
220 qed.
221
222 lemma bi_TC_confluent: ∀A,B,R. bi_confluent A B R →
223                        bi_confluent A B (bi_TC … R).
224 #A #B #R #HR #a0 #a1 #b0 #b1 #H elim H -a1 -b1
225 [ #a1 #b1 #H01 #a2 #b2 #H02
226   elim (bi_TC_strip … HR … H01 … H02) -a0 -b0 /3 width=4 by ex2_2_intro, bi_inj/
227 | #a1 #b1 #a3 #b3 #_ #H13 #IH #a2 #b2 #H02
228   elim (IH … H02) -a0 -b0 #a0 #b0 #H10 #H20
229   elim (bi_TC_strip … HR … H13 … H10) -a1 -b1 /3 width=7 by ex2_2_intro, bi_step/
230 ]
231 qed.
232
233 lemma bi_TC_decomp_r: ∀A,B. ∀R:bi_relation A B.
234                       ∀a1,a2,b1,b2. bi_TC … R a1 b1 a2 b2 →
235                       R a1 b1 a2 b2 ∨
236                       ∃∃a,b. bi_TC … R a1 b1 a b & R a b a2 b2.
237 #A #B #R #a1 #a2 #b1 #b2 * -a2 -b2 /2 width=1/ /3 width=4 by ex2_2_intro, or_intror/
238 qed-.
239
240 lemma bi_TC_decomp_l: ∀A,B. ∀R:bi_relation A B.
241                       ∀a1,a2,b1,b2. bi_TC … R a1 b1 a2 b2 →
242                       R a1 b1 a2 b2 ∨
243                       ∃∃a,b. R a1 b1 a b & bi_TC … R a b a2 b2.
244 #A #B #R #a1 #a2 #b1 #b2 #H @(bi_TC_ind_dx … a1 b1 H) -a1 -b1
245 [ /2 width=1 by or_introl/
246 | #a1 #a #b1 #b #Hab1 #Hab2 #_ /3 width=4 by ex2_2_intro, or_intror/ (**) (* auto fails without #_ *)
247 ]
248 qed-.
249
250 (* relations on unboxed triples *********************************************)
251
252 definition tri_RC: ∀A,B,C. tri_relation A B C → tri_relation A B C ≝
253                    λA,B,C,R,a1,b1,c1,a2,b2,c2. R … a1 b1 c1 a2 b2 c2 ∨
254                    ∧∧ a1 = a2 & b1 = b2 & c1 = c2.
255
256 lemma tri_RC_reflexive: ∀A,B,C,R. tri_reflexive A B C (tri_RC … R).
257 /3 width=1 by and3_intro, or_intror/ qed.
258
259 definition tri_star: ∀A,B,C,R. tri_relation A B C ≝
260                      λA,B,C,R. tri_RC A B C (tri_TC … R).
261
262 lemma tri_star_tri_reflexive: ∀A,B,C,R. tri_reflexive A B C (tri_star … R).
263 /2 width=1 by/ qed.
264
265 lemma tri_TC_to_tri_star: ∀A,B,C,R,a1,b1,c1,a2,b2,c2.
266                           tri_TC A B C R a1 b1 c1 a2 b2 c2 →
267                           tri_star A B C R a1 b1 c1 a2 b2 c2.
268 /2 width=1 by or_introl/ qed.
269
270 lemma tri_R_to_tri_star: ∀A,B,C,R,a1,b1,c1,a2,b2,c2.
271                          R a1 b1 c1 a2 b2 c2 → tri_star A B C R a1 b1 c1 a2 b2 c2.
272 /3 width=1 by tri_TC_to_tri_star, tri_inj/ qed.
273
274 lemma tri_star_strap1: ∀A,B,C,R,a1,a,a2,b1,b,b2,c1,c,c2.
275                        tri_star A B C R a1 b1 c1 a b c →
276                        R a b c a2 b2 c2 → tri_star A B C R a1 b1 c1 a2 b2 c2.
277 #A #B #C #R #a1 #a #a2 #b1 #b #b2 #c1 #c #c2 *
278 [ /3 width=5 by tri_TC_to_tri_star, tri_step/
279 | * #H1 #H2 #H3 destruct /2 width=1 by tri_R_to_tri_star/
280 ]
281 qed.
282
283 lemma tri_star_strap2: ∀A,B,C,R,a1,a,a2,b1,b,b2,c1,c,c2. R a1 b1 c1 a b c →
284                        tri_star A B C R a b c a2 b2 c2 →
285                        tri_star A B C R a1 b1 c1 a2 b2 c2.
286 #A #B #C #R #a1 #a #a2 #b1 #b #b2 #c1 #c #c2 #H *
287 [ /3 width=5 by tri_TC_to_tri_star, tri_TC_strap/
288 | * #H1 #H2 #H3 destruct /2 width=1 by tri_R_to_tri_star/
289 ]
290 qed.
291
292 lemma tri_star_to_tri_TC_to_tri_TC: ∀A,B,C,R,a1,a,a2,b1,b,b2,c1,c,c2.
293                                     tri_star A B C R a1 b1 c1 a b c →
294                                     tri_TC A B C R a b c a2 b2 c2 →
295                                     tri_TC A B C R a1 b1 c1 a2 b2 c2.
296 #A #B #C #R #a1 #a #a2 #b1 #b #b2 #c1 #c #c2 *
297 [ /2 width=5 by tri_TC_transitive/
298 | * #H1 #H2 #H3 destruct /2 width=1 by/
299 ]
300 qed.
301
302 lemma tri_TC_to_tri_star_to_tri_TC: ∀A,B,C,R,a1,a,a2,b1,b,b2,c1,c,c2.
303                                     tri_TC A B C R a1 b1 c1 a b c →
304                                     tri_star A B C R a b c a2 b2 c2 →
305                                     tri_TC A B C R a1 b1 c1 a2 b2 c2.
306 #A #B #C #R #a1 #a #a2 #b1 #b #b2 #c1 #c #c2 #H *
307 [ /2 width=5 by tri_TC_transitive/
308 | * #H1 #H2 #H3 destruct /2 width=1 by/
309 ]
310 qed.
311
312 lemma tri_tansitive_tri_star: ∀A,B,C,R. tri_transitive A B C (tri_star … R).
313 #A #B #C #R #a1 #a #b1 #b #c1 #c #H #a2 #b2 #c2 *
314 [ /3 width=5 by tri_star_to_tri_TC_to_tri_TC, tri_TC_to_tri_star/
315 | * #H1 #H2 #H3 destruct /2 width=1 by/
316 ]
317 qed.
318
319 lemma tri_star_ind: ∀A,B,C,R,a1,b1,c1. ∀P:relation3 A B C. P a1 b1 c1 →
320                     (∀a,a2,b,b2,c,c2. tri_star … R a1 b1 c1 a b c → R a b c a2 b2 c2 → P a b c → P a2 b2 c2) →
321                     ∀a2,b2,c2. tri_star … R a1 b1 c1 a2 b2 c2 → P a2 b2 c2.
322 #A #B #C #R #a1 #b1 #c1 #P #H #IH #a2 #b2 #c2 *
323 [ #H12 elim H12 -a2 -b2 -c2 /3 width=6 by tri_TC_to_tri_star/
324 | * #H1 #H2 #H3 destruct //
325 ]
326 qed-.
327
328 lemma tri_star_ind_dx: ∀A,B,C,R,a2,b2,c2. ∀P:relation3 A B C. P a2 b2 c2 →
329                        (∀a1,a,b1,b,c1,c. R a1 b1 c1 a b c → tri_star … R a b c a2 b2 c2 → P a b c → P a1 b1 c1) →
330                        ∀a1,b1,c1. tri_star … R a1 b1 c1 a2 b2 c2 → P a1 b1 c1.
331 #A #B #C #R #a2 #b2 #c2 #P #H #IH #a1 #b1 #c1 *
332 [ #H12 @(tri_TC_ind_dx … a1 b1 c1 H12) -a1 -b1 -c1 /3 width=6 by tri_TC_to_tri_star/
333 | * #H1 #H2 #H3 destruct //
334 ]
335 qed-.