8
CSE 20: Discrete Mathematics for Computer Science Prof. Miles Jones 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 1. Truth table for basic logical connectives 3 not, and, or, xor, implies Logical connectives 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 4

CSE 20: Discrete Mathematics Truth tables for basic ... - Truth... · Truth tables for basic logical connectives ! not, and, or, xor, implies 2. Truth table for new/made-up connectives

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CSE 20: Discrete Mathematics Truth tables for basic ... - Truth... · Truth tables for basic logical connectives ! not, and, or, xor, implies 2. Truth table for new/made-up connectives

CSE 20: Discrete Mathematics for Computer ScienceProf. Miles Jones

Today’s Topics: Propositional logic1. 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

1. Truth table for basic logical connectives

3

not, and, or, xor, implies

Logical connectives

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

4

Page 2: CSE 20: Discrete Mathematics Truth tables for basic ... - Truth... · Truth tables for basic logical connectives ! not, and, or, xor, implies 2. Truth table for new/made-up connectives

Logical connectives: Operator precedence

Operator Precedence¬ (not) 1∧ (and) 2∨ (or) 3→ (implies) 4↔ (iff) 5

5

! As with programming, it is good practice to use parenthesis for clarity

Truth tables:AND ∧

p q p∧qF F ?F T ?T F ?T T ?

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

Truth tables:AND ∧

p q p∧qF F FF T FT F FT T T

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

Truth tables:AND ∧ OR ∨

p q p∧qF F FF T FT F FT T T

p q p∨qF F FF T TT F TT T T

I’m interested in seeing if this makes intuitive sense to you – can you explain why each output makes sense, using example sentences?

Page 3: CSE 20: Discrete Mathematics Truth tables for basic ... - Truth... · Truth tables for basic logical connectives ! not, and, or, xor, implies 2. Truth table for new/made-up connectives

OR is tricky in English

ORp q p OR qF F FF T TT F TT T T

XORp q p XOR qF F FF T TT F TT T F

9

Birthday party host: “Do you want some cake OR ice-cream?” 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

Implies! p→ q! p implies q! if p then q! q when p! q if p

10

What does it mean: IMPLIES

11

! I say: “If you win the 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 am I 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

What does it mean: IMPLIES

12

! 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

Page 4: CSE 20: Discrete Mathematics Truth tables for basic ... - Truth... · Truth tables for basic logical connectives ! not, and, or, xor, implies 2. Truth table for new/made-up connectives

Truth tables: IMPLIESp q p→qF FF TT FT T

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?

Truth tables: IMPLIESp q p→qF F TF T TT F FT T T

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?

Truth tables: IMPLIESp q p→qF F TF T TT F FT T T

T, F, F, T F, T, T, T F, F, F, T F, T, T, F None/more/other

A false statement implies anything!!!!!!!

Implies! p=I hit my thumb with a hammer ! q=my thumb hurts ! p → q= If I hit my thumb with a hammer

then my thumb hurts.

16

p q p→qF F TF T TT F FT T T

Page 5: CSE 20: Discrete Mathematics Truth tables for basic ... - Truth... · Truth tables for basic logical connectives ! not, and, or, xor, implies 2. Truth table for new/made-up connectives

2. Truth table for new/made-up connectives

17

Making our own connective: AtLeastOneOfTheseThreeALOOTT(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

18

p q p OR q

F F F

F T T

T F T

T T T

Making our own connective: AtLeastOneOfTheseThreeALOOTT(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

19

p q p OR q

F F F

F T T

T F T

T T T

N variables ! 2N rows (ignoring header row)

Making our own connective: AtLeastOneOfTheseThreeALOOTT(p,q,r)

20

p q r ALOOTT(p,q,r)

F F F

F F T

F T F

F T T

T F F

T F T

T T F

T T T

Homework

Page 6: CSE 20: Discrete Mathematics Truth tables for basic ... - Truth... · 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

21

Truth table for (p→q)∧¬p

22

p q p→q ¬p (p→q)∧¬pF FF TT FT T

Truth table for (p→q)∧¬p

23

p q p→q ¬p (p→q)∧¬pF F TF T TT F FT T T

Truth table for (p→q)∧¬p

24

p q p→q ¬p (p→q)∧¬pF F T TF T T TT F F FT T T F

Page 7: CSE 20: Discrete Mathematics Truth tables for basic ... - Truth... · Truth tables for basic logical connectives ! not, and, or, xor, implies 2. Truth table for new/made-up connectives

Truth table for (p→q)∧¬p

25

p q p→q ¬p (p→q)∧¬pF F T T TF T T T TT F F F FT T T F F

Truth table for ¬q→(p^q)

26

p q ¬q p∧q ¬q→(p∧q)F F T F FF T F F TT F T F FT T F T T

Truth table for ¬pORq

27

p q ¬p ¬pORqF F T TF T T TT F F FT T F T

Truth table for ¬p∧q

28

p q ¬p ¬p∧qF F T TF T T TT F F FT T F T

¬p∧q is logically equivalent to p→q!!!!!

Page 8: CSE 20: Discrete Mathematics Truth tables for basic ... - Truth... · Truth tables for basic logical connectives ! not, and, or, xor, implies 2. Truth table for new/made-up connectives

All possible truth tables for two variables

29

¬∧ → ¬p ¬q ¬⊕ ¬∨ ∨ ⊕ q p ∧ ∧∧p q 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

F F T T T T T T T T F F F F F F F FF T T T T T F F F F T T T T F F F FT F T T F F T T F F T T F F T T F FT T T F T F T F T F T F T F T F T F