logic and discrete math lecture notes 3zhang/teaching/cse240/spring...truth of facts vs. validity of...

57
1 CSE 240 Logic and Discrete Math Lecture notes 3 Weixiong Zhang Washington University in St. Louis http://www.cse.wustl.edu/~zhang/teaching /cse240/Spring10/index.html

Upload: others

Post on 29-May-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

1

CSE 240Logic and Discrete Math

Lecture notes 3

Weixiong ZhangWashington University in St. Louis

http://www.cse.wustl.edu/~zhang/teaching/cse240/Spring10/index.html

Page 2: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

2

Today

Refresher: Chapter 1.2

Chapter 1.3 : Arguments

All i

mag

es a

re c

opyr

ight

ed t

o th

eir

resp

ectiv

e co

pyrig

ht h

olde

rs a

nd r

epro

duce

d he

re fo

r ac

adem

ic p

urpo

ses

unde

r th

e co

nditi

on o

f “fa

ir us

ing”

.

Page 3: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

3

Interpretation

In propositional logic interpretation is a mapping from variables in your formulae to {true, false}

Example:Formula: A v BInterpretation 1: A = true, B = falseInterpretation 2: A = false, B = false

Page 4: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

4

Interpretations

How many interpretations do the following formulae allow?A B

4

(AB & A) B4

Why not 8 or 16?

The number of interpretations is 2N where Nis the number of independent variables

Page 5: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

5

Questions?

Page 6: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

6

ConditionsSuppose we care about statement X

X = “this assignment is copied”We want to evaluate X (true/false?)

Suppose we know A such that AXA is a sufficient conditionA=“the cheater is caught in the act”

Suppose we know B such that XBB is a necessary conditionB=“there was an original assignment to copy from”

Page 7: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

7

Criteria

Suppose we know C such that CXC is a criterionC=“someone has copied this assignment”

Graphically:

X

A

B

C

Page 8: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

8

Wanted : Criteria

Medical testsSoftware/hardware correctnessFraud/cheatingFinancial marketPsychology (e.g., in sales)Science : mathematics, physics, chemistry, etc.Logic :

If C is a criterion for X then C ≡ X !

Page 9: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

9

PracticeIt is frequently non-trivial to derive a criterion for a real-life property X

Then we have to settle for:Sufficient conditions:

“If this quality test passes then the product is fine”Necessary conditions:

“If the patient breaks a leg they will be in pain”

Statistical validity : the condition works most of the timeIn logic : the condition works all the time!

Page 10: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

10

Derivation of Criteria

Logic/Mathematics/Theoretical sciences:Equivalent transformationsProofs by contradiction

Empirical sciences:Statistical testsFunction approximation

Artificial Intelligence:Machine learning

These methods are

notguaranteed to produce true

criteria…

Page 11: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

11

Questions?

Page 12: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

12

Logic EquivalencePropositions/statements/formulae A and B are logically equivalent when:

A holds if and only if B holdsNotation: A ≡ BExamples:

A v A is equivalent to:A

A v ~A is equivalent to:true

Page 13: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

13

Challenge

