Download presentation
Presentation is loading. Please wait.
Published byRolf Wells Modified over 6 years ago
1
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 9 Relations Slides are adopted from “Discrete Mathematics and It's Applications” Kenneth H. Rosen; 7th edition, 2012.
2
Relations What is a relation?
Relation between elements of sets is just a subset of the Cartesian product of the sets. Relations can be used to solve problems such as: Determining which pairs of cities are linked by airline flights in a network, Finding a viable order for the different phases of a complicated project, Producing a useful way to store information in computer databases.
3
Relations What is a relation?
Let A and B be any two sets. A binary relation from A to B, written R : A B, is a subset of the Cartesian product A x B. Recall: A x B = {(a, b) | a A, b B} We use the notation a R b to denote that (a, b) ∈ R and a R b to denote that (a, b) R. Moreover, when (a, b) belongs to R, a is said to be related to b by R. In other words, a binary relation from A to B is a set R of ordered pairs where the first element of each ordered pair comes from A and the second element comes from B.
4
Relations Example : Let A be the set of students in your school, and let B be the set of courses. Let R be the relation that consists of those pairs (a, b), where a is a student enrolled in course b. Let A be the students in a the CS major A = {Ali, Ahmed, Fares, Nasser} Let B be the courses the department offers B = {CS190, CS201, CS202} We specify relation R A B as the set that lists all students a A enrolled in class b B R = {(Ali, CS101), (Ahmed, CS201), (Fares, CS202), (Nasser, CS201), (Nasser, CS202)}
5
Relations . Example
6
Relations .
7
Relations Example : Let A = {0, 1, 2} and B = {a, b}. Then {(0, a), (0, b), (1, a), (2, b)} is a relation from A to B. This means, for instance, that 0 R a, but that 1 R b. Relations can be represented graphically, as shown in Figure, using arrows to represent ordered pairs. Another way to represent this relation is to use a table, which is also done in Figure
8
Relations on a set Definition: A relation on the set A is a relation from A to A . In other words, a relation on a set A is a subset o f A x A . Example: Let A be the set { 1, 2, 3, 4 } Which ordered pairs are in the relation R = { (a , b) | a divides b }? Solution: we see that R = {(1,1), (1,2), (1,3), (1,4), (2,2), (2,4), (3,3), (4,4)} 1 2 3 4 1 2 3 4 R 1 2 3 4 X
9
Relations Example: Consider some relations on the set of integers
R1 = { (a , b) | a ≤ b } R2 = { (a , b) | a > b } R3 = { (a , b) | a = b or a = - b } R4 = { (a , b) | a = b } R5 = { (a , b) | a = b+1 } R6 = { (a , b) | a + b ≤ 3 } Which o f these relations contain each o f the pairs ( 1 , 1 ), ( 1 , 2), (2 , 1 ), ( 1 , - 1 ), and (2, 2)?
10
Relations Answer: 1. A relation on set A is a subset from A×A.
Example: How many relations are there on a set with n elements? Answer: 1. A relation on set A is a subset from A×A. 2. A has n elements so A×A has n2 elements. 3. Number of subsets for n2 elements is , thus there are relations on a set with n elements. e.g. If S = {a, b, c}, there are relations.
11
Properties of Relations
There are several properties that are used to classify relations on a set. We will introduce the most important of these here. Reflexive Irreflexive Symmetric Antisymmetric Transitive
12
Properties of Relations
Definition: A relation R on a set A is called reflexive if (a, a) R for every element a A. Example: Consider the following relations on a set A = { l , 2, 3 , 4} : R1 = {( 1 , 1 ), ( 1 , 2), (2 , 1 ), (2, 2), (3 , 4), (4, 1 ) , (4, 4)} , R2 = {( 1 , 1 ), ( 1 , 2), (2, I ) } , R3 = { ( I , 1 ) , ( 1 , 2 ) , ( 1 , 4), (2, 1 ), (2, 2), (3 , 3 ) , (4, 1 ) , (4, 4)}, R4 = {(2, 1 ), (3 , 1 ) , (3 , 2), (4, 1 ) , (4, 2), (4, 3)} , R5 = {( 1 , 1 ) , ( 1 , 2), ( 1 , 3), ( 1 , 4), (2, 2), (2, 3), (2, 4), (3 , 3), (3 , 4), (4, 4)} , R6 = {(a, b) | a ≤ b} . Which of these relations are reflexive? Solution: The relations R3 , R5 and R6 are reflexive because they both contain all pairs of the form (a , a), namely, ( 1 , 1 ), (2, 2), (3 , 3), and (4, 4). The other relations are not reflexive because they do not contain all of these ordered pairs.
13
Properties of Relations
Definition: A relation R on a set A is called irreflexive if (a , a) R for all a A. A relation can be neither reflexive nor irreflexiv Note: “irreflexive” ≠ “not reflexive” Example: Let A = {1, 2} and R = {(1, 2), (2, 1), (1, 1)} It is not reflexive, because (2, 2) R, It is not irreflexive, because (1, 1) R.
14
Properties of Relations
Definition: A relation R on a set A is called symmetric if for all a, b A, if (a , b) R (b , a) R. A relation R on a set A is called antisymmetric if for all a, b A, if (a, b) R (b, a) R. That is, for all a, b ∈ A, if ((a , b) R (b , a) R) a=b. Example: Consider these relations on the set of integers: R1 = {(a, b) | a = b} Symmetric , antisymmetric. R2 = {(a, b) | a > b}, Not symmetric, antisymmetric. R3 = {(a, b) | a = b + 1}, Not symmetric, antisymmetric
15
Properties of Relations
Example: Consider the following relations on a set A = { l , 2, 3 , 4} : R1 = {( 1 , 1 ), ( 1 , 2), (2 , 1 ), (2, 2), (3 , 4), (4, 1 ) , (4, 4)} , R2 = {( 1 , 1 ), ( 1 , 2), (2, I ) } , R3 = { ( I , 1 ) , ( 1 , 2 ) , ( 1 , 4), (2, 1 ), (2, 2), (3 , 3 ) , (4, 1 ) , (4, 4)}, R4 = {(2, 1 ), (3 , 1 ) , (3 , 2), (4, 1 ) , (4, 2), (4, 3)} , R5 = {( 1 , 1 ) , ( 1 , 2), ( 1 , 3), ( 1 , 4), (2, 2), (2, 3), (2, 4), (3 , 3), (3 , 4), (4, 4)} , R6 = {(3 , 4)} . Which of these relations are symmetric and which are antisymmetric? Solution: The relations R2 and R3 are symmetric. The relations R4, R5 , and R6 are all antisymmetric. The relation R1 neither symmetric nor antisymmetric .
16
Properties of Relations
Example: Let A = {1, 2, 3}. R1 = {(1, 2), (2, 2), (3, 1), (1, 3)} Not reflexive, not irreflexive, not symmetric, not antisymmetric R2 = {(2, 2), (1, 3), (3, 2)} Not reflexive, not irreflexive, not symmetric, antisymmetric R3 = {(1, 1), (2, 2), (3, 3)} Reflexive, not irreflexive, symmetric, antisymmetric R4 = {(2, 3)} Not reflexive, irreflexive, not symmetric, antisymmetric
17
Properties of Relations
Definition: A relation R on a set A is called transitive if for all a, b, c A, ((a , b)R (b , c)R) (a , c)R If a < b and b < c, then a < c Thus, < is transitive If a = b and b = c, then a = c Thus, = is transitive
18
Properties of Relations
Example: Consider the following relations on a set A = { l , 2, 3 , 4} : R1 = {( 1 , 1 ), ( 1 , 2), (2 , 1 ), (2, 2), (3 , 4), (4, 1 ) , (4, 4)} , R2 = {( 1 , 1 ), ( 1 , 2), (2, 1 ) } , R3 = { ( I , 1 ) , ( 1 , 2 ) , ( 1 , 4), (2, 1 ), (2, 2), (3 , 3 ) , (4, 1 ) , (4, 4)}, R4 = {(2, 1 ), (3 , 1 ) , (3 , 2), (4, 1 ) , (4, 2), (4, 3)} , R5 = {( 1 , 1 ) , ( 1 , 2), ( 1 , 3), ( 1 , 4), (2, 2), (2, 3), (2, 4), (3 , 3), (3 , 4), (4, 4)} , R6 = {(3 , 4)} . Which of these relations are transitive? Solution: The relations R4 , R5 , and R6 are transitive. The relations R1 , R2 , and R3 are not transitive.
19
Summary of properties of relations
20
Combining Relations Combining Relations
Because relations from A to B are subsets of A x B, two relations from A to B can be combined in any way two sets can be combined. There are two ways to combine relations R1 and R2 Via Set operators Via relation “composition” Example: Let A = {1, 2, 3} and B = {1, 2, 3, 4}. The relations R1 = {(1, 1), (2, 2), (3, 3)} and R2 = {(1, 1), (1, 2), (1, 3), (1, 4)} can be combined to obtain R1 ∪ R2 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (3, 3)}, R1 ∩ R2 = {(1, 1)}, R1 − R2 = {(2, 2), (3, 3)}, R2 − R1 = {(1, 2), (1, 3), (1, 4)}.
21
Combining Relations Example: Let Solution:
R1 = {(x, y) | x < y} R2 = {(x, y) I x > y}, on the set of real numbers What are RI U R2 , RI R2 , RI - R2 , R2 - RI, and RI R2? Solution: (x , y) R1 U R2 if and only if (x , y) R1 or (x, y) R2 (x , y) R1 U R2 if and only if x < y or x > y. Since, the condition x < y or x > y is the same as the condition x y Then R1 U R2 = {(x, y) I x y} (x, y) impossible to belong to both R1 and R2 So, R1 R2 = R1 - R2 = R1 R2 – R1 = R2 RI R2 = R1 U R2 - R1 R2 = {(x, y) | x y}
22
Combining Relations Definition: Example:
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 a ∈ A, c ∈ C, and for which there exists an element b ∈ B such that (a, b) ∈ R and (b, c) ∈ S. We denote the composite of R and S by S ◦ R. Example: What is the composite of the relations R and S, where R is the relation from {I, 2, 3} to {I, 2, 3, 4} With R = {(1, 1), (1, 4), (2, 3), (3, 1), (3, 4)} and S is the relation from {l, 2, 3, 4} to {0, 1, 2} With S = {(1, 0), (2, 0), (3, 1), (3, 2), (4, I)}? Solution: S R = {(1, 0), (1, 1), (2, 1), (2, 2), (3, 0), (3, I)}
23
Combining Relations Definition: powers of a relation R
Let R be a relation on the set A. The powers Rn, n = 1,2, 3, ... , are defined recursively by: Example: Let R = {(I, 1), (2, 1), (3, 2), (4, 3)}. Find the powers Rn , n = 2, 3,4, .... Solution: R2 = R o R R2 = {(1, 1), (2, 1), (3, 1), (4, 2)} R3 = R2 o R R3 = {(I, 1), (2, 1), (3, 1), (4, I)}. R4 = R3 = {(1, 1), (2, 1), (3, 1), (4, I)}. It follows that Rn = R3 for n = 5, 6, 7, .... Verify this!
24
Equivalence Relations
. A relation on a set A is called an equivalence relation if it is reflexive, symmetric, and transitive.
25
Equivalence Relations
Example: Which of these relations on {0, 1, 2, 3} are equivalence relations? Determine the properties of an equivalence relation that the others lack 1- { (0,0), (1,1), (2,2), (3,3) } Has all the properties, thus, is an equivalence relation 2- { (0,0), (0,2), (2,0), (2,2), (2,3), (3,2), (3,3) } Not reflexive: (1,1) is missing Not transitive: (0,2) and (2,3) are in the relation, but not (0,3) 3- { (0,0), (1,1), (1,2), (2,1), (2,2), (3,3) } 4- { (0,0), (1,1), (1,3), (2,2), (2,3), (3,1), (3,2) (3,3) } Not transitive: (1,3) and (3,2) are in the relation, but not (1,2) 5- { (0,0), (0,1) (0,2), (1,0), (1,1), (1,2), (2,0), (2,2), (3,3) } Not symmetric: (1,2) is present, but not (2,1) Not transitive: (2,0) and (0,1) are in the relation, but not (2,1)
26
Equivalence Relations
Example: Let m be a positive integer with m > 1. Show that the relation R = { (a , b) I a == b (mod m)} is an equivalence relation on the set of integers. Solution: We can see that a == b (mod m) if and only if m divides a - b. Note that a - a = 0 is divisible by m , because 0 = 0· m . Hence, a == a (mod m), so congruence modulo m is reflexive. Now suppose that a == b (mod m). Then a - b is divisible by m, so a - b = km , where k is an integer. It follows that b - a = (-k)m , so b == a (mod m). Hence, congruence modulo m is symmetric. Next, suppose that a == b (mod m) and b == c (mod m). Then m divides both a - b and b - c. Therefore, there are integers k and I with a - b = km and b - c = I m . Adding these two equations shows that a - c = (a - b) + (b - c) = km + Im = (k + I) m . Thus, a == c (mod m). Therefore, congruence modulo m is transitive. It follows that congruence modulo m is an equivalence relation.
27
Equivalence Relations
Example: Let R be a relation on Z defined as follows: a R b if and only if 5 | (a2 – b2). Show that R is an equivalence relation. Solution: R is reflexive: a2 – a2 = 0 = 0×5 5 | (a2 – a2) a R a. R is symmetric: If a R b 5 | (a2 – b2) a2 – b2 = m×5, m Z b2 – a2 = (-m)×5 5 | (b2 – a2) b R a. R is transitive: Suppose that a R b 5 | (a2 – b2) a2 – b2 = m×5, m Z and b R c 5 | (b2 – c2) b2 – c2 = k×5, k Z . Now (a2 – b2) + (b2 – c2) = (a2 – c2) =(m + k)×5 5 | (a2 – c2) a R c.
28
Equivalence classes Definition: Let R be an equivalence relation on a set A. The set of all elements that are related to an element a of A is called the equivalence class of a. The equivalence class of a with respect to R is denoted by [a]R. When only one relation is under consideration, we can delete the subscript R and write [a] for this equivalence class. In other words, if R is an equivalence relation on a set A, the equivalence class of the element a is [a]R = {s I (a , s) R } . If b [a]R, then b is called a representative of this equivalence class.
29
Equivalence classes Example: What are the equivalence classes of 0 and 1 for congruence modulo 4? Solution: The equivalence class of 0 contains all integers a such that a == 0 (mod 4). The integers in this class are those divisible by 4. Hence, the equivalence class of 0 for this relation is [0] = { , -8, -4, 0, 4, 8 , } . The equivalence class of 1 contains all the integers a such that a == 1 (mod 4). The integers in this class are those that have a remainder of 1 when divided by 4. Hence, the equivalence class of 1 for this relation is [ 1 ] = { , -7, -3 , 1 , 5 , 9, } .
30
Relations and Their Properties
Exercises:
31
Relations and Their Properties
32
Relations and Their Properties
33
Relations and Their Properties
1. Which of these relations on {0, 1, 2, 3} are equivalence relations? Determine the properties of an equivalence relation that the others lack. {(0, 0), (1, 1), (2, 2), (3, 3)} b) {(0, 0), (0, 2), (2, 0), (2, 2), (2, 3), (3, 2), (3, 3)} c) {(0, 0), (1, 1), (1, 2), (2, 1), (2, 2), (3, 3)} d) {(0, 0), (1, 1), (1, 3), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)} e) {(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 2), (3, 3)}
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.