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