2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department of the University of Bologna, Italy.
7 ||A|| This file is distributed under the terms of the
8 \ / GNU General Public License Version 2
10 V_______________________________________________________________ *)
12 include "basics/relations.ma".
14 (* transitive closcure (plus) *)
16 inductive TC (A:Type[0]) (R:relation A) (a:A): A → Prop ≝
17 |inj: ∀c. R a c → TC A R a c
18 |step : ∀b,c.TC A R a b → R b c → TC A R a c.
20 theorem trans_TC: ∀A,R,a,b,c.
21 TC A R a b → TC A R b c → TC A R a c.
22 #A #R #a #b #c #Hab #Hbc (elim Hbc) /2/
25 theorem TC_idem: ∀A,R. exteqR … (TC A R) (TC A (TC A R)).
26 #A #R #a #b % /2/ #H (elim H) /2/
29 lemma monotonic_TC: ∀A,R,S. subR A R S → subR A (TC A R) (TC A S).
30 #A #R #S #subRS #a #b #H (elim H) /3/
33 lemma sub_TC: ∀A,R,S. subR A R (TC A S) → subR A (TC A R) (TC A S).
34 #A #R #S #Hsub #a #b #H (elim H) /3/
37 theorem sub_TC_to_eq: ∀A,R,S. subR A R S → subR A S (TC A R) →
38 exteqR … (TC A R) (TC A S).
39 #A #R #S #sub1 #sub2 #a #b % /2/
42 theorem TC_inv: ∀A,R. exteqR ?? (TC A (inv A R)) (inv A (TC A R)).
44 #H (elim H) /2/ normalize #c #d #H1 #H2 #H3 @(trans_TC … H3) /2/
48 inductive star (A:Type[0]) (R:relation A) (a:A): A → Prop ≝
49 |sstep: ∀b,c.star A R a b → R b c → star A R a c
52 lemma R_to_star: ∀A,R,a,b. R a b → star A R a b.
56 theorem trans_star: ∀A,R,a,b,c.
57 star A R a b → star A R b c → star A R a c.
58 #A #R #a #b #c #Hab #Hbc (elim Hbc) /2/
61 theorem star_star: ∀A,R. exteqR … (star A R) (star A (star A R)).
62 #A #R #a #b % /2/ #H (elim H) /2/
65 lemma monotonic_star: ∀A,R,S. subR A R S → subR A (star A R) (star A S).
66 #A #R #S #subRS #a #b #H (elim H) /3/
69 lemma sub_star: ∀A,R,S. subR A R (star A S) →
70 subR A (star A R) (star A S).
71 #A #R #S #Hsub #a #b #H (elim H) /3/
74 theorem sub_star_to_eq: ∀A,R,S. subR A R S → subR A S (star A R) →
75 exteqR … (star A R) (star A S).
76 #A #R #S #sub1 #sub2 #a #b % /2/
79 theorem star_inv: ∀A,R.
80 exteqR ?? (star A (inv A R)) (inv A (star A R)).
82 #H (elim H) /2/ normalize #c #d #H1 #H2 #H3 @(trans_star … H3) /2/
86 ∀A,R,x,y.star A R x y → x = y ∨ ∃z.R x z ∧ star A R z y.
87 #A #R #x #y #Hstar elim Hstar
88 [ #b #c #Hleft #Hright *
89 [ #H1 %2 @(ex_intro ?? c) % //
90 | * #x0 * #H1 #H2 %2 @(ex_intro ?? x0) % /2/ ]
94 (* right associative version of star *)
95 inductive starl (A:Type[0]) (R:relation A) : A → A → Prop ≝
96 |sstepl: ∀a,b,c.R a b → starl A R b c → starl A R a c
97 |refll: ∀a.starl A R a a.
99 lemma starl_comp : ∀A,R,a,b,c.
100 starl A R a b → R b c → starl A R a c.
101 #A #R #a #b #c #Hstar elim Hstar
102 [#a1 #b1 #c1 #Rab #sbc #Hind #a1 @(sstepl … Rab) @Hind //
103 |#a1 #Rac @(sstepl … Rac) //
107 lemma star_compl : ∀A,R,a,b,c.
108 R a b → star A R b c → star A R a c.
109 #A #R #a #b #c #Rab #Hstar elim Hstar
110 [#b1 #c1 #sbb1 #Rb1c1 #Hind @(sstep … Rb1c1) @Hind
115 lemma star_to_starl: ∀A,R,a,b.star A R a b → starl A R a b.
116 #A #R #a #b #Hs elim Hs //
117 #d #c #sad #Rdc #sad @(starl_comp … Rdc) //
120 lemma starl_to_star: ∀A,R,a,b.starl A R a b → star A R a b.
121 #A #R #a #b #Hs elim Hs // -Hs -b -a
122 #a #b #c #Rab #sbc #sbc @(star_compl … Rab) //
125 fact star_ind_l_aux: ∀A,R,a2. ∀P:predicate A.
127 (∀a1,a. R a1 a → star … R a a2 → P a → P a1) →
128 ∀a1,a. star … R a1 a → a = a2 → P a1.
129 #A #R #a2 #P #H1 #H2 #a1 #a #Ha1
130 elim (star_to_starl ???? Ha1) -a1 -a
131 [ #a #b #c #Hab #Hbc #IH #H destruct /3 width=4/
132 | #a #H destruct /2 width=1/
136 (* imporeved version of star_ind_l with "left_parameter" *)
137 lemma star_ind_l: ∀A,R,a2. ∀P:predicate A.
139 (∀a1,a. R a1 a → star … R a a2 → P a → P a1) →
140 ∀a1. star … R a1 a2 → P a1.
141 #A #R #a2 #P #H1 #H2 #a1 #Ha12
142 @(star_ind_l_aux … H1 H2 … Ha12) //
147 lemma TC_to_star: ∀A,R,a,b.TC A R a b → star A R a b.
148 #R #A #a #b #TCH (elim TCH) /2/
151 lemma star_case: ∀A,R,a,b. star A R a b → a = b ∨ TC A R a b.
152 #A #R #a #b #H (elim H) /2/ #c #d #star_ac #Rcd * #H1 %2 /2/.
155 (* equiv -- smallest equivalence relation containing R *)
157 inductive equiv (A:Type[0]) (R:relation A) : A → A → Prop ≝
158 |inje: ∀a,b,c.equiv A R a b → R b c → equiv A R a c
159 |refle: ∀a,b.equiv A R a b
160 |syme: ∀a,b.equiv A R a b → equiv A R b a.
162 theorem trans_equiv: ∀A,R,a,b,c.
163 equiv A R a b → equiv A R b c → equiv A R a c.
164 #A #R #a #b #c #Hab #Hbc (elim Hbc) /2/
167 theorem equiv_equiv: ∀A,R. exteqR … (equiv A R) (equiv A (equiv A R)).
171 lemma monotonic_equiv: ∀A,R,S. subR A R S → subR A (equiv A R) (equiv A S).
172 #A #R #S #subRS #a #b #H (elim H) /3/
175 lemma sub_equiv: ∀A,R,S. subR A R (equiv A S) →
176 subR A (equiv A R) (equiv A S).
177 #A #R #S #Hsub #a #b #H (elim H) /2/
180 theorem sub_equiv_to_eq: ∀A,R,S. subR A R S → subR A S (equiv A R) →
181 exteqR … (equiv A R) (equiv A S).
182 #A #R #S #sub1 #sub2 #a #b % /2/
185 (* well founded part of a relation *)
187 inductive WF (A:Type[0]) (R:relation A) : A → Prop ≝
188 | wf : ∀b.(∀a. R a b → WF A R a) → WF A R b.
190 lemma WF_antimonotonic: ∀A,R,S. subR A R S →
191 ∀a. WF A S a → WF A R a.
192 #A #R #S #subRS #a #HWF (elim HWF) #b
193 #H #Hind % #c #Rcb @Hind @subRS //
196 (* added from lambda_delta *)
198 lemma TC_strap: ∀A. ∀R:relation A. ∀a1,a,a2.
199 R a1 a → TC … R a a2 → TC … R a1 a2.
202 lemma TC_reflexive: ∀A,R. reflexive A R → reflexive A (TC … R).
205 lemma TC_star_ind: ∀A,R. reflexive A R → ∀a1. ∀P:predicate A.
206 P a1 → (∀a,a2. TC … R a1 a → R a a2 → P a → P a2) →
207 ∀a2. TC … R a1 a2 → P a2.
208 #A #R #H #a1 #P #Ha1 #IHa1 #a2 #Ha12 elim Ha12 -a2 /3 width=4/
211 inductive TC_dx (A:Type[0]) (R:relation A): A → A → Prop ≝
212 |inj_dx: ∀a,c. R a c → TC_dx A R a c
213 |step_dx : ∀a,b,c. R a b → TC_dx A R b c → TC_dx A R a c.
215 lemma TC_dx_strap: ∀A. ∀R: relation A.
216 ∀a,b,c. TC_dx A R a b → R b c → TC_dx A R a c.
217 #A #R #a #b #c #Hab elim Hab -a -b /3 width=3/
220 lemma TC_to_TC_dx: ∀A. ∀R: relation A.
221 ∀a1,a2. TC … R a1 a2 → TC_dx … R a1 a2.
222 #A #R #a1 #a2 #Ha12 elim Ha12 -a2 /2 width=3/
225 lemma TC_dx_to_TC: ∀A. ∀R: relation A.
226 ∀a1,a2. TC_dx … R a1 a2 → TC … R a1 a2.
227 #A #R #a1 #a2 #Ha12 elim Ha12 -a1 -a2 /2 width=3/
230 fact TC_ind_dx_aux: ∀A,R,a2. ∀P:predicate A.
231 (∀a1. R a1 a2 → P a1) →
232 (∀a1,a. R a1 a → TC … R a a2 → P a → P a1) →
233 ∀a1,a. TC … R a1 a → a = a2 → P a1.
234 #A #R #a2 #P #H1 #H2 #a1 #a #Ha1
235 elim (TC_to_TC_dx ???? Ha1) -a1 -a
236 [ #a #c #Hac #H destruct /2 width=1/
237 | #a #b #c #Hab #Hbc #IH #H destruct /3 width=4/
241 lemma TC_ind_dx: ∀A,R,a2. ∀P:predicate A.
242 (∀a1. R a1 a2 → P a1) →
243 (∀a1,a. R a1 a → TC … R a a2 → P a → P a1) →
244 ∀a1. TC … R a1 a2 → P a1.
245 #A #R #a2 #P #H1 #H2 #a1 #Ha12
246 @(TC_ind_dx_aux … H1 H2 … Ha12) //
249 lemma TC_symmetric: ∀A,R. symmetric A R → symmetric A (TC … R).
250 #A #R #HR #x #y #H @(TC_ind_dx ??????? H) -x /3 width=1/ /3 width=3/
253 lemma TC_star_ind_dx: ∀A,R. reflexive A R →
254 ∀a2. ∀P:predicate A. P a2 →
255 (∀a1,a. R a1 a → TC … R a a2 → P a → P a1) →
256 ∀a1. TC … R a1 a2 → P a1.
257 #A #R #HR #a2 #P #Ha2 #H #a1 #Ha12
258 @(TC_ind_dx … P ? H … Ha12) /3 width=4/
261 definition Conf3: ∀A,B. relation2 A B → relation A → Prop ≝ λA,B,S,R.
262 ∀b,a1. S a1 b → ∀a2. R a1 a2 → S a2 b.
264 lemma TC_Conf3: ∀A,B,S,R. Conf3 A B S R → Conf3 A B S (TC … R).
265 #A #B #S #R #HSR #b #a1 #Ha1 #a2 #H elim H -a2 /2 width=3/
268 inductive bi_TC (A,B:Type[0]) (R:bi_relation A B) (a:A) (b:B): relation2 A B ≝
269 |bi_inj : ∀c,d. R a b c d → bi_TC A B R a b c d
270 |bi_step: ∀c,d,e,f. bi_TC A B R a b c d → R c d e f → bi_TC A B R a b e f.
272 lemma bi_TC_strap: ∀A,B. ∀R:bi_relation A B. ∀a1,a,a2,b1,b,b2.
273 R a1 b1 a b → bi_TC … R a b a2 b2 → bi_TC … R a1 b1 a2 b2.
274 #A #B #R #a1 #a #a2 #b1 #b #b2 #HR #H elim H -a2 -b2 /2 width=4/ /3 width=4/
277 lemma bi_TC_reflexive: ∀A,B,R. bi_reflexive A B R →
278 bi_reflexive A B (bi_TC … R).
281 inductive bi_TC_dx (A,B:Type[0]) (R:bi_relation A B): bi_relation A B ≝
282 |bi_inj_dx : ∀a1,a2,b1,b2. R a1 b1 a2 b2 → bi_TC_dx A B R a1 b1 a2 b2
283 |bi_step_dx : ∀a1,a,a2,b1,b,b2. R a1 b1 a b → bi_TC_dx A B R a b a2 b2 →
284 bi_TC_dx A B R a1 b1 a2 b2.
286 lemma bi_TC_dx_strap: ∀A,B. ∀R: bi_relation A B.
287 ∀a1,a,a2,b1,b,b2. bi_TC_dx A B R a1 b1 a b →
288 R a b a2 b2 → bi_TC_dx A B R a1 b1 a2 b2.
289 #A #B #R #a1 #a #a2 #b1 #b #b2 #H1 elim H1 -a -b /3 width=4/
292 lemma bi_TC_to_bi_TC_dx: ∀A,B. ∀R: bi_relation A B.
293 ∀a1,a2,b1,b2. bi_TC … R a1 b1 a2 b2 →
294 bi_TC_dx … R a1 b1 a2 b2.
295 #A #B #R #a1 #a2 #b1 #b2 #H12 elim H12 -a2 -b2 /2 width=4/
298 lemma bi_TC_dx_to_bi_TC: ∀A,B. ∀R: bi_relation A B.
299 ∀a1,a2,b1,b2. bi_TC_dx … R a1 b1 a2 b2 →
300 bi_TC … R a1 b1 a2 b2.
301 #A #b #R #a1 #a2 #b1 #b2 #H12 elim H12 -a1 -a2 -b1 -b2 /2 width=4/
304 fact bi_TC_ind_dx_aux: ∀A,B,R,a2,b2. ∀P:relation2 A B.
305 (∀a1,b1. R a1 b1 a2 b2 → P a1 b1) →
306 (∀a1,a,b1,b. R a1 b1 a b → bi_TC … R a b a2 b2 → P a b → P a1 b1) →
307 ∀a1,a,b1,b. bi_TC … R a1 b1 a b → a = a2 → b = b2 → P a1 b1.
308 #A #B #R #a2 #b2 #P #H1 #H2 #a1 #a #b1 #b #H1
309 elim (bi_TC_to_bi_TC_dx ??????? H1) -a1 -a -b1 -b
310 [ #a1 #x #b1 #y #H1 #Hx #Hy destruct /2 width=1/
311 | #a1 #a #x #b1 #b #y #H1 #H #IH #Hx #Hy destruct /3 width=5/
315 lemma bi_TC_ind_dx: ∀A,B,R,a2,b2. ∀P:relation2 A B.
316 (∀a1,b1. R a1 b1 a2 b2 → P a1 b1) →
317 (∀a1,a,b1,b. R a1 b1 a b → bi_TC … R a b a2 b2 → P a b → P a1 b1) →
318 ∀a1,b1. bi_TC … R a1 b1 a2 b2 → P a1 b1.
319 #A #B #R #a2 #b2 #P #H1 #H2 #a1 #b1 #H12
320 @(bi_TC_ind_dx_aux ?????? H1 H2 … H12) //
323 lemma bi_TC_symmetric: ∀A,B,R. bi_symmetric A B R →
324 bi_symmetric A B (bi_TC … R).
325 #A #B #R #HR #a1 #a2 #b1 #b2 #H21
326 @(bi_TC_ind_dx ?????????? H21) -a2 -b2 /3 width=1/ /3 width=4/
329 lemma bi_TC_transitive: ∀A,B,R. bi_transitive A B (bi_TC … R).
330 #A #B #R #a1 #a #b1 #b #H elim H -a -b /2 width=4/ /3 width=4/
333 definition bi_Conf3: ∀A,B,C. relation3 A B C → bi_relation A B → Prop ≝ λA,B,C,S,R.
334 ∀c,a1,b1. S a1 b1 c → ∀a2,b2. R a1 b1 a2 b2 → S a2 b2 c.
336 lemma bi_TC_Conf3: ∀A,B,C,S,R. bi_Conf3 A B C S R → bi_Conf3 A B C S (bi_TC … R).
337 #A #B #C #S #R #HSR #c #a1 #b1 #Hab1 #a2 #b2 #H elim H -a2 -b2 /2 width=4/
340 lemma bi_TC_star_ind: ∀A,B,R. bi_reflexive A B R → ∀a1,b1. ∀P:relation2 A B.
341 P a1 b1 → (∀a,a2,b,b2. bi_TC … R a1 b1 a b → R a b a2 b2 → P a b → P a2 b2) →
342 ∀a2,b2. bi_TC … R a1 b1 a2 b2 → P a2 b2.
343 #A #B #R #HR #a1 #b1 #P #H1 #IH #a2 #b2 #H12 elim H12 -a2 -b2 /3 width=5/
346 lemma bi_TC_star_ind_dx: ∀A,B,R. bi_reflexive A B R →
347 ∀a2,b2. ∀P:relation2 A B. P a2 b2 →
348 (∀a1,a,b1,b. R a1 b1 a b → bi_TC … R a b a2 b2 → P a b → P a1 b1) →
349 ∀a1,b1. bi_TC … R a1 b1 a2 b2 → P a1 b1.
350 #A #B #R #HR #a2 #b2 #P #H2 #IH #a1 #b1 #H12
351 @(bi_TC_ind_dx … P ? IH … H12) /3 width=5/
354 definition bi_star: ∀A,B,R. bi_relation A B ≝ λA,B,R,a1,b1,a2,b2.
355 (a1 = a2 ∧ b1 = b2) ∨ bi_TC A B R a1 b1 a2 b2.
357 lemma bi_star_bi_reflexive: ∀A,B,R. bi_reflexive A B (bi_star … R).
360 lemma bi_TC_to_bi_star: ∀A,B,R,a1,b1,a2,b2.
361 bi_TC A B R a1 b1 a2 b2 → bi_star A B R a1 b1 a2 b2.
364 lemma bi_R_to_bi_star: ∀A,B,R,a1,b1,a2,b2.
365 R a1 b1 a2 b2 → bi_star A B R a1 b1 a2 b2.
368 lemma bi_star_strap1: ∀A,B,R,a1,a,a2,b1,b,b2. bi_star A B R a1 b1 a b →
369 R a b a2 b2 → bi_star A B R a1 b1 a2 b2.
370 #A #B #R #a1 #a #a2 #b1 #b #b2 *
371 [ * #H1 #H2 destruct /2 width=1/
376 lemma bi_star_strap2: ∀A,B,R,a1,a,a2,b1,b,b2. R a1 b1 a b →
377 bi_star A B R a b a2 b2 → bi_star A B R a1 b1 a2 b2.
378 #A #B #R #a1 #a #a2 #b1 #b #b2 #H *
379 [ * #H1 #H2 destruct /2 width=1/
384 lemma bi_star_to_bi_TC_to_bi_TC: ∀A,B,R,a1,a,a2,b1,b,b2. bi_star A B R a1 b1 a b →
385 bi_TC A B R a b a2 b2 → bi_TC A B R a1 b1 a2 b2.
386 #A #B #R #a1 #a #a2 #b1 #b #b2 *
387 [ * #H1 #H2 destruct /2 width=1/
392 lemma bi_TC_to_bi_star_to_bi_TC: ∀A,B,R,a1,a,a2,b1,b,b2. bi_TC A B R a1 b1 a b →
393 bi_star A B R a b a2 b2 → bi_TC A B R a1 b1 a2 b2.
394 #A #B #R #a1 #a #a2 #b1 #b #b2 #H *
395 [ * #H1 #H2 destruct /2 width=1/
400 lemma bi_tansitive_bi_star: ∀A,B,R. bi_transitive A B (bi_star … R).
401 #A #B #R #a1 #a #b1 #b #H #a2 #b2 *
402 [ * #H1 #H2 destruct /2 width=1/
407 lemma bi_star_ind: ∀A,B,R,a1,b1. ∀P:relation2 A B. P a1 b1 →
408 (∀a,a2,b,b2. bi_star … R a1 b1 a b → R a b a2 b2 → P a b → P a2 b2) →
409 ∀a2,b2. bi_star … R a1 b1 a2 b2 → P a2 b2.
410 #A #B #R #a1 #b1 #P #H #IH #a2 #b2 *
411 [ * #H1 #H2 destruct //
412 | #H12 elim H12 -a2 -b2 /2 width=5/ -H /3 width=5/
416 lemma bi_star_ind_dx: ∀A,B,R,a2,b2. ∀P:relation2 A B. P a2 b2 →
417 (∀a1,a,b1,b. R a1 b1 a b → bi_star … R a b a2 b2 → P a b → P a1 b1) →
418 ∀a1,b1. bi_star … R a1 b1 a2 b2 → P a1 b1.
419 #A #B #R #a2 #b2 #P #H #IH #a1 #b1 *
420 [ * #H1 #H2 destruct //
421 | #H12 @(bi_TC_ind_dx ?????????? H12) -a1 -b1 /2 width=5/ -H /3 width=5/