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.

Slides:



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

8.3 Representing Relations Connection Matrices Let R be a relation from A = {a 1, a 2,..., a m } to B = {b 1, b 2,..., b n }. Definition: A n m  n connection.
Representing Relations Using Matrices
Discrete Mathematics Lecture # 16 Inverse of Relations.
Ch. 8: Relations 8.1 Relations and their Properties.
Discrete Structures Chapter 5 Relations Nurul Amelina Nasharuddin Multimedia Department.
1 Representing Relations Part 2: directed graphs.
1 Relations Rosen 5 th ed., ch Relations Relationships between elements of sets occur very often.Relationships between elements of sets occur very.
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank and Modified By Mingwu Chen Relations.
Discussion #26 Chapter 5, Sections /15 Discussion #26 Binary Relations: Operations & Properties.
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.
MATRICES. Matrices A matrix is a rectangular array of objects (usually numbers) arranged in m horizontal rows and n vertical columns. A matrix with m.
1 Representing Relations Epp section ??? CS 202 Aaron Bloomfield.
Relations Chapter 9.
Chapter 9 1. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing.
Applied Discrete Mathematics Week 10: Equivalence Relations
Module #21 - Relations Representing Relations Rosen 6 th ed., Ch. 8.
Module #18: Relations, part I
Relations Rosen 5 th ed., ch. 7. Binary Relations Let A, B be any sets. A binary relation R from A to B, written (with signature) R:A×B, or R:A,B, is.
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.
Discrete Math for CS Binary Relation: A binary relation between sets A and B is a subset of the Cartesian Product A x B. If A = B we say that the relation.
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.
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.
Sets and Subsets Set A set is a collection of well-defined objects (elements/members). The elements of the set are said to belong to (or be contained in)
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) 7.3 관계의 표현 (Representing Relations) 2006 년 봄학기 문양세 강원대학교 컴퓨터과학과.
Discrete Mathematics Lecture # 15 Types of Relations (contd.)
Relation. 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.
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
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.
Relations Section 9.1, 9.3—9.5 of Rosen Spring 2012
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.
Relations. L222 Agenda –Relations 7.3 Representing Relations As subsets of Cartesian products Column/line diagrams Boolean matrix Digraph Operations on.
Matrices and Determinants
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 7.3: Representing Relations In this section, we will cover two ways to represent a relation over a finite set other than simply listing the relation.
Section 9.3. Section Summary Representing Relations using Matrices Representing Relations using Digraphs.
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.
Chapter8 Relations 8.1: Relations and their properties.
15.1 CompSci 102© Michael Frank Today’s topics RelationsRelations –Kinds of relations –n-ary relations –Representations of relations Reading: Sections.
Discrete Mathematical
Relations and Their Properties
Relations.
Relations Chapter 9.
Representing Relations
Dr. Ameria Eldosoky Discrete mathematics
CSE115/ENGR160 Discrete Mathematics 04/28/11
Relations Rosen 5th ed., ch. 7.
Discrete Mathematics and its Applications
§7.3 Representing Relations Longin Jan Latecki
Rosen 5th ed., ch. 7 ~32 slides (in progress), ~2 lectures
Relations and Their Properties
8.1 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.
Combining relations via relational composition
§7.3 Representing Relations Longin Jan Latecki
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
Relations 12/7/2019.
4.4 Properties of Relations
Presentation transcript:

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 subset of A×B. – E.g., let < : N↔N :≡ {(n,m) | n < m} The notation a R b or aRb means (a,b)  R. – E.g., a < b means (a,b)  < If aRb we may say “a is related to b (by relation R)”, or “a relates to b (under relation R)”. A binary relation R corresponds to a predicate function P R :A×B→{T,F} defined over the 2 sets A,B; e.g., “eats” :≡ {(a,b)| organism a eats food b}

