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