]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/lib/basics/relations.ma
semantics of the if-machine.
[helm.git] / matita / matita / lib / basics / relations.ma
1 (*
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.                     
5     ||I||                                                                 
6     ||T||  
7     ||A||  This file is distributed under the terms of the 
8     \   /  GNU General Public License Version 2        
9      \ /      
10       V_______________________________________________________________ *)
11
12 include "basics/logic.ma".
13
14 (********** predicates *********)
15
16 definition predicate: Type[0] → Type[0]
17 ≝ λA.A→Prop.
18
19 (********** relations **********)
20 definition relation : Type[0] → Type[0]
21 ≝ λA.A→A→Prop. 
22
23 definition relation2 : Type[0] → Type[0] → Type[0]
24 ≝ λA,B.A→B→Prop.
25
26 definition reflexive: ∀A.∀R :relation A.Prop
27 ≝ λA.λR.∀x:A.R x x.
28
29 definition symmetric: ∀A.∀R: relation A.Prop
30 ≝ λA.λR.∀x,y:A.R x y → R y x.
31
32 definition transitive: ∀A.∀R:relation A.Prop
33 ≝ λA.λR.∀x,y,z:A.R x y → R y z → R x z.
34
35 definition irreflexive: ∀A.∀R:relation A.Prop
36 ≝ λA.λR.∀x:A.¬(R x x).
37
38 definition cotransitive: ∀A.∀R:relation A.Prop
39 ≝ λA.λR.∀x,y:A.R x y → ∀z:A. R x z ∨ R z y.
40
41 definition tight_apart: ∀A.∀eq,ap:relation A.Prop
42 ≝ λA.λeq,ap.∀x,y:A. (¬(ap x y) → eq x y) ∧
43 (eq x y → ¬(ap x y)).
44
45 definition antisymmetric: ∀A.∀R:relation A.Prop
46 ≝ λA.λR.∀x,y:A. R x y → ¬(R y x).
47
48 (********** operations **********)
49 definition Runion ≝ λA.λR1,R2:relation A.λa,b. R1 a b ∨ R2 a b.
50 interpretation "union of relations" 'union R1 R2 = (Runion ? R1 R2).
51     
52 definition Rintersection ≝ λA.λR1,R2:relation A.λa,b.R1 a b ∧ R2 a b.
53 interpretation "interesecion of relations" 'intersects R1 R2 = (Rintersection ? R1 R2).
54
55 definition inv ≝ λA.λR:relation A.λa,b.R b a.
56
57 definition subR ≝ λA.λR,S:relation A.(∀a,b. R a b → S a b).
58 interpretation "relation inclusion" 'subseteq R S = (subR ? R S).
59
60 (**********P functions **********)
61
62 definition compose ≝
63   λA,B,C:Type[0].λf:B→C.λg:A→B.λx:A.f (g x).
64
65 interpretation "function composition" 'compose f g = (compose ? ? ? f g).
66
67 definition injective: ∀A,B:Type[0].∀ f:A→B.Prop
68 ≝ λA,B.λf.∀x,y:A.f x = f y → x=y.
69
70 definition surjective: ∀A,B:Type[0].∀f:A→B.Prop
71 ≝λA,B.λf.∀z:B.∃x:A.z = f x.
72
73 definition commutative: ∀A:Type[0].∀f:A→A→A.Prop 
74 ≝ λA.λf.∀x,y.f x y = f y x.
75
76 definition commutative2: ∀A,B:Type[0].∀f:A→A→B.Prop
77 ≝ λA,B.λf.∀x,y.f x y = f y x.
78
79 definition associative: ∀A:Type[0].∀f:A→A→A.Prop
80 ≝ λA.λf.∀x,y,z.f (f x y) z = f x (f y z).
81
82 (* functions and relations *)
83 definition monotonic : ∀A:Type[0].∀R:A→A→Prop.
84 ∀f:A→A.Prop ≝
85 λA.λR.λf.∀x,y:A.R x y → R (f x) (f y).
86
87 (* functions and functions *)
88 definition distributive: ∀A:Type[0].∀f,g:A→A→A.Prop
89 ≝ λA.λf,g.∀x,y,z:A. f x (g y z) = g (f x y) (f x z).
90
91 definition distributive2: ∀A,B:Type[0].∀f:A→B→B.∀g:B→B→B.Prop
92 ≝ λA,B.λf,g.∀x:A.∀y,z:B. f x (g y z) = g (f x y) (f x z).
93
94 lemma injective_compose : ∀A,B,C,f,g.
95 injective A B f → injective B C g → injective A C (λx.g (f x)).
96 /3/; qed-.
97
98 (* extensional equality *)
99
100 (* moved inside sets.ma
101 definition exteqP: ∀A:Type[0].∀P,Q:A→Prop.Prop ≝
102 λA.λP,Q.∀a.iff (P a) (Q a). *)
103
104 definition exteqR: ∀A,B:Type[0].∀R,S:A→B→Prop.Prop ≝
105 λA,B.λR,S.∀a.∀b.iff (R a b) (S a b).
106
107 definition exteqF: ∀A,B:Type[0].∀f,g:A→B.Prop ≝
108 λA,B.λf,g.∀a.f a = g a.
109
110 (*
111 notation " x \eqP y " non associative with precedence 45 
112 for @{'eqP A $x $y}.
113
114 interpretation "functional extentional equality" 
115 'eqP A x y = (exteqP A x y). *)
116
117 notation "x \eqR y" non associative with precedence 45 
118 for @{'eqR ? ? x y}.
119
120 interpretation "functional extentional equality" 
121 'eqR A B R S = (exteqR A B R S).
122
123 notation " f \eqF g " non associative with precedence 45
124 for @{'eqF ? ? f g}.
125
126 interpretation "functional extentional equality" 
127 'eqF A B f g = (exteqF A B f g).
128