Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett

Similar presentations


Presentation on theme: "CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett"— Presentation transcript:

1 CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett

2 Today’s Topics: Propositional logic
Truth tables for basic logical connectives not, and, or, xor, implies Truth table for new/made-up connectives “Step-by-step” truth tables for complex propositional formulas Equivalence rules

3 1. Truth table for basic logical connectives
not, and, or, xor, implies

4 Logical connectives and p  q p && q or p  q p || q xor p  q p ^ q
math Java/C++ and p  q p && q or p  q p || q xor p  q p ^ q not p !p If/then, implies p  q If and only if, iff p  q We will use the math notation

5 Logical connectives: Operator precedence
 (not) 1  (and) 2  (or) 3  (implies) 4  (iff) 5 As with programming, it is good practice to use parenthesis for clarity

6 Truth tables: AND  Is it: F,F,F,F F,T,T,T T,T,T,F F,F,F,T
None/More/Other p q pq F ? T I’m interested in seeing if this makes intuitive sense to you – can you explain why each output makes sense, using example sentences?

7 Truth tables: AND  Is it: F,F,F,F F,T,T,T T,T,T,F F,F,F,T
None/More/Other p q pq F T I’m interested in seeing if this makes intuitive sense to you – can you explain why each output makes sense, using example sentences?

8 Truth tables: AND  OR  p q pq F T p q pq F T
I’m interested in seeing if this makes intuitive sense to you – can you explain why each output makes sense, using example sentences?

9 OR is tricky in English OR XOR
p q p OR q F T p q p XOR q F T Birthday party host: “Do you want some cake OR ice-crem?” YOU CAN HAVE BOTH (imagine it is rude to have nothing) Diner breakfast special: “Pancake, two eggs and bacon XOR sausage.” YOU MUST PICK EXACTLY ONE

10 What does it mean: IMPLIES
Prof Lovett says: “If you win the CA state lottery between now and the end of quarter, you will get an A+ in this class.” 4 months later… under which of the following scenarios is Prof. Lovett a liar? You won the lottery and got an A+ You won the lottery and got a B+ You did not win the lottery and got an A+ You did not win the lottery and got a B+ None/More/Other

11 What does it mean: IMPLIES
Your roommate: “If you come to my party Friday, you will have fun” Under which of the following scenarios is your roommate a liar? You stayed home studying Friday and you did not have fun. You stayed home studying Friday and you had fun. You went to the party Friday and did not have fun. You went to the party Friday and you had fun None/More/Other

12 Truth tables: IMPLIES p q pq F T T, F, F, T F, T, T, T F, F, F, T
None/more/other I’m interested in seeing if this makes intuitive sense to you – can you explain why each output makes sense, using example sentences?

13 Truth tables: IMPLIES p q pq F T T, F, F, T F, T, T, T F, F, F, T
None/more/other I’m interested in seeing if this makes intuitive sense to you – can you explain why each output makes sense, using example sentences?

14 2. Truth table for new/made-up connectives

15 Making our own connective: AtLeastOneOfTheseThree ALOOTT(p,q,r)
p OR q F T Let’s make a truth table for ALOOTT. How many rows and columns should be in our truth table (ignoring header row)? 5 rows, 4 columns 6 rows, 4 columns 7 rows, 4 columns 8 rows, 4 columns 9 rows, 4 columns

16 Making our own connective: AtLeastOneOfTheseThree ALOOTT(p,q,r)
p OR q F T Let’s make a truth table for ALOOTT. How many rows and columns should be in our truth table (ignoring header row)? 5 rows, 4 columns 6 rows, 4 columns 7 rows, 4 columns 8 rows, 4 columns 9 rows, 4 columns N variables  2N rows (ignoring header row)

17 Making our own connective: AtLeastOneOfTheseThree ALOOTT(p,q,r)

18 3. “Step-by-step” truth tables for complex propositional formulas

19 Truth table for (pq)p
? T F,F,T,T T,F,T,F T,T,F,F F,F,F,T Other Use truth tables of IMPLIES,NOT,AND!

20 Truth table for (pq)p

21 Truth table for (pq)p

22 Truth table for (pq)p

23 Truth tables for complex formulas
Intermediate columns: build complex expression step by step Each intermediate column is a basic connective (NOT,AND,OR,…) applied to already calculated previous columns Use truth tables of basic connectives to compute the value of new column, one at a time

24 4. Proving equivalence of two propositions using truth tables

25 Which pair of propositions are equivalent to each other?
p → q ¬p ∨ q T F p, ¬p p → q, ¬p q, ¬p ∨ q ¬q, ¬p Other/none/more than one

26 Truth table for (p → q) ∧ ¬p
(p → q) ∧ ¬p is equivalent to: q p → q ¬p ∨ q ¬p Other/none/more than one

27 Hardware for (p → q) ∧ ¬p Hardware for ¬p Back to the Algebra analogy:
we do similar simplification in jr. high math: a + b – 2a + 3b + a –(8b/2) + a = a

28 Hardware design efficiency
Improved performance of CPUs depends in part on squeezing logic onto as tiny amount of silicon as possible, and using as little electricity/heat as possible. Minimizing logic gates helps both.

29 How can we prove that two propositions are not equivalent?
Make a truth table that has columns for both, and verify that not all the entries in the two columns are T Make a truth table that has columns for both, and verify that at least one of the entries in the two columns is F Make a truth table that has columns for both, and make sure that the two columns are not identical to each other. Make a truth table that has columns for both, and make sure that in the row where the input variables are all T, the propositions are both F


Download ppt "CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett"

Similar presentations


Ads by Google