Sie sind auf Seite 1von 38

RELATIONS

Chapter-5
RELATIONS
Mathematical objects designed to specify and
describe relationships between elements of a set
or sets.
A function f from a set A to a set B assigns
exactly one element of B to each element of A.
In relations there is no restriction. An element in
A can be assigned more than one element in B.
Relations are generalization of functions; they
can be used to express a much wider class of
relationships between sets.
BINARY RELATIONS
Let A, B be any sets. The relationship between
the elements of these two sets are represented by
a Binary Relation.
i.e. a binary relation from A to B is a set R where
a R b denotes (a, b) R.
a is said to be related to b by R.
R A X B
The elements of A X B and R are said to be
ordered pair since the first element in the set
comes from the set A and the second element
comes from the set B.
Let A = {2, 3, 4}, and B ={4, 5}. Then
A X B ={(2, 4), (2, 5), (3, 4), (3, 5), (4, 4), (4, 5)}.
_
RELATIONS AS GRAPH
Let A = {2, 3, 4}, and B ={4, 5}. Then
A X B ={(2, 4), (2, 5), (3, 4), (3, 5), (4, 4), (4,
5)}.
2
3
4
(2, 4)
(3, 4)
(3, 5)
(4, 4)
(4, 5)
(2, 5)
BINARY RELATIONS
Let A = {2, 3, 4}, and B ={4, 5}. Then
A X B ={(2, 4), (2, 5), (3, 4), (3, 5), (4, 4),
(4,5)}.
Other relations from A to B:
i)
ii) {(2, 4)}
iii) {(2, 4), (2, 5)}
iv) {(2, 4), (3, 4), (4, 4)}
v) {(2, 4), (3, 4), (4, 5)}
vi) A X B
For finite sets A, B with |A| = m and
|B| = n, there are 2
mn
relations from A
to B, including the empty relation as
well as the relation A X B itself.
EXAMPLES OF BINARY RELATIONS
Let A={0, 1, 2} and B={a, b}. Then
R={(0, a), (0, b), (1, a), (2, b)} is a relation from Ato B.
For instance, we have 0Ra, 0Rb, etc
Can we have visualized expressions of relations?
Let A be the set of all cities, and let B be the set of
the 50 states in the USA.
Define the relation R by specifying that
(a, b)belongs to R if city a is in state b. For instance,
( Boulder, Colorado), ( Bangor , Maine), (Ann Arbor ,
Michigan),
( Middletown , New Jersey), ( Middletown , New
York),
(Cupertino , California), and (Red Bank , New Jersey)
EXAMPLE
Let A be the set {1, 2, 3,4}. Which ordered pairs
are in the relation R = { (a, b) R / a divides b} ? e
PROPERTIES OF RELATIONS
Of special Binary Relation is the relation of the
set A on A i.e. A X A called a binary relation on A.
The Relation is called Reflexive, which simply
means that each element a of A is related to
itself.
R on a set A is called reflexive if
a ((a, a) R) where A is the universe of
discourse.
REFLEXIVE
Reflexive
A relation is reflexive if, we observe that for all values
a:
a R a In other words, all values are related to
themselves.
The relation of equality, "=" is reflexive. Observe that
for, say, all numbers a (the domain is R):
a = a So "=" is reflexive.
In a reflexive relation, we have arrows for all values
in the domain pointing back to themselves:
Note that is also reflexive (a a for any a in R). On
the other hand, the relation < is not (a < a is false for
any a in R).
SYMMETRIC
Symmetric
A relation is symmetric if, we observe that for all
values a and b:
a R b implies b R a The relation of equality again is
symmetric. If x=y, we can also write that y=x also.
In a symmetric relation, for each arrow we have
also an opposite arrow, ie. there is either no arrow
between x and y, or an arrow points from x to y and
an arrow back from y to x:
Neither nor < is symmetric (2 3 and 2 < 3 but
not 3 2 nor 3 < 2 is true).
TRANSITIVE
A relation is transitive if for all values a, b, c:
a R b and b R c implies a R c The relation greater-
than ">" is transitive. If x > y, and y > z, then it is true
that x > z. This becomes clearer when we write down
what is happening into words. x is greater than y and
y is greater than z. So x is greater than both y and z.
The relation is-not-equal "" is not transitive. If x y
and y z then we might have x = z or x z (for
example 1 2 and 2 3 and 1 3 but 0 1 and 1 0
and 0 = 0).
In the arrow diagram, every arrow between two
values a and b, and b and c, has an arrow going
straight from a to c.
ANTI SYMMETRIC
A relation is anti symmetric if we observe that for
all values a and b:
a R b and b R a implies that a=b Notice that
anti symmetric is not the same as "not
symmetric."
Take the relation greater than or equals to, "" If
x y, and y x, then y must be equal to x. a
relation is anti-symmetric if and only if aEA,
(a,a)ER
EXAMPLE
Given the above information, determine which relations
are reflexive, transitive, symmetric, or anti symmetric
on the following - there may be more than one
characteristic. (Answers follow to even numbered
questions.) x R y if
x = y
x < y
x
2
= y
2
x y
Answers
Symmetric, Reflexive, Transitive and Anti symmetric
Transitive
Symmetric, Reflexive, Transitive (but not Anti
symmetric: 1 = (-1) but 1 -1)
Reflexive, Transitive and Anti symmetric
PROPERTIES OF RELATIONS
Let A = {1, 2, 3, 4}
R
1
and R
2
are examples of reflexive relations
since they contain all pairs of the form (a, a).
R
1
= {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4,
1), (4, 4)}.
R
2
= {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2,
4), (3, 3), (3, 4), (4, 4)}.
PROPERTIES OF RELATIONS
Relation R on set A is called symmetric if
(a, b) R (b, a) R, for all a, b A
Let A={1, 2, 3}
R
1
= {(1, 2), (2, 1), (1, 3), (3, 1)}. symmetric
R
2
= {(1, 1), (2, 2), (3, 3), (2, 3), (3, 2)}.
reflexive and symmetric
R
3
= {(1, 1), (2, 3), (3, 3)}. Neither reflexive nor
symmetric.
PROPERTIES OF RELATIONS
A relation R on a set A is called anti symmetric
if (a, b)eR and (b, a)eR only when a = b
Another way of stating this is
ab, (a,b)eR (b,a)eR.
A relation R on a set A is called asymmetric if
(a, b)eR implies that (b,a)eR for all a, beA.
ANTISYMMETRY
The terms symmetry and antisymmetry are not
opposites, since a relation can have both of these
properties or may lack both of them.
A relation can not be both if it contains some pair
of the form (a, b) where a b.
Symmetry and Asymmetry, however, are
opposite.
SYMMETRY - ANTISYMMETRY
A = {1, 2, 3, 4}
R
1
= {(1,1), (1, 2), (2, 1)} Symmetric
R
2
= {(1,1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4,
4)} Symmetric
R
3
= {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4),
(3, 3), (3, 4), (4, 4)} Antisymmetry
R
4
= {(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)}
Asymmetry
TRANSITIVITY
A relation R is transitive iff (for all a,b,c)
(a,b)eR . (b,c)eR (a,c)eR.
So if a is related to b and b is related to c, we
want a related to c with b playing the role of
intermediary.
e.g. A = {1, 2, 3, 4)
R = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)}
COMBINING RELATIONS
Relations are sets, and therefore, we can apply
the usual set operations to them.
If we have two relations R1 and R2, and both of
them are from a set A to a set B, then we can
combine them to R1 U R2, R1 R2, or R1 R2.
In each case, the result will be another relation
from A to B.
COMBINING RELATIONS EXAMPLE
Let A = {1, 2, 3} and B = {1, 2, 3, 4}
R
1
={(1, 1),(2, 2),(3, 3)}
R
2
= {(1, 1),(1, 2),(1, 3),(1, 4)}
R
1
R
2
={(1, 1),(1, 2),(1, 3),(1, 4),(2, 2),(3, 3)}
R
1
R
2
={(1, 1)}
R
1
R
2
={(2, 2), (3, 3)}
R
2
R
1
={(1, 2),(1, 3),(1, 4)}
COMBINING RELATIONS
and there is another important way to
combine relations.
Definition: Let R be a relation from a set
A to a set B and S a relation from B to a set
C. The composite of R and S is the relation
consisting of ordered pairs (a, c), where
aeA, ceC, and for which there exists an
element beB such that (a, b)eR and (b,
c)eS. We denote the composite of R and S
by SR.
In other words, if relation R contains a
pair (a, b) and relation S contains a pair (b,
c), then SR contains a pair (a, c).
COMBINING RELATIONS
Example: Let D and S be relations on A = {1, 2, 3, 4}.
D = {(a, b) | b = 5 - a} b equals (5 a)
S = {(a, b) | a < b} a is smaller than b
D = {(1, 4), (2, 3), (3, 2), (4, 1)}
S = {(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)}
SD =
D maps an element a to the element (5 a), and
afterwards S maps (5 a) to all elements larger than (5
a), resulting in SD = {(a,b) | b>5 a} or SD = {(a,b)
| a + b>5}.
{(2, 4),(3, 3),(3, 4),(4, 2),(4, 3),(4, 4)}
COMBINING RELATIONS
Definition: Let R be a relation on the set A.
The powers R
n
, n = 1, 2, 3, , are defined
inductively by
R
1
= R
R
n+1
= R
n
R
In other words:
R
n
= RR R (n times the letter R)
REPRESENTING RELATIONS
Some ways to represent n-ary relations:
With an explicit list or table of its tuples.
With a function from the domain to {T,F}.
Or with an algorithm for computing this function.
Some special ways to represent binary relations:
With a zero-one matrix.
With a directed graph.
USING ZERO-ONE MATRICES
(
(
(

1 0 0
0 1 0
0 1 1
Mark
Fred
Joe
Sally Mary Susan
To represent a binary relation R:AB by an
|A||B| 0-1 matrix M
R
= [m
ij
], let m
ij
= 1
iff (a
i
,b
j
)eR.
E.g., Suppose Joe likes Susan and Mary,
Fred likes Mary, and Mark likes Sally.
Then the 0-1 matrix
representation
of the relation
Likes:BoysGirls
relation is:
ZERO-ONE REFLEXIVE, SYMMETRIC
Terms: Reflexive, non-reflexive, irreflexive,
symmetric, asymmetric, and antisymmetric.
These relation characteristics are very easy to
recognize by inspection of the zero-one matrix.
(
(
(
(

(
(
(
(

(
(
(
(

(
(
(
(

0
0
1 1 1
0

0
0 1
1

0
0
0
0

1
1
1
1
Reflexive:
all 1s on diagonal
Irreflexive:
all 0s on diagonal
Symmetric:
all identical
across diagonal
Antisymmetric:
all 1s are across
from 0s
any-
thing
any-
thing
any-
thing
any-
thing
USING DIRECTED GRAPHS
A directed graph or digraph G=(V
G
,E
G
) is a set V
G
of vertices (nodes) with a set E
G
_V
G
V
G
of edges
(arcs,links). Visually represented using dots for
nodes, and arrows for edges. Notice that a relation
R:AB can be represented as a graph G
R
=(V
G
=AB,
E
G
=R).
(
(
(

1 0 0
0 1 0
0 1 1
Mark
Fred
Joe
Sally Mary Susan
Matrix representation M
R
:
Graph
rep. G
R
:
Joe
Fred
Mark
Susan
Mary
Sally
Node set V
G
(black dots)
Edge set E
G
(blue arrows)
DIGRAPH REFLEXIVE, SYMMETRIC
It is extremely easy to recognize the
reflexive/irreflexive/ symmetric/antisymmetric
properties by graph inspection.

Reflexive:
Every node
has a self-loop
Irreflexive:
No node
links to itself
Symmetric:
Every link is
bidirectional


Antisymmetric:
No link is
bidirectional

These are asymmetric & non-antisymmetric These are non-reflexive & non-irreflexive
DIGRAPH REFLEXIVE, SYMMETRIC,
TRANSITIVE
a
b
d
c
a b
d
c
a
b
d c
a
b
d
c
reflexive symmetric transitive
R={(a,b),(b,c),(c,d),(d,a)}
8.4: CLOSURES OF RELATIONS
For any property X, the X closure of a set A is
defined as the smallest superset of A that has the
given property.
The reflexive closure of a relation R on A is obtained
by adding (a,a) to R for each aeA. I.e., it is R I
A
The symmetric closure of R is obtained by adding
(b,a) to R for each (a,b) in R. I.e., it is R R
1
The transitive closure or connectivity relation of R is
obtained by repeatedly adding (a,c) to R for each
(a,b),(b,c) in R.
I.e., it is

+
e
=
Z n
n
R R
*
EQUIVALENCE RELATIONS
An equivalence relation (e.r.) on a set A is simply any
binary relation on A that is reflexive, symmetric,
and transitive.
E.g., = itself is an equivalence relation.
For any function f:AB, the relation have the same f
value, or =
f
: {(a
1
,a
2
) | f(a
1
)=f(a
2
)} is an equivalence
relation,
e.g., let m=mother of then =
m
= have the same mother is an
e.r.
EQUIVALENCE RELATION EXAMPLES
Strings a and b are the same length.
Integers a and b have the same absolute value.
Real numbers a and b have the same fractional
part. (i.e., a b e Z)
Integers a and b have the same residue modulo m.
(for a given m>1)
DIRECTED GRAPH
A directed Graph or digraph consists of a set V of
vertices (or nodes) together with a set E of
ordered pairs of elements of V called edges (or
arcs).
The vertex a is called the initial vertex of the
edge (a ,b) and the vertex b is called the
terminal vertex of this edge.
An edge of the form (a, a) is represented using an
arc from the vertex a back to itself , such an edge
is called a loop.
EXAMPLE
Draw a directed graph with vertices a, b, c, d and
edges (a, b), (a, d), (b, b), (b, d), (c, a), (c, b) and
(d, b).
REPRESENTING RELATIONS USING
MATRICES
A relation between finite sets can be represented
using a zero-one matrix.
( )
( )

e
e
=
R b a
R b , a
m
j , i
j i
j i
0
1
EXAMPLE
Let Which
ordered pairs are in the relation R represented
by the matrix.
{ } { }
5 4 3 2 1 3 2 1
b , b , b , b , b B & a , a , a A = =
EXAMPLE
Suppose that the relation R on a set is
represented by the matrix ,
Is R reflexive, symmetric or anti symmetric?
(
(
(

=
1 1 0
1 1 1
0 1 1
R
M

Das könnte Ihnen auch gefallen