You are on page 1of 40

First-Order Logic

Chapters 8
Section 1 – 5
Outline
 First-order logic (FOL)
 Sentences
 Russell & Norvig, chapter 8
 Inference
 Russell & Norvig, chapter 9
Review Logical agent
 Propositional logic : Very Simple Logic
 Equivalence, Validity And Satisfaibility
 Rules:
 Equivalence: two sentences α and β are
logically equivalent if they are true in the same
of set of models
 Validity: A sentence is valid if it is true in all
models
 Satisfaibility: a sentence is satisfiable if it is
true in some model
Rules and Equivalences
 Logical equivalences
 (α  β)  (β  α)
 (α  β)  (β  α)
 ((α  β)  γ)  (α  (β  γ))
 ((α  β)  γ)  (α  (β  γ))
 ¬(¬α)  α
 (α  β)  (¬β  ¬α)
 (α  β)  (¬α  β)
 (α  β)  ((α  β)  (β  α))
 ¬(α  β)  (¬α  ¬β)
 ¬(α  β)  (¬α  ¬β)
 (α  (β  γ))  ((α  β)  (α  γ))
 (α  (β  γ))  ((α  β)  (α  γ))
Prove
 Prove ¬(¬α)  α
 ¬(α  β)  (¬α  ¬β)
Validity
 Prove (P^Q)(Q^P)

P Q P^Q Q^P (P^Q)(Q^P)

T T T T T

T F F F T

F T F F T

F F F F T
Validity (class work)
 Prove (PVQ)(QVP)

P Q PVQ QVP (PVQ)(QVP)

T T ? ? ?

T F ? ? ?

F T ? ? ?

F F ? ? ?
Validity
 Prove (p^(Q^R)(P^Q)^R)
P Q R (Q^R) P^(Q^R) (P^Q) (P^Q)^R P^(Q^R) (P^Q)^r
)
T T T T T T T T
T T F F F T F T
T F T F F F F T
T F F F F F F T
F T T F F F F T
F T F F F F F T
F F T F F F F T
F F F F F F F T
Satisfiable
 Prove (Smoke  Fire)
Smoke Fire Smoke Fire
T T T

T F F

F T T

F F T
Validity
 Prove (Smoke  Smoke)

Smoke Smoke Smoke Smoke


T T T

F F T
First-Order Logic
 Propositional logic is limited
 Cannot represent information concisely
 We want something more expressive

 First-order logic
 Allows the representation of objects, functions
on objects and relations between objects
 Allows us to represent almost any English
sentence
New Symbols in FOL
 Constant symbol
 An individual object in the world
 Bob, James, Hat

 Predicate symbol
 A relation between two objects that can be true or false
 Brother(Bob, James), OnHead(Hat, Bob)

 Function symbol
 Special type of relation that maps one object to another
 Head(Bob)
 All symbols begin with uppercase letters
New Variables in FOL
 Begin with lowercase letters
 Stand-in for any symbol

 Brother(x,y)
 x is the brother of y
New Quantifiers in FOL
 Universal quantifier 
 x means “For all x…”
 Always true
 Usually used with 
 x means “Not all x…”

 Existential quantifier 
 x means “There exists an x…”
 True for at least one interpretation
 Usually used with 
 x means “There exists no x…”
Properties of New Quantifiers

 Duality
 x P(x) same as x P(x)
 x P(x) same as x P(x)

 Nesting
 x y P(x,y) same as y x P(x,y)
 x y P(x,y) same as y x P(x,y)
 x y P(x,y) not same as y x P(x,y)
Sentences in FOL
 Term
 Constant symbol, function symbol, or variable

 Atom (atomic sentence)


 Predicate symbol with value true or false
 Represents a relation between terms

 Sentence (complex sentence)


 Atom(s) joined together using logical connectives
and/or quantifiers
Example Sentences
 Purple mushrooms are poisonous
Example Sentences
 Purple mushrooms are poisonous
 Purple(x)  Mushroom(x)  Poisonous(x)
Example Sentences
 Purple mushrooms are poisonous
 Purple(x)  Mushroom(x)  Poisonous(x)

 Some purple mushrooms are poisonous


Example Sentences
 Purple mushrooms are poisonous
 Purple(x)  Mushroom(x)  Poisonous(x)

 Some purple mushrooms are poisonous


 x Purple(x)  Mushroom(x)  Poisonous(x) (bad!)
Example Sentences
 Purple mushrooms are poisonous
 Purple(x)  Mushroom(x)  Poisonous(x)

 Some purple mushrooms are poisonous


 x Purple(x)  Mushroom(x)  Poisonous(x) (bad!)
 x Purple(x)  Mushroom(x)  Poisonous(x)
Example Sentences
 Purple mushrooms are poisonous
 Purple(x)  Mushroom(x)  Poisonous(x)
 Some purple mushrooms are poisonous
 x Purple(x)  Mushroom(x)  Poisonous(x) (bad!)
 x Purple(x)  Mushroom(x)  Poisonous(x)

 No purple mushrooms are poisonous


