Announcements

ICS 6B } Regrades for Quiz #3 and Homeworks #4 & Boolean Algebra & Logic 5 are due Thursday

Lecture Notes for Summer Quarter, 2008

Michele Rousseau

Set 7 – Ch. 8.4, 8.5, 8.6 Lecture Set 7 - Chpts 8.4, 8.5, 8.6 2

Grades Overall Grades & Quiz #3… Quiz #3 90-100 } Max: 100%

} Min: 42% 80-89 } Median: 83% 70-79

Overall 60-69 less } Max: 99% than 50

} Min 45% 01234567 } Median: 84% Overall Quiz #3

Lecture Set 7 - Chpts 8.4, 8.5, 8.6 3 Lecture Set 7 - Chpts 8.4, 8.5, 8.6 4

Today’s Lecture

} Chapter 8 8.4, 8.5, 8.6 ● Closures of Relations 8.4 Chapter 8: Section 8.4 ● Equivalence Relations 8.5 ● Partial Orderings 8.6

Closures of Relations

Lecture Set 7 - Chpts 8.4, 8.5, 8.6 5

1 of Relations Reflexive Closure Let R be a on set A. Example Let P be a property (reflexive, symmetric, etc.) A1,2,3 The closure of R with respect to the property P R1,1,1,2,1,3 is the smallest relation containing R which has this property. P“being reflexive”

} In other words, add the minimum number of pairs to obtain R is not reflexive, b/c its missing 2,2, 3,3 property P. The smallest reflexive relation containing R is } Note: This may not be possible. S1,1,1,2,1,3,2,2,3,3 Example: This is the reflexive closure of R & it’s the intersection A1,2,3,4, R1,1,1,3,14 of all of the reflexive relations that contain R P is being “irreflexive” Any relation on A which is reflexive and contains R } If the closure S of R w.r.t. P exists, must include: ● Then the relations S is the intersection of all the relations R which satisfy property p. 1,1,1,2,1,3 and 1,1, 2,2, 3,3 Lecture Set 7 - Chpts 8.4, 8.5, 8.6 7 R The diagonal pairs in AxA 8

Symmetric Closure Reflexive Closure (2) Example

} Let R be a relation on set A. A1,2,3 R1,1,1,2,1,3 } Then the reflexive closure of R always exists: we just need to add all the P“being symmetric” elements of the form a,a with a A. R is not symmetric , b/c it’s missing 2,1, 3,1 The smallest symmetric relation containing R is } In other words the “diagonal in AxA” S1,1,1,2,1,3,2,1,3,1 Note: we are adding R-1

Theorem: This is the symmetric closure of R. If R is a relation on A, denote by ={(a,a): aA} Generalized: the diagonal in AxA. Then the reflexive closure of R If R is a relation on A. Then the symmetric closure of R exists and is equal to exists and is equal to Sreflexive = R -1 Ssymy = R R

Lecture Set 7 - Chpts 8.4, 8.5, 8.6 9 10

Irreflexive, AntiSymmetric & Symmetric Closure (2) Example Asymetric Closures Assume P “being irreflexive” A 1,2,3,4 R 1,3,2,2, 2,4, 3,3, 3,4, 4,3 A1,2,3,4, R1,1,1,3,14 R‐13,1, 2,2, 4,2, 3,3, 4,3, 3,4 } Shows that if R is not irreflexive we can’t make it irreflexive. Then ÆThus the irreflexive closure of R does not exist R R‐1 1,3,3,1,2,2,2,4,4,2,3,3,3,4,4,3 } When R is irreflexive This is the symmetric closure of R Æ the irreflexive closure of R exists – it is R itself. } The relation R then is the smallest irreflexive R R‐1 is the smallest symm‐relation containing R, relation containing R basically we are adding 3,1 & 4,2 which is } This also applies to: what R needed to become symmetric Lecture Set 7 - Chpts 8.4, 8.5, 8.6 11 ÆAntisymmetric & Asymetric closures. 12

2 In terms of a Digraph In terms of a Matrix

} To find the reflexive closure } To find the reflexive closure ● add loops. ● Put 1’s on the diagonal. } To find the symmetric closure } To find the symmetric closure ● add arcs in the opposite direction. ● Take the transpose MT of the connection matrix M } To find the transitive closure ‐ if there is a R path from a to b Note: This relation is denoted RT or Rc and ● add a direct arc from a to b. and called the converse of R

