0% found this document useful (0 votes)
39 views13 pages

FolAgents HND

This document provides an introduction to first order logic (FOL) for agents. It discusses some key components of FOL, including objects, relations, functions, logical symbols, terms, atomic formulas, well-formed formulas, interpretations, and evaluating FOL formulas. It also covers important concepts such as models, validity, satisfiability, and logical consequence. Common mistakes to avoid when using quantifiers and logical connectives are also highlighted.

Uploaded by

Asad Memon
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)
39 views13 pages

FolAgents HND

This document provides an introduction to first order logic (FOL) for agents. It discusses some key components of FOL, including objects, relations, functions, logical symbols, terms, atomic formulas, well-formed formulas, interpretations, and evaluating FOL formulas. It also covers important concepts such as models, validity, satisfiability, and logical consequence. Common mistakes to avoid when using quantifiers and logical connectives are also highlighted.

Uploaded by

Asad Memon
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/ 13

First Order

Logic for
Agents

First Order Logic for Agents

Summary

First Order
Logic for
Agents

♦ FOL
♦ Wumpus world in FOL
♦ Situation calculus
Pros and cons of propositional logic

First Order
Logic for
Agents Propositional logic is declarative: pieces of syntax
correspond to facts
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
Meaning in propositional logic is context-independent
(unlike natural language, where meaning depends on context)
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

Components of First Order Logic

First Order
Logic for
Agents Objects, Relations, Functions

Whereas propositional logic assumes world contains facts,


rst-order logic (like natural language) assumes the world con-
tains: Objects, Relations, Functions.

Objects: people, houses, numbers, theories, colors, football


games, wars, centuries ···
Relations: red, round, multistoried ···,
brother of, bigger than, inside, part of, has color, occurred
after, owns, comes between, ···
Functions: father of, best friend, second half of, one more
than, beginning of ···
The Language: Logical Symbols

First Order
Logic for Logical Symbols
Agents
A rst order language L is built upon the following sets of sym-
bols:

propositional connectives: ¬,∧,∨


(plus the shortcuts =⇒ and ⇐⇒ );
propositional constants > and ⊥
(represent True and False respectively);

equality =
(not always included);

a denumerable set of individual variable symbols:


x1 , x2 , · · · ;
universal quantication ∀;
existentional quantication ∃;

Denition of FOL Formulas

First Order
Logic for
Agents

FOL formulas

Inductive denition of basic components

1 Terms
E.g., c , x , f (x , y ), f (g (c ), y ), plus (plus (x , 1), 3), . . .
2 Atomic Formulas
E.g., P (x ), Q (x , c ), R (x , f (x , y + c )), · · ·
First Order Formulas

First Order
Logic for Well-Formed Formulas
Agents
The set of formulae of L is inductively dened as follows:

Every atom is a formula;

If A is a formula ¬A is a formula;
If ◦ is a binary operator, A and B are formulas, then A◦B
is a formula;

IfA is a formula, x is a free variable in A then ∀xA and


∃xA are formulas
All formulas are generated by a nite number of
applications of the above rules.

Example (FOL Formulas)

P (x ), ∃xQ (x , c ), ∀xR (x , f (x , y + c )), · · ·

Interpretations in FOL

First Order
Logic for In Prop. Logic an Interpretation for a formula G is an
Agents
assignment of truth values to each atoms occuring in the
formula

In FOL we have to do more than that:


1 Specify a domain of interest (e.g., real numbers)
2 An assignment to constants, function symbols and
predicate symbols

Example (Interpretation)

Consider the set of formulas: {∀xP (x ), ∃xQ (x )};


An interpretation will need to specify a domain, e.g. D = {1, 2}
and an assignment for all predicate symbol from D to the set
{T , F }, for example {P (1) = T , P (2) = F } and
{Q (1) = F , Q (2) = T }.
Interpretation: Example

First Order
Logic for Example (Interpretation)
Agents

∀x ∃yP (x , y )

D , the set of human beings


P A (a, b) = true i b is father of a
All human beings have a father

D , the set of human beings


P A (a, b) = true i b is mother of a
0

All human beings have a mother

D the set of natural numbers


P A (a, b) = true i a < b
00

For every nat number there is a greater one

