<<

Mat3770 — Relations

Relations

Digraphs Reflexive Mat3770 — Relations Symmetric

Transitive

Composition

Data Structure Equiv Spring 2014

Equiv Classes

Partitions

Transitive Closure tsr(R) Student Responsibilities

Mat3770 — Relations Reading: Textbook, Section 8.1, 8.3, 8.5 Relations Assignments: Digraphs Sec 8.1 1a-d, 3a-d, 5ab, 16, 28, 31, 48bd Reflexive Sec 8.3 1ab, 3ab, 5, 14a-c, 18(ab), 23, 26, 36 Symmetric Sec 8.5 2ad, 5, 15, 22, 35, 43a-c, 61 Transitive

Composition Attendance: Spritefully Encouraged

Data Structure

Equiv Overview Relation Sec 8.1 Relations and Their Properties Equiv Classes

Partitions Sec 8.3 Representing Relations Transitive Sec 8.5 Equivalence Relations Closure tsr(R) Section 8.1 — Relations and Their Properties

Mat3770 — Relations Binary Relations

Relations

Digraphs Definition:A R from a set A to a set B is a Reflexive

Symmetric R ⊆ A × B.

Transitive Composition Note: there are no constraints on relations as there are on Data Structure functions. Equiv Relation Equiv Classes We have a common graphical representation of relations, a Partitions directed graph. Transitive Closure tsr(R) Directed Graphs

Mat3770 — Relations Definition:A Directed Graph (Digraph) D from A to B Relations is: Digraphs 1. a collection of vertices V ⊆ A ∪ B, and Reflexive 2. a collection of edges E ⊆ A × B Symmetric

Transitive

Composition If there is an ordered pair e =< x, y > in R, then there is an Data Structure arc or edge from x to y in D. (Note: E = R) Equiv Relation

Equiv Classes The elements x and y are called the initial and terminal Partitions vertices of the edge e. Transitive Closure tsr(R) Relation Example

Mat3770 — Relations Let A = { a, b, c },

Relations B = { 1, 2, 3, 4 }, and

Digraphs

Reflexive R be defined by the ordered pairs or edges: Symmetric { < a, 1 >, < a, 2 >, < c, 4 > } Transitive

Composition Then we can represent R by the digraph D:

Data Structure 1 Equiv A Relation 2 Equiv Classes B Partitions 3 Transitive Closure C tsr(R) 4 Relation on a Single Set A

Mat3770 — Relations Definition: A binary relation R on a set A is a subset of A × A or a relation from A to A. Relations

Digraphs Reflexive Let A = { a, b, c } Symmetric

Transitive Composition R = { < a, a >, < a, b >, < a, c > } Data Structure

Equiv Relation Then a digraph representation of R is: Equiv Classes

Partitions b Transitive a Closure tsr(R) c Notes

Mat3770 — Relations

Relations Digraphs An arc of the form < x, x > on a digraph is called a loop. Reflexive

Symmetric

Transitive

Composition Question: How many binary relations are there on a set A?

Data Another way to think of it: Structure

Equiv How many are there of A × A? Relation

Equiv Classes

Partitions

Transitive Closure tsr(R) Special Properties of Binary Relations

Mat3770 — Given Relations 1. A universe U Relations

Digraphs 2. A binary relation R on a subset A of U

Reflexive Definition: R is reflexive IFF Symmetric Transitive ∀ x [x ∈ A → < x, x >∈ R] Composition

Data Structure Notes: Equiv If A = ∅, then the implication is vacuously true Relation

Equiv Classes The void relation on an empty set is reflexive Partitions

Transitive Closure If A is not void, then all vertices in the reflexive relation must tsr(R) have loops Symmetric and Antisymmetric Properties

Mat3770 — Relations Definition: R is symmetric IFF ∀x∀y[< x, y >∈ R → < y, x >∈ R] Relations Digraphs Note: if there is an arc < x, y >, there must be an arc Reflexive < y, x > Symmetric

Transitive Composition Definition: R is antisymmetric IFF Data Structure ∀x∀y[(< x, y >∈ R) ∧ (< y, x >∈ R) → x = y] Equiv Relation Note: If there is an arc from x to y, there cannot be one from Equiv Classes

Partitions y to x if x6= y.

Transitive Closure To prove a relation is antisymmetric, show logically that if tsr(R) < x, y > is in R and x 6= y, then < y, x > is not in R. The Transitive Property

Mat3770 — Relations

