0% found this document useful (0 votes)
52 views100 pages

Unit 3 Knowledge Representation

This document provides information about knowledge representation in expert systems. It discusses how a knowledge-based agent consists of a knowledge base and inference engine. The knowledge base contains representations of what is known about the world, expressed as sentences in a knowledge representation language. The inference engine derives new sentences from the knowledge base and input. Different types of knowledge like procedural and declarative knowledge are discussed. Logic is presented as a way to represent knowledge precisely in a computer-readable form. Examples like the Wumpus world environment are provided to illustrate knowledge representation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views100 pages

Unit 3 Knowledge Representation

This document provides information about knowledge representation in expert systems. It discusses how a knowledge-based agent consists of a knowledge base and inference engine. The knowledge base contains representations of what is known about the world, expressed as sentences in a knowledge representation language. The inference engine derives new sentences from the knowledge base and input. Different types of knowledge like procedural and declarative knowledge are discussed. Logic is presented as a way to represent knowledge precisely in a computer-readable form. Examples like the Wumpus world environment are provided to illustrate knowledge representation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 100

UNIT 3

KNOWLEDGE
REPRESENTATION
Knowledge in Expert Systems

Conventional
Knowledge-Based
Programming
Systems

Algorithms Knowledge
+ Data Structures + Inference
= Programs = Expert System
A Knowledge-Based Agent
• A knowledge-based agent consists of a knowledge base
(KB) and an inference engine (IE).
• A knowledge-base is a set of representations of what
one knows about the world (objects and classes of
objects, the fact about objects, relationships among
objects, etc.)
• Each individual representation is called a sentence.
• The sentences are expressed in a knowledge
representation language.
• Examples of sentences
– The moon is made of green cheese
– If A is true then B is true
– A is false
– All humans are mortal
– Confucius is a human
3
• The Inference engine derives new sentences from the input
and KB
• The inference mechanism depends on representation in KB
• The agent operates as follows:
1. It receives percepts from environment
2. It computes what action it should perform (by IE and KB)
3. It performs the chosen action (some actions are simply
inserting inferred new facts into KB).
domain independent alg

Input from Inference Output


environment Engine (actions)

ASK Learning
(KB update)
Knowledge
TELL
Base
domain specific content

4
A simple knowledge-based agent

• The agent must be able to:


– Represent states, actions, etc.
– Incorporate new percepts
– Update internal representations of the world
– Deduce hidden properties of the world
– Deduce appropriate actions
KB can be viewed at different levels
• Knowledge Level.
– The most abstract level -- describe agent by saying what it
knows.
– Example: A taxi agent might know that the Golden Gate
Bridge connects San Francisco with the Marin County.
• Logical Level.
– The level at which the knowledge is encoded into sentences.
– Example: Links(GoldenGateBridge, SanFrancisco,
MarinCounty).
• Implementation Level.
– The physical representation of the sentences in the logical
level.
– Example: “(Links GoldenGateBridge, SanFrancisco,
MarinCounty)”
6
Types of Knowledge

• Procedural ,eg: Functions


Such knowledge can only be used in one way –by
executing it
• Declarative ,:eg: Constraints and rules
It can also be used to perform many different sorts of
inferences

7
Representation, Reasoning, and Logic
• The objective of knowledge representation is to express
knowledge in a computer-tractable form, so that agents
can perform well.
• A knowledge representation language is defined by:
– Its syntax which defines all possible sequences of
symbols that constitute sentences of the language
(grammar to form sentences)
– Its semantics determines the facts in the world to
which the sentences refer (meaning of sentences)
• Each sentence makes a claim about the world.
– Its proof theory (inference rules and proof
procedures)

8
LOGIC

• Logic has complete inference procedures.


– All valid inferences can be proven, in principle, by a machine.
• Cook’s fundamental theorem of NP-completeness states that all
difficult search problems (scheduling, planning, CSP etc.) can be
represented as logical inference problems. (U of T).
• Logic is declarative.
• Think of logic as a kind of language for expressing knowledge.
– Precise, computer readable.
• A proof system allows a computer to infer consequences of known
facts.
• Programming languages lack general mechanism for deriving facts
from other facts.
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

