0% found this document useful (0 votes)
18 views27 pages

Unit III-FOL

first order lgoic

Uploaded by

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

Unit III-FOL

first order lgoic

Uploaded by

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

First-Order Logic

Outline
• Why FOL?
• Syntax and semantics of FOL
• Using FOL
Pros and cons of propositional logic
 Propositional logic is declarative
 Propositional logic allows partial/disjunctive/negated
information
– (unlike most data structures and databases)
 Propositional logic is compositional:
– meaning of B1,1  P1,2 is derived from meaning of B1,1 and of P1,2

 Propositional logic has very limited expressive power


– (unlike natural language)
– E.g., cannot say "pits cause breezes in adjacent squares“
• except by writing one sentence for each square
• a separate rule about breezes and pits for each square




First-order logic
• Whereas propositional logic assumes the world
contains facts,
• first-order logic (like natural language) assumes the
world contains
– Objects: people, houses, numbers, colors, baseball
games, wars, squares, pits, wumpuses,…
– Relations: red, round, prime, brother of, bigger than, part
of, comes between, is breezy, is adjacent to, shoots …
– Functions: father of, best friend, one more than, plus, …

Examples:
• “One plus two equals three.” Objects: one, two, three, one plus
two; Relation: equals;
Function: plus. (“One plus two” is a name for the object that is
obtained by applying the function “plus” to the objects “one”
and “two.” “Three” is another name for this object.)

• “Squares neighboring the wumpus are smelly.” Objects: wumpus,


squares; Property: smelly; Relation: neighboring.

• “Evil King John ruled England in 1200.” Objects: John, England,


1200; Relation: ruled during; Properties: evil, king.
Syntax of FOL: Basic elements
• Constants KingJohn, 2, NUS,...
• Predicates Brother, >,...
• Functions Sqrt, LeftLegOf,...
• Variables x, y, a, b,...
• Connectives , , , , 
• Equality =
• Quantifiers , 
The formal grammar
1. The syntax of
first-order logic
with equality,
specified in
Backus–Naur
form
2. Operator
precedences are
specified, from
highest to
lowest.
3. The precedence
of quantifiers is
such that a
quantifier holds
over everything
to the right of it.
Atomic sentences
Atomic sentence = predicate (term1,...,termn)
or term1 = term2

Term = function (term1,...,termn)


or constant or variable

• E.g.,1 Brother(KingJohn,RichardTheLionheart)
• 2 King John’s left leg : LeftLegOf(KingJohn)

• 3 Richard the Lionheart’s father is married to King John’s
mother
• Married(Father(Richard),Mother(John))
Complex sentences
• Complex sentences are made from atomic
sentences using connectives

E.g. Sibling(KingJohn,Richard) 
Sibling(Richard,KingJohn)

• S, S1  S2, S1  S2, S1  S2, S1  S2,


Truth in first-order logic
• Sentences are true with respect to a model and an interpretation

• Model contains objects (domain elements) and relations among


them

• Interpretation specifies referents for


constant symbols → objects
predicate symbols → relations
function symbols → functional relations

• An atomic sentence predicate(term1,...,termn) is true


iff the objects referred to by term1,...,termn
are in the relation referred to by predicate
Models for FOL: Example
Universal quantification
 <variables> <sentence>

Everyone at NUS is smart:


x At(x,NUS)  Smart(x)
 x P is true in a model m iff P is true with x being each
possible object in the model
• Roughly speaking, equivalent to the conjunction of
instantiations of P
• ∀x King(x) ⇒ Person(x).


 All kings are persons
A common mistake to avoid
• Typically,  is the main connective with 
• Common mistake: using  as the main
connective with :
x At(x,NUS)  Smart(x)
means “Everyone is at NUS and everyone is smart”


Existential quantification
 <variables> <sentence>

• Someone at NUS is smart:


 x At(x,NUS)  Smart(x)$
 x P is true in a model m iff P is true with x being some
possible object in the model