Relations Definition: R is transitive IFF Digraphs Reflexive ∀x∀y∀z[(< x, y >∈ R) ∧ (< y, z >∈ R) → < x, z >∈ R] Symmetric

Transitive

Composition Note: If there is an arc from x to y and one from y to z, then

Data there must be one from x to z. Structure

Equiv Relation This is the most difficult property to check. We will develop Equiv Classes algorithms to check this later. Partitions

Transitive Closure tsr(R) Mat3770 — AB Relations

Relations

Digraphs

Reflexive

Symmetric CD

Transitive

Composition

Data Structure

Equiv Relation Equiv Classes R reflexive symmetric antisymmetric transitive √ √ √ Partitions A Transitive B Closure √ C tsr(R) √ √ D Combining Relations — Set Operations

Mat3770 — Relations A very large set of potential questions! For example, let R1

Relations and R2 be binary relations on a set A. Then we have Digraphs questions of the form: Reflexive If R1 has Property 1 and Symmetric R2 has Property 2, Transitive does R1 ? R2 have Property 3? Composition

Data Structure

Equiv For example, If R1 is symmetric and R2 is antisymmetric, Relation does it follow that R1 ∪ R2 is transitive? Equiv Classes Partitions If so, we need to prove it; Transitive otherwise, we can find a counterexample. Closure tsr(R) Another Example

Mat3770 — Relations Let R1 and R2 be transitive on A. Does it follow that R1 ∪ Relations R2 is transitive? Digraphs

Reflexive Symmetric Consider: Transitive A = { 1, 2 } Composition R1 = { < 1, 2 > } Data Structure R2 = { < 2, 1 > }

Equiv Relation Equiv Classes Then R1 ∪ R2 = { < 1, 2 >, < 2, 1 > }. which is not Partitions transitive. (Why not?) Transitive Closure tsr(R) Composition of Relations

Mat3770 — Relations Definition: Suppose R1 is a relation from A to B R2 is a relation from B to C Relations Digraphs Then the composition of R2 with R1, denoted R2 ◦ R1, is Reflexive the relation from A to C: Symmetric Transitive If < x, y > is a member of R1 and Composition < y, z > is a member of R2 , then Data < x, z > is a member of R2 ◦ R1 Structure

Equiv Relation For < x, y > to be in the composite relation R2 ◦ R1, there Equiv Classes must exist a y in B Partitions

Transitive Closure We read compositions right to left as in functions, applying tsr(R) R1 first, then R2 in this example. Example of a Composite Relation

Mat3770 — Relations 1

Relations A Digraphs 2 Reflexive B Symmetric 3 Transitive C Composition

Data 4 Structure Equiv R1 R2 Relation

Equiv Classes

Partitions

Transitive Closure R2 ◦ R1 = { < B, 2 >, < B, 4 > } tsr(R) A Relation Composed with Itself

Mat3770 — Relations Definition: Let R be a binary relation on A. Then the Relations powers Rn, n = 1, 2, 3,... are defined recursively by: Digraphs

Reflexive Basis:R1 = R Symmetric Transitive Induction:Rn+1 = Rn ◦ R Composition

Data Structure

Equiv Relation Note: An ordered pair < x, y > is in Rn IFF there is a path Equiv Classes of length n from x to y following the arcs (in the direction of Partitions the arrows) in R. Transitive Closure tsr(R) Composites on R

Mat3770 — Relations

Relations

Digraphs

Reflexive Symmetric R1 = R R2 = R1 R Transitive

Composition

Data Structure

Equiv Relation

Equiv Classes

Partitions

Transitive Closure R3 = R2 R R4 = R3 R tsr(R) A Very Important Theorem

Mat3770 — R is transitive IFF Rn ⊆ R for n > 0. Relations

Proof ( ⇒ ): R transitive → Rn ⊆ R Relations Digraphs Use a direct proof with proof by induction Reflexive Assume R is transitive & show Rn ⊆ R by induction Symmetric Basis: Obviously true for n = 1 Transitive Induction: Composition IH: Assume Rk ⊆ R for some arbitrary k > 0 Data k+1 Structure IS: Show R ⊆ R Equiv Rk+1 = Rk ◦ R, so if < x, y > is in Rk+1, then there is a z Relation such that < x, z > is in Rk and < z, y > is in R. Equiv Classes k Partitions But, since R ⊆ R, < x, z > is in R Transitive R is transitive, so < x, y > is in R Closure tsr(R) Since < x, y > was an arbitrary edge, the result follows Proof ( ⇐ )

