Relations and their Properties

Slides:



Advertisements
Similar presentations
Partial Orderings Section 8.6.
Advertisements

Relations Relations on a Set. Properties of Relations.
Representing Relations Using Matrices
5/16/20151 You Never Escape Your… Relations. 5/16/20152Relations If we want to describe a relationship between elements of two sets A and B, we can use.
Applied Discrete Mathematics Week 11: Graphs
Chapter 7 Relations : the second time around
1 Relations: The Second Time Around Chapter 7 Equivalence Classes.
Relations binary relations xRy on sets x  X y  Y R  X  Y Example: “less than” relation from A={0,1,2} to B={1,2,3} use traditional notation 0 < 1,
1 Partial Orderings Based on Slides by Chuck Allison from Rosen, Chapter 8.6 Modified by.
Partially Ordered Sets (POSets)
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
Chapter Relations and Their Properties 8.2 n-ary Relations and Their Applications 8.3 Representing Relations 8.4 Closures of Relations 8.5 Equivalence.
1 Partial Orderings Aaron Bloomfield CS 202 Rosen, section 7.6.
Copyright © Cengage Learning. All rights reserved.
CS Discrete Mathematical Structures Mehdi Ghayoumi MSB rm 132 Ofc hr: Thur, 9:30-11:30a Fall 2002KSU - Discrete Structures1.
April 10, 2002Applied Discrete Mathematics Week 10: Relations 1 Counting Relations Example: How many different reflexive relations can be defined on a.
Chapter 9. Chapter Summary Relations and Their Properties Representing Relations Equivalence Relations Partial Orderings.
Discrete Structures – CNS2300
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.
2.6 Equivalence Relation §1.Equivalence relation §Definition 2.18: A relation R on a set A is called an equivalence relation if it is reflexive, symmetric,
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.
Discrete Structures1 You Never Escape Your… Relations.
1 Closures of Relations: Transitive Closure and Partitions Sections 8.4 and 8.5.
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen 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, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Relations, Functions.
Fall 2002CMSC Discrete Structures1 You Never Escape Your… Relations.
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.
Lecture on Relations 1Developed by CSE Dept., CIST Bhopal.
1 Partial Orderings Aaron Bloomfield CS 202 Epp, section ???
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.
Discrete Structures – CNS2300
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.
4. Relations and Digraphs Binary Relation Geometric and Algebraic Representation Method Properties Equivalence Relations Operations.
Unit II Discrete Structures Relations and Functions SE (Comp.Engg.)
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.
1 Partial Orderings Based on Slides by Chuck Allison from Rosen, Chapter 8.6 Modified by.
Chapter8 Relations 8.1: Relations and their properties.
1 Partial Orderings Epp, section Introduction An equivalence relation is a relation that is reflexive, symmetric, and transitive A partial ordering.
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.
Representing Relations Using Digraphs
Relations and Their Properties
Chapter 5 Relations and Operations
Relations.
CSE 2813 Discrete Structures
Unit-III Algebraic Structures
Partial Orderings CSE 2813 Discrete Structures.
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.
Partial Orderings.
Relations and Digraphs
Aaron Bloomfield CS 202 Epp, section ???
Applied Discrete Mathematics Week 6: Relations/Digraphs
교환 학생 프로그램 내년 1월 중순부터 6월 초 현재 학부 2,3 학년?
Relations: The Second Time Around
Presentation transcript:

Relations and their Properties Section 9.1 Relations and their Properties

Binary Relation from A to B Let A and B be sets. A binary relation from A to B is a subset of A x B. Binary because there are two sets.

Example Let A = { a, b, c } and B = { x, y } then A x B = {(a,x), (a,y), (b,x), (b,y), (c,x), (c,y)} Any subset of A x B is a relation from A to B. Therefore let, for example: R1 = {(a,x), (c,y)} R2 = {(a,y), (b,x)} ¿How many relations from A to B are there? 2^(|A|*|B|)

