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

Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

  • Upload
    doxuyen

  • View
    227

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

1

Weixiong ZhangWashington University in St. Louis

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

CSE 240Logic and Discrete Math

Lecture notes Predicate Logic

Page 2: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

2

Today

Chapter 2.1

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 Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

3

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 4: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

4

Summary

Logical implication/entailment:A entails/logically implies 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 X=(AB) is a tautology

Page 5: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

5

Summary

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

Page 6: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

6

Clarification #1

We have used the following expressions synonymously:

A entails BA logically implies B(A therefore B) is a valid argumentB logically follows from A

In reality there are some subtle differencesTechnically we mean:

“A logically implies B”Every model for A is also a model for B

Page 7: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

7

Clarification #2Can computers generate a derivation/proof given a conclusion and a set of premises?

Propositional logic is decidable:the tabular methodapplication of inference rules

Predicate logic is semi-decidableIf a proof exists then it can (theoretically) be found by machinesIf the proof doesn’t exist then the algorithm may not stop

Page 8: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

8

Clarification #3

Derivation of a statement: a sequence of statementsstart with the premiseseach statement logically follows from the previous statementsat some point the conclusion is arrived at

Derivations are annotated with the inference rules used

Page 9: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

9

Limitations of Propositional Logic

Let’s get back to Socrates“All people are mortal”“Socrates is a man”“Socrates is mortal”

Can we formalize this in propositional logic?Our previous attempt was:

“If Socrates is a man then Socrates is mortal”“Socrates is a man”“Socrates is mortal”

Clearly NOT the same!

Page 10: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

10

What is the matter?

The problem is:We operate with constant objects onlyWe have no domain context and no domain variablesWe cannot say “all”, “is a”, etc.

Solution?Predicate Logic

Page 11: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

11

Predicate LogicLogic objects (constants/variables):

P, Q, R, …true, false

Connectives:&, v, , …

Domain objects (constants/variables):Socrates, CSE240

Predicates:Mortal(Socrates)TaughtAtWashU(CSE240)Happened(snow,yesterday)

Quantifiers:For all, Exists

Statements/formulae:Atomic, conjunctive, etc.Quantified (universally / existentially)

Page 12: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

12

Translation Examples“Every man is mortal”

Define man(X), mortal(x)∀x [man(X) mortal(x)]

“Socrates is a man”man(Socrates)

“Socrates is mortal”mortal(Socrates)

The last statement logically follows from the premises (by universal elimination)Q: how about define man-mortal(x)?

Granularity of the representation unit of objects or concept to present

Page 13: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

13

More translations“Ducks fly”

Define duck(x), flies(x)∀x [duck(x) flies(x)]

“F-16s fly”Define F-16(x) ∀x [F-16(x) flies(x)]

“F-16s are ducks”∀x [F-16(x) duck(x)]

The last statement does not logically follow from the premisesWhat if we define duck-flies(x)?

Page 14: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

14

Translation Examples“Every person is a Knave or a Knight”

define person(x), Knave(x) and Knight(x)This can be translate to IF… THEN…∀x [person(x) [Knave(x) v Knight(x)]]

“Every person is a Knave or a Knight but not both”

∀x [person(x) [Knave(x) v Knight(x)] & ~[Knave(x) & Knight(x)]]

Page 15: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

15

Translation Examples“Nothing is better than God”

Define better-than(x,y)Different ways to say this …

∀x [~better-than(x,God)]~[∃x better-than(x,God)]

“A (any) sandwich is better than nothing”Define sandwich(x)∀x [sandwich(x) better-than(x,Nothing)]

“A sandwich is better than God”∀x [sandwich(x) better-than(x,God)]

The last statement does not logically follow from the premises

Page 16: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

16

Translation Examples“No man lives forever”

First define man(x) and lives-forever(x)Different ways to say this …

If a man (any), then will not live forever

