0% found this document useful (0 votes)
63 views

Forward and Backward Chaining: - Horn Form

The document discusses logical inference techniques for agents, including forward chaining and backward chaining. Forward chaining works by firing rules whose premises are satisfied in the knowledge base and adding conclusions. Backward chaining works backwards from a query to prove premises of rules concluding the query. Both techniques are sound and complete for Horn clause knowledge bases. Propositional logic can represent an agent in the Wumpus world but has limitations due to rapid proliferation of clauses as the state space increases.

Uploaded by

NkwochaChinedu
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)
63 views

Forward and Backward Chaining: - Horn Form

The document discusses logical inference techniques for agents, including forward chaining and backward chaining. Forward chaining works by firing rules whose premises are satisfied in the knowledge base and adding conclusions. Backward chaining works backwards from a query to prove premises of rules concluding the query. Both techniques are sound and complete for Horn clause knowledge bases. Propositional logic can represent an agent in the Wumpus world but has limitations due to rapid proliferation of clauses as the state space increases.

Uploaded by

NkwochaChinedu
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/ 18

Forward and backward

chaining
Horn Form (restricted)
KB = conjunction of Horn clauses
Horn clause =
proposition symbol; or
(conjunction of symbols) symbol

E.g., C (B A) (C D B)

Modus Ponens (for Horn Form): complete for Horn KBs


1 n
1, ,n,

Can be used with forward chaining or backward chaining.


These algorithms are very natural and run in linear time

IAGA 2005/2006

217

Forward chaining
Idea: fire any rule whose premises are satisfied in the
KB,
add its conclusion to the KB, until query is found

IAGA 2005/2006

218

Forward chaining algorithm

Forward chaining is sound and complete for


Horn KB
IAGA 2005/2006

219

Forward chaining example

IAGA 2005/2006

220

Forward chaining example

IAGA 2005/2006

221

Forward chaining example

IAGA 2005/2006

222

Forward chaining example

IAGA 2005/2006

223

Forward chaining example

IAGA 2005/2006

224

Forward chaining example

IAGA 2005/2006

225

Forward chaining example

IAGA 2005/2006

226

Forward chaining example

IAGA 2005/2006

227

Proof of completeness

FC derives every atomic sentence that is


entailed by KB
1. FC reaches a fixed point where no new atomic
sentences are derived
2. Consider the final state as a model m, assigning
true/false to symbols
3. Every clause in the original KB is true in m
a1 ak b

4. Hence m is a model of KB
5. If KB q, q is true in every model of KB,
including m

IAGA 2005/2006

228

Backward chaining
Idea: work backwards from the query q:
to prove q by BC,
check if q is known already, or
prove by BC all premises of some rule concluding q

Avoid loops: check if new subgoal is already on the goal


stack
Avoid repeated work: check if new subgoal
1. has already been proved true, or
2. has already failed

IAGA 2005/2006

229

Backward chaining example

IAGA 2005/2006

230

Backward chaining example

IAGA 2005/2006

231

Backward chaining example

IAGA 2005/2006

232

Backward chaining example

IAGA 2005/2006

233

Backward chaining example

IAGA 2005/2006

234

Backward chaining example

IAGA 2005/2006

235

Backward chaining example

IAGA 2005/2006

236

10

Backward chaining example

IAGA 2005/2006

237

Backward chaining example

IAGA 2005/2006

238

11

Backward chaining example

IAGA 2005/2006

239

Forward vs. backward


chaining
FC is data-driven, automatic, unconscious
processing,
e.g., object recognition, routine decisions

May do lots of work that is irrelevant to the goal


BC is goal-driven, appropriate for problem-solving,
e.g., Where are my keys? How do I get into a PhD program?

Complexity of BC can be much less than linear in


size of KB

IAGA 2005/2006

240

12

Efficient propositional
inference
Two families of efficient algorithms for propositional
inference:
Complete backtracking search algorithms
DPLL algorithm (Davis, Putnam, Logemann,
Loveland)
Incomplete local search algorithms
WalkSAT algorithm

IAGA 2005/2006

241

The DPLL algorithm


Determine if an input propositional logic sentence (in CNF) is
satisfiable.
Improvements over truth table enumeration:
1. Early termination
A clause is true if any literal is true.
A sentence is false if any clause is false.

2. Pure symbol heuristic


Pure symbol: always appears with the same "sign" in all clauses.
e.g., In the three clauses (A B), (B C), (C A), A and B are pure,
C is impure.
Make a pure symbol literal true.

3. Unit clause heuristic


Unit clause: only one literal in the clause
The only literal in a unit clause must be true.

IAGA 2005/2006

242

13

The DPLL algorithm

IAGA 2005/2006

243

The WalkSAT algorithm


Incomplete, local search algorithm
Evaluation function: The min-conflict heuristic of
minimizing the number of unsatisfied clauses
Balance between greediness and randomness

IAGA 2005/2006

244

14

The WalkSAT algorithm

IAGA 2005/2006

245

Hard satisfiability problems


Consider random 3-CNF sentences.
e.g.,
(D B C) (B A C) (C
B E) (E D B) (B E
C)
m = number of clauses
n = number of symbols
Hard problems seem to cluster near m/n =
4.3 (critical point)
IAGA 2005/2006

246

15

Hard satisfiability problems

IAGA 2005/2006

247

Hard satisfiability problems

Median runtime for 100 satisfiable random 3CNF sentences, n = 50


IAGA 2005/2006

248

16

Inference-based agents in the


wumpus world
A wumpus-world agent using propositional logic:
P1,1
W1,1
Bx,y (Px,y+1 Px,y-1 Px+1,y Px-1,y)
Sx,y (Wx,y+1 Wx,y-1 Wx+1,y Wx-1,y)
W1,1 W1,2 W4,4
W1,1 W1,2
W1,1 W1,3

64 distinct proposition symbols, 155 sentences

IAGA 2005/2006

249

IAGA 2005/2006

250

17

Expressiveness limitation of
propositional logic
KB contains "physics" sentences for every single
square
For every time t and every location [x,y],
L FacingRightt Forwardt tLx+1,y
t x,y
Rapid proliferation of clauses

IAGA 2005/2006

251

Summary
Logical agents apply inference to a knowledge base to derive
new information and make decisions
Basic concepts of logic:

syntax: formal structure of sentences


semantics: truth of sentences wrt models
entailment: necessary truth of one sentence given another
inference: deriving sentences from other sentences
soundness: derivations produce only entailed sentences
completeness: derivations can produce all entailed sentences

Wumpus world requires the ability to represent partial and


negated information, reason by cases, etc.
Resolution is complete for propositional logic
Forward, backward chaining are linear-time, complete for Horn
clauses
Propositional logic lacks expressive power

IAGA 2005/2006

252

18

You might also like