8.4 Closures of Relations Definition: The closure of a relation R with respect to property P is the relation obtained by adding the minimum number of.

Slides:



Advertisements
Similar presentations
Epp, section 10.? CS 202 Aaron Bloomfield
Advertisements

Equivalence Relations
Relations Relations on a Set. Properties of Relations.
CSE115/ENGR160 Discrete Mathematics 04/26/12 Ming-Hsuan Yang UC Merced 1.
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.
Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.
De Bruijn sequences Rotating drum problem:
Graph-02.
Recursive Definitions and Structural Induction
Section 7.4: Closures of Relations Let R be a relation on a set A. We have talked about 6 properties that a relation on a set may or may not possess: reflexive,
Representing Relations Using Matrices
Applied Discrete Mathematics Week 11: Graphs
8.4 Closures of Relations. Intro Consider the following example (telephone line, bus route,…) abc d Is R, defined above on the set A={a, b, c, d}, transitive?
Applied Discrete Mathematics Week 12: Trees
Recursive Definitions Rosen, 3.4 Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
Theoretical Computer Science COMP 335 Fall 2004
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.
Properties of Relations In many applications to computer science and applied mathematics, we deal with relations on a set A rather than relations from.
Mathematical Preliminaries Strings and Languages Preliminaries 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.
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.
Based on slides by Y. Peng University of Maryland
CSC-2259 Discrete Structures
8.3 Representing Relations Directed Graphs –Vertex –Arc (directed edge) –Initial vertex –Terminal vertex.
5.2 Trees  A tree is a connected graph without any cycles.
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 © Cengage Learning. All rights reserved. CHAPTER 8 RELATIONS.
Induction Proof. Well-ordering A set S is well ordered if every subset has a least element. [0, 1] is not well ordered since (0,1] has no least element.
1 Chapter Equivalence, Order, and Inductive Proof.
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.
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,
Section 7.5 Equivalence Relations Longin Jan Latecki Temple University, Philadelphia
Chapter Relations and Their Properties
 Quotient graph  Definition 13: Suppose G(V,E) is a graph and R is a equivalence relation on the set V. We construct the quotient graph G R in the follow.
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.
8.5 Equivalence Relations
Great Theoretical Ideas in Computer Science for Some.
COMPSCI 102 Introduction to Discrete Mathematics.
1 Closures of Relations Based on Aaron Bloomfield Modified by Longin Jan Latecki Rosen, Section 8.4.
Section 9.3. Section Summary Representing Relations using Matrices Representing Relations using Digraphs.
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Trees.
Chapter8 Relations 8.1: Relations and their properties.
Representing Relations Using Digraphs
Relations and Their Properties
Outline 1 Properties of Planar Graphs 5/4/2018.
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 
Relations Chapter 9.
Aaron Bloomfield CS 202 Rosen, section 7.4
CSE115/ENGR160 Discrete Mathematics 04/28/11
CSNB 143 Discrete Mathematical Structures
Mathematical Structures for Computer Science Chapter 6
Discrete Math (2) Haiming Chen Associate Professor, PhD
Applied Discrete Mathematics Week 10: Equivalence Relations
Based on slides by Y. Peng University of Maryland
Relations.
Closures of Relations: Transitive Closure and Partitions
Discrete Mathematics for Computer Science
Closures of Relations Epp, section 10.1,10.2 CS 202.
Chapter 8 (Part 2): Relations
Representing Relations Using Matrices
Presentation transcript:

8.4 Closures of Relations Definition: The closure of a relation R with respect to property P is the relation obtained by adding the minimum number of ordered pairs to R to obtain property P. In terms of the digraph representation of R --To find the reflexive closure - add loops. --To find the symmetric closure - add arcs in the opposite direction. --To find the transitive closure - if there is a path from a to b, and a path from b to c, add an arc from a to c. Note: Reflexive and symmetric closures are easy. Transitive closures can be very complicated.

Closures of Relations Definition: Let A be a set and let △ = {<x, x> | x in A}. △ is called the diagonal relation on A (sometimes called the equality relation E). Note that D is the smallest (has the fewest number of ordered pairs) relation which is reflexive on A. Theorem: Let R be a relation on A. The reflexive closure of R, denoted r(R) , is R ÈD. • Add loops to all vertices on the digraph representation of R. • Put 1’s on the diagonal of the connection matrix of R.

Closures of Relations Example 1: What is the reflexive closure of the relation R={(a, b) | a< b} on the set of integers? Example 2: What is the symmetric closure of the relation R={(a, b) | a> b} on the set of positive integers?

Symmetric Closure Definition: Let R be a relation on A. Then R-1 or the inverse of R is the relation R-1 = {< y, x >|< x, y > ÎR} Note: to get R-1 • reverse all the arcs in the digraph representation of R • take the transpose MT of the connection matrix M of R. Note: This relation is sometimes denoted as RT or Rc and called the converse of R The composition of the relation with its inverse does not necessarily produce the diagonal relation (recall that the composition of a bijective function with its inverse is the identity).

Symmetric Closure Theorem: Let R be a relation on A. The symmetric closure of R, denoted s(R ), is the relation RÈ R-1 . Example 2: What is the symmetric closure of the relation R={(a, b) | a> b} on the set of positive integers? Example :

Symmetric Closure Examples: If A = Z, then r( ≠ ) = Z  Z If A = Z+, then s( < ) = ≠ . What is the (infinite) connection matrix of s(<)? If A = Z, then s(≦) = ?