Example Sentences
 Purple mushrooms are poisonous
 Purple(x)  Mushroom(x)  Poisonous(x)
 Some purple mushrooms are poisonous
 x Purple(x)  Mushroom(x)  Poisonous(x) (bad!)
 x Purple(x)  Mushroom(x)  Poisonous(x)

 No purple mushrooms are poisonous


 x Purple(x)  Mushroom(x)  Poisonous(x)
Example Sentences
 Purple mushrooms are poisonous
 Purple(x)  Mushroom(x)  Poisonous(x)
 Some purple mushrooms are poisonous
 x Purple(x)  Mushroom(x)  Poisonous(x) (bad!)
 x Purple(x)  Mushroom(x)  Poisonous(x)

 No purple mushrooms are poisonous


 x Purple(x)  Mushroom(x)  Poisonous(x)
 x Purple(x)  Mushroom(x)  Poisonous(x)
Example Sentences
 Purple mushrooms are poisonous
 Purple(x)  Mushroom(x)  Poisonous(x)
 Some purple mushrooms are poisonous
 x Purple(x)  Mushroom(x)  Poisonous(x) (bad!)
 x Purple(x)  Mushroom(x)  Poisonous(x)
 No purple mushrooms are poisonous
 x Purple(x)  Mushroom(x)  Poisonous(x)
 x Purple(x)  Mushroom(x)  Poisonous(x)

 There are exactly two purple mushrooms


Example Sentences
 Purple mushrooms are poisonous
 Purple(x)  Mushroom(x)  Poisonous(x)
 Some purple mushrooms are poisonous
 x Purple(x)  Mushroom(x)  Poisonous(x) (bad!)
 x Purple(x)  Mushroom(x)  Poisonous(x)
 No purple mushrooms are poisonous
 x Purple(x)  Mushroom(x)  Poisonous(x)
 x Purple(x)  Mushroom(x)  Poisonous(x)

 There are exactly two purple mushrooms


 x y z Purple(x)  Mushroom(x)  Purple(y) 
Mushroom(y)  (x=y)  Purple(z) 
Mushroom(z)  (x=z)  (y=z)
Implication Truth Table
 If α is true, then β must be true
for the implication to be true
α β αβ  If α is false, then we have no
T T T
information about β
 β might be true or false without
T F F affecting the implication
F T T  β is not necessarily true
F F T  If implication is true and α is
true, then β must be true
(Modus Ponens)
Universal Implication
 x={ , , }
 All purple mushrooms are poisonous
 x Purple(x)  Mushroom(x)  Poisonous(x)
 Universal: all three implications are true
 is purple and a mushroom  is poisonous
 is purple and a mushroom  is poisonous
 is purple and a mushroom  is poisonous
 But the first one is the only one where the
premise is true, therefore the only one where we
know the consequent is true (Modus Ponens)
 Otherwise, we don’t know whether x is poisonous
Existential Implication
 x={ , , }
 Some purple mushrooms are poisonous
 x Purple(x)  Mushroom(x)  Poisonous(x)
 Existential: at least one implication is true
 is purple and a mushroom  is poisonous
 is purple and a mushroom  is poisonous
 is purple and a mushroom  is poisonous
 But all those where the premise is false are
true
 The existential implication doesn’t give us any
information
Existential Conjunction
 x={ , , }
 Some purple mushrooms are poisonous
 x Purple(x)  Mushroom(x)  Poisonous(x)
 Existential: at least one statement is true
 is purple and a mushroom and is poisonous
 is purple and a mushroom and is poisonous
 is purple and a mushroom and is poisonous
 The first statement is true, the other two are
false
 The existential quantifier is satisfied
 The situation is consistent with our original meaning
Universal Conjunction
 x={ , , }
 All purple mushrooms are poisonous
 x Purple(x)  Mushroom(x)  Poisonous(x)
 Universal: all three statements are true
 is purple and a mushroom and is poisonous
 is purple and a mushroom and is poisonous
 is purple and a mushroom and is poisonous
 “Everything is a poisonous purple mushroom”
 This is false, and not the original meaning of our
sentence
Summary
 Universal quantifier 
 Usually used with  to create universal rules
 Using it with  makes blanket statements about
all objects in the world

 Existential quantifier 
 Usually used with  to list properties of an
object
 Using it with  creates sentences that do not
say much
Example Sentences

 You can fool some people


all the time
Example Sentences
 You can fool some people all the
time
Example Sentences

 Everyone who loves all animals is


loved by someone
Example Sentences
 Everyone who loves all animals is
loved by someone
Example Sentences

 No living man can kill the Witch-King


Example Sentences

 No living man can kill the Witch-King


Wumpus World in FOL
 Predicate to represent adjacent rooms
 x,y,a,b Adjacent([x,y],[a,b]) 
[a,b]  {[x+1,y], [x-1,y], [x,y+1], [x,y-1]}
 Sentences to represent the relationship
between breezy rooms and pits
 r Breeze(r)  s Adjacent(r,s)  Pit(s)
 s Pit(s)  (r Adjacent(r,s)  Breeze(r))

You might also like