Logical Agents
Logical Agents
Logical AI
The idea is that an agent can represent knowledge of its world, its goals
and the current situation by sentences in logic and decides what to do by
inferring that a certain action or course of action is appropriate to achieve
its goals.”
John McCarthy in Concepts of logical AI, 2000
http://www.formal.standford.edu/jmc/concepts-ai/ concepts-ai.html
KNOWLEDGE-BASED AGENTS
Constraint satisfaction problems
“Low-level intelligence” Bayesian Networks
4 x 4 grid of rooms
Squares adjacent to wumpus are smelly
Squares adjacent to pit are breezy
Glitter iff gold is in the same square
Shooting kills wumpus if you are facing it
Shooting uses up the only arrow
Grabbing picks up gold if in same square
Releasing drops the gold in same square
THE WUMPUS WORLD PEAS DESCRIPTION
Performance measure
gold +1000,
death (eaten or falling in a pit) -1000
-1 per action taken,
-10 for using the arrow
the games ends either when the agent dies or
comes out of the cave
THE WUMPUS WORLD PEAS DESCRIPTION
Environment
4 x 4 grid of rooms
Agent starts in square [1,1] facing to the right
Locations of the gold, and wampus are chosen
randomly with a uniform distribution from all
squares except [1,1]
Each square other than the start can be a pit
with probability of 0.2
THE WUMPUS WORLD PEAS DESCRIPTION
Sensors:
Stench, Breeze, Glitter, Bump, Scream
Represents as a 5-element list
Example: [Stench, Breese, None, None, None]
Actuators:
Left turn, Right turn, Forward, Grab, Release,
Shoot
WUMPUS WORLD PROPERTIES
Fully Observable
No – only local perception
Deterministic
Yes – outcomes exactly specified
Episodic
No – sequential at the level of actions
Static
Yes – Wumpus and Pits do not move
Discrete
Yes
Single-agent?
Yes – Wumpus is essentially a natural feature
EXPLORING A WUMPUS WORLD
A = Agent
B = Breeze
G = Gold
Ok = Safe square
P = Pit
S = Stench
V = Visited
W = Wumpus
EXPLORING A WUMPUS WORLD
EXPLORING A WUMPUS WORLD
EXPLORING A WUMPUS WORLD
EXPLORING A WUMPUS WORLD
EXPLORING A WUMPUS WORLD
EXPLORING A WUMPUS WORLD
EXPLORING A WUMPUS WORLD
LOGIC
Just like arithmetic operators, there is an operator precedence when evaluating logical operators as follows:
1. Expressions in parentheses are processed (inside to outside)
2. Negation
3. AND
4. OR
5. Implication
6. Bi conditional
7. Left to right
Use parentheses whenever you have any doubt!
BUILDING PROPOSITIONS
LOGICAL EQUIVALENCE
Two propositions p and q are logically equivalent if and only if the columns in the truth table giving their truth values
agree.
We write this as p ↔ q or p ≡ q.
PROPERTIES OF OPERATORS
TAUTOLOGY AND CONTRADICTION
Summary:
WUMPUS WORLD KB
Semantics: Determine entailment by Model Checking, that is enumerate all models and show that the
sentence α must hold in all models.
Syntax: Determine entailment by Theorem Proving, that is apply rules of inference to KB to build a proof of
α without enumerating and checking all models.
Given a Knowledge Base (KB) (set of sentences in PL), given a query α output whether KB entails α
noted:
Search for proofs is a more ancient way than enumerating models (We can ignore irrelevant
information)
Truth tables have an exponential number of models.
The idea of inference is to repeat applying inference rules to the KB.
Inference can be applied whenever suitable premises are found in the KB.
Inference is sound. How about completeness?
THEOREM PROVING
Forward or Backward chaining: use of modus ponens on a restricted form of propositions (Horn
clauses)
Resolution: ONE single inference rule
Invented by Robinson, 1965
Resolution + Search = complete inference algorithm.
PROOF BY RESOLUTION
PROOF BY RESOLUTION
PROOF BY RESOLUTION
CONVERSION TO CNF
CONVERSION TO CNF
CONVERSION TO CNF
CONVERSION TO CNF
RESOLUTION ALGORITHM
RESOLUTION EXAMPLE
FORWARD/BACKWARD CHAINING
FORWARD CHAINING
FORWARD CHAINING EXAMPLE
FORWARD CHAINING EXAMPLE
FORWARD CHAINING EXAMPLE
FORWARD CHAINING EXAMPLE
FORWARD CHAINING EXAMPLE
FORWARD CHAINING EXAMPLE
FORWARD CHAINING EXAMPLE
FORWARD CHAINING EXAMPLE
BACKWARD CHAINING
BACKWARD CHAINING EXAMPLE
BACKWARD CHAINING EXAMPLE
BACKWARD CHAINING EXAMPLE
BACKWARD CHAINING EXAMPLE
BACKWARD CHAINING EXAMPLE
BACKWARD CHAINING EXAMPLE
BACKWARD CHAINING EXAMPLE
BACKWARD CHAINING EXAMPLE
BACKWARD CHAINING EXAMPLE
BACKWARD CHAINING EXAMPLE
BACKWARD CHAINING EXAMPLE
FORWARD VS BACKWARD
Forward chaining:
Data-driven, automatic, unconscious processing,
May do lots of work that is irrelevant to the goal
Backward chaining:
Goal-driven, appropriate for problem-solving,
Limits of PL?
1. PL is not expressive enough to describe all the world around us. It can't express
information about different object and the relation between objects.
2. PL is not compact. It can't express a fact for a set of objects without
enumerating all of them which is sometimes impossible.
Example: We have a vacuum cleaner (Roomba) to clean a 10x10 squares
in the classroom. Use PL to express information about the squares.
PROPOSITIONAL LOGIC
FIRST ORDER LOGIC
FIRST ORDER LOGIC
FIRST ORDER LOGIC
FIRST ORDER LOGIC
SUMMARY
SUMMARY
JOHN MCCARTHY
CREDIT