Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Relations, Functions.

Slides:



Advertisements
Similar presentations
Partial Orderings Section 8.6.
Advertisements

Equivalence Relations
Relations Relations on a Set. Properties of Relations.
Chapter 3 Relations. Section 3.1 Relations and Digraphs.
Basic Properties of Relations
Applied Discrete Mathematics Week 11: Graphs
Algebraic Structures DEFINITIONS: PROPERTIES OF BINARY OPERATIONS Let S be a set and let  denote a binary operation on S. (Here  does not necessarily.
Copyright © Cengage Learning. All rights reserved. CHAPTER 1 SPEAKING MATHEMATICALLY SPEAKING MATHEMATICALLY.
CS2210(22C:19) Discrete Structures Relations Spring 2015 Sukumar Ghosh.
Chapter 7 Relations : the second time around
Discrete Structures Chapter 5 Relations Nurul Amelina Nasharuddin Multimedia Department.
CSE115/ENGR160 Discrete Mathematics 05/03/11 Ming-Hsuan Yang UC Merced 1.
Discrete Mathematics Lecture#11.
1 Partial Orderings Based on Slides by Chuck Allison from Rosen, Chapter 8.6 Modified by.
Relations Chapter 9.
Chapter 9 1. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing.
Week 8 - Wednesday.  What did we talk about last time?  Cardinality  Countability  Relations.
Set theory Sets: Powerful tool in computer science to solve real world problems. A set is a collection of distinct objects called elements. Traditionally,
Ordered Sets. Relations. Equivalence Relations 1.
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.
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
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.
8.3 Representing Relations Directed Graphs –Vertex –Arc (directed edge) –Initial vertex –Terminal vertex.
Copyright © Cengage Learning. All rights reserved. CHAPTER 8 RELATIONS.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Relations.
Discrete Mathematics Relation.
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Relations and their Properties
Sets, Relations, and Lattices
Mathematical Preliminaries
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)
1 RELATIONS Learning outcomes Students are able to: a. determine the properties of relations – reflexive, symmetric, transitive, and antisymmetric b. determine.
Relations. Important Definitions We covered all of these definitions on the board on Monday, November 7 th. Definition 1 Definition 2 Definition 3 Definition.
Equivalence Relations. Partial Ordering Relations 1.
Problem Statement How do we represent relationship between two related elements ?
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
Unit II Discrete Structures Relations and Functions SE (Comp.Engg.)
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,
1 RELATIONS Learning outcomes Students are able to: a. determine the properties of relations – reflexive, symmetric, transitive, and antisymmetric b. determine.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 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.
Copyright © Cengage Learning. All rights reserved. CHAPTER 8 RELATIONS.
RelationsCSCE 235, Spring Introduction A relation between elements of two sets is a subset of their Cartesian products (set of all ordered pairs.
Set Theory Concepts Set – A collection of “elements” (objects, members) denoted by upper case letters A, B, etc. elements are lower case brackets are used.
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.
ORDERED SETS. RELATIONS COSC-1321 Discrete Structures 1.
Chap. 7 Relations: The Second Time Around
1 Partial Orderings Based on Slides by Chuck Allison from Rosen, Chapter 8.6 Modified by.
Advanced Digital Designs Jung H. Kim. Chapter 1. Sets, Relations, and Lattices.
Section 9.3. Section Summary Representing Relations using Matrices Representing Relations using Digraphs.
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.
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 is a relation on.
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
Relations and Their Properties
Chapter 5 Relations and Operations
CSE15 Discrete Mathematics 05/03/17
Introduction to Relations
Relations Binary relations represent relationships between the elements of two sets. A binary relation R from set A to set B is defined by: R  A 
Equivalence Relations
Relations Chapter 9.
Set, Combinatorics, Probability & Number Theory
CS201: Data Structures and Discrete Mathematics I
교환 학생 프로그램 내년 1월 중순부터 6월 초 현재 학부 2,3 학년?
Chapter 8 (Part 2): Relations
Presentation transcript:

Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Relations, Functions and Matrices

Binary Relations A relation establishes some kind of connection between an ordered pair of elements from some set or sets. Relations are defined in several ways One way is just to list a set of ordered pairs Another way is to define the relation in terms of x and y We write x  y to mean that the ordered pair (x, y) satisfies the relationship  Example 1: Let S = {1, 2, 3}; S  S = { (1,1), (1,2), (1,3), (2,1), (2,2), (2,3), (3,1), (3,2), (3,3) } List of ordered pairs: (1,1), (2,2), (3,3) Definition: x = y Example 2: Same set of ordered pairs List of pairs: (1, 2), (1, 3), (2, 3) Definition: x < y Section 4.1Relations1

Binary Operations v Binary Relations Both involve ordered pairs from some set. Operations represent an action using the elements of the ordered pair that produces a result; e.g., x ◦ y, where the operation is addition. Relations indicate that some relation exists between the elements; x  y is true if (x, y) is in the relation and false otherwise. In a way, relations are a special kind of operation where the result is Boolean. Compare to operators in a programming language. Arithmetic operators ( addition, modulus, etc.) produce an answer Relational operators ( =, >=, etc.) produce a true/false result. Section 4.1Relations2

Section 4.1Relations3 Binary Relations DEFINITION: BINARY RELATION on a set S: Given a set S, a binary relation on S is a subset of S  S (a set of ordered pairs of elements of S). A binary relation is always a subset of ordered pairs from some universal set with the property that: x  y  (x, y)   Example: What is the set where  on S is defined by x  y  x + y is odd? S = {1, 2}; S  S = { (1, 1), (1, 2), (2, 1), (2,2)} The set for  is {(1,2), (2,1)}. Example: S = {1, 2, 4} and the Cartesian product of S and S is: S  S = {(1,1), (1,2), (1,4), (2,1), (2,2), (2,4), (4,1), (4,2), (4,4)} Then the subset of S  S satisfying the relation x  y  x = 1/2y, is: {(1, 2), (2, 4)}

Section 4.1Relations4 Relations on Multiple Sets DEFINITION: RELATIONS ON MULTIPLE SETS Given two sets S and T, a binary relation from S to T is a subset of S  T. Given n sets S 1, S 2, …., S n for n > 2, an n-ary relation on S 1  S 2  …  S n is a subset of S 1  S 2  …  S n. S = {1, 2, 3} and T = {2, 4, 7}. Then x  y  x = y/2 is the set {(1,2), (2,4)}. S = {2, 4, 6, 8} and T = {2, 3, 4, 6, 7}. What is the set that satisfies the relation x  y  x = (y + 2)/2. The set is {(2,2), (4,6)}.

Section 4.1Relations5 Types of Relationships One-to-one: If each first component and each second component only appear once in the relation. (In examples below, S and T may be the same set) One-to-many: If a first component is paired with more than one second component. Many-to-one: If a second component is paired with more than one first component. Many-to-many: If at least one first component is paired with more than one second component and at least one second component is paired with more than one first component.

Section 4.1Relations6 Relationships: Examples If S = {2, 5, 7, 9}, then identify the types of the following relationships: {(5,2), (7,5), (9,2)}many-to-one {(2,5), (5,7), (7,2)}one-to-one {(7,9), (2,5), (9,9), (2,7)}many-to-many

Section 4.1Relations7 Properties of Relationships DEFINITION: REFLEXIVE, SYMMETRIC, AND TRANSITIVE RELATIONS Let  be a binary relation on a set S. Then:  is reflexive means (  x) (x  S  (x,x)  )  is symmetric means: (  x)(  y) (x  S  y  S  (x,y)    (y,x)   )  is transitive means: (  x)(  y)(  z) (x  S  y  S  z  S  (x,y)  (y,z)   (x,z)  )  is antisymmetric means: (  x)(  y) (x  S  y  S  (x,y)    (y,x)   x = y) Example: Consider the relation  on the set of natural numbers N. Is it reflexive? Yes, since for every nonnegative integer x, x  x. Is it symmetric? No, since x  y doesn’t imply y  x. If this was the case, then x = y. This property is called antisymmetric. Is it transitive? Yes, since if x  y and y  z, then x  z.

Symmetric and Antisymmetric A relation is symmetric if, for every (x, y) in the relation (y, x) must also be in the relation. If  is the relation “greater than” and S is the set of integers, is  symmetric? What about the relation “is equal to”? A relation is antisymmetric if, whenever (x, y) is in the relation and (y, x) is in the relation, then x = y. If  is the relation “greater than” and S is the set of integers, is  antisymmetric? Is it symmetric? What about the relation “is equal to”? What can you conclude about the equality relation? “Not symmetric”: informally, a relation is “not symmetric” if some (x, y) belongs to the relation but (y, x) doesn’t. Section 4.1Relations8

Section 4.1Relations9 Closures of Relations DEFINITION: CLOSURE OF A RELATION A binary relation  * on set S is the closure of a relation  on S with respect to property P if: 1.  * has the property P 2.    * 3.  * is a subset of any other relation on S that includes  and has the property P Example: Let S = {1, 2, 3} and  = {(1,1), (1,2), (1,3), (3,1), (2,3)}. This is not reflexive, symmetric, or transitive. The closure of  with respect to reflexivity is {(1,1),(1,2),(1,3), (3,1), (2,3), (2,2), (3,3)} and it contains . The closure of  with respect to symmetry is {(1,1), (1,2), (1,3), (3,1), (2,3), (2,1), (3,2)}. The closure of  with respect to transitivity is {(1,1), (1,2), (1,3), (3,1), (2,3), (3,2), (3,3), (2,1), (2,2)}.

Section 4.1Relations10 Exercise: Closures of Relations Find the reflexive, symmetric and transitive closure of the relation {(a,a), (b,b), (c,c), (a,c), (a,d), (b,d), (c,a), (d,a)} on the set S = {a, b, c, d} Practice 7 – see solution in back of book

Section 4.1Relations11 Partial Ordering and Equivalence Relations DEFINITION: PARTIAL ORDERING A binary relation on a set S that is reflexive, antisymmetric, and transitive is called a partial ordering on S. If  is a partial ordering on S, then the ordered pair (S,  ) is called a partially ordered set (also known as a poset). Denote an arbitrary, partially ordered set by (S,  ); in any particular case,  has some definite meaning such as “less than or equal to,” “is a subset of,” “divides,” and so on. It’s a generic symbol representing some relation. Examples: On N, x  y  x  y. On {0,1}, x  y  x = y 2  

Terminology – Partial Ordering Let (S,  ) be a partially ordered set. For x, y in S, if x  y (x is related to y) but x  y we say that x is a predecessor of y, (x < y ) or y is a successor of x. If x < y and there is no z such that x < z < y, then x is an immediate predecessor of y. The partial ordering defined by this kind of relation connects some, but not necessarily all, of the elements Two elements may be unrelated to each other, other elements may not be related to any other element. If x  y for all x, then x is a least element of the partially ordered set. If there’s no element x in S with x < y then y is said to be minimal. Easier to understand by looking at a picture. Section 4.1Relations12

Section 4.1Relations13 Hasse Diagram Hasse Diagram: A diagram used to visually depict a partially ordered set if S is finite. Each of the elements of S is represented by a dot, called a node, or vertex, of the diagram. If x is an immediate predecessor of y, then the node for y is placed above the node for x and the two nodes are connected by a straight-line segment. Example: Given the partial ordering on a set S = {a, b, c, d, e, f } as {(a,a), (b,b), (c,c), (d,d), (e,e), (f, f), (a, b), (a,c), (a,d), (a,e), (d,e)}, the Hasse diagram is:

Section 4.1Relations14 Equivalence Relation DEFINITION: EQUIVALENCE RELATION A binary relation on a set S that is reflexive, symmetric, and transitive is called an equivalence relation on S. Examples: On N, x  y  x + y is even. On {1, 2, 3}, 

Section 4.1Relations15 Partitioning a Set DEFINITION: PARTITION OF A SET It is a collection of nonempty disjoint subsets of S whose union equals S. For  an equivalence relation on set S and x  S, then [x] is the set of all members of S to which x is related, called the equivalence class of x. Thus: [x] = {y | y  S  x  y} Hence, for  = {(a,a), (b,b), (c,c), (a,c), (c,a)} [a] = {a, c} = [c]

Section 4.1Relations16 Congruence Modulo n DEFINITION: CONGRUENCE MODULO n For integers x and y and positive integer n, x = y(mod n) if x  y is an integral multiple of n. This binary relation is always an equivalence relation Congruence modulo 4 is an equivalence relation on Z. Construct the equivalence classes [0], [1], [2], and [3]. Note that [0], for example, will contain all integers differing from 0 by a multiple of 4, such as 4, 8, 12, and so on. The distinct equivalence classes are: [0] = {..., -8, -4, 0, 4, 8,...} [1] = {..., -7, -3, 1, 5, 9,...} [2] = {..., -6, -2, 2, 6, 10,...} [3] = {..., -5, -1, 3, 7, 11,...}

Section 4.1Relations17 Partial Ordering and Equivalence Relations

Section 4.1Relations18 Exercises 1. Which of the following ordered pairs belongs to the binary relation  on N? x  y  x + y < 7; (1,3), (2,5), (3,3), (4,4) x  y  2x + 3y = 10; (5,0), (2,2), (3,1), (1,3) 2. Show the region on the Cartesian plane such that for a binary relation  on R: x  y  x 2 + y 2  25 x  y  x  y 3. Identify each relation on N as one-to-one, one-to-many, many- to-one or many-to-many:   

Section 4.1Relations19 Exercises 4. S = {0, 1, 2, 4, 6}. Which of the following relations are reflexive, symmetric, antisymmetric, and transitive. Find the closures for each category for all of them:       5. For the relation {(1,1), (2,2), (1,2), (2,1), (1,3), (3,1), (3,2), (2,3), (3,3), (4,4), (5,5), (4,5), (5,4)} What is [3] and [4]?