Presentation is loading. Please wait.

Presentation is loading. Please wait.

Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Propositional Logic: Conditionals and Logical Equivalence Steve Wolfman, based on notes.

Similar presentations


Presentation on theme: "Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Propositional Logic: Conditionals and Logical Equivalence Steve Wolfman, based on notes."— Presentation transcript:

1 snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Propositional Logic: Conditionals and Logical Equivalence Steve Wolfman, based on notes by Patrice Belleville and others

2 Lecture Prerequisites Reread Sections 1.1 and 1.4. Read Section 1.2. Solve problems like Exercise Set 1.1, #19- 29, and 39-46; Set 1.2, #5-15, 20, 22, and 38-46; and Set 1.4, #26-32. Complete the open-book, untimed quiz on WebCT that was due before class.

3 Learning Goals: Pre-Class By the start of class, you should be able to: –Translate back and forth between simple natural language statements and proposition 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

4 Learning Goals: In-Class By the end of this unit, you should be able to: –Explore alternate forms of propositional logic statements by application of equivalence rules, especially in order to simplify complex statements or massage statements into a desired form. Note: in this learning goal, we are not asking you to memorize the equivalence rules or their names! However, as you become familiar with them, you’ll find that your exploration is easier and more effective.

5 Learning Goals: Bonus We will also revisit the previous goal: –Evaluate propositional logic as a “model of computation” for combinational circuits, including at least one explicit shortfall (e.g., referencing gate delays, fan-out, transistor count, wire length, instabilities, shared sub- circuits, etc.).

6 Quiz 2 Notes: Circuits for 7-seg LED What is the question asking? What is logical equivalence? When is a circuit “correct”? When should the light come on? Can an input be “disconnected”? Consider translating into prop logic (our model!). Approaches people tried: Try some values with the circuits and see if they’re correct (and have the same output) Explore equivalences. Find the intended formula and compare. Compare how “easy” or “often” the LED comes on.

7 RECALL: Problem: 4-Segment LED Display Problem: Build a circuit that displays the numbers 1 through 9 represented by four Boolean values a, b, c, and d on a 4- segment Boolean display. 12345 6789

8 RECALL: Representing Positive Integers This is the convention we (and computers) use for positive integers (up to 9): #abcd 0FFFF 1FFFT 2FFTF 3FFTT 4FTFF 5FTFT 6FTTF 7FTTT #abcd 8TFFF 9TFFT

9 Problem: Equivalent Circuits Problem: Here are four circuits to drive the top LED in the 4-segment display (assuming our 4-bit input is “abcd”). Which are correct? Which are equivalent to each other? 1.(~a  b)  (a  ~b  ~c) 2.(~a  b)  a 3.a  b 4.a  b

10 Concept Q: 4-Segment LED How many of the logic statement “circuits” are correct? a.0 b.1 c.2 d.3 e.4

11 Concept Q: 4-Segment LED How many “equivalence classes” are there? a.0 b.1 c.2 d.3 e.4 An “equivalence class” is a set whose members are all equivalent to each other and not to anything else in the “universe”. In our case, “equivalent” means two circuits’ propositional logic representations are logically equivalent, and “universe” means the four circuits in the problem. If we make it to relations at the end of the term, we’ll talk more about equivalence classes!

12 Problem: Arbitrary Logic Expression Problem: Aliens hold the Earth hostage, and only you can save it by proving (a  b)  ~(b  a)  ~a  b. Isn’t it amazing how well-motivated all our problems are? Reminder (p. 20 of Epp, 3d ed.): p  q  ~p  q

13 Concept Q: Alien Threat Which of these leads to a correct solution? a.Take the simpler side and massage it to look like the more complex side. b.Take the more complex side and massage it to look like the simpler side. c.Take both sides and work toward a common statement. d.Write the truth table. e.None of these.

14 How To Format A Proof Our proofs won’t always be as neat and clean as equivalence proofs, but good habits can help in communicating your intent. So: 1.Start a proof by stating the theorem to be proven: “Theorem: (a  b)  ~(b  a)  ~a  b” 2.Number each step of the proof. 3.In each step, include the “data” for the step (e.g., the statement so far in an equiv proof) and the “justification” (e.g., the rule by which the current data follows from the previous step’s data). 4.End your proof by proving the theorem!

15 Problem: “Multiplexer” Problem: Devise a simple circuit that, given two normal inputs ( a and b ) and a control signal (c), produces one input when the control signal is 1 and the other when the control is 0. Start from the truth-table- derived formula on the right. (~c  ~b  a)  (~c  b  a)  (c  b  ~a)  (c  b  a) This circuit is called a multiplexer. a b y c 0 1