∀x [man(x) ~lives-forever(x)]Different ways to say this …

It’s not true that …There is a man and the man lives forever

~[∃x [man(x) & lives-forever(x)]]

Page 17: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

17

Translation Examples

“Everyone likes CSE240”define WashU-student(x), likes(x,y)∀x [WashU-student(x) likes(x,CSE240)]

“Someone likes CSE240”∃x [WashU-student(x) likes(x,CSE240)]

Is this correct?

∃x [WashU-student(x) & likes(x,CSE240)]

Page 18: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

18

Translation Examples

“no even number is a prime except 2”define even(x), prime(x)∀x [even(x) ~prime(x)]What about except 2?

Equal(x,2)

∀x [even(x) & ~equal(x,2) ~prime(x) ]

Page 19: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

19

Predicate LogicLogic objects (constants/variables):

P, Q, R, …true, false

Connectives:&, v, , …

Domain objects (constants/variables):Socrates, CSE240

Predicates:Mortal(Socrates)TaughtAtWashU (CSE240)Happened(snow,yesterday)

Quantifiers:For all, Exists

Statements/formulae:Atomic, conjunctive, etc.Quantified (universally / existentially)

Page 20: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

20

Domain Objects

We can now have variables and constants of a non-Boolean nature:

Socrates is a constant (a specific member) in the set of all peopleX is a variable over the set of people

i.e., X can be any personWe can instantiate X=Socrates

Domain of a variable is the set of values it can take on

Page 21: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

21

PredicatesIn other words:

Predicates take domain objects and map them to true/false depending on the properties of the objects

Predicate = a property of an object we want testThus, a predicate with all its variables instantiated is a statement (i.e., true/false)

Example:BetterThan(v1,v2)BetterThan(Ferrari,nothing)=true

Page 22: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

22

Truth SetSuppose P(x) is “x is a factor of 8”So how about the following:

P(1)TrueP(2)TrueP(0)False

The set of all x such that P(x) holds is called the truth set of P(x)

Here it would be {1,2,4,8}The truth set of some predicate can be infinite

Page 23: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

23

Examples

Suppose P(x,y,r) is “x2+y2=r2”What is the truth set of P(x,y,5)?

Circle with the radius of 5 centered in the origin

Suppose P(n) is “n is an even three-digit prime number”What is the truth set of P(n)?

An empty set

Page 24: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

24

Propositional Logic?

But what about our dearly beloved propositional statements?

P v Q

Here P and Q are propositional/Boolean variables/statementsThey don’t take any domain objectsThey simply hold or don’t hold

How can we have them in the predicate logic?

Page 25: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

25

Fear Not!

A Boolean variable/constant (e.g., P=true) is simply a 0-arity predicate:

P()

So propositional logic is back!Example: propositional Modus Ponens:

P Q P() Q()P P()Thus, Q Thus, Q()

Page 26: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

26

Predicate Formulae

Everything from propositional logicBoolean variables become 0-arity predicates…

Additionally:Predicates, e.g.:

Mortal(x)Universally quantified formulae, e.g.:

∀x [man(x) mortal(x)]Existentially quantified formulae, e.g.:

∃x [man(x) & likes(x,240)]

Page 27: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

27

Recall: interpretation

In propositional logic interpretation is a mapping/assignment of all propositional variables to true/false

Example:Formula: A v BInterpretation: II(A)=trueI(B)=falseI(A v B)=true

Page 28: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

28

Extended InterpretationsIn predicate calculus to specify an interpretation we need to:

Select domain sets Assign all domain constantsAssign semantics to all predicates

Example:Predicate formula: D=(∀x [likes(x,c240)])A possible interpretation assigns:

Domain set for x : peopleDomain value for 2nd argument of likes(a,b) : thingsDomain value for constant c240 : class CSE240Semantics for predicate likes(a,b) : holds iff person a likes object b

Page 29: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

29