Evaluation of FOL formulas

First Order
Logic for Given an interpretation I = hD , Ai, FOL formulas are evaluated
Agents
to true or false according to the following rules:

If S is an atomic formula and S , P (t1 , · · · , tn ), S is true


A A A
i P (t1 , · · · , tn ) = >

If S is an atomic formula and S , t1 = t2 , S is true i


t1A = t2A .
If S is a formula evaluated to true then ¬S is false.

If S and T are two formulas then S ∧ T is true i A and


T are true.
If S and T are two formulas then S ∨ T is true i A or T
are true

If S , ∀xG is true i G is true for every element d ∈ D.


If S , ∃xG is true i G is true for at least one element
d ∈ D.
Examples of FOL formula evaluation

First Order
Logic for Example (Example of evaluation)
Agents

G , ∀x ∃yP (x , y )
InterpretationI for G
D = 1, 2 and P A (x , y ) = true i x < y
To evaluate G we have to evaluate for each element d ∈ D the
formula H , ∃yP (d , y ).

x = 1 we have to check whether there is at least one


0 A
element d ∈ D such that P (1, d ) holds, i.e. such that
0

1 < d . We observe that 1 < 2 holds, thus for x = 1 the


0

formula H is true.

x = 2 however H is false.
Thus G is false under I

Models, validity, satisability

First Order
Logic for Given the notion of interpretion, the concepts of model, validity
Agents and satisability can be dened as for propositional logic.

Denition (Model)

An interpretation I is a model for G i G is evaluated to true


under I. We write I |= G .

Denition (Validity)

A formula G is valid i it is evaluated to true under all its


interpretations. We write |= G

Denition (Inconsistency)

A formula G is inconsistent i it is evaluated to false under all


its interpretations
Logical consequence

First Order
Logic for Denition (Logical consequence)
Agents
A formula G is a logical consequence of formulas {F1 , · · · , Fn }
i for every interpretation I if I |= F1 ∧ · · · ∧ Fn we have that
I |= G .
The following theorems hold also for First Order Logic

Theorem (Deduction Theorem)

Given a set of formulas {F1 , · · · , Fn } and a formula G,


F1 ∧ · · · ∧ Fn |= G i |= F1 ∧ · · · ∧ Fn =⇒ G

Theorem (Proof by Refutation)

Given a set of formulas {F1 , · · · , Fn } and a formula G,


|= F1 ∧ · · · ∧ Fn =⇒ G i F1 ∧ · · · ∧ Fn ∧ ¬G is inconsistent.

A common mistake to avoid

First Order
Logic for
Agents

Typically, =⇒ is the main connective with ∀


Common mistake: using ∧ as the main connective with ∀:

∀ x At (x , Berkeley ) =⇒ Smart (x )

means Everyone that is at Berkeley is smart

∀ x At (x , Berkeley ) ∧ Smart (x )

means Everyone is at Berkeley and everyone is smart


Another common mistake to avoid

First Order
Logic for
Agents

Typically, ∧ is the main connective with ∃


Common mistake: using =⇒ as the main connective with ∃:

∃ x At (x , Stanford ) ∧ Smart (x )

is true if there is someone at standford that is smart

∃ x At (x , Stanford ) =⇒ Smart (x )

is true if there is anyone who is not at Stanford!

Properties of quantiers

First Order
Logic for
Agents

∀x ∀ y is the same as ∀ y ∀ x (why??)


∃x ∃ y is the same as ∃ y ∃ x (why??)
∃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
Quantier duality: each can be expressed using the other
∀ x Likes (x , IceCream) ¬∃ x ¬Likes (x , IceCream)
∃ x Likes (x , Broccoli ) ¬∀ x ¬Likes (x , Broccoli )
Interacting with FOL KBs

First Order
Logic for
Agents
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 Action(a, 5))
I.e., does KB entail any particular actions 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 |= S σ

Knowledge base for the wumpus world

First Order
Logic for
Agents

Perception and Actions

