CS 103 Discrete Structures Lecture 19 Relations. Chapter 9.

Slides:



Advertisements
Similar presentations
CSE115/ENGR160 Discrete Mathematics 04/26/12 Ming-Hsuan Yang UC Merced 1.
Advertisements

Discrete Mathematics Relations
Basic Properties of 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.
CSE115/ENGR160 Discrete Mathematics 05/03/11 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.
1 Relations Rosen 6 th ed., § Relations Re lationships between elements of sets occur in many contextsRe lationships between elements of sets occur.
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.
Relations and Their Properties
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.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Relations, Functions.
Digraphs and Relations Warm Up. The Divisibility Relation Let “|” be the binary relation on N×N such that a|b (“a divides b”) iff there is an n ∈ N such.
Sets Define sets in 2 ways  Enumeration  Set comprehension (predicate on membership), e.g., {n | n  N   k  k  N  n = 10  k  0  n  50} the set.
1 Relations and Their Properties Rosen, section 7.1 CS/APMA 202 Aaron Bloomfield.
Chapter 7: Relations Relations(7.1) Relations(7.1) n-any Relations & their Applications (7.2) n-any Relations & their Applications (7.2)
Discrete Mathematics Relation.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Relations, Functions.
1 RELATIONS Learning outcomes Students are able to: a. determine the properties of relations – reflexive, symmetric, transitive, and antisymmetric b. determine.
Section 4.4 Properties of Relations. Order Relations Draw an arrow diagram for the relation R defined on the set {1,2,3,4} such that
Relations. Important Definitions We covered all of these definitions on the board on Monday, November 7 th. Definition 1 Definition 2 Definition 3 Definition.
Discrete Mathematics Lecture # 15 Types of Relations (contd.)
1 Partial Orderings Aaron Bloomfield CS 202 Epp, section ???
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
Lecture 4.1: Relations Basics CS 250, Discrete Structures, Fall 2012 Nitesh Saxena Adopted from previous lectures by Cinda Heeren.
Representing Relations Using Matrices A relation between finite sets can be represented using a zero-one matrix Suppose R is a relation from A = {a 1,
Chapter Relations and Their Properties
1 RELATIONS Learning outcomes Students are able to: a. determine the properties of relations – reflexive, symmetric, transitive, and antisymmetric b. determine.
Keep in Your Notes!! list the first 15 perfect squares 1² = 2² = 3² =
RelationsCSCE 235, Spring Introduction A relation between elements of two sets is a subset of their Cartesian products (set of all ordered pairs.
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.
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), (
Advanced Digital Designs Jung H. Kim. Chapter 1. Sets, Relations, and Lattices.
Lecture 4.1: Relations Basics CS 250, Discrete Structures, Fall 2011 Nitesh Saxena *Adopted from previous lectures by Cinda Heeren.
1 CMSC 250 Discrete Structures CMSC 250 Lecture 41 May 7, 2008.
Section 9.1. Section Summary Relations and Functions Properties of Relations Reflexive Relations Symmetric and Antisymmetric Relations Transitive Relations.
Lecture 7: Relations Dr Andrew Purkiss-Trew Cancer Research UK Mathematics for Computing.
Relations Chapter 9 Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent of McGraw-Hill.
Relations and Their Properties
Citra Noviyasari, S.Si, MT
CSE 2813 Discrete Structures
Relations and Their Properties
Relations Chapter 9.
Applied Discrete Mathematics Week 10: Relations
RELATION KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS )
Aaron Bloomfield CS 202 Epp, section ???
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 9 Relations Slides are adopted from.
Applied Discrete Mathematics Week 9: 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
Relations and their Properties
Introduction to Relations and Functions
Formal Definition and Examples
Lecture 4.1: Relations Basics
Discrete Math (2) Haiming Chen Associate Professor, PhD
REVISION Relation. REVISION Relation Introduction to Relations and Functions.
Agenda Lecture Content: Relations (Relasi)
Lecture # 16 Inverse of Relations
Presentation transcript:

CS 103 Discrete Structures Lecture 19 Relations

Chapter 9

Chapter Summary Relations and Their Properties

Section 9.1

Section Summary Relations and Functions Properties of Relations Reflexive Relations Symmetric and Antisymmetric Relations Transitive Relations Combining Relations

Binary Relations A relation is a subset of the Cartesian product Relations can be used to solve problems such as: Determining which pairs of cities are linked by airline flights in a network Finding a feasible order for the different phases of a complicated project Producing a useful way to store information in computer databases A binary relation R from a set A to a set B is a subset R ⊆ A × B. Therefore, R consists of ordered pairs where the 1 st element of each ordered pair comes from A and the 2 nd element comes from B

Binary Relations (a, b)  R means a is related to b by R a R b denotes (a, b)  R a R b denotes (a, b)  R Example 1: Let A be the set of students, B be the set of courses and R be the relation that consists of pairs (a, b), where a is a student enrolled in course b. Then, If Ahmad and Ali are enrolled in CS103, then (Ahmad, CS103)  R and (Ali, CS103)  R If Ahmad is also enrolled in CS111, then (Ahmad, CS111)  R If Ali is not enrolled in CS111, then (Ali, CS111)  R

Binary Relations Example 2: Let A be the set of cities, B be the set of regions. (a, b) belongs to R if city a is in region b Then (Al-Mahd, Al-Madinah), (Gada, Makkah), and (Al-Zolfy, Ryiadh) are in R Example 3 A = {0, 1, 2} B = {a, b} R = {(0, a), (0, b), (1, a), (2, b)} is a relation from A to B We also can represent the relation from the set A to the set B graphically or using a table

Binary Relations on a Set A binary relation on the set A is a relation from A to A. In other words, a relation on a set A is a subset of A  A Example 1: A = {a, b, c}. Then R = {(a, a),(a, b), (a, c)} is a relation on A Example 2: A = {1, 2, 3, 4}. Which ordered pairs are in the relation R = {(a, b) | a divides b}? R = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 4), (3, 3), (4, 4)}

