203L01S16
203L01S16
What mathematics should a CS/CE know and use? Well, Figure 1: Bender helping us remember Discreet != Discrete
much of what we do involves discrete numbers. In fact
as computers slowly take over the world, things that were formally continuous are now discrete.
Computation and a discrete worldview go hand-in-hand. Computer data is discrete (all stored as bits no
matter what the data is). Time on a computer occurs in discrete steps (clock ticks), etc. Because we
work almost solely with discrete values, it makes since that we’d need to know discrete mathematics.
Discrete mathematics is actually a collection of a large number of different types of mathematics all
used when working with discrete data. Some things we are going to cover in this class include:
Logic1 (propositional logic, predicate logic, quantified formulae, logical deductions)
o Architecture (logic gates) My area!
o Software engineering (specification and verification)
o Programming languages (semantics, logic programming)
o Databases (relational algebra and SQL)
o Artificial intelligence (automatic theorem proving)
o Algorithms (complexity and expressiveness)
o Theory of computation (general notions of computability)
Proofs (including the analysis of algorithms)
o Software engineering (verification of correctness)
o Algorithm analysis (showing a task will complete within some time bound (“on time”))
o Parallel systems (proving a protocol will function correctly in all cases)
Asymptotic notation (“Big Oh” and its friends)
o Algorithm design and choice (allows us to reasonable compare algorithms rather than
implementations)
Counting and discrete probability
o Architecture (how caches behave, how branch predictors behave) Still my area!
o Modeling failure in software and hardware
1
List from: http://www.cs.rice.edu/~vardi/comp409/, a 400-level class on logic in CS!
EECS 203 Spring 2016 Lecture 1 Page 2 of 12
So I’ll use this material a lot in future classes (or the real world)?
Some of it you will use a lot. I use logic, counting & discrete probability as well as asymptotic notation
on a regular basis no matter what classes I teach (daily to weekly). I use proof techniques only very
rarely. And honestly, I only use a small fraction of each of these topics. I’d say I use only about 25% of
this class material more than once a year. But each person will use different parts depending on what
they do.
But more so, discrete math gives us the needed language to discuss and solve problems. Let’s consider
two examples2:
What’s really cool is that we can use the same algorithms to solve either of these two problems! And
that’s what this class should bring you. A worldview that lets you quickly see ways to address and solve
problems you’ll encounter as a CS or CE student.
OK, now that’s we’ve got an idea what the class is about, let’s address some administrative issues.
2
Text for Six Degrees of Kevin Bacon comes from the Wikipedia article of the same name.
EECS 203 Spring 2016 Lecture 1 Page 3 of 12
Piazza: http://piazza.com/umich/summer2016/eecs203
GSIs:
Emily Graetz
o Friday discussions
o Office hours:
o Sunday 2-5 in UGLi Basement (middle tables)
o Tuesday 4-6, Wednesday 4-6, Friday 2-5 in 1637 Beyster (learning center).
Jasmine Powell
o Thursday discussion
o Office hours:
o Monday 5-7 in East Hall B723
o Thursday 3-5 in 1637 Beyster (learning center).
Grades:
10% individual homework (7 assignments, drop 1)
o HW1 posted, due Thursday at 3pm!
10% group homework (6 assignments, drop 1, groups of 1 to 3, hard problems, must use LaTeX!)
o Groups can change each assignment if you choose. Only list people that help!
16% quizes (5 quizzes, drop 1, start of lecture, no notes, 15-25 minutes)
29% midterm (May 31st, class time, one
page of notes)
35% final (June 24th at 4pm, two pages of
notes)
Cooperation:
You are welcome to study together,
discussing ideas, etc.
o But individual homework
assignments are to be done
individually!
For group assignments you should only be
working with your group.
\end{administrivia};
\begin{discrete math}
Propositions (1.1)
We spend a lot time proving things in this course. What is a proof?
A formal proof of a proposition is a chain of logical deductions leading to the proposition from a
base set of axioms.
Propositional logic
What is a proposition?
A proposition is a declarative statement that is either true or false.
Logical operators
Say we live in the rather black and white world where we are dealing with propositions. So if S is “Mark
is going to the Store” and C is “Mark likes Computer games” then we’ll assume that each phrase is either
true or false (as opposed only sort of liking computer games). We can then use connectives to combine
the variables.
The above statement is only true if both phrases are true. Let that sentence be X. We can now draw
the “truth table” for X (we’ll use the other tables in a minute). When is X true?
T F F T
s c x T T T F
s c
F F T T
F T _AND_ F F
EECS 203 Spring 2016 Lecture 1 Page 5 of 12
___________ ___________
s c c
F F F
F T T
T F
T T
___________
p AND q
p OR q
NOT p
p XOR q
Compound
Expression in English
Proposition
p “It is not the case that p”
Truth tables
English is often too ambiguous. (It doesn’t clearly distinguish between pq and pq, for instance.) A
truth table is an unambiguous way to show the meaning of a compound proposition. We will use them
a lot. Fill in the following table!
p q p p p p p
q q q q q
T T
T F
F T
F F
Implication
Many people have trouble with pq. In English, saying “p implies q”
suggests that there is a causal connection between p and q. In logic, pq
means the truth table on the right. Thus, 0=1 Brehob is POTUS has truth
value T!
It takes practice to get the right intuitions about pq. One useful
perspective:
Another one: The only way for pq to be false, is for p to be true, and q to be false.
_________________________________________
EECS 203 Spring 2016 Lecture 1 Page 7 of 12
Examples
#1: Let’s How can we express these compound propositions in terms of p, q, r, s?
English Compound proposition
If it rains, I’ll watch a movie and eat popcorn.
#2:
A B S M
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
Write a truth table for the following word problem:
EECS 203 Spring 2016 Lecture 1 Page 8 of 12
Now, can you draw gates for this? Hint: it can be done with 4 gates (2 AND, 1 OR,
1 NOT).
There are a number of ways to simplify this circuit, but one way is using propositional logic
equivalencies. After doing so, you can get this:
• The top (unoptimized) circuit has 10 AND/OR/NOR/NAND gates, 2 XNORS and 1 inverter.
• The bottom circuit has 8 AND/OR/NOR/NAND gates, 1 XOR and 2 inverters.
Later (Wednesday…) we’ll start looking a bit about how to go about proving that the two circuits are
equivalent. But before we jump to that, let’s take a short look at “applications” of propositional logic.
We’ve already looked at logic gates a bit (and we’ll do more today time allowing). But for now I want to
jump to using propositional logic to help solve logic puzzles.
EECS 203 Spring 2016 Lecture 1 Page 10 of
12
Let’s play with some logic problems for a bit, and then
see how we can use propositional logic to help with
them.
The setup
There is this island in the middle of the ocean where
there are two kinds of people: the liars and the truth-
tellers. The liars always lie. Any question you ask them
will be answered with a lie. The truth-tellers always
answer the truth.
Puzzle #1
1. You're walking in this island and you meet two people A and B, from the island
2. A says “B is a truth teller”
3. B says “We are of different types”
4. Which one(s), if any, are liars?
Puzzle #2
1. Suppose that you meet three people A, B and C from the island.
2. You ask A “Are you a liar?”
3. A answers but his voice is drowned out by a clap of thunder.
4. You ask B “What did A say?”
5. B answers, “A said he is a liar”
6. C exclaims, “Don't believe what B said, he's lying”
7. C then adds “Also, A is a liar”
8. Which ones are liars?
1 2 3
Each place has a value. We normally work in base 10, so each place is 10 times bigger than the last.
In binary we work in base 2. Consider the number 100102 (the subscript indicates the base).
1 0 0 1 0
Recall that in digital logic, we treat “T” as “1” and “F” as “0”. Consider a device that adds two one-digit
binary numbers and outputs a 2 digit binary number. Let the inputs be A and B and the output be R[1:0]
(where R[1:0] means R1 concatenated with R0).
A
+ B
====
R1R0
Write the truth table for this adder. R1 is to be the most significant digit (farthest to the left in the 2’s
place in this example) while R0 is to be the least significant digit (farthest to the right, in the 1’s place).
Then draw the logic gates.
A B R1 R0
0 0
0 1
1 0
1 1
The point is that we can use basic logic to do arithmetic. You may say “great, I can add two one-bit
numbers”. But it turns out we can use this basic idea of using logic states to represent numbers to do all
kinds of math. A modern computer can easily do 5-10 billion additions of 64-bit numbers in a second!
All based on this basic idea. In fact, all computers are built around this simple idea that we can use logic
to do arithmetic. i
i
Material for these notes are taken from previous semester’s slides and the text without attribution. Other sources will be
cited in-line. XKCD comics (stick figure comics) taken from xkcd.com per CC BY-NC 2.5 license. It should be clear where
Wikipedia sources come from. Use of Futurama comic claimed as fair use.