0% found this document useful (0 votes)
7 views25 pages

02 Fol 1

Uploaded by

hariskhan38273
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views25 pages

02 Fol 1

Uploaded by

hariskhan38273
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

First-Order Logic (FOL)

aka. predicate calculus


Laura Dillon
Computer Science & Engineering
Michigan State University

Adapted from:
Tuomas Sandholm
Carnegie Mellon University
Computer Science Department

Fall 2014, CSE 814 Overview of Predicate Logic & 1


Automated Reasoning
First-Order Logic (FOL)
Syntax
User defines these primitives:
– Constant symbols (i.e., the "individuals" in the world)
E.g., Mary 3

– Function symbols (map individuals to individuals)


E.g., father-of(Mary) sum(5,39) 5 + 39

– Predicate symbols (map individuals to truth values)


E.g., father-of_is_(Mary,Tom)
eq(father-of(Mary), Tom) father-of(Mary) = Tom
less-than(0,x) 0 < x
True False

Fall 2014, CSE 814 Overview of Predicate Logic & 2


Automated Reasoning
First-Order Logic (FOL)
Syntax
• FOL supplies these primitives:
– Variable symbols. E.g., x,y
stand for “individuals” in some “domain”
– Connectives.
Same as in PL: not (~), and (^), or (v), implies
(=>), if and only if (<=>)
– Quantifiers: Universal (A) and Existential (E)

Fall 2014, CSE 814 Overview of Predicate Logic & 3


Automated Reasoning
Quantifiers
• Universal quantification:(Ax)P(x) means that P holds
for all values of x in the domain associated with x.
– E.g., (Ax)(dolphin(x) => mammal(x))

• Existential quantification: (Ex)P(x) means that P holds


for some value of x in the domain associated with x.
– E.g., (Ex)( mammal(x) ^ lays-eggs(x))

Fall 2014, CSE 814 Overview of Predicate Logic & 4


Automated Reasoning
First-Order Logic (FOL)
Syntax and terminology
• A term is a constant symbol, a variable symbol, or a function symbol
applied to terms, e.g,
3 x length(x) min(x, y)

• An atom is a predicate symbol applied to terms, e.g.,


is_in(x, cse814) is_prime(n)

• A literal is an atom or a negated atom, e.g.,


is_in(x, cse814) ~is_in(x, cse814)

• If P and Q are literals and x is a variable, then the following are sentences:
P V Q P ^ Q ~P
P => Q P <=> Q
(Ax)P (Ex)P

Fall 2014, CSE 814 Overview of Predicate Logic & 5


Automated Reasoning
First-Order Logic (FOL)
Syntax and terminology
• In the sentences (Ax)P and (Ex)P we assume wlog that no
nested quantifiers in P use x:
– every occurrence within P of the variable x is bound by the quantifier
– every occurrence within P of a variable that is not bound by any
quantifier within P is free
E.g.:
– In (Ay)(Ez)P(x,y,z): y and z are bound and x is free

• A well-formed formula (wff) is a sentence containing no "free" variables,


e.g.,
– A wff: (Ax)(Ay) P(x,y)
– A sentence, but not a wff: (Ay)P(x,y)

Fall 2014, CSE 814 Overview of Predicate Logic & 6


Automated Reasoning
Quantifiers…
• Universal quantifiers are usually used with "implies" to form
"if-then rules."
– E.g., (Ax)(in_cse814(x) => smart(x))
– A common mistake is instead use:
(Ax)(in_cse814(x) ^ smart(x))

• Existential quantifiers are usually used with "and" to specify a


list of properties or facts about a specific individual.
– E.g., (Ex) (in_cse814(x) ^ smart(x))

– A common mistake is to instead use:


(Ex)(in_cse814(x) => smart(x))

Fall 2014, CSE 814 Overview of Predicate Logic & 7


Automated Reasoning
Quantifiers...
• Changing the name of a quantified variable does not
change meaning provided no name clash:
– (Ax)P(x,y) is logically equivalent to (Az)P(z,y)
– (Ax)P(x,y) is not logically equivalent to (Ay)P(y,y)
– To be safe: replace with a “new” variable name (one not
used anywhere else in the wff)

• Changing the name of a free variable does change


meaning:
– (Ax)P(x,y) is not logically equivalent to (Ax)P(x,w)

Fall 2014, CSE 814 Overview of Predicate Logic & 8


Automated Reasoning
Quantifiers...
• Changing the order of the same types of quantifiers
does not change the meaning:
– (Ax)(Ay)P(x,y) is equivalent to (Ay)(Ax)P(x,y).
– (Ex)(Ey)P(x,y) is equivalent to (Ey)(Ex)P(x,y)

