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

Slides:



Advertisements
Similar presentations
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 Propositional Logic: A First Model of Computation Steve Wolfman, based on notes by Patrice.
Advertisements

Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 Introduction to Induction Steve Wolfman 1.
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 Introduction & Motivation Steve Wolfman, based on notes by Patrice Belleville and others.
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 Functions Steve Wolfman, based on notes by Patrice Belleville and others 1.
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 Rewriting Predicate Logic Statements Steve Wolfman, based on notes by Patrice Belleville.
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 Introduction to Induction Steve Wolfman 1.
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 DFAs in Depth Steve Wolfman, based on notes by Patrice Belleville and others.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Propositional Logic: A First Model of Computation Steve Wolfman, based on notes by Patrice.
Snick  snack 1 CPSC 121: Models of Computation 2009 Winter Term 1 Number Representation Steve Wolfman, based on notes by Patrice Belleville and others.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Propositional Logic: Conditionals and Logical Equivalence Steve Wolfman, based on notes.
Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Propositional Logic, Continued Steve Wolfman, based on notes by Patrice Belleville and.
Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.
Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Introduction & Motivation Steve Wolfman, based on notes by Patrice Belleville and others.
Boolean Algebra Computer Science AND (today is Monday) AND (it is raining) (today is Monday) AND (it is not raining) (today is Friday) AND (it is.
Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Rewriting Predicate Logic Statements Steve Wolfman, based on notes by Patrice Belleville.
Snick  snack CPSC 121: Models of Computation 2010/11 Winter Term 2 Propositional Logic: A First Model of Computation Steve Wolfman, based on notes by.
Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 DFAs in Depth Benjamin Israel Notes heavily borrowed from Steve Wolfman’s,
Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 Rewriting Predicate Logic Statements Steve Wolfman, based on notes by Patrice Belleville.
Snick  snack CPSC 121: Models of Computation 2010/11 Winter Term 2 Propositional Logic, Continued Steve Wolfman, based on notes by Patrice Belleville.
EE1J2 – Discrete Maths Lecture 5
Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Proof Techniques (Part B) Steve Wolfman, based on notes by Patrice Belleville and others.
Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 Sets Steve Wolfman, based on notes by Patrice Belleville and others 1.
Snick  snack CPSC 121: Models of Computation 2010/11 Winter Term 2 Introduction & Motivation Steve Wolfman, based on notes by Patrice Belleville and others.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Proof (First Visit) Steve Wolfman, based on notes by Patrice Belleville, Meghan Allen.
Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Propositional Logic: A First Model of Computation Steve Wolfman, based on notes by Patrice.
Snick  snack CPSC 121: Models of Computation 2010/11 Winter Term 2 Propositional Logic: Conditionals and Logical Equivalence Steve Wolfman, based on notes.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Sets Steve Wolfman, based on notes by Patrice Belleville and others.
Logic: From Greeks to philosophers to circuits. COS 116, Spring 2012 Adam Finkelstein.
Digital Systems Presented by Prof Tim Johnson
CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
CS1Q Computer Systems Lecture 5 Simon Gay. Lecture 5CS1Q Computer Systems - Simon Gay2 Where we are Global computing: the Internet Networks and distributed.
Chapter 3.5 Logic Circuits. How does Boolean algebra relate to computer circuits? Data is stored and manipulated in a computer as a binary number. Individual.
Chapter 1 The Logic of Compound Statements. Section 1.1 Logical Form and Logical Equivalence.
Introduction to Proofs
CS1Q Computer Systems Lecture 8
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Describing the World with Predicate Logic Steve Wolfman, based on notes by Patrice Belleville.
Dr. Naveed Riaz Design and Analysis of Algorithms 1 1 Formal Methods in Software Engineering Lecture # 24.
Logical Form and Logical Equivalence Lecture 2 Section 1.1 Fri, Jan 19, 2007.
Snick  snack CPSC 121: Models of Computation 2013W2 Introduction to Induction Steve Wolfman 1.
CPSC 121: Models of Computation Unit 2 Conditionals and Logical Equivalences Unit 2 - Conditionals 1 Based on slides by Patrice Belleville and Steve Wolfman.
Snick  snack CPSC 121: Models of Computation 2013W2 Propositional Logic: A First Model of Computation Steve Wolfman, based on notes by Patrice Belleville.
CPSC 121: Models of Computation Unit 0 Introduction George Tsiknis Based on slides by Patrice Belleville and Steve Wolfman.
Boolean Algebra. Logical Statements A proposition that may or may not be true:  Today is Monday  Today is Sunday  It is raining.
Snick  snack CPSC 121: Models of Computation 2012 Summer Term 2 Introduction & Motivation Steve Wolfman, based on notes by Patrice Belleville and others.
Chapter 7 Logic, Sets, and Counting
Snick  snack CPSC 121: Models of Computation 2013W2 Propositional Logic: Conditionals and Logical Equivalence Steve Wolfman, based on notes by Patrice.
Chapter 7 Logic, Sets, and Counting Section 1 Logic.
Logical Form and Logical Equivalence Lecture 1 Section 1.1 Wed, Jan 12, 2005.
CPSC 121: Models of Computation Unit 3 Representing Numbers and Other Values in a Computer Based on slides by Patrice Belleville and Steve Wolfman.
Boolean Logic.
1 Program Development  The creation of software involves four basic activities: establishing the requirements creating a design implementing the code.
Logic Design EE-2121 Manesh T. Digital Systems  Introduction  Binary Quantities and Variables  Logic Gates  Boolean Algebra  Combinational Logic.
MATH 110 Sec 12-1 Lecture: Intro to Counting Introduction to Counting: Just how many are there?
Dr. Naveed Riaz Design and Analysis of Algorithms 1 1 Formal Methods in Software Engineering Lecture # 25.
Mathematics for Computing Lecture 2: Computer Logic and Truth Tables Dr Andrew Purkiss-Trew Cancer Research UK
Snick  snack 1 CPSC 121: Models of Computation 2008/9 Winter Term 2 Number Representation Steve Wolfman, based on notes by Patrice Belleville and others.
Chapter 1 Logic and proofs
CPSC 121: Models of Computation 2008/9 Winter Term 2
CPSC 121: Models of Computation 2016W2
Module 2: Conditionals and Logical Equivalences
DeMorgan’s Theorem DeMorgan’s 2nd Theorem
CPSC 121: Models of Computation 2008/9 Winter Term 2
Dr. Clincy Professor of CS
Dr. Clincy Professor of CS
CPSC 121: Models of Computation
CPSC 121: Models of Computation 2008/9 Winter Term 2
CPSC 121: Models of Computation
Presentation transcript:

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

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 2

Quiz 2 Review: “Meaning” of  Consider the following truth table for p  ~q And, consider the following statement: “Anytime that p is true, q must be false.” Does this mean the same thing as p  ~q? 3 pq~q p  ~q TTFF TFTT FTFT FFTT

Quiz 2 Review: “Meaning” of  Consider the following truth table for p  ~q And, consider the following statement: “Anytime that p is true, q must be false.” Does this mean the same thing as p  ~q? 4 pq~q p  ~q TTFF TFTT FTFT FFTT

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? 5 pq~q p  ~q TTFF TFTT FTFT FFTT

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? 6 pq~q p  ~q TTFF TFTT FTFT FFTT

Quiz 2 Review: “Meaning” of  Consider the following truth table for p  q And, consider the following statement: “q  p.” Does this mean the same thing as p  q? 7 pq p  q TTT TFF FTF FFT

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? 8 pq p  q TTT TFF FTF FFT

Quiz 2 Review: “Meaning” of  Consider the following truth table for p  q And, consider the following statement: “p  q and ~p  ~q.” Does this mean the same thing as p  q? 9 pq p  q TTT TFF FTF FFT

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, # Complete the open-book, untimed quiz on Vista that was due before class. 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 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 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.). 12

Where We Are in The Big Stories Theory 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.) 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. 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

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

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

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

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

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