Note: Reflexive and Symmetric closures are easy Transitive can be complicated

Lecture Set 7 - Chpts 8.4, 8.5, 8.6 13 Lecture Set 7 - Chpts 8.4, 8.5, 8.6 14

Transitive Closure t(R) Paths

} This is a little more difficult } A path of length n in a diagram G is the c b •Because (a,b) and (b,c) the sequence of edges: transitive closure must contain (a,c) ● x0, x1 x1, x2…xn‐1, xn •Similarly it must contain (b,d) ● The terminal vertex of the previous arc a d matc hes the in itia l ver tex o f the fo llow ing arc } The edges a,c and b,d seem to be the least amount of edges that need to be added in order to make R } If x0 xn the path is called a cycle or a circuit. transitive This is similarly true for relations c b •This is not Transitive – because of (a,c), (b,d) – we need to add (a,d) Now it is transitive – it may take a d several iterations

Lecture Set 7 - Chpts 8.4, 8.5, 8.6 so t(R)=Ra,c,b,d,a,d 15 Lecture Set 7 - Chpts 8.4, 8.5, 8.6 16

Theorem: Let R be a relation on set A. There is a path of length n from a to b iff a,b Rn From the induction Hypothesis Proof: by induction a,x R } Basis: And since x,b is a path of length n 1 An arc from a to b is a path of length 1 which is in R R. x,b Rn Hence the assertion is true for n1 c x if a,x R } Induction Hypothesis: n Assume the assertion is true for n. and x,b R , Show it is true for n1 a b then a,b Rn R Rn1 } There is a path of length n1 from a to b iff Q.E.D Æ quod erat demonstrandum there is an x A such that “that which was to have been demonstrated” there is a path of length 1 from ato xand a path of length n from x to b. Lecture Set 7 - Chpts 8.4, 8.5, 8.6 17 Lecture Set 7 - Chpts 8.4, 8.5, 8.6 18

3 Proof Transitivity Closure (2) Theorem: R* is the transitive closure of R. Theorem: Proof: Let R be a relation on set A. * The connectivity relation or the star closure We must show that R is transitive ∞ * * is the relation R* =Rn Suppose a,b R and b,c R n1 Show a,c R* } R* is the union of all powers of R ● By definition of R* , a,b Rm for some m n } Notice that R* contains the ordered set a,b if and b,c R for some n there is a path from a to b ● Then a,c RnRm Rmn which is contained * } tR is the smallest transitive relation containing R in R . * } R is transitive iff Rn is contained in R for all n Hence R must be transitive } Notice that R * contains R 1 n * Lecture Set 7 - Chpts 8.4, 8.5, 8.6 19 ● Because RR R R 20

So R* is a transitive relation containing R In fact we only have to consider paths of n or less

By definition the transitive closure of R, tR, is the Theorem: If |A| n, then any path of length n must smallest transitive relation containing R. contain a cycle To prove this lets suppose S is any transitive relation Proof: that contains R If we write down a list of more than n vertices representing a path in R, some vertex must appear at WthWe must show S contitains R* thto show R* ithis the least twice in the list by the Pigeon Hole Principle. smallest such relation. Thus Rk for k n doesn’t contain any arcs that don’t * 2 R S, so R S S since S is transitive already appear in the first n powers of R. There fore Rn Sn S for all n. Hence S must contain R* since it must also contain the union of all powers of R. Q.E.D Lecture Set 7 - Chpts 8.4, 8.5, 8.6 21 Lecture Set 7 - Chpts 8.4, 8.5, 8.6 22

Corollaries 3 Methods to construct R* = R R2 . . . Rn

Corollary: If | A | n, then 1. Digraphs tR R* R R2 . . . Rn 2. Binary Matrices 3. Warshall’s Alggorithm detailed in book Corollary: We can find the connection matrix of tR by computing the join of the first n powers of the connection matrix of R.

Lecture Set 7 - Chpts 8.4, 8.5, 8.6 23 Lecture Set 7 - Chpts 8.4, 8.5, 8.6 24

4 Method 1: Diagraphs Example: Digraphs Constructing R* R R2 . . . Rn using N=4 Digraphs: } Aa,b,c,d b c Given R draw the corresponding diagraph D } Ra,b,b,c,c,d } The digraph of R is: Then compute We get R2 a, c, b, d a Rend points of paths of length 1 in D. d R3 a, d 2 R endpoints of paths of length 2 in D R4 b c . . . Then n R* R R2 R3 R4 a R endpoints of paths of length n in D d Then compute R* R R2 . . . Rn a,b,b,c,c,d,a,c,b,d,a,d Æ this is the transitive closure of R. Lecture Set 7 - Chpts 8.4, 8.5, 8.6 25 Lecture Set 7 - Chpts 8.4, 8.5, 8.6 26