• A simple model for reasoning


– Agent is told or perceives new evidence
• E.g., A is true
– Agent then infers new facts to add to the KB
• E.g., KB = { A -> (B OR C) }, then given A and not C we can infer that B is true
• B is now added to the KB even though it was not explicitly asserted, i.e., the
agent inferred B
Wumpus World

• Environment
– Cave of 4×4
– Agent enters in [1,1]
– 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 PEAS description

• Performance measure
– gold +1000, death -1000
– -1 per step, -10 for using the arrow
• Environment
– Squares adjacent to wumpus are smell
– 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
• Sensors: Stench, Breeze, Glitter, Bump, Scream
• Actuators: Left turn, Right turn, Forward, Grab, Release, Shoot
Wumpus world characterization

• 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
Connection World-Representation

entail
Sentences Sentences
represent represent
Conceptualization

World W

hold
Facts Facts
about W about W
hold
What is a logical language?
• 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

– Note: standard logic – each sentence is T of F wrt eachworld


• Fuzzy logic – allows for degrees of truth.
Logic in general

• Logics are formal languages for representing information


such that conclusions can be drawn
• Syntax defines the sentences in the language
• Semantics define the "meaning" of sentences;
– i.e., define truth of a sentence in a world
• E.g., the language of arithmetic
– x+2 ≥ y is a sentence; x2+y > {} is not a sentence
– x+2 ≥ y is true iff the number x+2 is no less than the
number y
– x+2 ≥ y is true in a world where x = 7, y = 1
– x+2 ≥ y is false in a world where x = 0, y = 6
Entailment

• Entailment means that one thing follows from another:


KB ╞ α
• Knowledge base KB entails sentence α if and only if α is true in
all worlds where KB is true

– E.g., the KB containing “the Giants won” and “the Reds


won” entails “Either the Giants won or the Reds won”
– E.g., x+y = 4 entails 4 = x+y
– Entailment is a relationship between sentences (i.e.,
syntax) that is based on semantics
Models
• Logicians typically think in terms of models, which are
formally structured worlds with respect to which truth can
be evaluated
• We say m is a model of a sentence α if α is true in m

• M(α) is the set of all models of α

• Then KB ╞ α iff M(KB)  M(α)


– E.g. KB = Giants won and Reds
won α = Giants won
Entailment in the wumpus world

Situation after detecting nothing in


[1,1], moving right, breeze in
[2,1]

Consider possible models for KB


assuming only pits

3 Boolean choices  8 possible


models
Wumpus Models
Wumpus Models

B
B

B
B B

B B
B
Wumpus Models

B
B

B
B B

B B
B
Wumpus Models

B
B

B
B B

B B
B

KB = wumpus world + observations


1=“[1,2] is safe”
KB |= 1
Wumpus Models

B
B

B
B B

B B
B

KB = wumpus world + observations


2=“[2,2] is safe”
KB |= 2 ??
Wumpus Models

B
B

B
B B

B B
B

KB = wumpus world + observations


2=“[2,2] is safe”
KB |= 2 ??
Wumpus Models

B
B

B
B B

B B
B

KB = wumpus world + observations


2=“[2,2] is safe”
KB |= 2 NOT!
Logical inference

• The notion of entailment can be used for logic inference.


– Model checking (see wumpus example): enumerate
all possible models and check whether  is true.
• If an algorithm only derives entailed sentences it is called
sound or truth preserving.
– Otherwise it just makes things up.
i is sound if whenever KB |-i  it is also true that KB|
=
• Completeness : the algorithm can derive any sentence
that is entailed.
i is complete if whenever KB |=  it is also true that KB|-i

Inference

• KB ├i α = sentence α can be derived from KB by


procedure i
• Soundness: i is sound if whenever KB ├i α, it is also true
that KB╞ α
• Completeness: i is complete if whenever KB╞ α, it is also
true that KB ├i α
• Preview: we will define a logic (first-order logic) which is
expressive enough to say almost anything of interest,
and for which there exists a sound and complete
inference procedure.
• That is, the procedure will answer any question whose
answer follows from what is known by the KB.
Propositional logic: Syntax