Evaluating formulaePredicate formula: D=(∀x [likes(x,cse240)])

A possible interpretation assigns:Domain set for x : peopleDomain value for 2nd argument of likes(a,b) : thingsDomain value for constant cse240 : class cse240Semantics for predicate likes(a,b) : holds iff person alikes object b

So what is the value of formula D given the interpretation? True/false?

How can we tell?

Page 30: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

30

Evaluating Formula0-arity predicate : P()

Interpretation directly

Predicate with variables : P(x)Use the assignment of x and the semantics of P()

Universally quantified formula : ∀x P(x)Evaluates to true iff P(x) holds on all possible values of x

Existentially quantified formulae : ∃x P(x)Evaluates to true iff P(x) holds on at least one possible value of x

Page 31: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

31

Today

Chapter 2.1

Chapter 2.2

Chapter 2.3

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 32: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

32

The Plan

Up to date we have considered an informal introduction to predicate logic

We will introduce predicate logic formally today and dwell on subtle moments

Page 33: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

33

Predicate Logic (simplified)Boolean variables

P, Q, R, … can be T/FE.g., P=“5 is a prime number”

Connectives:&, v, , , ~

Domain variablesA,B,C,… draw values from a domain setsE.g., j is a variable over integer numbers

Predicates:P(X1,…,XN),… map from domain inputs to T/FE.g., P(j) = “j is a prime number”

Quantifiers:For all ∀, Exists ∃E.g., [∀j prime(j)] = “any number is a prime number”

Statements/formulae:Atomic, unit, negated, conjunctive, …, universally/existentially quantifiedE.g., [∀j [even(j) & ~equal(j,2) ~prime(j) ]] = “no even numbers are prime except 2”

Page 34: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

34

Note

Notice that we did away with 0-arity predicates such as P(), etc.

Any Boolean variable is a 0-arity predicate so we will just drop the parentheses…

Page 35: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

35

Def : Well-formed Formulae

A well-formed formula/sentence (wff) is a construction defined recursively:

Any Boolean variable is a wffAny predicate is a wffFor any wff X, ~(X) is a wffTwo wffs parenthesized and connected by v,&,, form a wff. For any wff X and a domain variable k:

∀k (X) is a wff∃k (X) is a wffHere X is within the scope of ∀k (or ∃k)

Page 36: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

36

Find wffs…

∀x [man(X) mortal(x)]∀x [sandwich(x) better-than(x,Nothing)]∀x [duck(x) flies(x)]~[∃x [man(x) & lives-forever(x)]]∀x [man(x) ~lives-forever(x)]∀x [person(x) [Knave(x) v Knight(x)]]∀x [person(x) [Knave(x) v Knight(x)]] & ~[Knave(x) & Knight(x)]

Page 37: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

37

Def : Interpretations

Interpretation for a wff Φ:Assigns T/F values to all Boolean variablesDefines a domain set for each domain variableDefines all predicates

Example: consider wff Φ = (∀j prime(j)) & PA possible interpretation:

Boolean variable P=TDomain variable j runs over integer numbersPredicate prime(x) holds iff x is a prime number

Page 38: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

38

Interpretation ExampleConsider wff:

∀x ∃y Likes(x,y)

Does it hold?Depends on the interpretation!

Interpretation: Domain set for x,y is {Angela,Belinda,Jean}Define predicate Likes(liker,liked) as:

Likes(Angela,Belinda)Likes(Belinda,Angela)Likes(Jean,Belinda)Likes(Jean,Angela)

Does it hold in this interpretation?Yes

Page 39: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

39

Model / Countermodel

Formula Φ holds given an interpretation I:Φ is satisfied by IThen Φ is satisfiableThen I is a model for Φ

Formula Φ doesn’t hold given I: Φ is not satisfied (or falsified) by IThen I is a countermodel for Φ

Page 40: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

40

Tautologies & Contradictions