Method 2: Binary Matrices Constructing R* R R2 . . . Rn using Binary Example: Matrices 0 1 0 0 0 0 1 0 Matrices } Aa,b,c,d MR 0 0 0 1 Given A and the relation R on A, construct the matrix } Ra,b,b,c,c,d 0 0 0 0 MR associated to R. [ ] 0 1 0 0 0 1 0 0 0 0 1 0 Then build the powers 2 M 0 0 1 0 0 0 1 0 0 0 0 1 2 R 0 0 0 1 0 0 0 1 0 0 0 0 R ÅÆ MR MR MR 0 0 0 0 0 0 0 0 0 0 0 0 R ÅÆ M3 M M M R R R R [][ ] [][ ][][ ] . . . N Times 0 1 0 0 0 0 1 0 0 0 0 1 n 0 0 1 0 0 0 0 1 0 0 0 0 R ÅÆ MR MR … MR 3 2 M 0 0 0 1 0 0 0 0 0 0 0 0 2 n R MR MR The matrix associated to R* R R . . . R is 0 0 0 0 0 0 0 0 0 0 0 0 2 n * [ ] M M M … M Note the order [ ] [ ] R R R R Once we get M *it is very easy to write down R* R 27 Lecture Set 7 - Chpts 8.4, 8.5, 8.6 28

Example: Matrices (2) Homework for 8.4

0 1 0 0 0 0 0 1 0 0 0 0 } 1 0 0 1 0 0 0 0 0 0 0 0 0 4 3 0 0 0 0 } 3 MR MR MR 0 0 0 1 0 0 0 0 0 0 0 0 [0 0 0 0 ][0 0 0 0 ][ ] } 5 } 9on 6 So we get: } 19 a,b MR* MR MR 2MR 3MR 4 } 25a,b which gives R* a,b,b,c,c,d,a,c,b,d,a,d

Lecture Set 7 - Chpts 8.4, 8.5, 8.6 29 Lecture Set 7 - Chpts 8.4, 8.5, 8.6 30

5 What is an Equivalence Relation?

Definition: Chapter 8: Section 8.5 A relation on set A is called an equivalence relation if it is reflexive, symmetric and transitive.

It is easy to recognize equivalence relations using digraphs.

Equivalence Relations } The subset of all elements related to a particular element forms a universal relation contains all possible arcs on that subset. The subdigraph representing the subset is called a complete subdigraph. All arcs are present.

} The number of such subsets is called the rank of the equivalence relation

Lecture Set 7 - Chpts 8.4, 8.5, 8.6 32

Examples Congruence modulo m a a Fix m, a positive integer. b b Let a,b be integers. We say that ab “a congruent to b modulo m” m c c if m|b‐a. The condition “m divides b‐a” means that you can find Rk2Rank=2 Rk2Rank=2 another integer k such that

a a b‐amk b b Examples 1 7 modulo 6 because 7‐16 is divisible by 6 42 30 modulo 6 because 30‐42‐6 is divisible by 6 c c 1 is not congruent to 14 modulo 6 because Rank=3 Rank=1 33 14‐1 is not div by 6 34

Example Equivalence Relations Let A & R a,b | ab modulo 6 Definition: Notice that If R is an equivalence relation and (a,b)R, then we say that ● R is reflexive – because aa modulo 6 , for all a’s “a is equivalent to b” ◘ this means that 6 divides a‐a ● R is symmetric because ab modulo 6 implies that } Notation: a~b instead of aRb ba modulo 6 ◘ this means that if 6 divides b‐a, then 6 also divides a‐b ● R is transitive, because if ab mod 6 and bc modulo 6 then ac modulo 6 ◘ Assumptions: b‐a 6k c‐b6t for some kt then we can write: c‐ac‐bb‐a6t6k Î 6 divides c‐a Then R “congruance modulo 6” is an equivalence relation 35 Lecture Set 7 - Chpts 8.4, 8.5, 8.6 36

