340 likes | 499 Views
CS 173: Discrete Mathematical Structures. Cinda Heeren heeren@cs.uiuc.edu Siebel Center, rm 2213 Office Hours: W 12:30-2:30. CS 173 Announcements.
E N D
CS 173:Discrete Mathematical Structures Cinda Heeren heeren@cs.uiuc.edu Siebel Center, rm 2213 Office Hours: W 12:30-2:30
CS 173 Announcements • Homework all finished. Self-study material on relations from Ch 8, Sec 1, 3, 5, 6. We’re posting the hwk we wish we had time to assign (with solutions). • Final exam 5/7, 1:30-4:30p. Email Cinda with conflicts. Room assignments posted on web site when determined. • Please check your scores on compass and make sure everything is accurate. Email section leader if there’s a problem. • Today, something special… Cs173 - Spring 2004
CS 173 Equivalence Classes Example: Back to coins in bags. Definition: Let R be an equivalence relation on S. The equivalence class of a S, [a]R, is [a]R = {b: aRb} a is just a name for the equiv class. Any member of the class is a representative. Cs173 - Spring 2004
CS 173 Equivalence Classes What equivalence relation we’ve seen recently has representatives [244], [7], [58], [1]? Cs173 - Spring 2004
Notice this is just a subset of S. CS173Equivalence Classes Definition: Let R be an equivalence relation on S. The equivalence class of a S, [a]R, is [a]R = {b: aRb} What does the set of equivalence classes on S look like? To answer, think about the relation from before: S = {people in this room} R = {(a,b) : a has the same # of coins in his/her bag as b} In how many different equivalence classes can each person fall? Cs173 - Spring 2004
Defn of [a]R symmetry transitivity symmetry Defn of [b]R CS173Equivalence Classes Lemma: Let R be an equivalence relation on S. Then • If aRb, then [a]R = [b]R • If not aRb, then [a]R [b]R = Proof: • Suppose aRb, and consider x S. x [a]R aRx xRa xRb bRx x [b]R Cs173 - Spring 2004
Thus, [a]Rand [b]R are either identical or disjoint. CS173Equivalence Classes Lemma: Let R be an equivalence relation on S. Then • If aRb, then [a]R = [b]R • If not aRb, then [a]R [b]R = Proof: 2. Suppose to the contrary that x [a]R [b]R. x [a]R x [b]R aRx and bRx aRx and xRb aRb, contradicting “not aRb” Cs173 - Spring 2004
Each Aiis called a block of the partition. CS173Equivalence Classes So S is the union of disjoint equivalence classes of relation R. A partition of a set S is a (perhaps infinite…or uncountably infinite) collection of sets {Ai} with • Each Ai non-empty • Each Ai S • For all i, j, Ai Aj = • S = Ai Cs173 - Spring 2004
CS173Equivalence Classes Give me a partition of the reals into 2 blocks: Give me a partition of the reals into 5 blocks: Cs173 - Spring 2004
Partition of, equivalence relation on Subset of, equivalence class of Relation on, partition of Equivalence relation on, partition of I have no clue. CS173Equivalence Classes Theorem: if R is a _____ S, then {[a]R : a S} is a _____ S. Theorem: if R is an equivalence relation on S, then {[a]R : a S} is a partition of S. Proof: we need to show that an equivalence relation R satisfies the definition of a partition. (we’ve spent the whole day doing this!) Cs173 - Spring 2004
CS173Equivalence Classes Theorem: if {Ai} is any partition of S, then there exists an equivalence relation R, whose equivalence classes are exactly the blocks Ai. Proof If {Ai} partitions S then define relation R on S to be R = {(a,b) : i, a Ai and b Ai} Next show that R is an equivalence relation. Reflexive and symmetric. Transitive? Suppose aRb and bRc. Then a and b are in Ai, and b and c are in Aj. But b Ai Aj, so Ai = Aj. So, a, b, c Ai, thus aRc. Cs173 - Spring 2004
a a for any real If a b, b c then a c If a b, b a then a = b = order < Actually total order. CS173Partially Ordered Sets (POSets) Let R be a relation then R is a Partially Ordered Set (POSet) if it is • Reflexive - aRa, a • Transitive - aRb bRc aRc, a,b,c • Antisymmetric - aRb bRa a=b, a,b Ex. (R,), the relation “” on the real numbers, is a partial order. Reflexive? How do you check? Transitive? Antisymmetric? Cs173 - Spring 2004
Yes, or No? Yes, x|x since x=1x (k=1) a|b means b=ak, b|c means c=bj. Does c=am for some m? c = bj = akj (m=kj) a|b means b=ak, b|a means a=bj. But b = bjk (subst) only if jk=1. jk=1 means j=k=1, and we have b=a1, or b=a CS173Partially Ordered Sets (POSets) Ex. (Z+, | ), the relation “divides” on positive integers. Reflexive? Transitive? Antisymmetric? Cs173 - Spring 2004
3|-3, and -3|3, but 3 -3. Yes, or No? Yes, x|x since x=1x (k=1) a|b means b=ak, b|c means c=bj. Does c=am for some m? c = bj = akj (m=kj) Not a poset. CS173Partially Ordered Sets (POSets) Ex. (Z, | ), the relation “divides” on integers. Reflexive? Transitive? Antisymmetric? Cs173 - Spring 2004
A B, B A A=B Now take an x, and suppose it’s in A. Must it also be in C? Yes, A A, A 2S A B, B C. Does that mean A C? A B means x A x B B C means x B x C Yes, by… Modus Ponens Modus Tollens DeMorgan’s Transitivity Yes, by MP A poset. CS173Partially Ordered Sets (POSets) Ex. (2S, ), the relation “subset” on set of all subsets of S. Reflexive? Transitive? Antisymmetric? Cs173 - Spring 2004
CS173Partially Ordered Sets (POSets) When we don’t have a special relation definition in mind, we use the symbol “” to denote a partial order on a set. When we know we’re talking about a partial order, we’ll write “a b” instead of “aRb” when discussing members of the relation. We will also write “a < b” if a b and a b. Cs173 - Spring 2004
0110 1000 0110 0000 0110 1110 0110 10111 Huh? CS173Partially Ordered Sets (POSets) Ex. A common partial order on bit strings of length n, {0,1}n, is defined as: a1a2…an b1b2…bn If and only if ai bi, i. 0110 and 1000 are “incomparable” … We can’t tell which is “bigger.” As a bit of an aside, this relation is exactly the same as the last example, (2S, ). Set S, on which we build 2S, has a size. That’s n. Suppose S is {a,b}. Then 2S = { {}, {a}, {b}, {a,b} } Think of bit strings as membership indicators for the elts of S Then 2S can be represented by {00,10,01,11} Cs173 - Spring 2004
In the string relation, we said 0001 because every bit in 00 is less than or = the corresp bit in 01. String on the right has at least all the 1 bits of the left, maybe more. If each 1 represents an element in S, then right side has all elts of the left, maybe more. CS173Partially Ordered Sets (POSets) 0110 and 1000 are “incomparable” … We can’t tell which is “bigger.” As a bit of an aside, this relation is exactly the same as the last example, (2S, ). Set S, on which we build 2S, has a size. That’s n. Suppose S is {a,b}. Then 2S = { {}, {a}, {b}, {a,b} } Think of bit strings as membership indicators for the elts of S Then 2S can be represented by {00,10,01,11} Cs173 - Spring 2004
Dictionary order, or alphabetic order, or lexicographic order is a partial order on words in the english language. This idea can be generalized to strings over any alphabet. CS173Partially Ordered Sets (POSets) Let (S, ) be a PO. If a b, or b a, then a and b are comparable. Otherwise, they are incomparable. Ex. In poset (Z+, |), 3 and 6 are comparable, 6 and 3 are comparable, 3 and 5 are not, 8 and 12 are not. A total order is a partial order where every pair of elements is comparable. Ex. (Z+, ), is a total order, because for every pair (a,b) in ZxZ, either a b, or b a. Cs173 - Spring 2004
4 3 2 Draw edge (a,b) if a b Don’t draw up arrows Don’t draw self loops Don’t draw transitive edges 1 CS173Hasse Diagrams Hasse diagrams are a special kind of graphs used to describe posets. Ex. In poset ({1,2,3,4}, ), we can draw the following picture to describe the relation. Cs173 - Spring 2004
{a,b,c} or 111 {a,b} or 110 {a,c} or 101 {b,c} or 011 {a} or 100 {b} or 010 {c} or 001 {} or 000 CS173Hasse Diagrams Have you seen this one before? Cs173 - Spring 2004
CS173Hasse Diagrams Reds are maximal. Blues are minimal. Consider this poset: Cs173 - Spring 2004
Did you get it right? Intuition: If a is maxiMAL, then no one beats a. If a is maxiMUM, a beats everything. Must minimum and maximum exist? Only if set is finite. No. Only if set is transitive. Yes. CS173Hasse Diagrams Definition: In a poset S, an element z is a minimum element if bS, zb. Write the defn of maximum! Cs173 - Spring 2004
CS173Hasse Diagrams Theorem: In every poset, if the maximum element exists, it is unique. Similarly for minimum. Proof: Suppose there are two maximum elements, a1 and a2, with a1a2. Then a1 a2, and a2a1, by defn of maximum. So a1=a2, a contradiction. Thus, our supposition was incorrect, and the maximum element, if it exists, is unique. Similar proof for minimum. Cs173 - Spring 2004
CS173Upper and Lower Bounds Defn: Let (S, ) be a partial order. If AS, then an upper bound for A is any element x S (perhaps in A also) such that a A, a x. A lower bound for A is any x S such that a A, a x. Ex. The upper bound of {g,j} is a. Why not b? a b c d e f j h g i Cs173 - Spring 2004
{a, b} has no UB. CS173Upper and Lower Bounds Defn: Let (S, ) be a partial order. If AS, then an upper bound for A is any element x S (perhaps in A also) such that a A, a x. A lower bound for A is any x S such that a A, a x. Ex. The upper bound of {g,j} is a. Why not b? a b Ex. The upper bounds of {g,i} is/are… A. I have no clue. B. c and e C. a D. a, c, and e c d e f j h g i Cs173 - Spring 2004
{g, h, i, j} has no LB. CS173Upper and Lower Bounds Defn: Let (S, ) be a partial order. If AS, then an upper bound for A is any element x S (perhaps in A also) such that a A, a x. A lower bound for A is any x S such that a A, a x. Ex. The lower bounds of {a,b} are d, f, i, and j. a b Ex. The lower bounds of {c,d} is/are… A. I have no clue. B. f, i C. j, i, g, h D. e, f, j c d e f j h g i Cs173 - Spring 2004
CS173Upper and Lower Bounds Defn: Given poset (S, ) and AS, x S is a leastupper bound (LUB) for A if x is an upper bound and for upper bound y of A, y x. x is a greatestlower bound for A if x is a lower bound and if x y for every UB y of A. a b Ex. LUB of {i,j} = d. Ex. GLB of {g,j} is… A. I have no clue. B. a C. non-existent D. e, f, j c d e f j h g i Cs173 - Spring 2004
This is because c and d are incomparable. CS173Upper and Lower Bounds Ex. In the following poset, c and d are lower bounds for {a,b}, but there is no GLB. Similarly, a and b are upper bounds for {c,d}, but there is no LUB. a b c d Cs173 - Spring 2004
shoes belt jacket socks jeans swter jwlry In what order will you get dressed while respecting constraints? uwear shirt CS173Total Orders Consider the problem of getting dressed. Precedence constraints are modeled by a poset in which a b iff you must put on a before b. Let (S, ) be a poset (S finite). We will extend to a total order on S, so we can decide for all incomparable pairs whether to make a b, or vice versa w/o violating T,R,A. Cs173 - Spring 2004
shoes belt jacket socks jeans swter jwlry NOT A REAL PROOF! Should use induction!! uwear shirt CS173Total Orders Things we need: Lemma: Every finite non-empty poset (S, ) has at least one minimal element. Proof: choose a0 S. If a0 was not minimal, then there exists a1 a0, and so on until a minimal element is found. Cs173 - Spring 2004
shoes belt jacket socks jeans swter jwlry uwear shirt CS173Total Orders More things we need: Lemma: If (S, ) is a poset with a minimal, then (S-{a}, ) is also a poset. Proof: If you remove minimal a reflexivity and antisymmetry still hold. If x,y,z S-{a}, with x y and y z, then x z too, since (S, ) was transitive. Cs173 - Spring 2004
shoes belt jacket socks jeans swter jwlry Depending on which min elt is chosen each time, a different total order is obtained, but all TOs will be consistent with the PO. uwear shirt CS173Total Orders Think about what this means: • There is always a minimal element. • If you remove it you still have a poset. alg Topological Sort Input: poset (S, ) Out: elements of S in total order While S Remove any min elt from S and output it. This suggests: Cs173 - Spring 2004
shoes belt jacket socks jeans swter jwlry uwear shirt t CS173Total Orders alg Topological Sort Input: poset (S, ) Out: elements of S in total order While S Remove any min elt from S and output it. Cs173 - Spring 2004