1
play

1 Problem : Outline 4-Segment LED Display Prereqs, Learning Goals, - PDF document

snick Outline snack Prereqs, Learning Goals, and Quiz Notes Problems and Discussion CPSC 121: Models of Computation Logical equivalence practice 2016W2 How to write a logical equivalence proof A flaw in our model


  1. snick  Outline snack • Prereqs, Learning Goals, and Quiz Notes • Problems and Discussion CPSC 121: Models of Computation – Logical equivalence practice 2016W2 – How to write a logical equivalence proof – A flaw in our model Propositional Logic: Conditionals and Logical Equivalence • Next Lecture Notes Steve Wolfman, based on notes by Patrice Belleville and others 1 2 This work is licensed under a Creative Commons Attribution 3.0 Unported License. Learning Goals: Pre-Class Learning Goals: In-Class By the start of class, you should be able to: By the end of this unit, you should be able to: – Translate back and forth between simple natural – Explore alternate forms of propositional logic language statements and propositional logic, now statements by application of equivalence rules, with conditionals and biconditionals. especially in order to simplify complex statements or massage statements into a desired form. – Evaluate the truth of propositional logical statements that include conditionals and – Evaluate propositional logic as a “model of biconditionals using truth tables. computation” for combinational circuits, including – Given a propositional logic statement and an at least one explicit shortfall (e.g., referencing equivalence rule, apply the rule to create an gate delays, fan-out, transistor count, wire length, equivalent statement. instabilities, shared sub-circuits, etc.). given (u  s)  s, apply p  q  ~p  q. Example: p maps to (u  s) and q maps to s. Note: ~(u  s)  s 10 11 Result: Where We Are in Motivating Problem The Big Stories Simplify this code, proving your simplification correct: Theory Hardware How do we model How do we build devices to computational systems? compute? Image version: List version: ;; Image -> Boolean ;; ListOfNatural -> Boolean ;; Produces true if image is too large to ;; Produces true if all numbers in lon ;; fit on the HEIGHT-by-WIDTH screen. ;; are positive and false otherwise. Now : practicing our second Now : learning to modify (define (too-large? image) (define (all-positive? lon) (if (> (image-width image) WIDTH) (cond [(empty? lon) true] technique for formally circuit designs using our true [else (if (<= (first lon) 0) (if (> (image-height image) HEIGHT) false establishing the truth of logical model, gaining true (all-positive? (rest lon)))])) false))) a statement (logical more practice equivalence proofs). designing circuits, and identifying a flaw (The first technique was in our model for circuits. truth tables.) 12 13 1

  2. Problem : Outline 4-Segment LED Display • Prereqs, Learning Goals, and Quiz Notes Problem : Build a circuit that displays the numbers 1 through 9 represented by four • Problems and Discussion Boolean values a, b, c, and d on a 4- – Logical equivalence practice segment Boolean display. – How to write a logical equivalence proof – A flaw in our model 1 2 3 4 5 • Next Lecture Notes 6 7 8 9 14 15 Problem : RECALL: 4-Segment LED Display Representing Positive Integers Problem : Build a circuit that displays the This is the convention we (and computers) use for the positive integers 0-9, which requires 4 variables: numbers 1 through 9 represented by four # a b c d Boolean values a, b, c, and d on a 4- 0 F F F F segment Boolean display. 1 F F F T 2 F F T F 3 F F T T 1 2 3 4 5 1 2 3 4 F T F F 5 F T F T 4 5 6 6 F T T F 7 F T T T 7 8 9 6 7 8 9 8 T F F F 9 T F F T 16 17 ... 1 2 3 1 2 3 Problem: Equivalent Circuits Problem: Equivalent Circuits 4 5 6 4 5 6 7 8 9 7 8 9 Problem: Consider these circuits for the top Problem: Consider these circuits for the top LED in the 4-segment display (assuming LED in the 4-segment display (assuming inputs abcd from the previous table): inputs abcd from the previous table). 1.(~a  b)  (a  ~b  ~c) 1.(~a  b)  (a  ~b  ~c) 2.(~a  b)  a 2.(~a  b)  a Which of 2, 3, and 4 are equivalent? 3.a  b 3.a  b a. None of them. b. 2 and 3 but not 4. 4.a  b 4.a  b c. 2 and 4 but not 3. d. 3 and 4 but not 2. e. 2, 3, and 4. 18 19 2

  3. 1 2 3 1 2 3 Problem: Equivalent Circuits Problem: Equivalent Circuits 4 5 6 4 5 6 7 8 9 7 8 9 Problem: Consider these circuits for the top Problem: Consider these circuits for the top LED in the 4-segment display (assuming LED in the 4-segment display (assuming inputs abcd from the previous table). inputs abcd from the previous table). 1.(~a  b)  (a  ~b  ~c) 1.(~a  b)  (a  ~b  ~c) 2.(~a  b)  a 2.(~a  b)  a Which of these proves that circuit 1 is How many of these are correct? not equivalent to circuit 3: 3.a  b 3.a  b a. None of them. a. 2 and 4 are equivalent b. One of them. 4.a  b 4.a  b b. 1 mentions c but 3 does not. c. Two of them. c. Their values differ on a= T b= F c= T . d. Three of them. d. None of these. e. All four of them. 20 21 Writing an Equiv Proof: Outline Prove (~a  b)  a  a  b Theorem : (~a  b)  a  a  b • Prereqs, Learning Goals, and Quiz Notes • Problems and Discussion Proof : (~a  b)  a – Logical equivalence practice – How to write a logical equivalence proof  a  (~a  b) by commutativity – A flaw in our model  (a  ~a)  (a  b) by distribution • Next Lecture Notes ...to be filled in...  a  b by identity QED 22 23 Writing an Equiv Proof: Writing an Equiv Proof: Prove (~a  b)  a  a  b Prove (~a  b)  a  a  b Theorem : (~a  b)  a  a  b Theorem : (~a  b)  a  a  b State your theorem. Proof : Explicitly start the proof. Proof : (~a  b)  a (~a  b)  a Start with one side... Start with one side...  a  (~a  b)  a  (~a  b) by commutativity by commutativity  (a  ~a)  (a  b)  (a  ~a)  (a  b) by distribution by distribution ...to be filled in... ...to be filled in...  a  b  a  b by identity by identity ...and work to the other. QED QED Each line starts with  to indicate End with QED! 24 25 it’s equivalent to the previous line. 3

  4. Writing an Equiv Proof: Problem : Prove (~a  b)  a  a  b Prove (~a  b)  a  a  b Theorem : (~a  b)  a  a  b Theorem : (~a  b)  a  a  b Proof : Proof : (~a  b)  a (~a  b)  a  a  (~a  b) by commutativity  (a  ~a)  (a  b) by distribution What’s missing?  a  (~a  b) by commutativity  ?????? by negation a. (a  b)  (a  ~a)  (a  b)  a  b by distribution by identity b. F  (a  b) c. a  (a  b) QED Give the next statement. And justify how you got it. ... d. None of these, but I  a  b by identity know what it is. e. None of these, and QED there’s not enough 26 27 information to tell. PRACTICE Problem : Collected Wisdom Arbitrary Logic Expression So far: Problem : Aliens hold the Earth hostage, • Try getting rid of  : p  q  ~p  q and only you can save it by proving • Try moving negations inward: ~(p  q)  ~p  ~q (a  b)  ~(b  a)  ~a  b. • Work from the more complex side first, BUT • Switch to different strategies/sides when you get stuck • In the end, write the proof in clean “one -side-to-the- other” form and double-check steps Also: • Try distribution to pull out common terms OR • Try distribution to rearrange terms • Try working with a simpler part of the statement first • Try getting rid of  : p  q  p  q  q  p • Try getting rid of  : p  q  ~(p  q) Reminder (“IMP” on “Dave’s Formula Sheet”): p  q  ~p  q 28 29 a 0 out “Multiplexer” Outline b 1 c • Prereqs, Learning Goals, and Quiz Notes A circuit that, given three inputs a , b , and c (the “control” signal), outputs a ’s value • Problems and Discussion when c is F and b ’s when c is T. – Logical equivalence practice – How to write a logical equivalence proof a b c out – A flaw in our model F F F F F F T F (~a  b  c)  • Next Lecture Notes F T F F ( a  ~b  ~c)  F T T T ( a  b  ~c)  T F F T ( a  b  c) T F T F T T F T 30 31 This circuit is called a multiplexer. T T T T 4

  5. a a 0 0 out out MUX Design Truthy MUX b 1 b 1 c c Here’s one implementation of the multiplexer What is the intended output if both a and b are T? (MUX) circuit. a. T (Is this equivalent b. F to the previous c. Unknown... but could be answered given a value slide’s formula? for c . Good question... d. Unknown... and might still be unknown even given prove that it is for a value for c . practice at home!) 32 33 a a 0 0 out out Glitch in MUX Design Trace: -1 ns b 1 b 1 c c Imagine the circuit is in steady-state with a , T b , and c all T. F Trace how changes F flow when we T change c to F, T T if each gate takes 10ns to operate. T 34 35 a 0 a 0 out out Trace: 0 ns Trace: 10 ns b b 1 1 c c T T * F F F T T T * * T T T F * F F OFF OFF 36 37 5

Recommend


More recommend