• Switching the order of universals and existentials


does change meaning:
– (Ax)(Ey)P(x,y)is not equivalent to(Ey)(Ax)P(x,y)

Fall 2014, CSE 814 Overview of Predicate Logic & 9


Automated Reasoning
Translating English to FOL
• Every gardener likes the sun.
(Ax) gardener(x) => likes(x,Sun)

• You can fool some of the people all of the time.


(Ex)(At) (person(x) ^ time(t)) => can-fool(x,t)

• You can fool all of the people some of the time.


(Ax)(Et) (person(x) ^ time(t) => can-fool(x,t)

• All purple mushrooms are poisonous.


(Ax) (mushroom(x) ^ purple(x)) => poisonous(x)

Fall 2014, CSE 814 Overview of Predicate Logic & 10


Automated Reasoning
Translating English to FOL…
• There are exactly two purple mushrooms.

(Ex)(Ey)(mushroom(x) ^ purple(x)
^ mushroom(y) ^ purple(y) ^ ~(x=y)
^ (Az)((mushroom(z) ^ purple(z))=>
((x=z) v (y=z)))

• For X to be above Y, X must either be (directly) on top of Y


or be on top of another object that is above Y.

(Ax)(Ay)(above(x,y) <=>
(on(x,y) v (Ez)((on(x,z) ^ above(z,y))))

Fall 2014, CSE 814 Overview of Predicate Logic & 11


Automated Reasoning
Identities for FOL
Identities for PL apply to FOL as well. E.g.,

~~P is logically equivalent to P (double negation)

P V Q is logically equivalent to Q V P (commutative law for V)

~(P V Q) is logically equivalent to (~P) ^ (~Q) (De Morgan)

...

Fall 2014, CSE 814 Overview of Predicate Logic & 12


Automated Reasoning
Fall 2014, CSE 814 Overview of Predicate Logic & 13
Automated Reasoning
Identities for FOL
New logical equivalences for FOL. E.g.,

(Ax)P(x) logically equiv to (Az)P(z) if z is a new var name


(Ex)P(x) logically equiv to (Ez)P(z) if z is a new var name

(Ax)(Ay)P(x,y) is logically equivalent to (Ay)(Ax)P(x,y)


(Ex)(Ey)P(x,y) is logically equivalent to (Ey)(Ex)P(x,y)

~(Ax)P(x) is logically equivalent to (Ex)~P(x)


~(Ex)P(x) is logically equivalent to (Ax)~P(x)
. . .
Fall 2014, CSE 814 Overview of Predicate Logic & 14
Automated Reasoning
Inference Rules for FOL
Inference rules for PL apply to FOL as well. E.g.,

Modus Ponens:
If p is true and if p => q is true, then q is true.

Conjunction (And-Introduction):
If p is true and if q is true, then p ^ q is true.

Simplification (And-Elimination):
If p ^ q is true, then p is true.
...
Resolution:
If ~p V q is true and if p V r is true, then q V r is true.

Fall 2014, CSE 814 Overview of Predicate Logic & 15


Automated Reasoning
Fall 2014, CSE 814 Overview of Predicate Logic & 16
Automated Reasoning
Inference Rules for FOL
New inference rules for use with quantifiers:
• Universal Instantiation
If (Ax)P(x) is true and if c is a constant in the domain of x,
then infer P(c).
– E.g., from (Ax)(food(x) => eats(Ziggy,x)) infer
food(IceCream) => eats(Ziggy,IceCream).

• Existential Instantiation
From (Ex)P(x) infer P(c) for some new constant c
– E..g., from (Ex)eats(Ziggy,x) infer eats(Ziggy,K).
– Note that the variable is replaced by a brand new constant that does not
occur in this or any other sentence in the premises or conclusions

Fall 2014, CSE 814 Overview of Predicate Logic & 17


Automated Reasoning
Inference Rules for FOL
New inference rules for use with quantifiers:
• Universal Generalization
If P(c) is true, where c is an arbitrary constant in the domain of x,
then infer (Ax)P(x)
– E.g., from eats(Ziggy,c) V ~food(c), for arbitrary c,
infer (Ax)(eats(Ziggy,x) V ~food(x)).

• Existential Generalization
If P(c) is true, where c is from the domain of x, then infer
(Ex)P(x).
– E.g., from eats(Ziggy, IceCream) we can infer
(Ex)eats(Ziggy, x).
– All instances of the given constant symbol are replaced by the new variable
symbol. Note that the variable symbol cannot already exist anywhere in the
expression.
Fall 2014, CSE 814 Overview of Predicate Logic & 18
Automated Reasoning
Fall 2014, CSE 814 Overview of Predicate Logic & 19
Automated Reasoning
Natural Deduction Proof
A proof that a set of hypotheses H implies a conclusion c:

A list of conclusions, the last of which is c, and their


justifications:
– An axiom (expressing domain knowledge),
– A hypothesis,
– An equivalence and an earlier conclusion, or
– A valid ROI and one or more earlier conclusions

Fall 2014, CSE 814 Overview of Predicate Logic & 20


Automated Reasoning
Example ND Proof
Informal argument: Someone in this class, owns a red
convertible. Everyone who owns a car has car insurance .
Therefore, someone in this class has car insurance.
In FOL:
Given hypotheses:
(Ex)(in_814(x) ^ owns_rc(x))
(Ax)(owns_car(x) => has_ins(x))
And axiom:
(Ax)(owns_rc(x) => owns_car(x))
Can we conclude:
(Ex)(in_814(x)^ has_ins(x))

Fall 2014, CSE 814 Overview of Predicate Logic & 21


Automated Reasoning
Example ND Proof
Proof:
1. (Ex)(in_814(x) ^ owns_rc(x)) 1st hypothesis
2. in_814(K) ^ owns_rc(K), for some K Exist. Inst. w/ 1
3. (Ax)(owns_rc(x) => owns_car(x)) axiom
4. owns_rc(K) => owns_car(K), for the K in 2 UI w/ 3
5. owns_car(K), for the K in 2 Simp. & MP /w 1 & 2
6. (Ax)(owns_car(x) => has_ins(x)) 2nd hypothesis
7. owns_car(K) => has_ins(K) , for the K in 2 Univ. Inst. w/6
8. has_ins(K), for the K in 2 MP w/ 5 & 7
9. in_814(K) ^ has_ins(K) , for the K in 2 Simp. & Conj w/ 2 & 8
10. (Ex)(in_814(x)^ has_ins(x)) EG & 9

Fall 2014, CSE 814 Overview of Predicate Logic & 22


Automated Reasoning
Natural Deduction Proof
In proving a conclusion of the form p => q, we may
assume p is true and prove that then q must be true.

A proof that a set of hypotheses H implies p => q:


A list of conclusions, the last of which is q, and their
justifications:
– An axiom (expressing domain knowledge),
– A hypothesis,
– The assumption that p is true
– An equivalence and an earlier conclusion, or
– A valid ROI and one or more earlier conclusions

Fall 2014, CSE 814 Overview of Predicate Logic & 23


Automated Reasoning
Example ND Proof
To show: ((Ax)P(x) V (Ax)Q(x)) => (Ax)(Ay)(P(x) V Q(y))
We first show: (Ax)P(x) => (Ax)(Ay)(P(x) V Q(y))
Proof:
1. (Ax)P(x) Assumption
2. P(K), for any K UI & 1
3. P(K) V Q(K’) , for any K and for any K’ Addition & 2
4. (Ay)(P(K) V Q(y)) for any K UG & 3
5. (Ax)(Ay)(P(x) V Q(y)) UG & 4
6. (Ax)P(x) => (Ax)(Ay)(P(x) V Q(y)) ND, 1 & 5
Similarly: (Ax)Q(x) => (Ax)(Ay)(P(x) V Q(y))
Then ((Ax)P(x) V (Ax)Q(x)) => (Ax)(Ay)(P(x) V Q(y))
follows from ((p => r)^(q => r)) <=> ((p V q) => r)
Fall 2014, CSE 814 Overview of Predicate Logic & 24
Automated Reasoning
Example ND Proof
To show: (Ax)(Ay)(P(x) V Q(y)) => ((Ax)P(x) V (Ax)Q(x))
Proof:
1.(Ax)(Ay)(P(x) V Q(y)) Assumption
2.(Ax)(P(x) V (Ay)Q(y)) *&1
3.(Ax)P(x) V (Ay)Q(y) *&2
4.(Ax)P(x) V (Ax)Q(x) Variable change
5.(Ax)(Ay)(P(x) V Q(y)) => ((Ax)P(x) V (Ax)Q(x))
ND, 1 & 4
* (Ax)(P(x) V Q) <=> (Ax)P(x) V Q if x does not occur in Q

All of this to conclude:


(Ax)(Ay)(P(x) V Q(y)) <=> ((Ax)P(x) V (Ax)Q(x))

Fall 2014, CSE 814 Overview of Predicate Logic & 25


Automated Reasoning

You might also like