CPSC 121: Models of Computation 2018S
Propositional Logic: A First Model of Computation Meghan Allen, based on notes by Steve Wolfman, Patrice Belleville and others
1
This work is licensed under a Creative Commons Attribution 3.0 Unported License.
CPSC 121: Models of Computation 2018S Propositional Logic: A First - - PowerPoint PPT Presentation
CPSC 121: Models of Computation 2018S Propositional Logic: A First Model of Computation Meghan Allen, based on notes by Steve Wolfman, Patrice Belleville and others 1 This work is licensed under a Creative Commons Attribution 3.0 Unported
Propositional Logic: A First Model of Computation Meghan Allen, based on notes by Steve Wolfman, Patrice Belleville and others
1
This work is licensed under a Creative Commons Attribution 3.0 Unported License.
2
3
4
How should you achieve pre-class goals? Use the quiz to guide your readings!
5
is flipped, the result will always result in the light turning on” [not quite what we intended]
from left to right”
(~x ^ y ^ ~z) v (~x ^ ~y ^ z)”
parts [switches] of the circuit”
at the same, but they can both be off. By working out the truth table, it proofs to be correct.”
6
Compare these two responses I'm not sure I understand the question...how does a logic circuit diagram connect to an electrical circuit? I understand this question but i dont know how to write it in terms of this circuit and logic stuff
7
Somewhere between these is the “marked for completeness line”. (The left one gets credit; the right does not.) At minimum: give the question a shot or ask a meaningful question in return!
8
But… follow the quiz collaboration guidelines. Closed-ended part: work alone (but open book). Open-ended part: work with anyone (but acknowledge).
Theory How do we model computational systems? Now: learning the underpinning of all our models (formal logical reasoning with Boolean values). Hardware How do we build devices to compute? Now: establishing
(gates), briefly justifying these as baselines, and designing complex functions from gates.
9
10
11
12
Input a Input b a b ~a a 5V 0V
http://alumni.media.mit.edu/~paulo/courses /howmake/mlfabfinalproject.htm
a b
Physical System “Truth Table” model
a b a b T T T T F T F T T F F F
We think of “flowing water” as true and “no water” as false, and the physical world becomes an effective representation for our ideas! Propositional logic model:
a b means “a OR b”
Circuit diagram model: the “OR” gate
14
Problem: Design a circuit to control a light so that the light changes state any time its switch is flipped.
15
The problem gives the story we have to implement. Be sure you understand the story and always keep it in mind!
Problem: Design a circuit to control a light so that the light changes state any time its switch is flipped.
16
Identifying inputs/outputs: consider these possible inputs and outputs: Input: the switch flipped or the switch is up Output: the light is shining or the light changed states Which are most useful for this problem?
Problem: Design a circuit to control a light so that the light changes state any time its switch is flipped.
17
Consider these possible solutions: Which of these solves the problem?
18
19
Getting the Story Right: Is the light on or off when both switches are up? a. On, in every correct solution. b. Off, in every correct solution. c. It depends, but a correct solution should always do the same thing given the same settings for the switches. d. It depends, and a correct solution might do different things at different times with the same switch settings. e. Neither on nor off.
20
Which of these circuits solves the problem?
21
22
Fill in the circuit’s truth table:
s1 s2 s3 T T T T T F T F T T F F F T T F T F F F T F F F
a. b. c. d. e.
T F F T F T T F
F T T F T F F T
F T F T F T F T
T F T F T F T F
None
these
23
Getting the Story Right: Which of these is enough alone to always know whether the light is on or off? a. Whether an odd number of switches is on. b. Whether the majority (two or more) of switches are on. c. Whether all the switches are on. d. Whether a switch has been flipped recently. e. None of these.
24
Modelling the Circuit: Which of these describes an incorrect solution? a. (s1 s2 s3) (s1 ~s2 ~s3) (~s1 s2 ~s3) (~s1 ~s2 s3) b. s1 s2 s3 (s1 s2 s3) c. s1 (s2 s3) d. (s1 ~(s2 s3)) (~s1 (s2 s3)) e. None of these is incorrect.
25
26
Understanding the story: How many inputs to our circuit are there?
27
28
How many different input wires does the circuit have?
29
A bit like a parameter like in CPSC 110, but we only get 1/0 parameters (Booleans).
How many different messages (values) must the circuit understand?
30
# a b c F F F 1 F F T 2 F T F 3 F T T 4 T F F 5 T F T 6 T T F 7 T T T
Of course, as Epp says, we could agree on a different convention.
31
This is the convention we use for the positive integers 0‐9, which requires (at least) 4 variables:
Notice the order: Fs first.
# a b c d F F F F 1 F F F T 2 F F T F 3 F F T T 4 F T F F 5 F T F T 6 F T T F 7 F T T T 8 T F F F 9 T F F T ...
32
Understanding the story: How many outputs from our circuit are there?
33
BEFORE we answer it: Is that a good question?
34
35
# a b c d F F F F 1 F F F T 2 F F T F 3 F F T T 4 F T F F 5 F T F T 6 F T T F 7 F T T T 8 T F F F 9 T F F T
F T F T F T F T F T
a. b. c. d.
these.
2 6 8
T F T F F F T F T F
F T F T T T F T F T
36
# a b c d out F F F F 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
37
(??) (??) (??) (??) See Epp (4th ed) Example 2.4.5! (3rd ed Example 1.4.5) Let’s try one!
# a b c d out F F F F 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
38
Which logical statement is true
# a b c d out F F F F 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
39
(~a ~b ~c ~d) (~a ~b c ~d) (~a b c ~d) ( a ~b ~c ~d)
# a b c d
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
40
# a b c d
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
41
42
43
44
45
a b c d
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
46
47
48
49
– 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: given (u s) s, apply p q ~p q. Note: p maps to (u s) and q maps to s. Result: ~(u s) s
50
51
60
Here are some assignment/exam‐like practice problems related to this lecture’s in‐class learning goals. Give them a shot!
61
Design a representation (for a digital logic circuit) for the state of a stop light. Design a circuit that takes the current states of a stop light and produces the next state. Design a circuit that takes the current states of two stop lights and produces true if they are “safe in combination” and false otherwise. (By “in combination” we mean that one of the states is the state of the lights along one road at an intersection and the other is the state of the lights along the perpendicular road.
62
63
The switch problems might give you a hint.
1 2 3 4 5 6 7 8 9
64
65
66
67
68