Formula Φ holds under any interpretation IΦ is valid

Φ is a tautology

Formula Φ doesn’t hold under any IΦ is a contradiction

Φ is unsatisfiable

Page 41: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

41

Example

Define Predicate P(X) as “person X drinks beer”

Consider∃x∀y [P(x) P(y)]“There exists a person such that if he/she drinks beer then everyone drinks beer”

True or false?

Page 42: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

42

Contingencies

Φ holds under any interpretation tautologyΦ does NOT hold under any interpretation contradictionWhat if Φ holds under some interpretations but not other?

Then Φ is a contingency

Page 43: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

43

Classify…

P & ~PP v ~PP & Q∀x P(x)∀x ((P(x) Q(x)) & P(x)) Q(x)∀x (P(x) v ~P(x)) (P(x) & ~P(x))

Page 44: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

44

Bindings & ScopeA variable can be free:

Sharp(X)

…or bound to a quantifier∀x P(x)

If variable X is bound to a quantifier then there is a binding between themThen X is said to be in the quantifier’s scopeHow about:

∀x ∀y (equal(x,y) v P(z) & (∃y B(x,y)))∀x ∃y P(x) & Q(x,y) v R(y)

CSE240 is case-sensitive! X is not the same as x

Page 45: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

45

Free variables Given an interpretation we can evaluate a formula, e.g.:

∀x ∃y Likes(x,y)

Consider the following formula:∃y Likes(x,y)

Suppose you are given the interpretation I:Domain set for x,y is {Angela,Belinda,Jean}Define predicate Likes(liker,liked) as:

Likes(Angela,Belinda)Likes(Jean,Belinda)Likes(Jean,Angela)

Is ∃y Likes(x,y) satisfied by I ?Cannot tell – x is a free variable…

Page 46: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

46

Substitutions

A wff that can be evaluated to T/F given an interpretation is called a statementFormulae with free variables may not be statements

That is so because an interpretation doesn’t touch free domain variables

A substitution “complements” an interpretation by assigning (substituting) all free domain variables

Page 47: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

47

Example Revisit the formula:

∃y Likes(x,y)Suppose you are given the interpretation I:

Domain set for x,y is {Angela,Belinda,Jean}Define predicate Likes(liker,liked) as:

Likes(Angela,Belinda)Likes(Jean,Belinda)Likes(Jean,Angela)

Additionally you have a substitution S:Free domain variable x is set to Angela

Is ∃y Likes(x,y) satisfied by I and S?Yes…

Page 48: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

48

Updated Definition

Formula Φ holds given an interpretation I and a substitution S:

Φ is satisfied by I and SThen Φ is satisfiableThen I and S form a model for Φ

Formula Φ doesn’t hold given I and S : Φ is not satisfied (or falsified) by I and SThen I and S form a countermodel for Φ

Page 49: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

49

Updated Definition

Formula Φ holds under every interpretation I and substitution S

Φ is valid

Φ is a tautology

Formula Φ doesn’t hold under any I andsubstitution S

Φ is a contradiction

Φ is unsatisfiable

Page 50: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

50

Updated Definition

Φ holds under some interpretations and substitutions but not others?

Then Φ is a contingency

Page 51: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

51

Note 1

Many formulae with free variables cannot be tautologies or contradictions

Their value depends on the substitution

However, some can:Likes(x,y) v ~Likes(x,y)… is a tautology despite two free variables

Page 52: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

52

Implicit Quantifiers

If x > 2 then x2 > 4

Textbook:∀ real numbers x, if x>2 then x2 > 4

More formally:∀x [x>2 ∃y square(x,y) & y>4]where predicates square(a,b) and c>d are defined over the set of real numbers

Implicit quantifiers

Implicit quantifiers

Page 53: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

53

Domain FunctionsConsider the last statement again:∀ real numbers x, if x>2 then x2 > 4Is it a wff? No! Why?

