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