Propositional Logic and Circuits, Part 2

advertisement
snick
∨
snack
Outline
• Learning Goals
• Problems and Discussion
CPSC 121: Models of Computation
2011 Winter Term 1
– Side note: numbers from Booleans
• Expressiveness of Propositional Logic
• Next Lecture Notes
Propositional Logic, Continued
Steve Wolfman, based on notes by Patrice
Belleville and others
2
1
Where We Are in
The Big Stories
Learning Goals: In-Class
By the end of this unit, you should be able
to:
– Build combinational computational systems
using propositional logic expressions and
equivalent digital logic circuits that solve real
problems, e.g., our 7- or 4-segment LED
displays (using a “DNF” or any other
successful approach).
Theory
How do we model
computational systems?
Hardware
How do we build devices to
compute?
Now: learning the
underpinnings of all our
models (formal logical
reasoning with Boolean
values).
Now: establishing
our baseline tool
(gates), briefly
justifying these as
baselines, and
designing complex
functions from gates.
3
4
Problem:
7-Segment LED Display
Outline
• Learning Goals
• Problems and Discussion
Problem: Design a circuit that displays the
numbers 0 through 9 using seven LEDs
(lights) in the shape illustrated above.
– Side note: numbers from Booleans
• Expressiveness of Propositional Logic
• Next Lecture Notes
5
6
Problem:
7-Segment LED Display
Problem:
7-Segment LED Display
Problem: Design a circuit that displays the
numbers 0 through 9 using seven LEDs
(lights) in the shape illustrated above.
Problem: Design a circuit that displays the
numbers 0 through 9 using seven LEDs
(lights) in the shape illustrated above.
Understanding the story: How many inputs are there?
a.
b.
c.
d.
e.
First: what’s the circuit’s job?
One
Seven
Ten
Sixteen
None of these
7
8
Problem:
7-Segment LED Display
Problem: Design a circuit that displays the
numbers 0 through 9 using seven LEDs
(lights) in the shape illustrated above.
Now, a new question: How many input symbols are there?
(How many different messages must the circuit understand?)
a.
b.
c.
d.
e.
One
Seven
Ten
Sixteen
None of these
(This is not the intended question when
9
we ask: “how many inputs are there”.)
Side Note:
Truth Tables and Numbers
If we agree on a convention for the rows of a
truth table, we can assign a number to
#
a
b
c
each rowB
Problem:
7-Segment LED Display
Problem: Design a circuit that displays the
numbers 0 through 9 using seven LEDs
(lights) in the shape illustrated above.
How many input “lines” are there?
(How many different sources of input carry those messages?)
a.
b.
c.
d.
e.
One
Seven
Ten
Sixteen
None of these
10
Representing Positive Integers
This is the convention we use for the positive integers
0-9, which requires (at least) 4 variables:
#
a
b
c
d
0
F
F
F
F
0
F
F
F
1
F
F
F
T
1
F
F
T
2
F
F
T
F
2
F
T
F
3
F
F
T
T
3
F
T
T
4
F
T
F
F
4
T
F
F
5
F
T
F
T
5
T
F
T
6
F
T
T
F
6
T
T
F
7
F
T
T
T
7
T
T
T
8
T
F
F
F
9
T
F
F
T
Of course, as Epp says, we could
11
agree on a different convention.
...
12
Notice the order: Fs first.
Problem:
7-Segment LED Display
Exercise:
Human Circuit
Problem: Design a circuit that displays the
numbers 0 through 9 using seven LEDs
(lights) in the shape illustrated above.
Let’s simulate the display with people.
Understanding the story: How many outputs are there?
a.
b.
c.
d.
e.
One
Seven
Ten
Sixteen
None of these
If you’re not at the front,
pick one person and
think about what their
algorithm is.
13
14
Exercise:
Human Circuit
Analyzing One Segment
What’s the truth table for the lower-left segment?
Which other people’s algorithms does your
person need to know about?
a. No one else’s
b. Only their neighbours’
c. Everyone else’s
d. Some other group
15
a.
b.
c.
d.
#
a
b
c
d
out
out
out
out
0
F
F
F
F
F
0
T
F
1
F
F
F
T
T
2
F
T
2
F
F
T
F
F
6
T
F
3
F
F
T
T
T
8
F
T
4
F
T
F
F
F
F
T
5
F
T
F
T
T
F
T
6
F
T
T
F
F
T
F
7
F
T
T
T
T
F
T
8
T
F
F
F
F
T
F
9
T
F
F
T
T
F
T
From the truth table, we can make an expression
for each true row and OR them together.
Let’s try another LED: the upper-right.
With eight Ts, we’d need eight expressions!
# a b c d out
T
1 F F F T
F
2 F F T F
T
3 F F T T
F
4 F T F F
F
5 F T F T
F
6 F T T F
T
7 F T T T
F
8 T F F F
T
9 T F F T
F
(~a ∧ ~b ∧ ~c ∧ ~d) ∨
(~a ∧ ~b ∧ c ∧ ~d) ∨
(~a ∧ b ∧ c ∧ ~d) ∨
( a ∧ ~b ∧ ~c ∧ ~d)
See Epp Example 1.4.5!
(4th ed number coming soon!)
16
Designing the Expression
with Many Ts
Analyzing One Segment
0 F F F F
e. None of
these.
17
#
a
b
c
d
out
0
F
F
F
F
T
1
F
F
F
T
T
2
F
F
T
F
T
3
F
F
T
T
T
4
F
T
F
F
T
5
F
T
F
T
F
6
F
T
T
F
F
7
F
T
T
T
T
8
T
F
F
F
T
9
T
F
F
T
T
Too bad we can’t
model Fs rather
than Ts!
18
Designing the Expression
with Many Ts
Problem:
7-Segment LED Display
We can by negating statement we construct!
(Instead of building out, we build ~out and
# a b c
d out
then negate it.)
0
F
F
F
F
T
1
F
F
F
T
T
2
F
F
T
F
T
3
F
F
T
T
T
4
F
T
F
F
T
5
F
T
F
T
F
6
F
T
T
F
F
7
F
T
T
T
T
8
T
F
F
F
T
9
T
F
F
T
T
Which of these correctly models the LED?
a. ~(~a ∧ b ∧ ~c ∧ d) ∨ ~(~a ∧ b ∧ c ∧ ~d)
b. ~(a ∧ ~b ∧ c ∧ ~d) ∨ ~(a ∧ ~b ∧ ~c ∧ d)
c. ~[(~a ∧ b ∧ ~c ∧ d) ∨ (~a ∧ b ∧ c ∧ ~d)]
d. ~[(a ∧ ~b ∧ c ∧ ~d) ∨ (a ∧ ~b ∧ ~c ∧ d)]
e. None of these
Problem: Design the seven LED display circuit.
Approach: Solve each of the seven outputs
separately and put the whole thing together.
Here’s the two LEDs we’ve solved, simplified:
19
PRACTICE Exercise
for Logical Equivalences
20
PRACTICE Exercise
for Circuit Design
Prove that our solution for the upper-right LED is
logically equivalent to the corresponding circuit
on the previous slide.
Prove that our solution for the lower-left LED is not
logically equivalent to the corresponding circuit
on the previous slide, and explain why not.
Finish the problem!
Note: to disprove a logical equivalence, you must
give truth values for the inputs that yield different
outputs.
22
21
Concept Q: 7-Segment LED
Outline
Imagine we were solving for one LED in a display for
“Brahmi” numerals. Which of these would never
make our problem harder?
a. More entries in the LED’s column of the truth
table that are true (turn some Fs into Ts).
b. Fewer entries in the LED’s column of the truth
table that are true (turn some Ts into Fs).
c. More legal input values (e.g., 0-15 instead of 0-9).
d. Fewer legal input values (e.g., 0-4 instead of 0-9).
e. All of these could make the problem harder.
23
• Prereqs, Learning Goals, and Quiz Notes
• Problems and Discussion
– Side note: numbers from Booleans
• Expressiveness of Propositional Logic
• Next Lecture Notes
24
Homework Problem: Expressiveness
of Propositional Logic
Problem: Is propositional logic (and
combinational circuits) universal for
Boolean functions—able to implement a
truth table with any number of columns
and list of T and F in the output?
a
b
c
d
out
F
F
F
F
F
F
F
F
T
T
F
F
T
F
T
F
F
T
T
F
F
T
F
F
T
...
Homework Problem: Expressiveness
of Propositional Logic
Problem: Is propositional logic universal for
Boolean functions?
You’ll prove this with an algorithm to turn
any truth table into a corresponding
propositional logic statement.
Universality is a pretty cool result for our
very first model!
?
25
Outline
26
Learning Goals: In-Class
• Prereqs, Learning Goals, and Quiz Notes
• Problems and Discussion
By the end of this unit, you should be able
to:
– Build combinational computational systems
using propositional logic expressions and
equivalent digital logic circuits that solve real
problems, e.g., our 7- or 4-segment LED
displays.
– Side note: numbers from Booleans
• Expressiveness of Propositional Logic
• Next Lecture Notes
28
27
Next Lecture Learning Goals:
Pre-Class
By the start of class, you should be able to:
– Translate back and forth between simple natural
language statements and propositional logic, now
with conditionals and biconditionals.
– Evaluate the truth of propositional logical
statements that include conditionals and
biconditionals using truth tables.
– Given a propositional logic statement and an
equivalence rule, apply the rule to create an
equivalent statement.
Example:
Note:
Result:
given (u ∧ s) → s, apply p → q ≡ ~p ∨ q.
p maps to (u ∧ s) and q maps to s.
29
~(u ∧ s) ∨ s
Next Lecture Prerequisites
Reread Sections 1.1 and 1.4 (3rd ed) or 2.1
and 2.4 (4th ed).
Read Section 1.2 (3rd ed) or 2.2 (4th ed).
Complete the open-book, untimed quiz on
Vista that’s due before the next class.
30
snick
∨
snack
Problem:
4-Segment LED Display
Problem: build a circuit that displays the
numbers 1 through 9 represented by four
Boolean values p, q, r, and s on a 4segment Boolean display.
Some Things to Try...
(on your own if you have time,
not required)
1
2
6
3
7
4
8
5
9
31
Problem:
One-Bit Addition
32
Problem: Updating the “PC”
Problem: build a circuit that takes three
one-bit numbers as input and outputs their
sum as a two-bit number.
Problem: Create logic that calculates the
amount to increase the PC by, given the
values NeedValC and NeedRegIDs.
33
Problem: Updating the “PC”
34
Concept Q: Fetch Logic
What’s the minimum number of Boolean
outputs necessary for this circuit?
a. 1
b. 2
c. 3
d. 4
e. Cannot be determined from the
information given.
35
36
Download