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 1. Truth tables for basic logical connectives  not, and, or, xor, implies 2. Truth table for new/made-up connectives 3. “Step-by-step” truth tables for complex propositional formulas 2

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

4 Logical connectives mathJava/C++  andp  qp && q  orp  qp || q  xorp  qp ^ q  not  p!p  If/then, impliesp  q  If and only if, iffp  q  We will use the math notation 4

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

6 Truth tables: AND  pq pqpq FF? FT? TF? TT? I’m interested in seeing if this makes intuitive sense to you – can you explain why each output makes sense, using example sentences? Is it: A. F,F,F,F B. F,T,T,T C. T,T,T,F D. F,F,F,T E. None/More/Other

7 Truth tables: AND  pq pqpq FFF FTF TFF TTT I’m interested in seeing if this makes intuitive sense to you – can you explain why each output makes sense, using example sentences? Is it: A. F,F,F,F B. F,T,T,T C. T,T,T,F D. F,F,F,T E. None/More/Other

8 Truth tables: AND  OR  pq pqpq FFF FTF TFF TTT pq pqpq FFF FTT TFT TTT 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 pqp OR q FFF FTT TFT TTT XOR pqp XOR q FFF FTT TFT TTF 9 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 10  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? A. You won the lottery and got an A+ B. You won the lottery and got a B+ C. You did not win the lottery and got an A+ D. You did not win the lottery and got a B+ E. None/More/Other

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

12 Truth tables: IMPLIES pq pqpq FF FT TF TT A. T, F, F, T B. F, T, T, T C. F, F, F, T D. F, T, T, F E. 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 pq pqpq FFT FTT TFF TTT A. T, F, F, T B. F, T, T, T C. F, F, F, T D. F, T, T, F E. 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 14

15 Making our own connective: AtLeastOneOfTheseThree ALOOTT(p,q,r)  Let’s make a truth table for ALOOTT. How many rows and columns should be in our truth table (ignoring header row)? A. 5 rows, 4 columns B. 6 rows, 4 columns C. 7 rows, 4 columns D. 8 rows, 4 columns E. 9 rows, 4 columns 15 pqp OR q FFF FTT TFT TTT

16 Making our own connective: AtLeastOneOfTheseThree ALOOTT(p,q,r)  Let’s make a truth table for ALOOTT. How many rows and columns should be in our truth table (ignoring header row)? A. 5 rows, 4 columns B. 6 rows, 4 columns C. 7 rows, 4 columns D. 8 rows, 4 columns E. 9 rows, 4 columns 16 pqp OR q FFF FTT TFT TTT N variables  2 N rows (ignoring header row)

17 Making our own connective: AtLeastOneOfTheseThree ALOOTT(p,q,r) 17 pqrALOOTT(p,q,r) FFF FFT FTF FTT TFF TFT TTF TTT

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

19 Truth table for (p  q)   p 19 pq pqpq pp (p  q)   p FF FT TF TT Use truth tables of IMPLIES,NOT,AND!

20 Truth table for (p  q)   p 20 pq pqpq pp (p  q)   p FF T FT T TF F TT T pqp  q FFT FTT TFF TTT

21 Truth table for (p  q)   p 21 pq pqpq pp (p  q)   p FFT T FTT T TFF F TTT F p pp FT TF

22 Truth table for (p  q)   p 22 pq pqpq pp (p  q)   p FFTT T FTTT T TFFF F TTTF F pq pqpq FFF FTF TFF TTT

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 Truth table for  (p  (q  p)) 24 pq??  (p  (q  p)) FF ? FT ? TF ? TT ? A.F,F,T,T B.T,F,T,F C.T,T,T,F D.F,F,F,T E.Other pq p  q FFT FTT TFF TTT

25 Truth table for (p  q)  (q  p) 25 pq?? (p  q)  (q  p) FF ? FT ? TF ? TT ? pq p  q FFF FTT TFT TTF A.F,F,T,T B.T,F,T,F C.T,T,T,F D.F,F,F,T E.Other pq p  q FFT FTT TFF TTT

26 Composing truth tables 26 pq?? (p NAND (p NAND q)) FF ? FT ? TF ? TT ? A.F,F,T,T B.T,F,T,F C.T,T,T,F D.F,F,F,T E.Other pq p NAND q FFT FTT TFT TTF


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

Similar presentations


Ads by Google