1 Relations and Their Properties Rosen, section 7.1 CS/APMA 202 Aaron Bloomfield.

Slides:



Advertisements
Similar presentations
1 Sets CS/APMA 202, Spring 2005 Rosen, section 1.6 Aaron Bloomfield.
Advertisements

Equivalence Relations
Binomial Coefficients
Discrete Mathematics Relations
Relations - review A binary relation on A is a subset of A×A (set of ordered pairs of elements from A) Example: A = {a,b,c,d,e} R = { (a,a),(a,b),(b,b),(b,c),
Basic Properties of Relations
Discrete Mathematics Lecture # 16 Inverse of Relations.
CS2210(22C:19) Discrete Structures Relations Spring 2015 Sukumar Ghosh.
CSE115/ENGR160 Discrete Mathematics 04/24/12 Ming-Hsuan Yang UC Merced 1.
Discussion #26 Chapter 5, Sections /15 Discussion #26 Binary Relations: Operations & Properties.
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.
1 Set Operations CS/APMA 202, Spring 2005 Rosen, section 1.7 Aaron Bloomfield.
1 The Pigeonhole Principle CS/APMA 202 Rosen section 4.2 Aaron Bloomfield.
1 Integers and Division CS/APMA 202 Rosen section 2.4 Aaron Bloomfield.
Reminders: –Test3 is scheduled for Friday, April 25 was sent that included a proposed schedule –HW 8 is due Wednesday, April 9 in class Pascal’s.
1 Representing Relations Epp section ??? CS 202 Aaron Bloomfield.
Relations Chapter 9.
Recursive Definitions and Structural Induction
1 Sequences and Summations CS/APMA 202 Rosen section 3.2 Aaron Bloomfield.
1 Partial Orderings Aaron Bloomfield CS 202 Rosen, section 7.6.
1 Permutations and Combinations CS/APMA 202 Rosen section 4.3 Aaron Bloomfield.
1 Relations and Their Properties Epp, section ??? CS 202 Aaron Bloomfield.
Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a.
Module #18: Relations, part I
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.
1 Predicates and Quantifiers CS/APMA 202, Spring 2005 Rosen, section 1.3 Aaron Bloomfield.
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.
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.
April 14, 2015Applied Discrete Mathematics Week 10: Equivalence Relations 1 Properties of Relations Definition: A relation R on a set A is called transitive.
Rosen, Section 8.5 Equivalence Relations
1 Algorithms CS/APMA 202 Rosen section 2.1 Aaron Bloomfield.
1 Representing Relations Rosen, section 7.3 CS/APMA 202 Aaron Bloomfield.
Representing Relations
CS 103 Discrete Structures Lecture 19 Relations. Chapter 9.
Discrete Mathematics Lecture # 15 Types of Relations (contd.)
1 Partial Orderings Aaron Bloomfield CS 202 Epp, section ???
1 Basics of Counting CS/APMA 202 Rosen section 4.1 Aaron Bloomfield.
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
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.
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), (
Section 9.1. Section Summary Relations and Functions Properties of Relations Reflexive Relations Symmetric and Antisymmetric Relations Transitive Relations.
Relations and Their Properties
Relations Chapter 9.
Aaron Bloomfield CS 202 Rosen, section 7.4
RELATION KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS )
Dr. Ameria Eldosoky Discrete mathematics
Aaron Bloomfield CS 202 Epp, section ???
Relations and Their Properties
Permutations and Combinations
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
CS2210 Discrete Structures Relations
Relations and Their Properties
8.1 Relations and Their Properties
Relations and their Properties
2/18/2019 §7.1 Binary Relations (2nd pass) and §7.2 n-ary Relations Longin Jan Latecki Slides adapted from Kees van Deemter who adopted them from Michael.
2/25/2019 §7.1 Binary Relations (2nd pass) and §7.2 n-ary Relations Longin Jan Latecki Slides adapted from Kees van Deemter who adopted them from Michael.
Properties of Relations
Discrete Math (2) Haiming Chen Associate Professor, PhD
Combining relations via relational composition
Equivalence Relations
Equivalence Relations
7/30/2019 §7.1 Binary Relations (2nd pass) and §7.2 n-ary Relations Longin Jan Latecki Slides adapted from Kees van Deemter who adopted them from Michael.
Lecture # 16 Inverse of Relations
Presentation transcript:

1 Relations and Their Properties Rosen, section 7.1 CS/APMA 202 Aaron Bloomfield