Well x2 is not a predicate and is not a variableIt is a domain function (square)!

We have not formally introduce domain functions

But we will use them anyway for the sake of:SimplicityConsistency with the text book

Page 54: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

54

Conversion to Predicates

The use of domain functions is justified:Because they can be expressed through domain predicates

Example:let function f map numbers to numbers:

f(n)=m

Then whenever we see f(x) in our wffWe will change it (with some care) to:

∃y Pf(x,y)Where Pf(n,m) holds iff f(n)=m

Page 55: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

55

Evaluating FormulaeBoolean variables

Interpretation directly

Predicate with variables : Likes(x)Use the assignment of x and the semantics of Likes()

Universally quantified formula : ∀x P(x)Evaluates to true iff P(x) holds on all possible values of x

Existentially quantified formulae : ∃x P(x)Evaluates to true iff P(x) holds on at least one possible value of x

Page 56: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

56

ExamplesConsider formula D:

∃x (x2 > x)Assume the standard algebraic interpretation

Suppose the domain set for variable x is {2,3,4}Does D hold or not?

Yes : 4>2

Suppose the domain set for variable x is the segment [0,1]Does S hold or not?

No : all numbers between 0 and 1 have their squares not greater than the number itself

Page 57: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

57

SummaryGIVEN a particular interpretation

To show that a ∀-quantified formula holds:Exhaust all possibilities – show that all examples satisfy the formula

To show that a ∀-quantified formula does NOT hold:Find a falsifying example

To show that a ∃-quantified formula holds:Find a satisfying example

To show that a ∃-quantified formula does NOT hold:Exhaust all possibilities and show that all examples falsify the formula

Page 58: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

58

Summary

How about classifying a formula:Tautology / Contradiction / Contingency

Contingencies are, perhaps, the easiest:Need to find a model and a counter-model

Tautologies / contradictions:Need to show that all possible interpretations satisfy/falsify the formulaMore difficult

Page 59: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

59

Restricted ∀-QuantifiersInformal:

Any number greater than 2 is positiveFormal:

∀x [x>2 x>0]Formal shorthand (“syntactic sugar”):

∀x>2 [x>0]Common mistake:

Use of & instead of ∀x [x>2 & x>0]“Any number is greater than 2 and greater 0”How about 1?

Page 60: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

60

Restricted ∃-QuantifiersInformal:

There is a positive solution to x2=1

Formal: ∃x [x>0 & x2=1]

Formal shorthand (“syntactic sugar”): ∃x>0 [x2=1]

Common mistake:Use of instead of &∃x [x>0 x2=1]“There exists a number such that if it is positive then it is a solution to x2=1”This formula is satisfied by any interpretation that contains 0among the numbers

Page 61: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

61

Restricted ∃-QuantifiersAnother example of…Common mistake: use of instead of &

“There exists an immortal man”

Correct:∃x [man(x) & ~mortal(x)]

Incorrect:∃x [man(x) ~mortal(x)]“There exists something such that if it is a man then it is immortal”

The latter formula is satisfied by any interpretation that allows x to run over non-man objects

E.g., x can be a duck satisfying the formula

Page 62: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

62

Limitations

It is Ok to use the shorthand with:Algebraic predicates: e.g., x>0Set membership: e.g., x∈D

Why?Because it is clear that your quantifiers is applied to the variable which follows it immediately:

∃x>0 [x2=1]

It is not Ok to use such shorthands with other predicates:

E.g., ∃P(x) [x2=1]

Page 63: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

63

Special cases : finite domains

Suppose you have a formula over a single variable x

If the domain of variable x is finite:{x1,…,xN}

Then ∀x P(x) is equivalent to:P(x1) & … & P(xN)

And ∃x P(x) is equivalent to:P(x1) v … v P(xN)

Page 64: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

64

Satisfying ∀/∃ statements

To show that ∀x P(x) we need to:Prove that every x satisfies P(x)