Propositional logic is the simplest logic – illustrates basic ideas


• The proposition symbols P1, P2 etc are sentences

If S is a sentence, S is a sentence (negation)



– If S1 and S2 are sentences, S1  S2 is a sentence (conjunction)

– If S1 and S2 are sentences, S1  S2 is a sentence (disjunction)

– If S1 and S2 are sentences, S1  S2 is a sentence (implication)

– If S1 and S2 are sentences, S1  S2 is a sentence (biconditional)

Symbols of Propositional Logic

– Connectives: , , , 
– Propositional symbols, e.g., P, Q, R, …
– True, False
Syntax of Propositional Logic

• sentence  atomic sentence | complex sentence


• atomic sentence  Propositional symbol, True, False
• Complex sentence  sentence
| (sentence  sentence)
| (sentence  sentence)
| (sentence  sentence)
• Examples:
– ((P  Q)  R)
– (A  B)  (C)
Order of Precedence

•    
• Examples:
–  A  B  C is equivalent to ((A)B)C
Models in Propositional Logic

• Assignment of a truth value – true or false – to every


atomic sentence
• Examples:
– Let A, B, C, and D be the propositional symbols
– is m = {A=true, B=false, C=false, D=true} a model?
– is m’ = {A=true, B=false, C=false} a model?
• How many models can be defined over n
propositional symbols?
Propositional logic: Semantics
Each model specifies true/false for each proposition symbol

E.g. P1,2 P2,2 P3,1


false true false

With these symbols, 8 possible models, can be enumerated automatically.

Rules for evaluating truth with respect to a model m:

S is true iff S is false


S1  S2 is true iff S1 is true and S2 is true
S1  S2 is true iff S1is true or S2 is true
S1  S2 is true iff S1 is false or S2 is true
i.e., is false iff S1 is true andS2 is false
S1  S2 is true iff S1S2 is true andS2S1 is true
Simple recursive process evaluates an arbitrary sentence, e.g.,

P1,2  (P2,2  P3,1) = true  (true  false) = true  true = true


Semantics of Propositional Logic
• It specifies how to determine the truth value
of any sentence in a model m
• The truth value of True is True
• The truth value of False is False
• The truth value of each atomic sentence is
given by m
• The truth value of every other sentence is
obtained recursively by using truth tables
Truth Tables

A B A AB AB AB


True True False True True True

True False False False True False

False False True False False True

False True True False True True


Propositional logic: Semantics

Each model specifies true/false for each proposition symbol

E.g. P1,2 P2,2 P3,1


false true false

With these symbols, 8 possible models, can be enumerated automatically.

Rules for evaluating truth with respect to a model m:

S is true iff S is false


S1  S2 is true iff S1 is true and S2 is true
S1  S2 is true iff S1is true or S2 is true
S1  S2 is true iff S1 is false or S2 is true
i.e., is false iff S1 is true andS2 is false
S1  S2 is true iff S1S2 is true andS2S1 is true

Simple recursive process evaluates an arbitrary sentence, e.g.,

P1,2  (P2,2  P3,1) = true  (true  false) = true  true = true


Truth tables for connectives
Terminology

• A sentence is valid iff its truth value is t in all


models (² f)
Valid sentences: true, : false, P Ç : P
• A sentence is satisfiable iff its truth value is t in
at least one model
Satisfiable sentences: P, true, : P
• A sentence is unsatisfiable iff its truth value is f
in all models
Unsatisfiable sentences: P Æ : P, false, : true
Inference