Mat3770 — Relations To complete the proof, we need to show:

Relations n Digraphs R ⊆ R → R is transitive

Reflexive

Symmetric 2 Transitive Use the fact that R ⊆ R and the definition of transitivity. Composition Proof left as an exercise. . . Data Structure

Equiv Relation Equiv Classes Thus, (given a finished proof of the above) we have shown: Partitions n Transitive R is transitive IFF R ⊆ R for n > 0 Closure tsr(R) Section 8.3 — Representing Relations

Mat3770 — Relations Connection Matrices

Relations

Digraphs Let R be a relation from A = { a , a ,..., a } to Reflexive 1 2 m

Symmetric B = { b1, b2,..., bn }

Transitive

Composition

Data Structure

Equiv Definition: An m × n connection matrix, M, for R is Relation defined by: Equiv Classes  1 if < a , b > ∈ R m = i j Partitions i,j 0 otherwise Transitive Closure tsr(R) Example

Mat3770 — Relations Assume the rows are labeled with the elements of A and the Relations columns are labeled with the elements of B. Digraphs Let A = { a, b, c }, B = { e, f, g, h }, and Reflexive R = { < a, e >, < c, g > } Symmetric

Transitive Composition   Data 1 0 0 0 Structure Then the connection matrix M for R is:  0 0 0 0  Equiv Relation 0 0 1 0

Equiv Classes

Partitions Transitive Note: The order of the elements of A and B is important! Closure tsr(R) Mat3770 — Relations Theorem. let R be a binary relation on a set A and let M be Relations its connection matrix. Then: Digraphs

Reflexive

Symmetric R is reflexive IFF Mi,i = 1 for all 1 ≤ i ≤ |A| Transitive

Composition

Data T Structure R is symmetric IFF M is a symmetric Matrix: M = M

Equiv Relation

Equiv Classes R is antisymmetric if Mij = 0 or Mji = 0 for all i 6= j Partitions

Transitive Closure tsr(R) Combining Connection Matrices — Join

Mat3770 — Relations

Relations Digraphs Definition: The of two matrices, M1 and M2, denoted Reflexive M1 ∨ M2, is the component–wise Boolean ”or” of the two Symmetric matrices. Transitive

Composition Data Fact: If M1 is the connection matrix for R1, and M2 is the Structure connection matrix for R , then the join of M and M , Equiv 2 1 2 Relation M1 ∨ M2, is the connection matrix for R1 ∪ R2 Equiv Classes

Partitions

Transitive Closure tsr(R) Combining Connection Matrices — Meet

Mat3770 — Relations

Relations Digraphs Definition:The meet of two matrices, M1 and M2, denoted Reflexive M1 ∧ M2, is the component–wise Boolean ”and” of the two Symmetric matrices. Transitive

Composition Data Fact: If M1 is the connection matrix for R1, and M2 is the Structure connection matrix for R , then the meet of M and M , Equiv 2 1 2 Relation M1 ∧ M2, is the connection matrix for R1 ∩ R2 Equiv Classes

Partitions

Transitive Closure tsr(R) Finding Connection Matrix Combinations

Mat3770 — Relations

Given the connection matrix for two relations, how does one Relations

Digraphs find the connection matrix for:

Reflexive Symmetric The :(A × A) − R Transitive

Composition

Data Structure The relative complement: R1 − R2 and R2 − R1

Equiv Relation

Equiv Classes The symmetric difference: R1 ⊕ R2 = (R1 − R2) ∪ (R2 − R1) Partitions

Transitive Closure tsr(R) The Composition

Mat3770 — Relations Definition: Let M1 be the connection matrix for R1, and M2 be the connection matrix for R . Relations 2 Digraphs Then the Boolean product of these two matrices, denoted Reflexive M1 ⊗ M2, is the connection matrix for the composition of R2 Symmetric with R1, R2 ◦ R1 Transitive

Composition Data (M ⊗ M ) = ∨n [(M ) ∧ (M ) )] Structure 1 2 ij k=1 1 ik 2 kj

Equiv Relation Equiv Classes Why? In order for there to be an arc < x, z > in the Partitions composition, then there must be an arc < x, y > in R1 and an Transitive Closure arc < y, z > in R2 for some y. tsr(R) Notes on Composition

Mat3770 — Relations

Relations The Boolean product checks all possible y’s. If at least one Digraphs such path exists, that is sufficient. Reflexive

Symmetric

Transitive

Composition The matrices M1 and M2 must be conformable: the number