Theorem 1.1.1 : Boolean AlgebraDerive the rest (e.g., #8) from the first 5 equivalences…

Page 14: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

14

Use of Equivalences

Deriving equivalent formulae!Of course, but why do we care?

Simplification of formula

Simplification of code

Simplification of hardware (e.g., circuits)

Derivation of criteria!

Page 15: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

15

Limitations

Not all statements are equivalent!Of course not, but what else is there?

Some formulae are stronger than others

They imply or entail other formula but not the other way around…

Equivalences cannot directly help us proving such entailments…

Page 16: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

16

EntailmentA collection of statements P1,…,Pn (premises) entails statement Q (conclusion) if and only if:

Whenever all premises hold the conclusion holds

For every interpretation I that makes all Pj hold, I also makes Q hold

Example:Premises:

P1 = “If Socrates is human then Socrates is mortal”P2 = “Socrates is human”

Conclusion:Q = “Socrates is mortal”

Page 17: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

17

Valid/Invalid Arguments

Suppose someone makes an argument:P1,..,PN therefore Q

The argument is called valid iff:P1,…,PN logically entail Q

That is:Q must hold if all Pi hold

Otherwise the argument is called invalid

Page 18: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

18

Example

Sample argument:P1 = “If Socrates is human then Socrates is mortal”P2 = “Socrates is human”Therefore:Q = “Socrates is mortal”

Valid / invalid?

Page 19: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

19

Entailment

Then is the following argument valid?P1

P2

entailsQ

Yes?Very well, but what if my interpretation I sets P1 and P2 to true but Q to false?

Then by definition Q is not entailed by P1 and P2

So do P1,P2 entail Q or do they not?

Page 20: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

20

What Happened…We considered P1, P2, and Q under a particular(common sense) interpretation:

P1 = “If Socrates is human then Socrates is mortal” trueP2 = “Socrates is human” trueQ = “Socrates is mortal” true

Thus, they were merely logical constants to us:P1=trueP2=trueQ=true

Page 21: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

21

Generality…Thus our argument was:

TrueTrueentailsTrue

Well, this is not very useful because it doesn’t tell us anything about validity of other arguments. For example:

P1=“If J.B. broke his leg then J.B. is in pain”P2=“J.B. broke his leg”entailsQ=“J.B. is in pain”

Is this argument valid?

Page 22: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

22

Extracting the Essence

How do we know it is valid?Because regardless of who J.B. is and what happened to him/her, we somehow know that:

If P1 and P2 holdThen Q will hold

But how do we know that?How can we extract the essence of the “dead Socrates” and “J.B. in pain” arguments?

Page 23: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

23

General Structure!Recall both arguments:

P1 “If Socrates is human then Socrates is mortal” “If J.B. broke his leg then J.B. is in pain”P2 “Socrates is human” “J.B. broke his leg”entailsQ “Socrates is mortal” “J.B. is in pain”

Note that P1, P2, and Q are related!Both arguments share the same structure:

P1 If X then YP2 XentailsQ Y

Then for any interpretation I as long as I satisfies P1and P2, interpretation I must satisfy Q

Page 24: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

24

Modus PonensThe “generalized” argument

P1 = X YP2 = XentailsQ = Y

…is much more useful!Why?

Because it captures the essence of both arguments and can be used for infinitely many more

“method of affirming” (Lat.)

Page 25: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

25

Valid Arguments (Revisited)Suppose someone makes an argument:

P1,..,PN therefore QThe argument is called valid iff:

P1,…,PN logically entail QThat is:

For any interpretation I that satisfies all Pj, interpretation I must necessarily satisfy Q

Usually: Pj and Q are somehow related formulae and P1 & … & PN can be true or false depending on the interpretation I

Page 26: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

26

Logical Form

Since:we consider all possible interpretationsthe conjunction of premises:

P1 & … & PNis not always true or false

The conclusion Q must follow from / be entailed by the premises… …by logical form of Pj and Q alone(p. 29 in the text)

Page 27: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

27

Questions?

Page 28: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

28

How Do We:Tell between a valid argument and an invalid argument:

People are mortal. Socrates is a man. Socrates is mortal.Ducks fly. F-16 flies. F-16 is a duck.

Prove that something logically follows from something else:

1: Everybody likes Buddha2: Everybody likes someone

Prove that something is logically equivalent to something else:

1: Everybody likes cream and sugar2: Everybody likes cream and everybody likes sugar

Prove that there is a contradiction?

Page 29: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

29

Propositional Logic

Method #1:Go through all possible interpretations and check the definition of valid argument

Method #2:Use derivation rules to get from the premises to the conclusion in a logically sound way

“derive the conclusions from premises”

Page 30: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

30

Method #1

Section 1.3 in the text proves many arguments/inference rules using truth tables

Suppose the argument is:P1,…,PN therefore Q

Create a truth table for formulaF=(P1 & … & PN Q)

Check if F is a tautology

Page 31: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

31

But Why? Recall:

Formula A entails formula Biff (A B) is a tautology

In general:premises P1,…,PN entail Qiffformula F=(P1 & … & PN Q)is a tautology

Page 32: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

32

Example #1

P v Q v R~R entails P v Q

valid/invalid?

(example 1.3.1 in the book, p. 30)

Page 33: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

33

Example #2

P v Q v R~R entails Q

valid/invalid?

Page 34: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

34

Example #3

P QP entails Q

valid/invalid?Modus ponens

Page 35: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

35

Example #4

P QQ entails P

valid/invalid?

Page 36: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

36

Example #5

P Q~Q entails ~P

valid/invalid?Modus tollens

Page 37: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

37

Example #6

P Qentails ~Q ~P

valid/invalid?

In fact, we proved last time that: (P Q) ≡ (~Q ~P)

Page 38: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

38

Example #7

P v Q~P & ~Qentails P & Q

valid/invalid?

Any argument with a contradiction in its premises is valid by default…

Page 39: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

39

Pros & Cons

Method #1:Pro: straight-forward, not much creativity machines can do

Con: the number of interpretations grows exponentially with the number of variables cannot do for many variables

Con: in predicate and some other logics even a small formula may have an infinitenumber of interpretations

Page 40: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

40

Questions?

Page 41: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

41

Method #2 : Derivations

To prove that an argument is valid:

Begin with the premises

Use valid/sound inference rules

Arrive at the conclusion

Page 42: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

42

Inference Rules

But what are these “inference rules”?They are simply…

…valid arguments!

Example:X & Y X & Y Z & WthereforeZ & W by modus ponens

Page 43: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

43

Example #1

(X&Y Z&W) & KX&YthereforeZ&WHow?(X&Y Z&W) & KX&Y Z&W by conjunctive simplificationX&YZ&W by modus ponens

Page 44: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

44

Derivations

The chain of inference rules that starts with the premises and ends with the conclusion…is called a derivation:

The conclusion is derived from the premises

Such a derivation makes a proof of argument’s validity

Page 45: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

45

Example #1

(X&Y Z&W) & KX&YthereforeZ&WHow?(X&Y Z&W) & KX&Y Z&W by conjunctive simplificationX&YZ&W by modus ponens

derivation

Page 46: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

46

Pros & Cons

Method #2:Pro: often can get a dramatic speed-up over truth tables.

Con: requires creativity and intuition harder to do by machines

Con: semi-decidable : there is no algorithm that can prove any first-order predicate logic argument to be valid or invalid

Page 47: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

47

Questions?

Page 48: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

48

Fallacies

An error in derivation leading to an invalid argumentVague formulations of premises/conclusionMissing stepsUsing non-sound inference rules, e.g.:

Converse errorInverse error

Page 49: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

49

Converse Error

If John is smart then John makes a lot of moneyJohn makes a lot of moneyTherefore:John is smart

Tries to use this non-sound “inference rule”:AB, BThus: A

Page 50: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

50

Inverse Error

If John is smart then John makes a lot of moneyJohn is not smartTherefore:John doesn’t make a lot of money

Tries to use this non-sound “inference rule”:AB, ~AThus: ~B

Page 51: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

51

Questions?

Page 52: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

52

Truth of facts vs. Validity of Arguments

The premises are assumed to be true ONLY in the context of the argument

The following argument is valid:If John Lennon was a rock star then he was a womanJohn Lennon was a rock starThus:John Lennon was a woman

But the 1st premise doesn’t hold under the common sense interpretation

Page 53: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

53

Inference Rules

Table 1.3.1 on page 39

If practice with the rules then will be more fluent using them

If are more fluent using them then will be more likely to get a better mark on exams

Page 54: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

54

Summary

Equivalence:A ≡ BA holds iff B holdsA is a criterion for BB is a criterion for AA entails BB entails AA and B are “equivalently strong”Formula F=(AB) is a tautology

Page 55: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

55

Summary

Entailment:A entails BB follows from AA∴B is a valid argumentA is a sufficient condition for BB is a necessary condition for AIf A holds then B holdsA may be “stronger than” BFormula F=(AB) is a tautology

Page 56: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

56

The Big Picture

Logic is being used to verify validity of arguments

An argument is valid iff its conclusion logically follows from the premises

Derivations are used to prove validity

Inference rules are used as part of derivations

Page 57: Logic and Discrete Math Lecture notes 3zhang/teaching/cse240/Spring...Truth of facts vs. Validity of Arguments The premises are assumed to be true ONLY in the context of the argument

57

Questions?