Title: CS 173: Discrete Mathematical Structures
1CS 173Discrete Mathematical Structures
- Cinda Heeren
- heeren_at_cs.uiuc.edu
- Siebel Center, rm 2213
- Office Hours W 1230-230
2CS 173 Announcements
- Homework 12 available, due 12/11, 8a.
- Final exam 12/14, 8-11a. Email Cinda with
conflicts. - Review 12/12, 5-6p, SC1404. Additional reviews
will be announced.
3CS173Partially 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 ? ab, ?a,b
Ex. (R,?), the relation ? on the real numbers,
is a partial order.
Reflexive?
How do you check?
Transitive?
Antisymmetric?
4CS173Partially Ordered Sets (POSets)
- Ex. (Z, ), the relation divides on positive
integers.
Reflexive?
Transitive?
Antisymmetric?
5CS173Partially Ordered Sets (POSets)
- Ex. (Z, ), the relation divides on integers.
Reflexive?
Transitive?
Antisymmetric?
6CS173Partially Ordered Sets (POSets)
- Ex. (2S, ? ), the relation subset on set of all
subsets of S.
Reflexive?
Transitive?
Antisymmetric?
7CS173Partially Ordered Sets (POSets)
- When we dont have a special relation definition
in mind, we use the symbol ? to denote a
partial order on a set.
When we know were talking about a partial order,
well write a ? b instead of aRb when
discussing members of the relation.
We will also write a lt b if a ? b and a ? b.
8CS173Partially Ordered Sets (POSets)
- Ex. A common partial order on bit strings of
length n, 0,1n, is defined as - a1a2an ? b1b2bn
- If and only if ai ? bi, ? i.
0110 and 1000 are incomparable We cant 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. Thats
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
9CS173Partially Ordered Sets (POSets)
0110 and 1000 are incomparable We cant 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. Thats
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
10CS173Partially 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.
11CS173Hasse 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.
12CS173Hasse Diagrams
- Have you seen this one before?
13CS173Hasse Diagrams
Reds are maximal. Blues are minimal.
14CS173Hasse Diagrams
- Definition In a poset S, an element z is a
minimum element if ?b?S, z?b.
Write the defn of maximum!
15CS173Hasse 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 a1?a2. Then a1 ? a2, and a2?a1, by
defn of maximum. So a1a2, a contradiction.
Thus, our supposition was incorrect, and the
maximum element, if it exists, is unique.
Similar proof for minimum.
16CS173Upper and Lower Bounds
- Defn Let (S, ?) be a partial order. If A?S,
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
f
e
j
h
i
g
17CS173Upper and Lower Bounds
- Defn Let (S, ?) be a partial order. If A?S,
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
f
e
j
h
i
g
18CS173Upper and Lower Bounds
- Defn Let (S, ?) be a partial order. If A?S,
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
f
e
j
h
i
g
19CS173Upper and Lower Bounds
- Defn Given poset (S, ?) and A?S, x ? S is a
least upper bound (LUB) for A if x is an upper
bound and for upper bound y of A, y ? x.
x is a greatest lower 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
f
e
j
h
i
g
20CS173Upper 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
21CS173Total 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.
22CS173Total Orders
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.
23CS173Total Orders
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.
24CS173Total 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
25CS173Total 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.
26CS173Graphs
Suppose YOU are the person in charge of
scheduling finals. Conflict exams are not
allowedthat is, no student can have two exams
scheduled for any one time. How many exam
periods do you need?
Suppose I give you a graph consisting of vertices
and edges. Your task is to label the vertices
with colors. Vertices which share an edge cannot
be colored the same. How many colors do you need?
27CS173Graphs
- Graphs are a very general way of representing
data. We can use graphs to model things as
diverse as - Scheduling problems
- Routes for travelling between cities
- Connections between atoms in a molecule
- Paths that messages can take in a network
- Dependence relations between events in a large
project
28CS173Graphs
29CS173Graphs
- Definitions you should understand
- Vertex
- Edge
- Weights
- Degree
- Neighbors
- Connected
- Complete
- Bipartite
- Planar
- Cycle
- Tree
- Path
- Circuit
30CS173Graphs
- A real estate agent wishes to give a tour of this
house, starting and ending outside, and going
through each door exactly once. - Can she do it?
31CS173Graphs
- Model the floor plan as a graph.
A
B
C
D
E
32CS173Graphs
- An equivalent question is Can we traverse the
graph, visiting each edge exactly once?
A
B
C
D
E
outside
33CS173Graphs
- A connected graph contains an Eulerian Circuit if
and only if every vertex has even degree. - A connected graph contains an Eulerian Path if
and only if exactly 2 vertices have odd degree.
34CS173Graphs
- Pick a vertex and attempt to find the Eulerian
Cycle...
35CS173Graphs
- The algorithm
- Pick a vertex u.
- Follow any edge from u to another vertex v.
- Travel from v to any other vertex. (This is
possible because all vertices have even degree.) - Continue forging a path until vertex u is reached
again. - If all edges are on the path, quit. Otherwise,
pick any vertex u on the current path, and
repeat the process to return to u, and then
splice the new route into the path. - Do this until all edges are included in the path.
36CS173Graphs
- Quiz time
- Which graphs have an Eulerian Circuit?
37CS173Graphs
- Quiz time
- Which graphs have an Eulerian Path?
38CS173Graphs
- Suppose you live in an itty bitty town, where
none of the streets are paved. Your community
WANTS to build a swimming pool, but they MUST
perform some road upgrades, and the budget is
limited. - The road committee has decided that its
important for a paved path to exist between every
pair of houses in the town. - A swimming pool will cost 1 million. The cost
of paving each stretch of road is given in the
graph below (10k). - Given these constraints, the graph, and a budget
of 1.4 million, can you upgrade the roads AND
build a swimming pool?
5
9
39CS173Graphs
- The road committee has decided that its
important for a paved path to exist between every
pair of houses in the town. Which ones should we
pave in order to minimize cost?
1
4
a
b
c
6
12
5
7
14
11
d
e
f
9
3
8
13
10
2
g
h
i
40CS173Graphs
1
4
a
b
c
6
12
5
7
14
11
d
e
f
9
3
8
13
10
2
g
h
i
41CS173Graphs
- Official name for the structure you created
- Minimal cost spanning tree
1
4
a
b
c
6
12
5
7
14
11
d
e
f
9
3
8
13
10
2
g
h
i
42CS173Graphs