Symmetric Closure Theorem: Let R1 and R2 be relations from A to B. Then ( R -1) -1 = R (R1∪R2) -1 = R1-1 ∪ R2-1 (R1∩ R2)-1= R1 -1∩R2 -1 (A x B) -1 = B x A Æ-1 = Æ (R1 - R2) -1 = R1 -1 - R2 -1 If A = B, then (R1R2) -1 = R2-1R1-1 If R1 Í R2 then R1-1 Í R2-1

Paths in Directed Graphs Definition 1: A path from a to b in the directed graph G is a sequence of edges (x0, x1), (x1, x2), (x2, x3), . . ., (xn-1, xn) in G, where n is a nonnegative integer, and x0= a and x1=b . that is , a sequence of edges where the terminal vertex of an edge is the same as the initial vertex in the next edge in the path. This path is denoted by x0, x1, x2, . . .,xn-1 ,xn and has length n. We view the empty set of edges as a path from a to a. a path of length n ≧1 that begins and ends at the same vertex is called a circuit or cycle.

Symmetric ClosurePaths in Directed Graphs Examples 3: Which of the following are paths in the directed graph show below? What are the lengths of those that are paths? Which of the paths in this list are circuits? a,b,e,d; a,e,c,d,b; b,a,c,b,a,a,b; d,c; c,b,a; e,b,a,d,a,b,e;

Paths in Directed Graphs Theorem: Let R be a relation on A. There is a path of length n from a to b iff <a, b> Î Rn . Proof: (by induction) • Basis: An arc from a to b is a path of length 1. which is in R1 = R. Hence the assertion is true for n = 1. • Induction Hypothesis : Assume the assertion is true for n. Show it must be true for n+1. There is a path of length n+1 from a to b iff there is an x in A such that there is a path of length 1 from a to x and a path of length n from x to b. From the Induction Hypothesis, <a, x> ÎR and since <x , b> is a path of length n, <x, b> Î Rn. If <a, x> Î R And <x, b> Î Rn , then <a, b> ÎRn。R = Rn+1 by the inductive definition of the powers of R.

Useful Results for Transitive Closure Theorem: If A Ì B and C Ì B, then A È C Ì B. Theorem: If R Ì S and T Ì U then R。T Ì S。U. Corollary: If R Ì S then Rn Ì Sn Theorem: If R is transitive then so is Rn Theorem: If Rk = Rj for some j > k, then Rj+m = Rn for some n £ j. We don’t get any new relations beyond Rj. As soon as you get a power of R that is the same as one you had before, STOP.

Transitive Closure Recall that the transitive closure of a relation R, t(R), is the smallest transitive relation containing R. Also recall: R is transitive iff Rn is contained in R for all n. Hence, if there is a path from x to y then there must be an arc from x to y, or <x, y> is in R. Example: If A = Z and R = {< i, i+1>} then t(R) = < Suppose R: is the following:

Transitive Closure Definition: The connectivity relation or the star closure of the relation R, denoted R*, is the set of ordered pairs <a, b> such that there is a path (in R) from a to b: R*=⋃n=1∞ Rn Examples: • Let A = Z and R = {<i, i+1>}. R* = < . • Let A = the set of people, R = {<x, y> | person x is a parent of person y}. R* = ?

Transitive Closure Theorem 2: t(R) = R*. Proof: Note: this is not the same proof as in the text. We must show that R* 1) is a transitive relation 2) contains R 3) is the smallest transitive relation which contains R. Part 2): Easy from the definition of R*. Part 1): Suppose <x, y> and <y, z> are in R*. Show <x, z> is in R*.

R Ì S so R2 Ì S2 Ì S since S is transitive Transitive Closure By definition of R*, <x, y> is in Rm for some m and <y, z> is in Rn for some n. Then <x, z> is in Rn Rm = Rm+n which is contained in R*. Hence, R* must be transitive. Part 3): Now suppose S is any transitive relation that contains R. We must show S contains R* to show R* is the smallest such relation. R Ì S so R2 Ì S2 Ì S since S is transitive Therefore Rn Ì Sn Ì S for all n. (why?) Hence S must contain R* since it must also contain the union of all the powers of R.

Transitive Closure Theorem: If |A| = n, then any path of length > n must contain a cycle. Proof: If we write down a list of more than n vertices representing a path in R, some vertex must appear at least twice in the list (by the Pigeon Hole Principle). Thus Rk for k > n doesn’t contain any arcs that don’t already appear in the first n powers of R.

Transitive Closure Lemma 1: Let A be a set with n elements, and let R be a relation on A . If there is a path of length at least one in R from a to b, then there is such a path with length not exceeding n. Moreover, when a ≠ b , if there is a path of length at least one in R from a to b, then there is such a path with length not exceeding n-1.

Transitive Closure Corollary: We can find the connection matrix of t(R) by computing the join of the first n powers of the connection matrix of R. Powerful Algorithm! Example:

Transitive Closure Theorem 3: Let MR be the zero-one matrix of the relation R on the relation R on a set with n elements. Then the zero-one matrix of the transitive closure R* is Example: Find the zero-one matrix of the transitive closure of the relation R where

Transitive Closure Algorithm 1 : A Procedure for Computing the procedure transitive closure (MR :zero-one nxn matrix) A := MR B := A for i :=2 to n begin A := A⊙MR B := B  A end {B is the zero-one matrix for R* }