2 What is a relation Let A and B be sets. A binary relation R is a subset of A  B Example Let A be the students in a the CS major Let A be the students in a the CS major A = {Alice, Bob, Claire, Dan} Let B be the courses the department offers Let B be the courses the department offers B = {CS101, CS201, CS202} We specify relation R = A  B as the set that lists all students a  A enrolled in class b  B We specify relation R = A  B as the set that lists all students a  A enrolled in class b  B R = { (Alice, CS101), (Bob, CS201), (Bob, CS202), (Dan, CS201), (Dan, CS202) } R = { (Alice, CS101), (Bob, CS201), (Bob, CS202), (Dan, CS201), (Dan, CS202) }

3 More relation examples Another relation example: Let A be the cities in the US Let A be the cities in the US Let B be the states in the US Let B be the states in the US We define R to mean a is a city in state b We define R to mean a is a city in state b Thus, the following are in our relation: Thus, the following are in our relation: (C’ville, VA) (Philadelphia, PA) (Portland, MA) (Portland, OR) etc… Most relations we will see deal with ordered pairs of integers

4 Representing relations CS101 CS201 CS202 Alice Bob Claire Dan CS101CS201CS202 AliceX BobXX Claire DanXX We can represent relations graphically: We can represent relations in a table: Not valid functions!

5 Relations vs. functions Not all relations are functions But consider the following function: All functions are relations! abcdabcd

6 When to use which? A function is used when you need to obtain a SINGLE result for any element in the domain Example: sin, cos, tan Example: sin, cos, tan A relation is when there are multiple mappings between the domain and the co- domain Example: students enrolled in multiple courses Example: students enrolled in multiple courses

7 Relations on a set A relation on the set A is a relation from A to A In other words, the domain and co-domain are the same set In other words, the domain and co-domain are the same set We will generally be studying relations of this type We will generally be studying relations of this type

8 Relations on a set Let A be the set { 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) } R1234 1XXXX 2XX 3X 4X

9 Consider some relations on the set Z Are the following ordered pairs in the relation? (1,1) (1,2) (2,1) (1,-1) (2,2) R 1 = { (a,b) | a≤b } R 2 = { (a,b) | a>b } R 3 = { (a,b) | a=|b| } R 4 = { (a,b) | a=b } R 5 = { (a,b) | a=b+1 } R 6 = { (a,b) | a+b≤3 } More examples X X X X X X X X X X X X X X X

10 Relation properties Six properties of relations we will study: Reflexive Reflexive Irreflexive Irreflexive Symmetric Symmetric Asymmetric Asymmetric Antisymmetric Antisymmetric Transitive Transitive

11 Reflexivity A relation is reflexive if every element is related to itself Or, (a,a)  R Or, (a,a)  R Examples of reflexive relations: =, ≤, ≥ =, ≤, ≥ Examples of relations that are not reflexive:

12 Irreflexivity A relation is irreflexive if every element is not related to itself Or, (a,a)  R Or, (a,a)  R Irreflexivity is the opposite of reflexivity Irreflexivity is the opposite of reflexivity Examples of irreflexive relations: Examples of relations that are not irreflexive: =, ≤, ≥ =, ≤, ≥

13 Reflexivity vs. Irreflexivity A relation can be neither reflexive nor irreflexive Some elements are related to themselves, others are not Some elements are related to themselves, others are not We will see an example of this later on

14 Google Maps

15 Symmetry A relation is symmetric if, for every (a,b)  R, then (b,a)  R Examples of symmetric relations: =, isTwinOf() =, isTwinOf() Examples of relations that are not symmetric:, ≤, ≥, ≤, ≥

16 Asymmetry A relation is asymmetric if, for every (a,b)  R, then (b,a)  R Asymmetry is the opposite of symmetry Asymmetry is the opposite of symmetry Examples of asymmetric relations: Examples of relations that are not asymmetric: =, isTwinOf(), ≤, ≥ =, isTwinOf(), ≤, ≥

17 Antisymmetry A relation is antisymmetric if, for every (a,b)  R, then (b,a)  R is true only when a=b Antisymmetry is not the opposite of symmetry Antisymmetry is not the opposite of symmetry Examples of antisymmetric relations: =, ≤, ≥ =, ≤, ≥ Examples of relations that are not antisymmetric:, isTwinOf(), isTwinOf()

18 Notes on *symmetric relations A relation can be neither symmetric or asymmetric R = { (a,b) | a=|b| } R = { (a,b) | a=|b| } This is not symmetric This is not symmetric -4 is not related to itself This is not asymmetric This is not asymmetric 4 is related to itself Note that it is antisymmetric Note that it is antisymmetric

19 Transitivity A relation is transitive if, for every (a,b)  R and (b,c)  R, then (a,c)  R If a < b and b < c, then a < c Thus, < is transitive Thus, < is transitive If a = b and b = c, then a = c Thus, = is transitive Thus, = is transitive

