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 Closure of Relations Reflexive Closure Let R be a relation on set A. Example Let P be a property (reflexive, symmetric, etc.) A 1,2,3 The closure of R with respect to the property P R 1,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. S 1,1 , 1,2 , 1,3 , 2,2 , 3,3 Example: This is the reflexive closure of R & it’s the intersection A 1,2,3,4 , R 1,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. A 1,2,3 R 1,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” S 1,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): a A} 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 A 1,2,3,4 , R 1,1 , 1,3 , 14 R‐1 3,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)=R a,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 n 1 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 n 1 a b then a,b Rn R Rn 1 } There is a path of length n 1 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 n 1 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 Rm n which is contained * } t R 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 R R 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, t R , 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 t R R* R R2 . . . Rn 2. Binary Matrices 3. Warshall’s Algg orithm detailed in book 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.
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: } A a,b,c,d b c Given R draw the corresponding diagraph D } R a,b , b,c , c,d } The digraph of R is: Then compute We get R2 a, c , b, d a R end 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 } A a,b,c,d MR 0 0 0 1 Given A and the relation R on A, construct the matrix } R a,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 ÅÆ M 3 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 } 9 on 6 So we get: } 19 a,b MR* MR MR 2 MR 3 MR 4 } 25 a,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 sub digraph representing the subset is called a complete sub digraph. 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 a b “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‐a mk b b Examples 1 7 modulo 6 because 7‐1 6 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 | a b modulo 6 Definition: Notice that If R is an equivalence relation and (a,b) R, then we say that ● R is reflexive – because a a modulo 6 , for all a’s “a is equivalent to b” ◘ this means that 6 divides a‐a ● R is symmetric because a b modulo 6 implies that } Notation: a~b instead of aRb b a modulo 6 ◘ this means that if 6 divides b‐a , then 6 also divides a‐b ● R is transitive, because if a b mod 6 and b c modulo 6 then a c modulo 6 ◘ Assumptions: b‐a 6k c‐b 6t for some kt then we can write: c‐a c‐b b‐a 6t 6k Î 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 = {b A: b~a} = {b A: (a,b) R} a b a } Notation: a R 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 a a,c , c a.c . b b a a , b b . c c } 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
T1 1,2 , T2 3 , T3 4,5 Yes } 3 a,b , T1 1,2,3 , T2 2,4 , T3 5 No } 21 T 1 , T 2,3 , T 4 No 1 2 4 } 23 } 26 on 1d , } 35 a,c } 41 a‐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 partially ordered set or “poset” } Notation: ● If A, R is a poset and a and b are 2 elements of A such that a,b R, 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 a b ● “a and b are comparable” if a b or b a ◘ i.e. if a,b R and b,a R ● R is transitive if a b and b c, than a c ● “a and b are incomparable” if neither a b nor b a } So,, , is a poset. ◘ i.e if a,b R and b,a R ● 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 a b called a total order, linear order or simple order. ● So, any two a,b R 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,b R or b,a R 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 P S , 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. S 0, 1 , P S , 0 , 1 , 0, 1 • 0 and 1 are incomparable since 0 1 and } A A a : a 0 R0 , R aRb 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. a b ● R is transitive } Lecture Set 7 - Chpts 8.4, 8.5, 8.6 49 So ,| is poset! 50
9