Binary Relation from A to B. 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. aRb denotes that (a,b) is an element of R and aRb indicates that (a,b) is not an element of R. When (a,b) belongs to R then a is related to b by R.

Example Let: R1 = { (a,x), (c,y) } R2 = { (a,y), (b,x) } Notation a R1 x b R1 x b R2 x

Depicting Relations Directed Graphs Tables Example: Suppose A = {0, 1, 2} and B = {a, b}. Let R be the relation on A x B defined as: {(0, a), (0, b), (1, a), (2, b)} Diagrams on next slide

Functions as Relations A function is a relation from A to B such that every element in A is the first element of exactly one ordered pair of R.

Relations on a Set A relation on the set A is a relation from A to A. A relation on the set A is a subset of AxA

How Many Relations? If |A| = n then |AxA| = n2 . Since a relation is a subset of AxA then the number of possible relations is

Reflexive Relations Consider the following relations on the set {1,2,3,4} {(2,2),(2,3),(2,4),(3,2),(3,3),(3,4)} {(1,1),(1,2),(2,1),(2,2),(3,3),(4,4)} {(2,4),(4,2)} Which ones are reflexive? {(1,2),(2,3),(3,4)} {(1,1),(2,2),(3,3),(4,4)} {(1,3),(1,4),(2,3),(2,4),(3,1),(3,4)}

Symmetric Relations Consider the following relations on the set {1,2,3,4} {(2,2),(2,3),(2,4),(3,2),(3,3),(3,4)} {(1,1),(1,2),(2,1),(2,2),(3,3),(4,4)} 3 and 5. How could we make the others symmetric? {(2,4),(4,2)} {(1,2),(2,3),(3,4)} {(1,1),(2,2),(3,3),(4,4)} {(1,3),(1,4),(2,3),(2,4),(3,1),(3,4)}

Antisymmetric Relations Consider the following relations on the set {1,2,3,4} {(2,2),(2,3),(2,4),(3,2),(3,3),(3,4)} {(1,1),(1,2),(2,1),(2,2),(3,3),(4,4)} {(2,4),(4,2)} Two elements are mutually related only if they’re equal. 4 and 5. How could we make the others antisymmetric? {(1,2),(2,3),(3,4)} {(1,1),(2,2),(3,3),(4,4)} {(1,3),(1,4),(2,3),(2,4),(3,1),(3,4)}

Examples Anther way to define antisymmetry: The relation ≤ on the real numbers is antisymmetric The relation ⊆ on sets is antisymmetric The equality relation, =, on the real numbers is both symnmetric and antisymmetric (antisymmetric ≠ asymmetric!) Anther way to define antisymmetry: aRb ∧a≠b →¬(bRa)

Transitive Relations Consider the following relations on the set {1,2,3,4} {(2,2),(2,3),(2,4),(3,2),(3,3),(3,4)} {(1,1),(1,2),(2,1),(2,2),(3,3),(4,4)} {(2,4),(4,2)} {(1,2),(2,3),(3,4)} {(1,1),(2,2),(3,3),(4,4)} {(1,3),(1,4),(2,3),(2,4),(3,1),(3,4)}

Composition of Relations

Rn

Transitivity

Section 9.2 n-ary Relations

Definition Let A1, A2, … , An be sets. An n-ary relation on these sets is a subset of A1 x A2 x … x An. The sets A1, A2, … , An are called the domains of the relation, and n is called its degree.

Databases and Relations Students StudentName IDnumber Major GPA Ackermann Adams Chou Goodfriend Rao Stevens 231455 888323 102147 453876 678543 786576 Computer Science Physics Mathematics Psychology 3.88 3.45 3.49 3.90 2.99 Discuss the domains and degree.

Operations Selection Projection Join Chooses tuples (rows) that satisfy a condition Projection Chooses slots (columns) by position number or name Join Combines tuples from two tables with a common key Do Python Demo