To show that ∃x P(x) we need to:Prove that there exists at least one x that satisfies P(x)

Page 65: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

65

De Morgan again…

To show that ~(∀x P(x)) we need to:Prove that not every x satisfies P(x)In other words, we need to find at least one x that does not satisfy P(X)But that is the same as proving that ∃x ~P(x)

Therefore:~(∀x P(x)) ∃x (~P(x))

are logically equivalentDe Morgan’s law for quantifiers

Page 66: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

66

And again…To show that ~(∃x P(x)) we need to:

Prove that there does not exists a single x satisfiesP(x)In other words, we need to show that all x do notsatisfy P(X)But that is the same as proving that ∀x ~P(x)

Therefore:~(∃x P(x)) ∀x (~P(x))

are logically equivalentDe Morgan’s law for quantifiers

Page 67: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

67

Examples

Statement:“Everyone snoozes in CSE240”

Negation:“Not every one snoozes in CSE240”“There is someone who doesn’t snooze in CSE240”

A common mistake:“Everyone does NOT snooze in CSE240”

Page 68: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

68

Examples

Statement:“Professors don’t make much money”

Negation:“There is a professor who makes a lot of money”

A common mistake:“Professors make much money”

Page 69: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

69

ExamplesStatement:

There is a secret agent who appeals to all women

Negation:For every secret agent there is a woman that the agent doesn’t appeal to

A common mistake:There is a secret agent who doesn’t appeal to all women

Page 70: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

70

In the nutshell…

When negating a quantified formula:Quantifier1 x1… QuantifierN xN P(x1,..,xN)

Do this:Change all ∃ to ∀Change all ∀ to ∃Negate the innermost formula P(…)

Be careful with scoping and connectives!

Page 71: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

71

Vacuous Truth of UQs

Suppose I say:“Presently, all men on the moon are happy”

Is it true or false?Think of it this way:

∀x [OnTheMoon(x) Happy(x)]

So, is it true or false?The internal implication is always vacuously true for there is presently no man on the MoonThus, the entire statement holds for any x

The entire statement holds

Page 72: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

72

Logical Implication

In propositional logic formula A logically implies formula B iff:

Every interpretation that satisfies A also satisfies B

In predicate logic?The same!

Page 73: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

73

Validity of Arguments

Hence validity of arguments is defined in the same way

The difference is: in predicate logic it is not always possible to go through all interpretations to prove that A logically implies B

Why?The number of interpretations can be infinite

Page 74: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

74

Inference Rules

Thus, proving arguments with inference rules becomes the (only) method of choice

We can also derive new inference rules for our toolbox

Page 75: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

75

Universal Instantiation

Consider a universally quantified statement:∀x∈D [P(x)]

Suppose you have a particular x0∈DWhat can you say about P(x0)?

It holds!

Why? Because predicate P(…) holds for all members of set DExample: “mortal Socrates” argument

Page 76: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

76

Universal Modus Ponens

Propositional modus ponens PQPThus, Q

Universal modus ponens∀x [P(x)Q(x)]P(a)Thus, Q(a)

Page 77: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

77

Diagrams for Validity

Diagrams can sometimes be used to:support a validity of an argumentor, show that an argument is invalid

Diagrams are not a formal proof!Use them to illustrate your reasoning ONLYExamples:

Valid : Modus PonensInvalid : abduction

mortal

human

Socrates pneumonia

fever

patient

Page 78: Logic and Discrete Math Lecture notes Predicate Logiczhang/teaching/cse240/Spring10/PredLogic.pdf · follows from the premises ... A Boolean variable/constant (e.g., P=true) ... The

78

Summary predicate logicEverything from propositional logicDomain variables, objectsUniversal/existential quantifiersWFF – grammar to write sentencesScope of a quantiferRepresentation

Every student takes CSE240Someone takes CSE240

De morgan’s law on negation with quantifiers