Data of columns of M1 must equal the number of rows of M2. Structure

Equiv Relation Equiv Classes If M1 is m × n and M2 is n × p, then M1 ⊗ M2 is m × p Partitions

Transitive Closure tsr(R) Composition Example — R2 ◦ R1

Mat3770 — Relations ABC 1 1 Relations 2 1 Digraphs 2 Reflexive 3 2 Symmetric Transitive 3 4 Composition 1 2 Data RR Structure

Equiv Relation

Equiv Classes 0 1 0 0 0 0 0 1 Partitions 0 1 = 0 0 0 1 = M 0 1 Transitive M 1 M 2 1 0 M 1 2 = Closure 0 1 0 0 0 1 0 1 tsr(R) Mat3770 — Relations (M1 ⊗ M2)12 = [(M1)11 ∧ (M2)12] ∨

[(M1)12 ∧ (M2)22] ∨ Relations [(M1)13 ∧ (M2)32] ∨ Digraphs

Reflexive [(M1)14 ∧ (M2)42] ∨

Symmetric = [0 ∧ 0] ∨ [1 ∧ 1] ∨ [0 ∧ 0] ∨ [0 ∧ 1] Transitive Composition = 1 Data Structure There is an arc in R1 from node 1 in A to node 2 in B Equiv Relation There is an arc in R2 from node 2 in B to node 2 in C Equiv Classes Partitions Hence, there is an arc in R2 ◦ R1 from node 1 in A to node 2 Transitive in C. Closure n tsr(R) A useful result: MRn = (MR ) Digraphs

Mat3770 — Given the digraphs for R and R , describe how to find the Relations 1 2 digraphs for:

Relations

Digraphs Union: R2 ∪ R1 Reflexive

Symmetric Intersection: R2 ∩ R1 Transitive

Composition

Data Relative Complement: R2 − R1 Structure

Equiv Relation Boolean Product: R2 ⊗ R1 Equiv Classes

Partitions Complement: A × A − R1 Transitive Closure tsr(R) Symmetric Difference: R1 ⊕ R2 Section 8.5 — Equivalence Relations

Mat3770 — Relations

Wherein we define new types of important relations by Relations

Digraphs grouping properties of relations together.

Reflexive

Symmetric

Transitive Definition: A relation R on a set A is an equivalence relation Composition IFF R is: Data Structure

Equiv reflexive Relation Equiv Classes symmetric, and Partitions

Transitive transitive Closure tsr(R) Equivalence Relations in Digraphs

Mat3770 — Relations Equivalence relations are easily recognized in digraphs

Relations

Digraphs The set of all elements related to a particular element forms a Reflexive

Symmetric subgraph in which all self–loops and arcs are present between

Transitive the included vertices.

Composition Data I.e., the digraph (or subdigraph) representing the subset will Structure be a complete digraph (or subdigraph). Equiv Relation Equiv Classes The number of such subsets is called the rank of the Partitions equivalence relation. Transitive Closure tsr(R) All Equivalence Relations on a Set with 3 Elements

Mat3770 — Relations rank = 3

Relations

Digraphs

Reflexive rank = 2

Symmetric

Transitive

Composition rank = 2 Data Structure

Equiv Relation rank = 2 Equiv Classes

Partitions

Transitive Closure tsr(R) rank = 1 Equivalence Classes

Mat3770 — Relations Each complete subset is called an equivalence class.

Relations A bracket around an element means the equivalence class in Digraphs which the element lies. Reflexive

Symmetric [x] = {y| < x, y >∈ R} Transitive

Composition

Data The element in the bracket is called a representative of the Structure equivalence class — we could have chosen any element in that Equiv Relation class.

Equiv Classes Partitions Three ways to say ”in the same equivalence class”: Transitive Closure aRb [a] = [b][a] ∩ [b] 6= ∅ tsr(R) Example — Equivalence Classes

Mat3770 — Relations a b Relations

Digraphs

Reflexive

Symmetric

Transitive

Composition

Data c Structure

Equiv Relation

Equiv Classes [a] = {a, c}, [c] = {a, c}, [b] = {b}

Partitions rank = 2 Transitive Closure tsr(R) Partitions

Mat3770 — Relations Definition: Let S1, S2,..., Sn be a collection of subsets of A. Then the collection forms a partition of A if the subsets are Relations non–empty, disjoint, and exhaust A. Digraphs S Reflexive Si 6= ∅ Si ∩ Sj = ∅ if i 6= j Si = A Symmetric