Perception
∀ b, g , t Percept ([Smell , b, g ], t ) =⇒ Smelt (t )
∀ s , b, t Percept ([s , b, Glitter ], t ) =⇒ AtGold (t )
Reex: ∀ t AtGold (t ) =⇒ Action (Grab , t )
Reex with internal state: do we have the gold already?
∀ t AtGold (t ) ∧ ¬Holding (Gold , t ) =⇒ Action(Grab, t )
Holding (Gold , t ) cannot be observed
⇒ keeping track of changes is essential
Deducing hidden properties I

First Order
Logic for
Agents

Properties of the world

Properties of locations (based on perception):


∀ x , t At (Agent , x , t ) ∧ Smelt (t ) =⇒ Smelly (x )
∀ x , t At (Agent , x , t ) ∧ Breeze (t ) =⇒ Breezy (x )

Deducing hidden properties II

First Order
Logic for
Agents

Properties of locations (based on environment rules):


E.g., Squares are breezy near a pit:
Diagnostic ruleinfer cause from eect
∀ y Breezy (y ) =⇒ ∃ x Pit (x ) ∧ Adjacent (x , y )
Causal ruleinfer eect from cause
∀ x , y Pit (x ) ∧ Adjacent (x , y ) =⇒ Breezy (y )
Neither of these is completee.g., the causal rule doesn't say
whether squares far away from pits can be breezy
Denition for the Breezy predicate:
∀ y Breezy (y ) ⇔ [∃ x Pit (x ) ∧ Adjacent (x , y )]
Keeping track of changes

First Order Facts hold in situations, rather than eternally


Logic for
Agents E.g., Holding (Gold , Now ) rather than just Holding (Gold )
Situation calculus is one way to represent changes in FOL:
Adds a situation argument to each non-eternal predicate
E.g., Now in Holding (Gold , Now ) denotes a situation
Situations are connected by the Result function
Result (a, s ) is the situation that results from doing a in s

Describing actions I

First Order
Logic for
Agents Eect axiomdescribe changes due to action
∀ s AtGold (s ) =⇒ Holding (Gold , Result (Grab, s ))
Frame axiomdescribe non-changes due to action
∀ s HaveArrow (s ) =⇒ HaveArrow (Result (Grab, s ))
Frame problem: nd an elegant way to handle non-change
(a) representationavoid frame axioms
(b) inferenceavoid repeated copy-overs to keep track of
state
Qualication problem: true descriptions of real actions require
endless caveatswhat if gold is slippery or nailed down or ...
Ramication problem: real actions have many secondary
consequenceswhat about the dust on the gold, wear and tear
on gloves, ...
Describing actions II

First Order
Logic for
Agents
Successor-state axioms solve the representational frame problem
Each axiom is about a predicate (not an action per se):

P true afterwards ⇔ [an action made P true

∨ P true already and no action

made P false]

For holding the gold:


∀ a, s Holding (Gold , Result (a, s )) ⇔
[(a = Grab ∧ AtGold (s ))
∨ (Holding (Gold , s ) ∧ a 6= Release )]

Making plans

First Order
Logic for
Agents

Initial condition in KB:


At (Agent , [1, 1], S0 )
At (Gold , [1, 2], S0 )
Query: Ask (KB , ∃ s Holding (Gold , s ))
i.e., in what situation will I be holding the gold?
Answer: {s /Result (Grab, Result (Forward , S0 ))}
i.e., go forward and then grab the gold
This assumes that the agent is interested in plans starting at S0
and that S0 is the only situation described in the KB
Making plans: A better way

First Order
Logic for
Agents

Represent plans as action sequences [a1 , a2 , . . . , an ]


PlanResult (p , s ) is the result of executing p in s
Then the query Ask (KB , ∃ p Holding (Gold , PlanResult (p , S0 )))
has the solution {p /[Forward , Grab ]}
Denition of PlanResult in terms of Result :
∀ s PlanResult ([ ], s ) = s
∀ a, p , s PlanResult ([a|p ], s ) = PlanResult (p , Result (a, s ))
Planning systems are special-purpose reasoners designed to do
this type of inference more eciently than a general-purpose
reasoner

Summary

First Order
Logic for
Agents

First-order logic:
 objects and relations are semantic primitives
 syntax: constants, functions, predicates, equality, quantiers
Increased expressive power: sucient to dene wumpus world
Situation calculus:
 conventions for describing actions and change in FOL
 can formulate planning as inference on a situation calculus
KB

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy