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/logic.ma".
14 (********** predicates *********)
16 definition predicate: Type[0] → Type[0]
19 (********** relations **********)
20 definition relation : Type[0] → Type[0]
23 definition relation2 : Type[0] → Type[0] → Type[0]
26 definition relation3 : Type[0] → Type[0] → Type[0] → Type[0]
29 definition reflexive: ∀A.∀R :relation A.Prop
32 definition symmetric: ∀A.∀R: relation A.Prop
33 ≝ λA.λR.∀x,y:A.R x y → R y x.
35 definition transitive: ∀A.∀R:relation A.Prop
36 ≝ λA.λR.∀x,y,z:A.R x y → R y z → R x z.
38 definition irreflexive: ∀A.∀R:relation A.Prop
39 ≝ λA.λR.∀x:A.¬(R x x).
41 definition cotransitive: ∀A.∀R:relation A.Prop
42 ≝ λA.λR.∀x,y:A.R x y → ∀z:A. R x z ∨ R z y.
44 definition tight_apart: ∀A.∀eq,ap:relation A.Prop
45 ≝ λA.λeq,ap.∀x,y:A. (¬(ap x y) → eq x y) ∧
48 definition antisymmetric: ∀A.∀R:relation A.Prop
49 ≝ λA.λR.∀x,y:A. R x y → ¬(R y x).
51 definition singlevalued: ∀A,B. predicate (relation2 A B) ≝ λA,B,R.
52 ∀a,b1. R a b1 → ∀b2. R a b2 → b1 = b2.
54 definition confluent1: ∀A. relation A → predicate A ≝ λA,R,a0.
55 ∀a1. R a0 a1 → ∀a2. R a0 a2 →
58 definition confluent: ∀A. predicate (relation A) ≝ λA,R.
59 ∀a0. confluent1 … R a0.
61 (* Reflexive closure ************)
63 definition RC: ∀A:Type[0]. relation A → relation A ≝
64 λA,R,x,y. R … x y ∨ x = y.
66 lemma RC_reflexive: ∀A,R. reflexive A (RC … R).
69 (********** operations **********)
70 definition Rcomp ≝ λA.λR1,R2:relation A.λa1,a2.
71 ∃am.R1 a1 am ∧ R2 am a2.
72 interpretation "relation composition" 'compose R1 R2 = (Rcomp ? R1 R2).
74 definition Runion ≝ λA.λR1,R2:relation A.λa,b. R1 a b ∨ R2 a b.
75 interpretation "union of relations" 'union R1 R2 = (Runion ? R1 R2).
77 definition Rintersection ≝ λA.λR1,R2:relation A.λa,b.R1 a b ∧ R2 a b.
78 interpretation "interesecion of relations" 'intersects R1 R2 = (Rintersection ? R1 R2).
80 definition inv ≝ λA.λR:relation A.λa,b.R b a.
82 (*********** sub relation ***********)
83 definition subR ≝ λA.λR,S:relation A.(∀a,b. R a b → S a b).
84 interpretation "relation inclusion" 'subseteq R S = (subR ? R S).
87 ∀T.∀R:relation T.R ⊆ R.
91 lemma sub_comp_l: ∀A.∀R,R1,R2:relation A.
92 R1 ⊆ R2 → R1 ∘ R ⊆ R2 ∘ R.
93 #A #R #R1 #R2 #Hsub #a #b * #c * /4/
96 lemma sub_comp_r: ∀A.∀R,R1,R2:relation A.
97 R1 ⊆ R2 → R ∘ R1 ⊆ R ∘ R2.
98 #A #R #R1 #R2 #Hsub #a #b * #c * /4/
101 lemma sub_assoc_l: ∀A.∀R1,R2,R3:relation A.
102 R1 ∘ (R2 ∘ R3) ⊆ (R1 ∘ R2) ∘ R3.
103 #A #R1 #R2 #R3 #a #b * #c * #Hac * #d * /5/
106 lemma sub_assoc_r: ∀A.∀R1,R2,R3:relation A.
107 (R1 ∘ R2) ∘ R3 ⊆ R1 ∘ (R2 ∘ R3).
108 #A #R1 #R2 #R3 #a #b * #c * * #d * /5 width=5/
111 (************* functions ************)
114 λA,B,C:Type[0].λf:B→C.λg:A→B.λx:A.f (g x).
116 interpretation "function composition" 'compose f g = (compose ? ? ? f g).
118 definition injective: ∀A,B:Type[0].∀ f:A→B.Prop
119 ≝ λA,B.λf.∀x,y:A.f x = f y → x=y.
121 definition surjective: ∀A,B:Type[0].∀f:A→B.Prop
122 ≝λA,B.λf.∀z:B.∃x:A.z = f x.
124 definition commutative: ∀A:Type[0].∀f:A→A→A.Prop
125 ≝ λA.λf.∀x,y.f x y = f y x.
127 definition commutative2: ∀A,B:Type[0].∀f:A→A→B.Prop
128 ≝ λA,B.λf.∀x,y.f x y = f y x.
130 definition associative: ∀A:Type[0].∀f:A→A→A.Prop
131 ≝ λA.λf.∀x,y,z.f (f x y) z = f x (f y z).
133 (* functions and relations *)
134 definition monotonic : ∀A:Type[0].∀R:A→A→Prop.
136 λA.λR.λf.∀x,y:A.R x y → R (f x) (f y).
138 (* functions and functions *)
139 definition distributive: ∀A:Type[0].∀f,g:A→A→A.Prop
140 ≝ λA.λf,g.∀x,y,z:A. f x (g y z) = g (f x y) (f x z).
142 definition distributive2: ∀A,B:Type[0].∀f:A→B→B.∀g:B→B→B.Prop
143 ≝ λA,B.λf,g.∀x:A.∀y,z:B. f x (g y z) = g (f x y) (f x z).
145 lemma injective_compose : ∀A,B,C,f,g.
146 injective A B f → injective B C g → injective A C (λx.g (f x)).
149 (* extensional equality *)
151 (* moved inside sets.ma
152 definition exteqP: ∀A:Type[0].∀P,Q:A→Prop.Prop ≝
153 λA.λP,Q.∀a.iff (P a) (Q a). *)
155 definition exteqR: ∀A,B:Type[0].∀R,S:A→B→Prop.Prop ≝
156 λA,B.λR,S.∀a.∀b.iff (R a b) (S a b).
158 definition exteqF: ∀A,B:Type[0].∀f,g:A→B.Prop ≝
159 λA,B.λf,g.∀a.f a = g a.
162 notation " x \eqP y " non associative with precedence 45
165 interpretation "functional extentional equality"
166 'eqP A x y = (exteqP A x y). *)
168 notation "x \eqR y" non associative with precedence 45
171 interpretation "functional extentional equality"
172 'eqR A B R S = (exteqR A B R S).
174 notation " f \eqF g " non associative with precedence 45
177 interpretation "functional extentional equality"
178 'eqF A B f g = (exteqF A B f g).
180 (********** relations on unboxed pairs **********)
182 definition bi_relation: Type[0] → Type[0] → Type[0]
185 definition bi_reflexive: ∀A,B. ∀R:bi_relation A B. Prop
186 ≝ λA,B,R. ∀x,y. R x y x y.
188 definition bi_symmetric: ∀A,B. ∀R: bi_relation A B. Prop ≝ λA,B,R.
189 ∀a1,a2,b1,b2. R a2 b2 a1 b1 → R a1 b1 a2 b2.
191 definition bi_transitive: ∀A,B. ∀R: bi_relation A B. Prop ≝ λA,B,R.
192 ∀a1,a,b1,b. R a1 b1 a b →
193 ∀a2,b2. R a b a2 b2 → R a1 b1 a2 b2.