16 Concept Q: Multiplexer Which of these equivalence rules is the lynchpin of your simplification? a.p  ~~p (Double Negation) b.p  p  p; p  p  p (Idempotent) c.p  (p  q)  p; p  (p  q)  p (Absorption) d.~(p  q)  ~p  ~q; ~(p  q)  ~p  ~q (De Morgan’s) e.None of these

17 Problem: Glitch in MUX Design Problem: Consider this solution for the multiplexer (MUX) circuit. Imagine the circuit is in steady-state with a, b, and c all 1 (true). Trace how changes flow when we change c to 0, if each gate takes 10ns to operate.

18 Concept Q: First MUX Circuit Assume the output starts at 1. We want it to end up at 1. How long does it take before it’s stable? (Choose the best answer.) a.0 ns (it never varies from 1) b.10 ns (it varies before 10ns, but not after) c.20 ns d.30 ns e.40 ns

19 Other Glitches in MUX? The mux has a glitch because the information from c travels down two paths to the output that have different delays. So, while waiting for the longer path to “catch up” the circuit can be incorrect. Can changing a (while holding b and c constant) cause a glitch? What about b ? If a and b are held constant and one of them is 0, can changing c cause a glitch?

20 A Glitchless MUX Our only glitch (when one input is changed at a time) is when c changes while a and b are both 1. What is the intended output if both a and b are one? Is this question answerable, or do you need more information?

21 Problem: Logical Correctness of the Glitchless MUX This circuit takes advantage of what we’ve discovered. Problem: Prove that it’s logically equivalent to the original MUX. Hint: break a  b up into two cases, where c is true and where c is false: a  b  c and a  b  ~c.

22 Concept Q: Second MUX Circuit Which of these equivalence rules is the lynchpin of your simplification? a.p  ~~p (Double Negation) b.p  p  p; p  p  p (Idempotent) c.p  (p  q)  p; p  (p  q)  p (Absorption) d.~(p  q)  ~p  ~q; ~(p  q)  ~p  ~q (De Morgan’s) e.None of these Problem: prove that (~c  a)  (c  b)  (a  b)  (~c  a)  (c  b)

23 Learning Goals: In-Class By the end of this unit, you should be able to: –Explore alternate forms of propositional logic statements by application of equivalence rules, especially in order to simplify complex statements or massage statements into a desired form. Note: in this learning goal, we are not asking you to memorize the equivalence rules or their names! However, as you become familiar with them, you’ll find that your exploration is easier and more effective.

24 Learning Goals: Bonus We will also revisit the previous goal: –Evaluate propositional logic as a “model of computation” for combinational circuits, including at least one explicit shortfall (e.g., referencing gate delays, fan-out, transistor count, wire length, instabilities, shared sub- circuits, etc.).

25 Next Lecture Learning Goals: Pre-Class By the start of class, you should be able to: –Convert positive numbers from decimal to binary and back. –Convert positive numbers from hexadecimal to binary and back. –Take the two’s complement of a binary number. –Convert signed (either positive or negative) numbers to binary and back. –Add binary numbers.

26 Next Lecture Prerequisites Read Section 1.5. Solve problems like Exercise Set 1.5, #1-16, 27-36, and 41-46. NOTE: the binary numbers in problems 27- 30 are signed (that is, they use the two’s complement representation scheme). Complete the open-book, untimed quiz on WebCT that’s due before the next class.

27 snick  snack More problems to solve... (on your own or if we have time)

28 Problem: String equals Consider the following from the Java 6 API documentation for the String class’s equals method:...The [method returns] true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object. Let n1 mean “this string is null”, n2 mean “the argument is null”, r mean “the method returns true”, and s mean “the two strings are objects that represent the same sequence of characters”. Presumably any two null strings are equal to each other. Then, equality would become something like “the method returns true if and only if the two strings both null or are objects that represent the same sequence of characters”. Problem: Is that logically equivalent to the statement from the API? Why or why not?

29 Problem: Decisions in Code Consider the following code, part of a “binary bounds search”: if target equals value then if lean-left-mode is true call the go-left routine otherwise call the go-right routine otherwise if target is less than value then call the go-left routine otherwise call the go-right routine

30 Problem: Decisions in Code Let gl mean “the go-left routine is called” Problem: complete the logical expression gl  _____________________ Problem: Use your logic to simplify the pseudocode so it requires just one “if/otherwise”.


Download ppt "Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Propositional Logic: Conditionals and Logical Equivalence Steve Wolfman, based on notes."

Similar presentations


Ads by Google