20 Transitivity examples Consider isAncestorOf() Let Alice be Bob’s parent, and Bob be Claire’s parent Let Alice be Bob’s parent, and Bob be Claire’s parent Thus, Alice is an ancestor of Bob, and Bob is an ancestor of Claire Thus, Alice is an ancestor of Bob, and Bob is an ancestor of Claire Thus, Alice is an ancestor of Claire Thus, Alice is an ancestor of Claire Thus, isAncestorOf() is a transitive relation Thus, isAncestorOf() is a transitive relation Consider isParentOf() Let Alice be Bob’s parent, and Bob be Claire’s parent Let Alice be Bob’s parent, and Bob be Claire’s parent Thus, Alice is a parent of Bob, and Bob is a parent of Claire Thus, Alice is a parent of Bob, and Bob is a parent of Claire However, Alice is not a parent of Claire However, Alice is not a parent of Claire Thus, isParentOf() is not a transitive relation Thus, isParentOf() is not a transitive relation

21 Relations of relations summary =<>≤≥ ReflexiveXXX IrreflexiveXX SymmetricX AsymmetricXX AntisymmetricXXX TransitiveXXXXX

22 Combining relations There are two ways to combine relations R 1 and R 2 Via Boolean operators Via Boolean operators Via relation “composition” Via relation “composition”

23 Combining relations via Boolean operators Consider two relations R ≥ and R ≤ We can combine them as follows: R ≥ U R ≤ = all numbers ≥ OR ≤ R ≥ U R ≤ = all numbers ≥ OR ≤ That’s all the numbers R ≥ ∩ R ≤ = all numbers ≥ AND ≤ R ≥ ∩ R ≤ = all numbers ≥ AND ≤ That’s all numbers equal to R ≥  R ≤ = all numbers ≥ or ≤, but not both R ≥  R ≤ = all numbers ≥ or ≤, but not both That’s all numbers not equal to R ≥ - R ≤ = all numbers ≥ that are not also ≤ R ≥ - R ≤ = all numbers ≥ that are not also ≤ That’s all numbers strictly greater than R ≤ - R ≥ = all numbers ≤ that are not also ≥ R ≤ - R ≥ = all numbers ≤ that are not also ≥ That’s all numbers strictly less than Note that it’s possible the result is the empty set

24 Combining relations via relational composition Let R be a relation from A to B, and S be a relation from B to C Let a  A, b  B, and c  C Let a  A, b  B, and c  C Let (a,b)  R, and (b,c)  S Let (a,b)  R, and (b,c)  S Then the composite of R and S consists of the ordered pairs (a,c) Then the composite of R and S consists of the ordered pairs (a,c) We denote the relation by S ◦ R Note that S comes first when writing the composition!

25 Combining relations via relational composition Let M be the relation “is mother of” Let F be the relation “is father of” What is M ◦ F? If (a,b)  F, then a is the father of b If (a,b)  F, then a is the father of b If (b,c)  M, then b is the mother of c If (b,c)  M, then b is the mother of c Thus, M ◦ F denotes the relation “maternal grandfather” Thus, M ◦ F denotes the relation “maternal grandfather” What is F ◦ M? If (a,b)  M, then a is the mother of b If (a,b)  M, then a is the mother of b If (b,c)  F, then b is the father of c If (b,c)  F, then b is the father of c Thus, F ◦ M denotes the relation “paternal grandmother” Thus, F ◦ M denotes the relation “paternal grandmother” What is M ◦ M? If (a,b)  M, then a is the mother of b If (a,b)  M, then a is the mother of b If (b,c)  M, then b is the mother of c If (b,c)  M, then b is the mother of c Thus, M ◦ M denotes the relation “maternal grandmother” Thus, M ◦ M denotes the relation “maternal grandmother” Note that M and F are not transitive relations!!!

26 Combining relations via relational composition Given relation R R ◦ R can be denoted by R 2 R ◦ R can be denoted by R 2 R 2 ◦ R = (R ◦ R) ◦ R = R 3 R 2 ◦ R = (R ◦ R) ◦ R = R 3 Example: M 3 is your mother’s mother’s mother Example: M 3 is your mother’s mother’s mother

27 Quick survey I felt I understood the material in this slide set… I felt I understood the material in this slide set… a) Very well b) With some review, I’ll be good c) Not really d) Not at all

28 Quick survey The pace of the lecture for this slide set was… The pace of the lecture for this slide set was… a) Fast b) About right c) A little slow d) Too slow

29 Quick survey How interesting was the material in this slide set? Be honest! How interesting was the material in this slide set? Be honest! a) Wow! That was SOOOOOO cool! b) Somewhat interesting c) Rather borting d) Zzzzzzzzzzz

30 Today’s demotivators