6 What is an Equivalence Class? Example – Equivalence Class 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. [a]R = {bA: b~a} = {b A: (a,b) R} a b a } Notation: aR or a for only 1 relation b } In other words Each of the subsets is called an equivalence class c } A bracket around an element means the equivalence c class in which the element lies. Rank=2 Rank=3 x y | x, y is in R aa,c, ca.c. bb aa, bb. cc } The element in the bracket is called a representative of the equivalence class. We could have chosen any one. Lecture Set 7 - Chpts 8.4, 8.5, 8.6 37 Lecture Set 7 - Chpts 8.4, 8.5, 8.6 38

Example We notice that: ● Every person belongs to exactly 1 of these If a is a person, and distinct equivalence classes R is the relation “having the same age”, then ● Distinct equivalence classes are disjoint ◘ They don’t intersect a all people that are the same age as a ● The union of all distinct equivalence classes The distinct equivalence classes are: is the full set of people. ● all people who are age 0 ● all people who are age 1 ● all people who are age 2 ● … and so on

Lecture Set 7 - Chpts 8.4, 8.5, 8.6 39 Lecture Set 7 - Chpts 8.4, 8.5, 8.6 40

Equivalence Partitions Formal Def of Partition Let S1, S2, . . ., Sn be a collection of subsets of A. Theorem: Then the collection forms a partition of A if the subsets are The equivalence classes of an equivalence relation R nonempty, disjoint and exhaust A. partition the set A into disjoint, nonempty subsets whose union is the entire set. } In other words: } Notation A| R ● The distinct equivalence classes partition A as a union of disjoint subsets } IhIn other wor ds,

S ● The distinct equivalence classes for a S 2 1 A= All people aged 1 thru 4 partition of A S7 Partitioned based on

S6 S3 “having the same age” A= } Called: S 5 2 ● the quotient set, or S4 1 3 even #s odd #s ● the partition of A induced by R, or 4 41 ● A modulo R 42

7 Examples Homework for 8.5

Let S be a set 1,2,3,4,5 } 1d Which are partitions of S? } 2d

T11,2, T23, T34,5 Yes } 3a,b, T11,2,3, T22,4, T35 No } 21 T 1, T 2,3, T 4 No 1 2 4 } 23 } 26 on 1d, } 35a,c } 41a‐d

Lecture Set 7 - Chpts 8.4, 8.5, 8.6 43 Lecture Set 7 - Chpts 8.4, 8.5, 8.6 44

What is a Partial Order? Let R be a relation on A. The R is a partial order iff R is: Chapter 8: Section 8.6 reflexive, antisymmetric, & transitive } A,R is called a or “poset” } Notation: ● If A, R is a poset and a and b are 2 elements of A such that a,bR, we write a b instead of aRb Partial Orderings NOTE: it is not required that two things be related under a partial order. ● That’s the “partial” of it.

46

Some more defintions Example } A; R the relation } If A,R is a poset and a,b are A, ● Then R is reflexive a a, a we say that: ● R is antisymmetric if a b & b a, then ab ● “a and b are comparable” if ab or ba ◘ i.e. if a,bR and b,aR ● R is transitive if a b and b c, than a c ● “a and b are incomparable” if neither ab nor ba } So,, , is a poset. ◘ i.e if a,bR and b,aR ● In this case either a b or b a so two things } If two objects are always related in a poset it is are always related maybe both if ab called a total order, linear order or simple order. ● So, any two a,bR are comparable ● In this case A,R is called a chain. ● Hence, is a total order and , , is a chain ● i.e if any two elements of A are comparable ● So for all a,b A, it is true that a,bR or b,aR Note: , is also a poset.. But and are not.. Why not? Lecture Set 7 - Chpts 8.4, 8.5, 8.6 47 Lecture Set 7 - Chpts 8.4, 8.5, 8.6 48

8 Example 3 Example 2 } A a divides b } If S is a set then PS, is a poset. R divisibility relation: aRb iff a|b ●It may not be the case that A B or B Then A. ● R is not reflexive because 0 does not divide 0 So, , | is not a poset ◘Eg. S0, 1, PS, 0, 1, 0, 1 • 0 and 1 are incomparable since 0 1 and } AA a : a 0R0, RaRb iff a|b 1 0 Then • 0,1 and 1 are comparable since 1 0, 1 ● R is reflexive so it is a poset, but ● R is antisymmetric because if a|b and b|a then ◘ is not a total order. ab ● R is transitive } Lecture Set 7 - Chpts 8.4, 8.5, 8.6 49 So ,|is poset! 50

9