How Many Relations on a Set? Because a relation on A is the same thing as a subset of A × A, we count the subsets of A × A As A × A has |A| 2 elements, and a set with m elements has 2 m subsets, therefore A × A has 2 |A| 2 subsets  there are 2 |A| 2 relations on a set A

Binary Relations on a Set: Example 3 Which of these relations on the set of integers contain each of the pairs (1, 1), (1, 2), (2, 1), (1, -1), and (2, 2)? R 1 = {(a, b) | a ≤ b} R 2 = {(a, b) | a > b} R 3 = {(a, b) | a = b or a = - b} R 4 = {(a, b) | a = b} R 5 = {(a, b) | a = b + 1} R 6 = {(a, b) | a + b ≤ 3} (1, 1)is inR 1, R 3, R 4, and R 6 (1, 2)is inR 1 and R 6 (2, 1) is inR 2, R 5, and R 6 (1, -1)is inR 2, R 3, and R 6 (2, 2)is inR 1, R 3, and R 4 Note that these relations are on an infinite set and each of these relations is an infinite set

Properties of Relations: Reflexive Properties are used to classify relations on a set A relation R on a set A is called reflexive iff ∀ x[x ∊ A ⟶ (x, x) ∊ R], i.e. (a, a)  R for every element a  A A= {1, 2, 3, 4} R 1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)} R 2 = {(1, 1), (1, 2), (2, 1)} R 3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)} R 4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)} R 5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)} R 6 = {(3, 4)}

Properties of Relations: Irreflexive Relation R on a set A is irreflexive if (a, a)  R for all a  A Some relations are neither reflexive nor irreflexive Example Let A = {1, 2} and R = {(1, 1)} It is not reflexive, because (2, 2)  R It is not irreflexive, because (1, 1)  R

Properties of Relations: Symmetric Relation R on a set A is symmetric iff (b, a)  R whenever (a, b)  R, for all a, b  A Relation R on a set A is antisymmetric iff (a, b)  R & (b, a)  R then a = b, for all a, b  A Relations can be symmetric & antisymmetric, simultaneously A = {1, 2, 3, 4} R 1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)} R 2 = {(1, 1), (1, 2), (2, 1)} R 3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)} R 4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)} R 5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)} R 6 = {(3, 4)}

Antisymmetric Property: Example Details R 1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)} Whenever 2 nd -last column shows Yes, last column does not show Yes.  R 5 is not Antisymmetric (a, b)(a, b)(b, a)(b, a) (b, a)  R 4 ? a=b?a=b? (1, 1) Yes (1, 2)(1, 2)(2, 1)YesNo (2, 1)(1, 2)YesNo (2, 2) Yes (3, 4)(4, 3)No- (4, 1)(1, 4)No- (4, 4) Yes

Antisymmetric Property: Example Details R 4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)} Whenever 2 nd -last column shows Yes, last column also shows Yes.  R 5 is Antisymmetric (a, b)(a, b)(b, a)(b, a) (b, a)  R 4 ? a=b?a=b? (2, 1)(1, 2)No- (3, 1)(3, 1)(1, 3)(1, 3) - (3, 2)(2, 3)No- (4, 1)(1, 4)No- (4, 2)(2, 4)No- (4, 3)(3, 4)No-

Antisymmetric Property: Example Details R 5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)} Whenever 2 nd -last column shows Yes, last column also shows Yes.  R 5 is Antisymmetric (a, b)(a, b)(b, a)(b, a) (b, a)  R 4 ? a=b?a=b? (1, 1) Yes (1, 2)(1, 2)(2, 1)(2, 1)No- (1, 3)(3, 1)No- (1, 4)(4, 1)No- (2, 2) Yes (2, 3)(3, 2)No- (2, 4)(4, 2)No- (3, 3) Yes (3, 4)(4, 3)No- (4, 4) Yes

