Logic Agents and Propositional Logic: Hassan Khosravi SPRING2011
Logic Agents and Propositional Logic: Hassan Khosravi SPRING2011
Logic
CHAPTER 7
HASSAN KHOSRAVI
SPRING2011
Knowledge-Based Agents
KB = knowledge base
A set of sentences or facts
e.g., a set of statements in a logic language
Inference
Deriving new sentences from old
e.g., using a set of logical statements to infer new ones
Environment
Cave of 4×4
16 rooms
Wumpus: A deadly beast who kills anyone
entering his room.
Pits: Bottomless pits that will trap you
forever.
Gold
Wumpus World
Agents Sensors:
Stench next to Wumpus
Breeze next to pit
Glitter in square with gold
Bump when agent moves into a wall
Scream from wumpus when killed
Agents actions
Agent can move forward, turn left or
turn right
Shoot, one shot
Wumpus World
Performance measure
+1000 for picking up gold
[2,1] = breeze
A formal language
KB = set of sentences
Syntax
what sentences are legal (well-formed)
E.g., arithmetic
X+2 >= y is a wf sentence, +x2y is not a wf sentence
Semantics
loose meaning: the interpretation of each sentence
More precisely:
Defines the truth of each sentence wrt to each possible world
e.g,
X+2 = y is true in a world where x=7 and y =9
X+2 = y is false in a world where x=7 and y =1
Example:
x + y = 4, where x = #men, y = #women
Possible models = all possible assignments of integers to x and y
Entailment
Consider possible models for KB assuming only pits and a reduced Wumpus
world
Comments:
Model-checking enumerates all possible worlds
Only works on finite domains, will suffer from exponential growth
of possible models
Wumpus models
α2 = "[2,2] is safe", KB ╞ α2
There are some models entailed by KB where 2 is
false
Logical inference
Complex sentences:
And-Elimination
Bi-conditional Elimination
Validity and satisfiability
Model checking
Searching through truth assignments.
Improved backtracking: Davis--Putnam-Logemann-Loveland (DPLL)
Heuristic search in model space: Walksat.
Normal Form
We want to prove: KB |
equivalent to : KB unsatifiable
literals
A “conjunction of disjunctions”
(A B) (B C D)
Clause Clause
(A B )
( A B ) Simplification
(B B ) B
Resolution Algorithm
True
False in
all worlds
Horn Clauses
• If we can reduce all clauses to “Horn clauses” resolution is linear in space and time
AND gate
OR gate
“OR” Gate
“AND” gate
Forward chaining example
Forward chaining example
Forward chaining example
Forward chaining example
Forward chaining example
Forward chaining example
Forward chaining
we need P to prove
L and L to prove P.
Backward chaining example
Backward chaining example
Backward chaining example
Backward chaining example
Backward chaining example
Backward chaining example
Backward chaining
Like FC, is linear and is also sound and complete (for Horn KB)
Model Checking
Underconstrained problems:
Relatively few clauses constraining the variables
Tend to be easy
16 of 32 possible assignments above are solutions
(so 2 random guesses will work on average)
Hard satisfiability problems
Investigate experimentally….
P(satisfiable) for random 3-CNF sentences, n
= 50
Run-time for DPLL and WalkSAT