Complementary Relations Let R:A↔B be any binary relation. Then, R:A↔B, the complement of R, is the binary relation defined by R :≡ {(a,b) | (a,b)  R} = (A×B) − R Note this is just R if the universe of discourse is U = A×B; thus the name complement. Note the complement of R is R.  <} = {(a,b) | ¬a<b} = ≥ Example: < = {(a,b) | (a,b)  <} = {(a,b) | ¬a<b} = ≥

Inverse Relations Any binary relation R:A↔B has an inverse relation R −1 :B↔A, defined by R −1 :≡ {(b,a) | (a,b)  R}. E.g., a} = >. E.g., if R:People→Foods is defined by aRb  a eats b, then: b R −1 a  b is eaten by a. (Passive voice.)

Relations on a Set 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 of A х A. Example 4. Let A be the set {1, 2, 3, 4}. Which ordered pairs are in the relation R = {(a, b) | a divides b}? Solution: R = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 4), (3, 3), (4, 4)}

Reflexivity A relation R on A is reflexive if  a  A, aRa. – E.g., the relation ≥ :≡ {(a,b) | a≥b} is reflexive. A relation is irreflexive iff its complementary relation is reflexive. (for every a  A, (a, a)  R) – Note “irreflexive” ≠ “not reflexive”! – Example: < is irreflexive. – Note: “likes” between people is not reflexive, but not irreflexive either. (Not everyone likes themselves, but not everyone dislikes themselves either.)

Symmetry & Antisymmetry A binary relation R on A is symmetric iff R = R −1, that is, if (a,b)  R ↔ (b,a)  R. i.e,  a  b((a, b)  R → (b, a)  R)) – E.g., = (equality) is symmetric. < is not. – “is married to” is symmetric, “likes” is not. A binary relation R is antisymmetric if  a  b(((a, b)  R  (b, a)  R) → (a = b)) – < is antisymmetric, “likes” is not.

Asymmetry A relation R is called asymmetric if (a,b)  R implies that (b,a)  R. – ‘=’ is antisymmetric, but not asymmetric. – < is antisymmetric and asymmetric. – “likes” is not antisymmetric and asymmetric.

Transitivity A relation R is transitive iff (for all a,b,c) (a,b)  R  (b,c)  R → (a,c)  R. A relation is intransitive if it is not transitive. Examples: “is an ancestor of” is transitive. “likes” is intransitive. “is within 1 mile of” is… ?

Examples of Properties of Relations Example 7. Relations on {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)}.

Examples Cont. Solution – Reflective : X, X, O, X, O, X – Irreflective : X, X, X, O, X, O – Symmetric : X, O, O, X, X, X – Antisymmetric : X, X, X, O, O, O – Asymmetric : X, X, X, O, X, O – Transitive : X, X, X, O, O, O

Examples Cont. Example 5. Relations on the set of integers – 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},

Examples Cont. Solution – Reflective : O, X, O, O, X, X – Irreflective : X, O, X, X, O, X – Symmetric : X, X, O, O, X, O – Antisymmetric : O, O, X, O, O, X – Asymmetric : X, O, X, X, O, X – Transitive : O, O, O, O, X, X

Composition of Relations DEFINITION: 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.

Composition of Relations Cont. R : relation between A and B S : relation between B and C S°R : composition of relations R and S – A relation between A and C – {(x,z)| x  A, z  C, and there exists y  B such that xRy and ySz } z w x y u R S A B C x A z w C S°R

Example RS

Example Cont. What is the composite of the relations R and S, where R is the relation from {1, 2, 3} to {1, 2, 3, 4} with R = {(1, 1), (1, 4), (2, 3), (3, 1), (3, 4)} and S is the relation from {1, 2, 3, 4} to {0, 1, 2} with S = {(1, 0), (2, 0), (3, 1), (3, 2), (4, 1)}. Solution: S ◦ R = {(1, 0), (1, 1), (2, 1), (2, 2), (3, 0), (3, 1)}

