Chapter 9
Chapter 9
Chapter 9
Chapter Summary
Relations and Their Properties
Representing Relations
Equivalence Relations
Partial Orderings
Relations and Their
Properties
Section 9.1
Section Summary
Relations and Functions
Properties of Relations
Reflexive Relations
Symmetric and Antisymmetric Relations
Transitive Relations
Combining Relations
Binary Relations
to a set B is a subset R ⊆ A × B.
Definition: A binary relation R from a set A
Example:
Let A = {0,1,2} and B = {a,b}
{(0, a), (0, b), (1,a) , (2, b)} is a relation from A
to B.
We can represent relations from a set A to a set
B graphically or using a table:
Relations are more general
than functions. A function is a
relation where exactly one
element of B is related to each
element of A.
Example
Let A be the students in a the CS major
A = {Alice, Bob, Claire, Dan}
Let B be the courses the department offers
B = {CS101, CS201, CS202}
We specify relation R = A B as the set that lists all
students a A enrolled in class b B
R = { (Alice, CS101), (Bob, CS201), (Bob, CS202),
(Dan, CS201), (Dan, CS202) }
6
Representing
We can represent
relations
We can represent
relations relations in a
graphically: table:
CS101 CS201 CS202
Alice
CS101
Alice X
Bob Bob X X
CS201
Claire
Claire
CS202
Dan X X
Dan
8
Binary Relation on a Set
A relation on the set A is a relation from A to A
relation from A to A.
Example:
Suppose that A = {a,b,c}. Then R = {(a,a),(a,b), (a,c)} is a
1 1 R 1 2 3 4
1 X X X X
2 2
2 X X
3 3 3 X
4 X
4 4
10
Binary Relations on a Set (cont.)
R1 = {(a,b) | a ≤ b}, R4 = {(a,b) | a = b},
Example: Consider these relations on the set of integers:
relation, we see that the pair (1,1) is in R1, R3, R4 , and R6:
Solution: Checking the conditions that define each
(1,2) is in R1 and R6: (2,1) is in R2, R5, and R6: (1, −1) is in
R2, R3, and R6 : (2,2) is in R1, R3, and R4.
Reflexivity
A relation is reflexive if every element is
related to itself
Or, (a,a)R
12
Reflexive Relations
Definition: R is reflexive iff (a,a) ∊ R for every element
a ∊ A. Written symbolically, R is reflexive if and only if
∀x[x∊U ⟶ (x,x) ∊ R]
R3 = {(a,b) | a = b or a = −b},
R3 = {(a,b) | a = b or a = −b},
empty relation on an empty set is
R6 = {(a,b) | a + b ≤
{(a,b) | a = b}.
reflexive!
R4 =3}.
The following relations are not reflexive:
R2 = {(a,b) | a > b} (note that 3 ≯ 3),
R5 = {(a,b) | a = b + 1} (note that 3 ≠3 + 1),
R6 = {(a,b) | a + b ≤ 3} (note that 4 + 4 ≰ 3).
Irreflexivity
A relation is irreflexive if every element is not
related to itself
Or, (a,a)R
Irreflexivity is the opposite of reflexivity
14
Symmetry
A relation is symmetric if, for every (a,b)R, then
(b,a)R
15
Symmetric Relations
Definition: R is symmetric iff (b,a) ∊ R whenever (a,b) ∊ R
for all a,b ∊ A. Written symbolically, R is symmetric if and
only if
∀x∀y [(x,y) ∊R ⟶ (y,x) ∊ R]
| ab>or
b},a = −b}, R5 = {(a,b) | a = b +
symmetric:
R3 =
R2{(a,b) |a=
1},{(a,b) | a = b},
= {(a,b)
3 = {(a,b) | a = b or a = −b},
R4 =R | a = b}, R6 = {(a,b) | a + b ≤
{(a,b) | a = b + 1}.
{(a,b)
R5 =3}.
The following relations are not antisymmetric:
R3 = {(a,b) | a = b or a = −b}
(note that both (1,−1) and (−1,1) belong to R3),
R6 = {(a,b) | a + b ≤ 3} (note that both (1,2) and (2,1) belong to R6).
Transitivity
A relation is transitive if, for every (a,b)R
and (b,c)R, then (a,c)R
20
Transitive Relations
whenever (a,b) ∊ R and (b,c) ∊ R, then (a,c) ∊ R, for all a,b,c ∊
Definition: A relation R on a set A is called transitive if
Consider isParentOf()
Let Alice be Bob’s parent, and Bob be Claire’s parent
Thus, Alice is a parent of Bob, and Bob is a parent of
Claire
However, Alice is not a parent of Claire
Thus, isParentOf() is not a transitive relation
22
Relations of relations summary
= < > ≤ ≥
Reflexive X X X
Irreflexive X X
Symmetric X
Asymmetric X X
Antisymmetric X X X X X
Transitive X X X X X
23
Combining Relations
Given two relations R1 and R2, we can
1 ∪ R2 ={(1,1),(1,2),(1,3),(1,4),(2,2),
R2 = {(1,1),(1,2),(1,3),(1,4)} can
beRcombined
R1 ∩ R2 relations: R1 − R2 ={(2,2),
using basic set operations to
(3,3)}
form new
R2 − R1 ={(1,2),(1,3),(1,4)}
={(1,1)} (3,3)}
Composition
Definition: Suppose
R1 is a relation from a set A to a set B.
R2 is a relation from B to a set C.
R1∘ R2 = {(b,x),(b,z)}
Combining relations via relational
composition
Let M be the relation “is mother of”
Let F be the relation “is father of”
What is M ◦ F?
If (a,b) F, then a is the father of b
If (b,c) M, then b is the mother of c
Thus, M ◦ F denotes the relation “maternal grandfather”
What is F ◦ M?
If (a,b) M, then a is the mother of b
If (b,c) F, then b is the father of c
Thus, F ◦ M denotes the relation “paternal grandmother”
What is M ◦ M?
If (a,b) M, then a is the mother of b
If (b,c) M, then b is the mother of c
Thus, M ◦ M denotes the relation “maternal grandmother”
Note that M and F are not transitive relations!!!
27
Combining relations via relational
composition
Given relation R
R ◦ R can be denoted by R2
R2 ◦ R = (R ◦ R) ◦ R = R3
Example: M3 is your mother’s mother’s mother
28
Powers of a Relation
Definition: Let R be a binary relation on A. Then
the powers Rn of the relation R can be defined
inductively by:
Basis Step: R1 = R
Inductive Step: Rn+1 = Rn ∘ R
(see the slides for Section 9.3 for further insights)
The powers of a transitive relation are subsets of the
relation. This is established by the following
R = {(a1, b2), (a2, b1),(a2, b3), (a2, b4),(a3, b1), (a3, b3),
(a3, b5)}.
Matrices of Relations on Sets
the main diagonal of MR are equal to 1.
If R is a reflexive relation, all the elements on
(1, 3), (1, 4), (2, 1), (2, 2), (2, 3), (3, 1), (3, 3), (4, 1), and (4, 3)
Solution: The ordered pairs in the relation are
Determining which Properties a Relation
has from its Digraph
so is (x,z).
Determining which Properties a Relation
has from its Digraph – Example 1
a b
c d
• Reflexive?
No, not every vertex has a loop
• Symmetric? Yes (trivially), there is no edge from one vertex to
• Antisymmetric?Yes (trivially), there is no edge from one vertex to
another
•Transitive?Yes,another
(trivially) since there is no edge from one vertex to
another
Determining which Properties a Relation
has from its Digraph – Example 2
a
b
c d
a
b
c d
Reflexive?
No, there are no loops
Symmetric?
No, for example, there is no edge from c to a
Antisymmetric?Yes, whenever there is an edge from one vertex to another, there is not
Transitive? No,onethere
going back
is no edge from a to b
Wrong!!!!
Determining which Properties a Relation
has from its Digraph – Example 4
b
a
c d
• Reflexive?
No, there are no loops
• Symmetric? No, for example, there is no edge from d
to a
• Antisymmetric? •Yes, whenever there is an edge from one
vertex
•Transitive?•Yes (trivially), there are no
to another, two is
there edges
not one going
where the first edge ends at the vertex
back
where the second edge begins
Example of the Powers of a Relation
a b a b
R2
d c d c
R
a b b
a
3
R4
d c d c
R
The pair (x,y) is in Rn if there is a path of length n from x to y in R
(following the direction of the arrows).
Equivalence Relations
Section 9.5
Section Summary
Equivalence Relations
Equivalence Classes
Equivalence Classes and Partitions
Equivalence Relations
Definition 1: A relation on a set A is called
an equivalence relation if it is reflexive,
symmetric, and transitive.
A ⊆ B and B ⊆ A, then A = B.
Antisymmetry: If A and B are positive integers with