Mat3770 — Relations
Total Page:16
File Type:pdf, Size:1020Kb
Mat3770 | Relations Relations Digraphs Reflexive Mat3770 | Relations Symmetric Transitive Composition Data Structure Equiv Spring 2014 Relation 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 binary relation R from a set A to a set B is a Reflexive Symmetric subset 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 = f a, b, c g, Relations B = f 1, 2, 3, 4 g, and Digraphs Reflexive R be defined by the ordered pairs or edges: Symmetric f < a; 1 >; < a; 2 >; < c; 4 > g 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 = f a, b, c g Symmetric Transitive Composition R = f < a; a >; < a; b >; < a; c > g 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 subsets 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 8 x [x 2 A ! < x; x >2 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 8x8y[< x; y >2 R ! < y; x >2 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 8x8y[(< x; y >2 R) ^ (< y; x >2 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 8x8y8z[(< x; y >2 R) ^ (< y; z >2 R) ! < x; z >2 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 p p p Partitions A Transitive B Closure p C tsr(R) p p 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 = f 1, 2 g Composition R1 = f < 1; 2 > g Data Structure R2 = f < 2; 1 > g Equiv Relation Equiv Classes Then R1 [ R2 = f < 1; 2 >; < 2; 1 > g. 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 = f < B; 2 >; < B; 4 > g 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 = f a ; a ;:::; a g to Reflexive 1 2 m Symmetric B = f b1; b2;:::; bn g Transitive Composition Data Structure Equiv Definition: An m × n connection matrix, M, for R is Relation defined by: Equiv Classes 1 if < a ; b > 2 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 = f a, b, c g, B = f e, f, g, h g, and Reflexive R = f < a; e >; < c; g > g Symmetric Transitive Composition 2 3 Data 1 0 0 0 Structure Then the connection matrix M for R is: 4 0 0 0 0 5 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.