Relational Algebra Demo reldb.py 4 Tables: parts suppliers projects spj (a table that connects the other 3 tables)

Representing Relations Section 9.3 Representing Relations

Using Matrices Let A = {1,2,3} and B={1,2}. Let the relation from A to B containing (a,b) if a>b. R would then equal {(2,1), (3,1), (3,2)} 1 2 1 2 3

Reflexive Relations

Symmetric SYMMETRIC NOT SYMMETRIC

Antisymmetric Mirror images are opposites. Diagonal is unimportant.

Boolean Matrices Join of Matrices Union of Relations Meet of Matrices Intersection of Relations Examples 4-6 in 9.3 (pages 593-594) Boolean Product of Matrices Composite Relations

Digraph Example a b c d V = {a,b,c,d} (b,b), (d,b), (b,d)} (a,b), (a,d), (c,a), (c,b), E = {

Spotting Properties via Graphs How can you spot the following properties from a graph? Reflexive Symmetric Antisymmetric Transitive Reflexive: every vertex has a loop. Symmetric: all non-loop mirror images are cycles (2-way) Antisymmetric: All non-loop mirror images are opposites (1-way) Transitive: not so easy! All polygonal paths are one-way complete.

Section 9.4 Closures of Relations

Reflexive Closure The reflexive closure of a relation, R, is the minimal relation containing R that is reflexive If R is already reflexive, it is its own reflexive closure Otherwise, add pairs (a,a) for all elements a, that are not already related to themselves. For example, if R = {(1,1), (1,2), (2,1), (3,2)}, the we add the following pairs: (2,2), (3,3).

Symmetric Closure The symmetric closure of a relation, R, is the minimal relation containing R that is symmetric If R is already symmetric, it is its own symmetric closure Otherwise, add pairs (b,a) for all pairs (a,b) in R that are not already there. For example, if R = {(1,1), (1,2), (2,1), (3,2)}, the we add the following pair: (2,3).

Can You Get There From Here? Often we want to know if there is a “path” from a to b (meaning a chain of pairs (a,x1), (x1,x2), … (xn,b)). We say that b is “reachable in R” from a. Forming this relation is harder than it appears

Transitive Closure The transitive closure of a relation, R, is the minimal relation containing R that is transitive. Theorem 1: There is a path from a to b in R of length n, if and only if (a,b) ⋲ Rn. (The composition of R with itself n-1 times). R defines paths of length 1 R2 adds paths of length 2, and so on…

Computing the Transitive Closure Rn computes paths of length n. This means that n+1 objects have been visited, forcing a repeat (cycle). So everything has been traversed! So all possible connected endpoints are computed by

Matrix Representation M* = M v M2 v M3 v … v Mn. See Example 7 in section 9.4, page 602-603. A more efficient algorithm (Warshall’s algorithm) is on page 606 (Algorithm 2 in section 9.4).

Equivalence Relations Section 9.5 Equivalence Relations

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

Examples: Let R be the relation on the set of strings such that a R b if and only if l (a) = l (b) where l (x) is the length of x. Let R be the relation on the set of real numbers such that a R b if and only if a-b is an integer.

Is this an equivalence relation? Which elements are “equivalent” (related to each other)?

Equivalence Classes 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 will delete the subscript R and write [a] for this equivalence class.

[0] = {…-14, -7, 0, 7, 14, 21,…} [1] = {…-13, -6, 1, 8, 15, 22,…} [2] = {…-12, -5, 2, 9, 16, 23,…} [3] = {…-11, -4, 3, 10, 17, 24,…} [4] = {…-10, -3, 4, 11, 18, 25,…} [5] = {…-9, -2, 5, 12, 19, 26,…} [6] = {…-8, -1, 6, 13, 20, 27,…}

Partition A partition of a set S is a collection of disjoint, nonempty subsets of S that have S as their union.

Equivalence Relations and Partitions Let R be an equivalence relation on a set S. Then the equivalence classes of R form a partition of S. Conversely, given a partition of the set S, there is an equivalence relation R that has the sets as its equivalence classes.

Section 9.6 Partial Orderings

Partially Ordered Set (POSET) A relation R on a set S is called a partial ordering or partial order if it is reflexive, antisymmetric, and transitive. A set S together with a partial ordering R is called a partially ordered set, or poset, and is denoted by (S, R)

Example (1) Let S = {1, 2, 3} and let R = {(1,1), (2,2), (3,3), (1, 2), (3,1), (3,2)} 1 2 3 The ordering here is 3,1,2.

In a poset, the notation a b denotes that This notation is used because the less than or equal to” relation is a paradigm for a partial ordering. (Note that the symbol is used to denote the relation in any poset, not just the “less than or equals” relation.) The notation a b denotes that a b, but

Example Let S = {1, 2, 3} and let R = {(1,1), (2,2), (3,3), (1, 2), (3,1), (3,2)} 2 2 3 2 1 2 3

Example (2) Consider the set of real numbers and the “less than or equal to” relation. (R, )

Example (3) Consider the power set of {a, b, c} and the subset relation. (P({a,b,c}), )

Comparable/Incomparable The elements a and b of a poset (S, ) are called comparable if either a b or b a. When a and b are elements of S such that neither a b nor b a, a and b are called incomparable. So a and b have to appear in at least one pair.

Example Consider the power set of {a, b, c} and the subset relation. (P({a,b,c}), ) So, {a,c} and {a,b} are incomparable

Total Orders If is a poset and every two elements of S are comparable, S is called totally ordered or linearly ordered set, and is called a total order or a linear order on S. A totally ordered set is also called a chain. (S, )

Example Consider again, the set of real numbers and the “less than or equal to” relation. (R, )

Hasse Diagrams Given any partial order relation defined on a finite set, it is possible to draw the directed graph that depicts the ordering. This makes it possible to associate a somewhat simpler graph, called a Hasse diagram, with a partial order relation defined on a finite set.

Hasse Diagrams (continued) Start with a directed graph of the relation in which all arrows point upward. Then eliminate: the loops at all the vertices, all arrows whose existence is implied by the transitive property, the direction indicators on the arrows.

Prerequisites Task Prerequisite Tasks Time Needed to Perform Task 1 2 3 4 5 6 7 8 9 2, 3 4, 5 6, 7, 8 7 hours 6 hours 3 hours 1 hour 2 hours 5 hours

Example – Job Scheduling (PERT chart) Task 4 6 hours Task 6 1 hour Task 2 6 hours Task 1 7 hours Task 5 3 hours Task 3 3 hours Task 9 5 hour Task 8 2 hour A rotated Hasse diagram. Task 7 1 hour

Example (Core CNS Classes) CNS301R CNS3520 CNS3060 CNS3690 CNS2420 CNS2600 CNS2300 CNS1410 CNS1510 CNS2810 CNS1400

Maximal and Minimal Elements a is a maximal in the poset (S, ) if there is no such that a b. Similarly, an element of a poset is called minimal if it is not greater than any element of the poset. That is, a is minimal if there is no element such that b a. It is possible to have multiple minimals and maximals.

2 and 5 are minimal. 12, 20, and 25 are maximal.

Greatest Element Least Element a is the greatest element in the poset (S, ) if b a for all . Similarly, an element of a poset is called the least element if it is less than all other elements in the poset That is, a is least element if there is no such that b a.

min, none, max, both.

Job Scheduling (Again) Task 4 6 hours Task 6 1 hour Task 2 6 hours Task 1 7 hours Task 5 3 hours Task 3 3 hours Task 9 5 hour Task 8 2 hour Pick a minimal element. Then remove it. Repeat. Copy this slide and simulate it! Task 7 1 hour How should we schedule the tasks?

Topological Sorting A total ordering is said to be compatible with the partial ordering R if a b whenever a R b. Constructing a total ordering from a partial ordering is called topological sorting.