Power of Relations DEFINITION: Let R be a relation on the set A. The powers R n, n = 1, 2, 3, …, are defined recursively by R 1 = R and R n+1 = R n ◦ R. EXAMPLE: Let R = {(1, 1), (2, 1), (3, 2), (4, 3)}. Find the powers R n, n = 2, 3, 4, …. Solution: 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 2 ◦ R = {(1, 1), (2, 1), (3, 1), (4, 1)} => R n = R 3

Power of Relations Cont. THEOREM: The relation R on a set A is transitive if and only if R n  R for n = 1, 2, 3, …. EXAMPLE: Let R = {(1, 1), (2, 1), (3, 2), (4, 3)}. Is R transitive? => No (see the previous page). EXAMPLE: Let R = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)}. Is R transitive? Solution: R 2 = ?, R 3 = ?, R 4 = ? => maybe a tedious task^^

Representing Relations Some special ways to represent binary relations: – With a zero-one matrix. – With a directed graph.

Using Zero-One Matrices To represent a relation R by a matrix M R = [m ij ], let m ij = 1 if (a i,b j )  R, else 0. E.g., Joe likes Susan and Mary, Fred likes Mary, and Mark likes Sally. The 0-1 matrix representation of that “Likes” relation:

Zero-One Reflexive, Symmetric Terms: Reflexive, non-Reflexive, irreflexive, symmetric, asymmetric, and antisymmetric. – These relation characteristics are very easy to recognize by inspection of the zero-one matrix. Reflexive: all 1’s on diagonal Irreflexive: all 0’s on diagonal Symmetric: all identical across diagonal Antisymmetric: all 1’s are across from 0’s any- thing anything

Finding Composite Matrix Let the zero-one matrices for S ◦ R, R, S be M S ◦ R, M R, M S. Then we can find the matrix representing the relation S ◦ R by: M S ◦ R = M R ⊙ M S EXAMPLE: M R M S M S ◦ R ⊙ =

Examples of matrix representation List the ordered pairs in the relation on {1, 2, 3} corresponding to these matrices (where the rows and columns correspond to the integers listed in increasing order).

Examples Cont. Determine properties of these relations on {1, 2, 3, 4}. R 1 R 2 R 3

Examples Cont. Solution – Reflective : X, O, X – Irreflective : O, X, O – Symmetric : O, X, O – Antisymmetric : X, X, X – Asymmetric : X, X, X

Examples Cont. – Transitive : – R 1 2 = ⊙ = – Not Transitive – Notice: (1, 4) and (4, 3) are in R 1 but not (1, 3)

Examples Cont. – R 2 2 = ⊙ = – R 2 3 = ⊙ =

Examples Cont. – R 2 4 = ⊙ = – Not transitive – Notice: (1, 3) and (3, 4) are in R 1 but not (1, 4)

Examples Cont. EXAMPLE: Let R = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)}. Is R transitive? Solution: transitive (see below) – R 2 ⊙ = – R 3 ⊙ = – R 3 3 = ⊙ =

Using Directed Graphs A directed graph or digraph G=(V G,E G ) is a set V G of vertices (nodes) with a set E G  V G ×V G of edges (arcs,links). Visually represented using dots for nodes, and arrows for edges. Notice that a relation R:A↔B can be represented as a graph G R =(V G =A  B, E G =R). MRMR GRGR Joe Fred Mark Susan Mary Sally Node set V G (black dots) Edge set E G (blue arrows)

Digraph Reflexive, Symmetric It is extremely easy to recognize the reflexive/irreflexive/ symmetric/antisymmetric properties by graph inspection.       Reflexive: Every node has a self-loop Irreflexive: No node links to itself Symmetric: Every link is bidirectional   Antisymmetric: No link is bidirectional    Asymmetric, non-antisymmetricNon-reflexive, non-irreflexive

Example Determine which are reflexive, irreflexive, symmetric, antisymmetric, and transitive. a b c a b c a b c transitiveReflexive Symmetric Not transitive Reflexive antisymmetric