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