Another common mistake to
avoid
• Typically,  is the main connective with 

• Common mistake: using  as the main


connective with :
x At(x,NUS)  Smart(x)
is true if there is anyone who is not at NUS!



Properties of quantifiers
 x y is the same as y x
 x y is the same as y x
 x y is not the same as y x
 x y Loves(x,y)
– “There is a person who loves everyone in the world”
 y x Loves(x,y)
– “Everyone in the world is loved by at least one person”

• Quantifier duality: each can be expressed using the other


 x Likes(x,IceCream) x Likes(x,IceCream)
 x Likes(x,Broccoli) x Likes(x,Broccoli)




Equality
• term1 = term2 is true under a given interpretation
if and only if term1 and term2 refer to the same
object

• E.g., definition of Sibling in terms of Parent:


x,y Sibling(x,y)  [(x = y)  m,f  (m = f) 
Parent(m,x)  Parent(f,x)  Parent(m,y)  Parent(f,y)]


Using FOL
The kinship domain:
• Brothers are siblings
x,y Brother(x,y)  Sibling(x,y)
• One's mother is one's female parent
m,c Mother(c) = m  (Female(m)  Parent(m,c))
• “Sibling” is symmetric
x,y Sibling(x,y)  Sibling(y,x)



• – “Each animal is an organism”
• – “All animals are organisms”
• – “If it is an animal then it is an organism”
• This can be formalised as:
– ∀x(Animal(x)→Organism(x))

– “Aliens exist”
– ∃xAlien(x)

– with the ‘exist’ matching the ∃, and


– “There are books that are heavy”
– ∃x(Book(x)∧heavy(x))
Examples – Cont..

● Translate the sentence "Every man is mortal"


into Predicate formula.
● Representation of statement in predicate form
− “x is a man” and “MAN(x),
− x is mortal” by MORTAL(x)
● Every man is mortal :
(x) (MAN(x)  MORTAL(x))
Using FOL
The set domain:
 s Set(s)  (s = {} )  (x,s2 Set(s2)  s = {x|s2})
 x,s {x|s} = {}
 x,s x  s  s = {x|s}
 x,s x  s  [ y,s2} (s = {y|s2}  (x = y  x  s2))]
 s1,s2 s1  s2  (x x  s1  x  s2)
 s1,s2 (s1 = s2)  (s1  s2  s2  s1)
 x,s1,s2 x  (s1  s2)  (x  s1  x  s2)
 x,s1,s2 x  (s1  s2)  (x  s1  x  s2)


Interacting with FOL KBs
• Suppose a wumpus-world agent is using an FOL KB and perceives
a smell and a breeze (but no glitter) at t=5:

Tell(KB,Percept([Smell,Breeze,None],5))
Ask(KB,a BestAction(a,5))

• I.e., does the KB entail some best action at t=5?


• Answer: Yes, {a/Shoot} ← substitution (binding list)
• Given a sentence S and a substitution σ,
• Sσ denotes the result of plugging σ into S; e.g.,
S = Smarter(x,y)
σ = {x/Hillary,y/Bill}
Sσ = Smarter(Hillary,Bill)
• Ask(KB,S) returns some/all σ such that KB╞ σ


Knowledge base for the
wumpus world
• Perception
 t,s,b Percept([s,b,Glitter],t)  Glitter(t)

• Reflex
 t Glitter(t)  BestAction(Grab,t)

Deducing hidden properties
 x,y,a,b Adjacent([x,y],[a,b]) 
[a,b]  {[x+1,y], [x-1,y],[x,y+1],[x,y-1]}
Properties of squares:
 s,t At(Agent,s,t)  Breeze(t)  Breezy(s)

Squares are breezy near a pit:


– Diagnostic rule---infer cause from effect
s Breezy(s)  \Exi{r} Adjacent(r,s)  Pit(r)
– Causal rule---infer effect from cause
r Pit(r)  [s Adjacent(r,s)  Breezy(s) ]


You might also like