1 / 53

CPSC 121: Models of Computation 2010/11 Winter Term 2

CPSC 121: Models of Computation 2010/11 Winter Term 2. Propositional Logic: Conditionals and Logical Equivalence Steve Wolfman, based on notes by Patrice Belleville and others. Outline. Prereqs, Learning Goals, and Quiz Notes Problems and Discussion Logical equivalence practice

Download Presentation

CPSC 121: Models of Computation 2010/11 Winter Term 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CPSC 121: Models of Computation2010/11 Winter Term 2 Propositional Logic: Conditionals and Logical Equivalence Steve Wolfman, based on notes by Patrice Belleville and others

  2. Outline • Prereqs, Learning Goals, and Quiz Notes • Problems and Discussion • Logical equivalence practice • How to write a logical equivalence proof • A flaw in our model • Next Lecture Notes

  3. Quiz 2 Review:Circuits? Our most common meaning for circuit will be “the set of gates (and other electronics components) that collectively map a set of inputs to the desired output(s)”. When we ask if multiple different circuits can correctly map input numbers to an output that controls an LED in the display, we mean “are there alternative designs to solve the problem?”

  4. Quiz 2 Review:“Meaning” of  When I say “if it’s raining, I’ll bring my umbrella”, do I mean: In other words, I might bring my umbrella even if it’s not raining? Probably not, in English. BUT, in logic  always means exactly that truth table! It just isn’t a great match for “normal” English. Better for legalistic English…

  5. Quiz 2 Review:“Meaning” of  Consider the following truth table for p  ~q And, consider the following statement: “p cannot be true unless q is false.” Does this mean the same thing as p  ~q?

  6. Quiz 2 Review:“Meaning” of  Consider the following truth table for p  ~q And, consider the following statement: “p cannot be true unless q is false.” Does this mean the same thing as p  ~q?

  7. Quiz 2 Review:“Meaning” of  Consider the following truth table for p  ~q And, consider the following statement: “If p is true, it guarantees q is false.” Does this mean the same thing as p  ~q?

  8. Quiz 2 Review:“Meaning” of  Consider the following truth table for p  q And, consider the following statement: “Either p and q, or ~p and ~q.” Does this mean the same thing as p  q?

  9. Quiz 2 Review:“F” vs. “c” I think “c” is a terrible symbol to use for a contradiction because “a” and “b” are natural variables to use in propositional logic expressions, and “c” is a natural one to use next. We will use “F” instead and avoid capital letters as names for propositional logic variables.

  10. 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: given (u  s)  s, apply p q  ~p  q.Note: p maps to (u  s) and q maps to s. Result: ~(u  s)  s Discuss point of learning goals.

  11. 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. • 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.). Discuss point of learning goals.

  12. Where We Are inThe Big Stories Theory Hardware How do we build devices to compute? Now: learning to modify circuit designs using our logical model, gaining more practice designing circuits, and identifying a flaw in our model for circuits. How do we model computational systems? Now: practicing our second technique for formally establishing the truth of a statement (logical equivalence proofs). (The first technique was truth tables.)

  13. Outline • Prereqs, Learning Goals, and Quiz Notes • Problems and Discussion • Logical equivalence practice • How to write a logical equivalence proof • A flaw in our model • Next Lecture Notes

  14. 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. 1 2 3 4 5 6 7 8 9

  15. 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. 1 2 3 4 5 1 2 3 4 5 6 7 8 9 6 7 8 9

  16. RECALL: Representing Positive Integers This is the convention we (and computers) use for the positive integers 0-9, which requires 4 variables:

  17. Problem: Equivalent Circuits Problem: Consider these circuits for the top LED in the 4-segment display (assuming inputs abcd from the previous table): • (~a  b)  (a  ~b  ~c) • (~a  b)  a • a  b • a  b 1 2 3 4 5 6 7 8 9

  18. Problem: Equivalent Circuits Problem: Consider these circuits for the top LED in the 4-segment display (assuming inputs abcd from the previous table). • (~a  b)  (a  ~b  ~c) • (~a  b)  a • a  b • a  b • Which of 2, 3, and 4 are equivalent? • None of them. • 2 and 3 but not 4. • 2 and 4 but not 3. • 3 and 4 but not 2. • 2, 3, and 4. 1 2 3 4 5 6 7 8 9

  19. Problem: Equivalent Circuits Problem: Consider these circuits for the top LED in the 4-segment display (assuming inputs abcd from the previous table). • (~a  b)  (a  ~b  ~c) • (~a  b)  a • a  b • a  b • How many of these are correct? • None of them. • One of them. • Two of them. • Three of them. • All four of them. 1 2 3 4 5 6 7 8 9

  20. Problem: Equivalent Circuits Problem: Consider these circuits for the top LED in the 4-segment display (assuming inputs abcd from the previous table). • (~a  b)  (a  ~b  ~c) • (~a  b)  a • a  b • a  b • Which of these proves that circuit 1 is not equivalent to circuit 3: • 2 and 4 are equivalent • 1 mentions c but 3 does not. • 1 is false with a=T b=F c=T. • None of these. 1 2 3 4 5 6 7 8 9

  21. Outline • Prereqs, Learning Goals, and Quiz Notes • Problems and Discussion • Logical equivalence practice • How to write a logical equivalence proof • A flaw in our model • Next Lecture Notes

  22. Writing an Equiv Proof: Prove (~a  b)  a  a  b Theorem: (~a  b)  a  a  b Proof: (~a  b)  a  a  (~a  b) by commutativity  (a  ~a)  (a  b) by distribution ...to be filled in...  a  b by identity QED

  23. Writing an Equiv Proof: Prove (~a  b)  a  a  b Theorem: (~a  b)  a  a  b Proof: (~a  b)  a  a  (~a  b) by commutativity  (a  ~a)  (a  b) by distribution ...to be filled in...  a  b by identity QED State your theorem. Explicitly start the proof. Start with one side...

  24. Writing an Equiv Proof: Prove (~a  b)  a  a  b Theorem: (~a  b)  a  a  b Proof: (~a  b)  a  a  (~a  b) by commutativity  (a  ~a)  (a  b) by distribution ...to be filled in...  a  b by identity QED Start with one side... ...and work to the other. Each line starts with  to indicate it’s equivalent to the previous line. End with QED!

  25. Writing an Equiv Proof: Prove (~a  b)  a  a  b Theorem: (~a  b)  a  a  b Proof: (~a  b)  a  a  (~a  b) by commutativity  (a  ~a)  (a  b) by distribution ...  a  b by identity QED Give the next statement. And justify how you got it.

  26. Problem: Prove (~a  b)  a  a  b Theorem: (~a  b)  a  a  b Proof: (~a  b)  a  a  (~a  b) by commutativity  (a  ~a)  (a  b) by distribution  ?????? by negation  a  b by identity QED • What’s missing? • (a  b) • F  (a  b) • a  (a  b) • None of these, but I know what it is. • None of these, and there’s not enough information to tell.

  27. Outline • Prereqs, Learning Goals, and Quiz Notes • Problems and Discussion • Logical equivalence practice • How to write a logical equivalence proof • A flaw in our model • Next Lecture Notes

  28. “Multiplexer” A circuit that, given three inputs a, b, and c (the “control” signal), outputs a’s value when c is F and b’s when c is T. a 0 out (~a  b  c)  ( a  ~b  ~c)  ( a  b  ~c)  ( a  b  c) b 1 c This circuit is called a multiplexer.

  29. MUX Design Here’s one implementation of the multiplexer (MUX) circuit. (Is this equivalentto the previousslide’s formula?Good question...prove that it is forpractice at home!) a 0 out b 1 c

  30. Truthy MUX What is the intended output if both a and b are T? • T • F • Unknown... but could be answered given a value for c. • Unknown... and might still be unknown even given a value for c. a 0 out b 1 c

  31. Glitch in MUX Design Imagine the circuit is in steady-state with a, b, and c all T. Trace how changes flow when we change c to F, if each gate takes 10ns to operate. a 0 out b 1 c PRACTICE: Prove that this circuit’s model is logically equivalent to the previous slide’s statement.

  32. Trace: -1 ns T F F a 0 T out T T b 1 T c

  33. Trace: 0 ns T F F a 0 T * out T T * b 1 F OFF c

  34. Trace: 10 ns T * F T a 0 T * out T F b 1 F OFF c

  35. Tracing a MUX 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.) • 0 ns (it never varies from 1) • 10 ns (it varies before 10ns, but not after) • 20 ns • 30 ns • 40 ns a 0 out b 1 c

  36. Trace: -1 ns T F F a 0 T out T T b 1 T c

  37. Trace: 0 ns T F F a 0 T * out T T * b 1 F OFF c

  38. Trace: 10 ns T * F T a 0 T * out T F b 1 F OFF c

  39. Trace: 20 ns T T T a 0 F * out T F b 1 F OFF c

  40. Trace: 30 ns T T T a 0 T out T F b 1 F OFF c

  41. Trace: 40 ns T T T a 0 T out T F b 1 F OFF c

  42. Other MUX Glitches? The mux glitches because information from c travels two paths with different delays. While the longer path “catches up” the circuit can be incorrect. PRACTICE: Trace the circuit to show why none of these can cause a glitch: • Changing a (keeping b and c constant) • Changing b (keeping a and c constant) • Changing c (keeping a and b constant if at least one of them is F) a 0 out b 1 c

  43. A Glitchless MUX This circuit uses what we know when a = b = T. PRACTICE: Prove that it’s logically equivalent to the original MUX. Hint: break a  b up into two cases, one where c is true and one where c is false: a  b  c and a  b  ~c. a 0 out b 1 c

  44. Outline • Prereqs, Learning Goals, and Quiz Notes • Problems and Discussion • Logical equivalence practice • How to write a logical equivalence proof • A flaw in our model • Next Lecture Notes

  45. 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. • 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.). Discuss point of learning goals.

  46. 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. Discuss point of learning goals.

  47. Next Lecture Prerequisites Read Section 1.5 and the supplemental handout: http://www.ugrad.cs.ubc.ca/~cs121/2009W1/Handouts/signed-binary-decimal-conversions.html 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 Vista that’s due before the next class.

  48. Some Things to Try... (on your own if you have time, not required)

  49. PRACTICE Problem: Arbitrary Logic Expression Problem: Aliens hold the Earth hostage, and only you can save it by proving (a b)~(ba)~ab. Reminder (p. 20 of Epp, 3d ed.): p  q  ~p  q Hint: usually start these problems from the more complex side.

  50. 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?

More Related