Transitive

Composition

Data Structure S2

Equiv S1 Relation A S Equiv Classes 4

Partitions S3 S5 Transitive Closure tsr(R) Mat3770 — Relations Theorem. The equivalence classes of an equivalence relation R Relations partition the set A into disjoint nonempty subsets whose union Digraphs is the entire set. Reflexive

Symmetric

Transitive The partition is denoted A/R and is called:

Composition

Data Structure the quotient set or

Equiv Relation the partition of A induced by R, or Equiv Classes

Partitions A modulo R

Transitive Closure tsr(R) Examples

Mat3770 — Relations 1. The set of integers such that aRb IFF a = b or a = −b

Relations 2. The natural numbers mod any integer: Digraphs For example, N mod 3 divides the natural numbers into 3 Reflexive equivalence classes: [0]3, [1]3, [2]3 Symmetric Transitive 3. a b Composition

Data Structure

Equiv Relation c Equiv Classes

Partitions Transitive [a] = {a}, [b] = {b, c}, [c] = {b, c} Closure tsr(R) rank = 2 Mat3770 — Relations

Relations

Digraphs Theorem. Let R be an equivalence relation on A. Then either

Reflexive

Symmetric [a] = [b] Transitive or Composition

Data [a] ∩ [b] = ∅ Structure

Equiv Relation Why?

Equiv Classes

Partitions

Transitive Closure tsr(R) Review — R ⊆ A × A

Mat3770 — Relations reflexive:(a, a) ∈ R ∀ a ∈ A Relations

Digraphs Reflexive symmetric:(b, a) ∈ R ↔ (a, b) ∈ R for a, b ∈ A Symmetric

Transitive Composition antisymmetric: Data Structure (b, a) ∈ R and (a, b) ∈ R, then a = b for a, b ∈ A

Equiv Relation Equiv Classes transitive: Partitions (a, b) ∈ R and (b, c) ∈ R, then (a, c) ∈ R for a, b, c ∈ A Transitive Closure tsr(R) Transitive Closure

Mat3770 — Relations A path in a digraph is a sequence of connected edges.

Relations Digraphs A path has length n, where n is the number of edges in the Reflexive path. Symmetric

Transitive Composition A circuit or cycle is a path that begins and ends at the same Data Structure vertex.

Equiv Relation ? Equiv Classes The connectivity relation R is the set of all pairs

Partitions such that there is a path between a and b in the relation R.

Transitive Closure This is also called the transitive closure of R. tsr(R) Mat3770 — Relations Theorem. If R1 and R2 are equivalence relations on A, then R1 ∩ R2 is an equivalence relation on A. Relations

Digraphs Reflexive Proof outline: Symmetric Transitive It would suffice to show that the intersection of: Composition

Data Structure reflexive relations is reflexive Equiv Relation

Equiv Classes symmetric relations is symmetric, and

Partitions Transitive transitive relations is transitive Closure tsr(R) Reflexive, Symmetric, Transitive Closure

Mat3770 — Definition. Let R be a relation on A. Then the reflexive, Relations symmetric, transitive closure of R, denoted tsr(R), is an

Relations equivalence relation induced by R on A.

Digraphs

Reflexive Example: Symmetric a b a b Transitive

Composition

Data Structure

Equiv Relation d c d c Equiv Classes

Partitions R tsr(R), rank = 2

Transitive Closure A = [a] [b] = {a} {b, c, d} tsr(R) A/R = { {a}, {b, c, d} } Mat3770 — Relations Theorem. tsr(R) is an equivalence relation.

Relations

Digraphs Reflexive Proof. We must be careful and show that tsr(R) is still Symmetric symmetric and reflexive. Transitive

Composition

Data Structure Since we only add arcs (rather than delete arcs) when Equiv Relation computing closures, it must be that tsr(R) is reflexive since all Equiv Classes loops < x, x > on the digraph must be present when Partitions constructing r(R). Transitive Closure tsr(R) Mat3770 — Relations

Relations If there is an arc < x, y >, then the symmetric closure of r(R) Digraphs ensures there is an arc < y, x >. Reflexive

Symmetric

Transitive We may now argue that if we construct the transitive closure Composition

Data of sr(R) and we add an edge < x, z > because there is a path Structure from x to z, then there must also exist a path from z to x, and Equiv Relation hence we also must add an edge < z, x >. Hence the

Equiv Classes transitive closure of sr(R) is symmetric.

Partitions

Transitive Closure tsr(R)