Discrete Math forCS
Binary Relation:
A binary relation between sets A and B is a subset of the
Cartesian Product A x B. If A = B we say that the relation is a
relation on A.
Suppose A = {1, 3, 5, 7} and B = {2, 4, 6, 8}.
Further suppose R = { (1,2), (3,4), (5,6), (7,8)}. This is a subset
of A x B so is a binary relation between A and B
A
B
8
6
4
2
1 3 5 7
2.
Discrete Math forCS
Binary Relation Exercise:
If R = { (a,b): a < b}. Show R on the diagram below.
A
B
8
6
4
2
1 3 5 7
3.
Discrete Math forCS
Binary Relations as Sets of Ordered Pairs:
Because we mention one set before another in a Cartesian
Product, A x B, the element, (a,b), in any relation, R, over A and
B must have its first element from A and its second element
from B.
So we say that the elements of R form ordered pairs.
4.
Discrete Math forCS
Exercise:
If X = {1, 2, 3, 4, 5, 6}, find R = { (x,y): x is a divisor of y}
R = { (1,1), (1,2), (1,3), (1,4), (1,5), (1,6), (2,2), (2,4), (2,6), (3,3), (3,6) }
5.
Discrete Math forCS
Graph Representation of a Binary Relation:
If A and B are two finite sets and R is a binary relation between
A and B we can represent this relation as a graph (set of
vertices and edges).
A = {1, 3, 5 ,7}, B = {2, 4, 6, 8}
R = {(a,b): a < b}
1
3
5
7
2
4
6
8
We call this graph a directed graph.
6.
Discrete Math forCS
Example:
A = {1, 2, 3, 4, 5, 6}. R is a relation on A defined by the following
directed graph.
Exercise: Give a rule-based
definition of R
R = {(a,b): a divides b}
1
6
2
3
4
5
7.
Discrete Math forCS
Matrix Representation of a Binary Relation:
If A and B are finite sets and R is a binary relation between A
and B then create a matrix, M, with the following properties:
the rows of the matrix are indexed by the elements of A
the columns of the matrix are indexed by elements of B
M(ai
,bj
) = 1 if (ai
,bj
) belongs to R; 0 otherwise
1
3
5
7
A
2 4 6 8
B
0 1 1 1
0 0 1 1
0 0 0 1
0 0 0 0
Exercise: Give a rule-based definition of R
R = {(a,b): a + 1 < b}
8.
Discrete Math forCS
Notation:
If R is a binary relation on a set, X, we write x R y whenever
(x,y) ε R.
Example: sister_of relationship on girls in a school can be expressed
as x is_sister_of y.
9.
Discrete Math forCS
RelationProperties:
Suppose R is a relation on a set A.
We say
R is reflexive if a R a for all a ε A.
R is symmetric if x R y ==> y R x for all x, y ε A.
R is antisymmetric when (x R y and y R x ==> x == y) for all
x, y ε A.
R is transitive when (x R y and y R z ==> x R z) for all
x, y, z ε A.
10.
Discrete Math forCS
Understanding Relations as Ordered Pairs:
R is reflexive if (x,x) ε R for all x ε A.
R is symmetric if when (x,y) ε R then (y,x) ε R for all x,y ε A.
R is antisymmetric if when (x,y) ε R and x != y then (y,x) ε R.
R is transitive if when (x,y) ε R and (y,z) ε R then (x,z) ε R
11.
Discrete Math forCS
Understanding Relations as digraphs.
If R is a relation represented as a di-graph then
R is reflexive if every node has a loop to itself attached.
R is symmetric if every directed edge is directed in both
directions.
R is antisymmetric if there is no bi-directional edge.
If there is a directed edge from x to y and another from y to z
then there is a directed edge from x to z
x
y
z
12.
Discrete Math forCS
Understanding Relations as Matrices:
Given a binary relation R on a finite set X.
Let M be the matrix whose rows and columns are indexed by
the elements of X.
R is reflexive if the elements on the leading diagonal are all
1(T).
R is symmetric if the matrix is symmetric about the main
diagonal.
R is antisymmetric if there are no symmetrical elements. Hence
if mij
== 1 the mji
!= 1.
The text says transitivity is not readily apparent. We'll see!