Download Relations - Discrete Structures - Lecture Slides and more Slides Discrete Structures and Graph Theory in PDF only on Docsity!
You Never Escape Your…
• Relations
Relations
- If we want to describe a relationship between elements of
two sets A and B, we can use ordered pairs with their first
element taken from A and their second element taken
from B.
- Since this is a relation between two sets , it is called a
binary relation.
- Definition: Let A and B be sets. A binary relation from A to
B is a subset of A×B.
- In other words, for a binary relation R we have
R ⊆ A×B. We use the notation aRb to denote that (a, b)∈R
and aRb to denote that (a, b)∉R.
Functions as Relations
- You might remember that a function f from a set A to a set
B assigns a unique element of B to each element of A.
- The graph of f is the set of ordered pairs (a, b) such that b
= f(a).
- Since the graph of f is a subset of A×B, it is a relation from
A to B.
- Moreover, for each element a of A, there is exactly one
ordered pair in the graph that has a as its first element.
Functions as Relations
- Conversely, if R is a relation from A to B such that every
element in A is the first element of exactly one ordered
pair of R, then a function can be defined with R as its
graph.
- This is done by assigning to an element a∈A the unique
element b∈B such that (a, b)∈R.
Relations on a Set
- Solution: R = { (1, 2), (1, 3), (1, 4), (2, 3),(2, 4),(3, 4)}
R 1 2 3 4
X X X
X X
X
Relations on a Set
- How many different relations can we define on a set A with n elements?
- A relation on a set A is a subset of A×A.
- How many elements are in A×A?
- There are n^2 elements in A×A, so how many subsets (= relations on A) does A×A have?
- The number of subsets that we can form out of a set with m elements is 2m^. Therefore, 2 n 2 subsets can be formed out of A×A.
- Answer: We can define 2n 2 different relations on A.
Properties of Relations
- Definitions:
- A relation R on a set A is called symmetric if (b, a)∈R
whenever (a, b)∈R for all a, b∈A.
- A relation R on a set A is called antisymmetric if
a = b whenever (a, b)∈R and (b, a)∈R.
- A relation R on a set A is called asymmetric if
(a, b)∈R implies that (b, a)∉R for all a, b∈A.
Properties of Relations
- Are the following relations on {1, 2, 3, 4}
symmetric, antisymmetric, or asymmetric?
R = {(1, 1), (1, 2), (2, 1), (3, 3), (4, 4)} symmetric
R = {(1, 1)} sym. and
antisym.
R = {(1, 3), (3, 2), (2, 1)} antisym.
and asym.
R = {(4, 4), (3, 3), (1, 4)} antisym.
Counting Relations
- Example: How many different reflexive relations can be defined on a set A containing n elements?
- Solution: Relations on R are subsets of A×A, which contains n^2 elements.
- Therefore, different relations on A can be generated by choosing different subsets out of these n^2 elements, so there are 2n^2 relations.
- A reflexive relation, however, must contain the n elements (a, a) for every a∈A.
- Consequently, we can only choose among n^2 – n = n(n – 1) elements to generate reflexive relations, so there are 2n(n – 1)^ of them.
Combining Relations
- Relations are sets, and therefore, we can apply the usual
set operations to them.
- If we have two relations R 1 and R 2 , and both of them are
from a set A to a set B, then we can combine them to R 1 ∪
R 2 , R 1 ∩ R 2 , or R 1 – R 2.
- In each case, the result will be another relation from A to
B.
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)}
- S°D = { (^) (2, 4), (3, 3), (3, 4), (4, 2), (4, 3),
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 S ° D = {(a,b) | b > 5 – a}
or S ° D = {(a,b) | a + b > 5}.
Combining Relations
- We already know that functions are just special cases of
relations (namely those that map each element in the
domain onto exactly one element in the codomain).
- If we formally convert two functions into relations, that is,
write them down as sets of ordered pairs, the composite of
these relations will be exactly the same as the composite of
the functions (as defined earlier).
Combining Relations
- Theorem: The relation R on a set A is transitive if and only if R n^ ⊆ R for all positive integers n.
- Remember the definition of transitivity:
- Definition: A relation R on a set A is called transitive if whenever (a, b)∈R and (b, c)∈R, then (a, c)∈R for a, b, c∈A.
- The composite of R with itself contains exactly these pairs (a, c).
- Therefore, for a transitive relation R, R°R does not contain any pairs that are not in R, so R°R ⊆ R.
- Since R°R does not introduce any pairs that are not already in R, it must also be true that (R°R)°R ⊆ R, and so on, so that R n^ ⊆ R.
n-ary Relations
- In order to study an interesting application of relations,
namely databases , we first need to generalize the concept
of binary relations to n-ary relations.
- Definition: Let A 1 , A 2 , …, An be sets. An n-ary relation on
these sets is a subset of A 1 ×A 2 ×…×A (^) n.
- The sets A 1 , A 2 , …, An are called the domains of the
relation, and n is called its degree.