Problem: Equivalent Circuits Problem: Consider these circuits for the top LED in the 4-segment display (assuming inputs abcd from the previous table). 1.(~a  b)  (a  ~b  ~c) 2.(~a  b)  a 3.a  b 4.a  b Which of the following proves that circuit 1 is not equivalent to any of circuits 2-4: a.2 and 4 are equivalent b.1 mentions c and 2-4 don’t. c.1 can change from T to F just by changing c’s value. d.None of these

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 24 State your theorem. Explicitly start the proof. Start with one side...

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 25 Start with one side... Each line starts with  to indicate it’s equivalent to the previous line....and work to the other. End with QED!

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 26 Give the next statement. And justify how you got it.

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 27 What’s missing? a.(a  b) b.F  (a  b) c.a  (a  b) d.None of these, but I know what it is. e.None of these, and there’s not enough information to tell.

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. This circuit is called a multiplexer. a b out c (~a  b  c)  ( a  ~b  ~c)  ( a  b  ~c)  ( a  b  c) abcout FFFF FFTF FTFF FTTT TFFT TFTF TTFT TTTT

Glitch in MUX Design Consider this multiplexer (MUX) circuit. 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. 30 PRACTICE: Prove that this circuit’s model is logically equivalent to the previous slide’s statement. a b out c 0 1

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

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

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

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.) 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 34 a b out c 0 1

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

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

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

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

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

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

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) 41 a b out c 0 1

Deglitching Our only glitch (when only one input is changed at a time) is when c changes while a and b are both T. What is the intended output if both a and b are T? a.T b.F c.Unknown... but could be answered with more information. d.Unknown... and could not be answered even with more information. 42 a b out c 0 1

A Glitchless MUX This circuit takes advantage of what we’ve discovered. 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. 43 a b out c 0 1

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 44

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.). 45

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. 46

Next Lecture Prerequisites Read Section 1.5 and the supplemental handout: Handouts/signed-binary-decimal-conversions.html Handouts/signed-binary-decimal-conversions.html Solve problems like Exercise Set 1.5, #1-16, 27-36, and NOTE: the binary numbers in problems 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. 47

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

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. 49

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

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 51

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”. 52

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...  a  b by identity QED 53 State your theorem. Explicitly start the proof. Start with one side... Each line starts with  to indicate it’s equivalent to the previous line. Give the next statement. And justify how you got it. End with QED!...and work to the other.