Post on 20-Apr-2018
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
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”
.
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
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
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
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
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
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
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!
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
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)
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
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)?
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)]]
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
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)]]
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)]
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) ]
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)
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
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
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
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
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?
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()
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)]
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
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
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?
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
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”
.
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
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”
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…
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)
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)]
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
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
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 Φ
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
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?
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
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))
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
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…
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
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…
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 Φ
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
50
Updated Definition
Φ holds under some interpretations and substitutions but not others?
Then Φ is a contingency
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
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
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
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
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
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
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
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
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?
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
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
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]
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)
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)
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
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
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”
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”
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
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!
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
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!
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
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
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
76
Universal Modus Ponens
Propositional modus ponens PQPThus, Q
Universal modus ponens∀x [P(x)Q(x)]P(a)Thus, Q(a)
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
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