• KB `i a
• Soundness: Inference procedure i is sound if whenever KB `i a,
it is also true that
KB ² a
• Completeness: Inference procedure i is complete if whenever
KB ² a, it is also true that KB `i a
Inference by enumeration
Depth-first enumeration of all models is sound and complete

• For n symbols, time complexity is O(2n), space complexity is O(n)


Logical equivalence
Two sentences are logically equivalent} iff true in same models:
α ≡ ß iff α╞ β and β╞ α


Validity and satisfiability
A sentence is valid if it is true in all models,
e.g., True, A A, A  A, (A  (A  B))  B

Validity is connected to inference via the Deduction Theorem:


KB ╞ α if and only if (KB  α) is valid

A sentence is satisfiable if it is true in some model


e.g., A B, C

A sentence is unsatisfiable if it is true in no models


e.g., AA

Satisfiability is connected to inference via the following:


KB ╞ α if and only if (KB α) is unsatisfiable
Rules of Inference
• a`b
• a
b
• Valid Rules of Inference:
– Modus Ponens
– And-Elimination
– And-Introduction
– Or-Introduction
– Double Negation
– Unit Resolution
– Resolution
Examples in Wumpus World

• Modus Ponens: a ) b, a ` b
(WumpusAhead Æ WumpusAlive) ) Shoot,
(WumpusAhead Æ WumpusAlive) a)b
a
` Shoot b
• And-Elimination: a Æ b ` a
(WumpusAhead Æ WumpusAlive) aÆb
` WumpusAlive a
• Resolution: a Ç b, : b Ç g ` a Ç g
(WumpusDead Ç WumpusAhead), aÇ b
(: WumpusAhead Ç Shoot) :bÇg
` (WumpusDead Ç Shoot) aÇ g
Proof Using Rules of Inference
Prove A ) B, (A Æ B) ) C, Therefore A ) C
• A)B´:AÇB
• A Æ B ) C ´ : (A Æ B) Ç C ´ : A Ç : B Ç C
• So : A Ç B resolves with : A Ç : B Ç C deriving : A Ç C
• This is equivalent to A ) C
Rules of Inference (continued)
• And-Introduction
a1, a2, …, an
a1 Æ a2 Æ …Æ an
• Or-Introduction
ai
a1 Ç a2 Ç …ai … Ç an
• Double Negation
::a
a
• Unit Resolution (special case of resolution)
aÇ b Alternatively: : a ) b
:b :b
a a
Wumpus World KB
• Proposition Symbols for each i,j:
– Let Pi,j be true if there is a pit in square i,j
– Let Bi,j be true if there is a breeze in square i,j
• Sentences in KB
– “There is no pit in square 1,1”
R1: : P1,1
– “A square is breezy iff pit in a neighboring square”
R2: B1,1 , (P1,2 Ç P2,1)
R3: B1,2 , (P1,1 Ç P1,3 Ç P2,2)
– “Square 1,1 has no breeze”, “Square 1,2 has a breeze”
R4: : B1,1
R5: B1,2
Inference in Wumpus World
• Apply biconditional elimination to R2:
R6: (B1,1) (P1,2 Ç P2,1)) Æ ((P1,2 Ç P2,1) ) B1,1)
• Apply AE to R6:
R7: ((P1,2 Ç P2,1) ) B1,1)
• Contrapositive of R7:
R8: (: B1,1 ) : (P1,2 Ç P2,1))
• Modus Ponens with R8 and R4 (: B1,1):
R9: :(P1,2 Ç P2,1)
• de Morgan:
R10: : P1,2 Æ : P2,1
Searching for Proofs
• Finding proofs is exactly like finding solutions to
search problems.
• Can search forward (forward chaining) to derive goal
or search backward (backward chaining) from the
goal.
• Searching for proofs is not more efficient than
enumerating models, but in many practical cases, it’s
more efficient because we can ignore irrelevant
propositions
Full Resolution Rule Revisited
• Start with Unit Resolution Inference Rule:

• Full Resolution Rule is a generalization of this


rule:

• For clauses of length two:


Resolution Applied to Wumpus World
• At some point we determine the absence
of a pit in square 2,2:
R13: : P2,2
• Biconditional elimination applied to R3
followed by modus ponens with R5:
R15: P1,1 Ç P1,3 Ç P2,2
• Resolve R15 and R13:
R16: P1,1 Ç P1,3
• Resolve R16 and R1:
R17: P1,3
Resolution: Complete Inference
Procedure
• Any complete search algorithm, applying only the
resolution rule, can derive any conclusion entailed by
any knowledge base in propositional logic.
• Refutation completeness: Resolution can always be
used to either confirm or refute a sentence, but it cannot
be used to enumerate true sentences.
Conjunctive Normal Form

• Conjunctive Normal Form is a disjunction of


literals. literals

• Example:

(A Ç B Ç : C) Æ (B Ç D) Æ (: A) Æ (B Ç C)

clause
CNF Example

Example: (A Ç B) , (C ) D)
• Eliminate ,
((A Ç B) ) (C ) D)) Æ ((C ) D) ) (A Ç B)
• Eliminate )
(: (A Ç B) Ç (: C Ç D)) Æ (: (: C Ç D) Ç (A Ç B) )
• Drive in negations
((: A Æ : B) Ç (: C Ç D)) Æ ((C Æ : D) Ç (A Ç B))
• Distribute
(: A Ç : C Ç D) Æ (: B Ç : C Ç D) Æ (C Ç A Ç B) Æ (: D Ç A Ç B)
Resolution
Conjunctive Normal Form (CNF)
conjunction of disjunctions of literals
clauses
E.g., (A  B)  (B  C  D)

Resolution inference rule (for CNF):



• li …  lk, m1  …  mn

li  …  li-1  li+1  …  lk  m1  …  mj-1  mj+1 ...  mn

where li and mj are complementary literals.


E.g., P1,3  P2,2, P2,2

P1,3

Resolution is sound and complete


for propositional logic

Resolution
Soundness of resolution inference rule:

(li  …  li-1  li+1  …  lk)  li


mj  (m1  …  mj-1  mj+1 ...  mn)
(li  …  li-1  li+1  …  lk)  (m1  …  mj-1  mj+1 ...  mn)
Conversion to CNF
B1,1  (P1,2  P2,1)β

Eliminate , replacing α  β with (α  β)(β  α).


1.
2. (B1,1  (P1,2  P2,1))  ((P1,2  P2,1)  B1,1)

2. Eliminate , replacing α  β with α β.

(B1,1  P1,2  P2,1)  ((P1,2  P2,1)  B1,1)

3. Move  inwards using de Morgan's rules and double-negation:

(B1,1  P1,2  P2,1)  ((P1,2  P2,1)  B1,1)

4. Apply distributivity law ( over ) and flatten:

(B1,1  P1,2  P2,1)  (P1,2  B1,1)  (P2,1  B1,1)


Resolution algorithm
Proof by contradiction, i.e., show KBα unsatisfiable

Resolution example
KB = (B1,1  (P1,2 P2,1))  B1,1 α = P1,2

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

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

Forward chaining is sound and complete for Horn KB



Forward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Forward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Forward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Forward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Forward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Forward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Forward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Forward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Forward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Forward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Forward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
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
4. a1  …  ak  b

5. Hence m is a model of KB
6. If KB╞ q, q is true in every model of KB, including m
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
Backward Chaining

• Motivation: Need goal-directed reasoning in order to


keep from getting overwhelmed with irrelevant
consequences
• Main idea:
– Work backwards from query q
– To prove q:
• Check if q is known already
• Prove by backward chaining all premises of some
rule concluding q
Backward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Backward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Backward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Backward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Backward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Backward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Backward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Backward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Backward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Backward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Backward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Backward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Backward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Backward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Backward Chaining Example

P) Q
LÆ M ) P
BÆL)M
AÆ P) L
AÆ B ) L
A
B
Forward Chaining vs. Backward Chaining

• FC is data-driven—it may do lots of work irrelevant to the


goal
• BC is goal-driven—appropriate for problem-solving
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
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
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


Expressiveness limitation of
propositional logic
• KB contains "physics" sentences for every single square
• For every time t and every location [x,y],
Lx,y  FacingRightt  Forwardt  Lx+1,y

t t
• Rapid proliferation of clauses
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 model
– 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

You might also like