Properties of Relations: Transitive Relation R on a set A is transitive if whenever (a, b)  R and (b, c)  R, then (a, c)  R, for all a, b, c  A A = {1, 2, 3, 4} R 1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)} R 2 = {(1, 1), (1, 2), (2, 1)} R 3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)} R 4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)} R 5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)} R 6 = {(3, 4)}

Transitive Property: Example Details R 1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)} Start with the first pair, (1,1). Here a=1, b=1. Are their pairs that have their 1 st elements as b? Yes Only one pair, (1, 2). Here b=1, c=2 Is (a, c) a member of R 1 ? Yes.  R 1 can be transitive. Now move to the next pair, (1, 2). Here a=1, b=2. Are their pairs that have their 1 st elements as b? Yes Two pairs, (2, 1), (2, 2). Here b=2, c=1 and c=2 Is (a, c) a member of R 1 ? Yes for both c=1 and c=2.  R 1 may be transitive. Now move to the next pair, (2, 1). Here a=2, b=1. Are their pairs that have their 1 st elements as b? Yes Two pairs, (1, 1), (1, 2). Here b=1, c=1 and c=2 Is (a, c) a member of R 1 ? Yes for both c=1 and c=2.  R 1 may be transitive. Now move to the next pair, (2, 2). Here a=2, b=2. Are their pairs that have their 1 st elements as b? Yes Two pairs, (2, 1), (2, 2). Here b=2, c=1 and c=2 Is (a, c) a member of R 1 ? Yes for both c=1 and c=2.  R 1 may be transitive. Now move to the next pair, (3, 4). Here a=3, b=4. Are their pairs that have their 1 st elements as b? Yes Two pairs, (4, 1), (4, 4). Here b=4, c=1 and c=4 Is (a, c) a member of R 1 ? No for c=1.  R 1 is not transitive. Finished! No need to do any further checking.

Transitive Property: Example Details R 4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)} There are no “No” answers in the last column. Therefore, the relation R 4 is transitive. (a, b)(a, b) Pairs with b as their 1 st element c (a, c)  R 4 ? (2, 1)--- (3, 1)(3, 1)--- (3, 2)(2, 1)1Yes (4, 1)--- (4, 2)(2, 1)1Yes (4, 3)(3, 1) (3, 2) 1212 Yes

Properties of Relations: Summary Reflexive  a  A,(a, a)  R Irreflexive  a  A,(a, a)  R Symmetric  a,b  A,(a, b)  R  (b, a)  R Antisymmetric  a,b  A,(a, b)  R  (b, a)  R  a = b Transitive  a,b,c  A,(a, b)  R  (b, c)  R  (a, c)  R

Combining Relations Relations are sets They can be combined in any way sets can be combined Example 1 Let A = {1, 2, 3}, B = {1, 2, 3, 4}, R 1 = {(1, 1), (2, 2), (3, 3)} R 2 = {(1, 1), (1, 2), (1, 3), (1, 4)}

Combining Relations: Example 2 R 1 = {(x, y) | x y}, where x,y  R R 1  R 2 = ? (x, y)  R 1  R 2 iff (x, y)  R 1 or (x, y)  R 2 (x, y)  R 1  R 2 iff x y x y implies that x  y  R 1  R 2 = {(x, y) | x  y} R 1  R 2 =  as (x, y) cannot belong to both R 1 & R 2 R 1 - R 2 = R 1 R 2 - R 1 = R 2 R 1  R 2 = R 1  R 2 - R 1  R 2 = {(x, y) | x  y} x > y x < y y -axis x-axis x = yx = y

R is a relation from set A to set B S is a relation from set B to set C The composite of R and S, S  R, 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 Example R is the relation from A = {1, 2, 3} to B = {1, 2, 3, 4} R = {(1, 1), (1, 4), (2, 3), (3, 1), (3, 4)} S is the relation from B = {1, 2, 3, 4} to C = {0, 1, 2} S = {(1, 0), (2, 0), (3, 1), (3, 2), (4, 1)} S  R = {(1, 0), (1, 1), (2, 1), (2, 2), (3, 0), (3, 1)} b b c c a a a a b b c c Composite of Relations

Powers of a Relation For relation R on set A, powers R n, n = 1, 2, 3,..., are defined recursively by Example R = {(1, 1), (2, 1), (3, 2), (4, 3)} = R 1 R 2 = R  R = {(1, 1), (2, 1), (3, 1), (4, 2)} R 3 = R 2  R = {(1, 1), (2, 1), (3, 1), (4, 1)} R 4 = R 3  R = {(1, 1), (2, 1), (3, 1), (4, 1)} = R 3 R n = R 3 for n = 5, 6, 7,.... as well

Section 9.1: Exercises