Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 9 Relations Slides are adopted from.

Slides:



Advertisements
Similar presentations
CSE 211- Discrete Structures
Advertisements

Equivalence Relations
Equivalence Relations
Relations Relations on a Set. Properties of Relations.
Discrete Mathematics Relations
April 9, 2015Applied Discrete Mathematics Week 9: Relations 1 Solving Recurrence Relations Another Example: Give an explicit formula for the Fibonacci.
Relations.
Discrete Mathematics Lecture # 16 Inverse of Relations.
Discrete Structures Chapter 5 Relations Nurul Amelina Nasharuddin Multimedia Department.
CSE115/ENGR160 Discrete Mathematics 04/24/12 Ming-Hsuan Yang UC Merced 1.
Discrete Mathematics Lecture#11.
1 Section 7.1 Relations and their properties. 2 Binary relation A binary relation is a set of ordered pairs that expresses a relationship between elements.
Relations Chapter 9.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 8: Relations Relations(8.1) n-any Relations &
Relation. Relations Recall the definition of the Cartesian (Cross) Product: The Cartesian Product of sets A and B, A x B, is the set A x B = { : x  A.
1 Relations and Their Properties Epp, section ??? CS 202 Aaron Bloomfield.
Chapter 9. Chapter Summary Relations and Their Properties Representing Relations Equivalence Relations Partial Orderings.
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
Unit Unit 04 Relations IT DisiciplineITD1111 Discrete Mathematics & Statistics STDTLP1 Unit 4 Relations.
Chapter 9. Section 9.1 Binary Relations Definition: A binary relation R from a set A to a set B is a subset R ⊆ A × B. Example: Let A = { 0, 1,2 } and.
Chapter 7: Relations Relations(7.1) Relations(7.1) n-any Relations & their Applications (7.2) n-any Relations & their Applications (7.2)
1 RELATIONS Learning outcomes Students are able to: a. determine the properties of relations – reflexive, symmetric, transitive, and antisymmetric b. determine.
CS 103 Discrete Structures Lecture 19 Relations. Chapter 9.
Discrete Mathematics Lecture # 15 Types of Relations (contd.)
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
1 RELATIONS Learning outcomes Students are able to: a. determine the properties of relations – reflexive, symmetric, transitive, and antisymmetric b. determine.
Chapter 8: Relations. 8.1 Relations and Their Properties Binary relations: Let A and B be any two sets. A binary relation R from A to B, written R : A.
Copyright © Cengage Learning. All rights reserved. CHAPTER 8 RELATIONS.
Relations and Functions ORDERED PAIRS AND CARTESIAN PRODUCT An ordered pair consists of two elements, say a and b, in which one of them, say a is designated.
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications (5 th Edition) Kenneth H. Rosen Chapter 7 Relations.
Binary Relations Definition: A binary relation R from a set A to a set B is a subset R ⊆ A × B. Example: Let A = { 0, 1,2 } and B = {a,b} {( 0, a), (
Chapter 4 With Question/Answer Animations 1. Chapter Motivation Number theory is the part of mathematics devoted to the study of the integers and their.
Section 9.1. Section Summary Relations and Functions Properties of Relations Reflexive Relations Symmetric and Antisymmetric Relations Transitive Relations.
Chapter8 Relations 8.1: Relations and their properties.
Relations Chapter 9 Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent of McGraw-Hill.
The Relation Induced by a Partition
Discrete Mathematical
Relations and Their Properties
Citra Noviyasari, S.Si, MT
Chapter 5 Relations and Operations
Modular Arithmetic with Applications to Cryptography
Relations.
Relations and Their Properties
CSE15 Discrete Mathematics 05/03/17
Equivalence Relations
Relations Chapter 9.
Lecture # 14 Types of Relations
Applied Discrete Mathematics Week 10: Relations
RELATION KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS )
Reflexivity, Symmetry, and Transitivity
Relations and Their Properties
CSE 504 Discrete Structures & Foundations of Computer Science
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
Applied Discrete Mathematics Week 9: Equivalence Relations
CS2210 Discrete Structures Relations
8.5 Equivalence Relations
Relations and Their Properties
8.1 Relations and Their Properties
CSE15 Discrete Mathematics 04/26/17
Applied Discrete Mathematics Week 5: Boolean Algebra
Applied Discrete Mathematics Week 6: Relations/Digraphs
Relations and their Properties
Introduction to Relations and Functions
Discrete Math (2) Haiming Chen Associate Professor, PhD
9.5 Equivalence Relations
Equivalence Relations
Equivalence Relations
REVISION Relation. REVISION Relation Introduction to Relations and Functions.
Chapter 8 (Part 2): Relations
Lecture # 16 Inverse of Relations
Presentation transcript:

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.

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.

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.

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)}

Relations . Example

Relations .

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

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

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)?  

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.

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

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.

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.

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  

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 .

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

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

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.

Summary of properties of relations

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)}.

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}

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)}

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!

Equivalence Relations . A relation on a set A is called an equivalence relation if it is reflexive, symmetric, and transitive.

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)

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.

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.

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.

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, . . . } .

Relations and Their Properties Exercises:

Relations and Their Properties

Relations and Their Properties

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)}