Вы находитесь на странице: 1из 79

Logical Agents

Russell & Norvig - AIMA2e

Ioan Alfred Letia

http://cs-gw.utcluj.ro/˜letia

letia@cs.utcluj.ro

Outline

Knowledge-based agentsOutline The wumpus world Logic Propositional logic: A very simple logic Reasoning patterns in propositional logic

The wumpus worldOutline Knowledge-based agents Logic Propositional logic: A very simple logic Reasoning patterns in propositional logic

LogicOutline Knowledge-based agents The wumpus world Propositional logic: A very simple logic Reasoning patterns in

Propositional logic: A very simple logicOutline Knowledge-based agents The wumpus world Logic Reasoning patterns in propositional logic Effective propositional

Reasoning patterns in propositional logicwumpus world Logic Propositional logic: A very simple logic Effective propositional inference Agents based on

Effective propositional inferencevery simple logic Reasoning patterns in propositional logic Agents based on propositional logic Artificial Intelligence

Agents based on propositional logiclogic Reasoning patterns in propositional logic Effective propositional inference Artificial Intelligence 07, 2004 – 2

Knowledge Bases

Inference engine

Knowledge base

Knowledge Bases Inference engine Knowledge base domain−independent algorithms domain−specific content Knowledge
Knowledge Bases Inference engine Knowledge base domain−independent algorithms domain−specific content Knowledge

domain−independent algorithms

domain−specific content

Knowledge base = set of sentences in a formal language sentences in a formal language

Declarative approach to building an agent (or other system): T ELL it what it needs to approach to building an agent (or other system): TELL it what it needs to know

Then it can A SK itself what to do—answers should follow from the KB ASK itself what to do—answers should follow from the KB

Agents can be viewed at the knowledge level , i.e. what they know, regardless of how implemented knowledge level, i.e. what they know, regardless of how implemented

Or at the implementation level , i.e. data structures in KB and algorithms that manipulate them implementation level, i.e. data structures in KB and algorithms that manipulate them

Knowledge-Based Agents

function KB-AGENT( percept) returns an action

static: KB, a knowledge base t, a counter, initially 0, indicating time

TELL(KB, MAKE-PERCEPT-SENTENCE( percept, t))

action

ASK(KB, MAKE-ACTION-QUERY(t))

TELL(KB, MAKE-ACTION-SENTENCE(action, t))

t + 1

t

return action

-A CTION -S ENTENCE ( action , t )) t + 1 t return action The

The agent must be able to:

Represent states, actions, etc., t )) t + 1 t return action The agent must be able to: Incorporate

Incorporate new perceptsThe agent must be able to: Represent states, actions, etc. Update internal representations of the world

Update internal representations of the worldto: Represent states, actions, etc. Incorporate new percepts Deduce hidden properties of the world Deduce appropriate

Deduce hidden properties of the worldnew percepts Update internal representations of the world Deduce appropriate actions Artificial Intelligence 07, 2004

Deduce appropriate actionsUpdate internal representations of the world Deduce hidden properties of the world Artificial Intelligence 07, 2004

ee ee ee r z ee r r z z ee r ee z r
ee
ee
ee
r
z
ee
r
r
z
z
ee
r
ee
z
r
PIT
Stench
r
z
B
z
PIT
Stench
B
Gold
B
Stench
B
e
PIT
e
START
B
B
e
e
e
e

1

2

3

4

Wumpus World PEAS

4

3

2

1

Performance measure gold +1000, death -1000, -1 per step, -10 for using arrow gold +1000, death -1000, -1 per step, -10 for using arrow

Environment Squares adjacent to wumpus are smelly Squares adjacent to pit are breezy Glitter iff gold 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

Sensors Breeze, Glitter, Smell Breeze, Glitter, Smell

Actuators Left turn, Right turn, Forward, Grab, Release, Shoot Left turn, Right turn, Forward, Grab, Release, Shoot

Glitter, Smell Actuators Left turn, Right turn, Forward, Grab, Release, Shoot Artificial Intelligence 07, 2004 –
Glitter, Smell Actuators Left turn, Right turn, Forward, Grab, Release, Shoot Artificial Intelligence 07, 2004 –
Glitter, Smell Actuators Left turn, Right turn, Forward, Grab, Release, Shoot Artificial Intelligence 07, 2004 –
Glitter, Smell Actuators Left turn, Right turn, Forward, Grab, Release, Shoot Artificial Intelligence 07, 2004 –
Glitter, Smell Actuators Left turn, Right turn, Forward, Grab, Release, Shoot Artificial Intelligence 07, 2004 –
Glitter, Smell Actuators Left turn, Right turn, Forward, Grab, Release, Shoot Artificial Intelligence 07, 2004 –
Glitter, Smell Actuators Left turn, Right turn, Forward, Grab, Release, Shoot Artificial Intelligence 07, 2004 –

Wumpus World Characterization

Wumpus World Characterization Observable?? Artificial Intelligence 07, 2004 – 6

Observable??

Wumpus World Characterization

Wumpus World Characterization Observable?? Deterministic?? No—only local perception Artificial Intelligence 07, 2004

Observable??

Wumpus World Characterization Observable?? Deterministic?? No—only local perception Artificial Intelligence 07, 2004

Deterministic??

No—only local perception

Wumpus World Characterization

Wumpus World Characterization Observable?? No—only local perception Deterministic?? Yes—outcomes exactly specified

Observable??

No—only local perception

Characterization Observable?? No—only local perception Deterministic?? Yes—outcomes exactly specified
Characterization Observable?? No—only local perception Deterministic?? Yes—outcomes exactly specified

Deterministic?? Yes—outcomes exactly specified Episodic??

Wumpus World Characterization

Wumpus World Characterization Observable?? No—only local perception Deterministic?? Yes—outcomes exactly specified

Observable??

No—only local perception

Characterization Observable?? No—only local perception Deterministic?? Yes—outcomes exactly specified
Characterization Observable?? No—only local perception Deterministic?? Yes—outcomes exactly specified

Deterministic?? Yes—outcomes exactly specified Episodic?? No—sequential at the level of actions

exactly specified Episodic?? No—sequential at the level of actions Static?? Artificial Intelligence 07, 2004 – 6

Static??

Wumpus World Characterization

Wumpus World Characterization Observable?? No—only local perception Deterministic?? Yes—outcomes exactly specified

Observable??

No—only local perception

Characterization Observable?? No—only local perception Deterministic?? Yes—outcomes exactly specified
Characterization Observable?? No—only local perception Deterministic?? Yes—outcomes exactly specified

Deterministic?? Yes—outcomes exactly specified Episodic?? No—sequential at the level of actions

Episodic?? No—sequential at the level of actions Static?? Discrete?? Yes—Wumpus and Pits do not move

Static??

Episodic?? No—sequential at the level of actions Static?? Discrete?? Yes—Wumpus and Pits do not move Artificial

Discrete??

Yes—Wumpus and Pits do not move

Wumpus World Characterization

Wumpus World Characterization Observable?? No—only local perception Deterministic?? Yes—outcomes exactly specified

Observable??

No—only local perception

Characterization Observable?? No—only local perception Deterministic?? Yes—outcomes exactly specified

Deterministic?? Yes—outcomes exactly specified

Episodic?? No—sequential at the level of actions No—sequential at the level of actions

Episodic?? No—sequential at the level of actions Static?? Discrete?? Yes—Wumpus and Pits do not move Yes

Static??

Episodic?? No—sequential at the level of actions Static?? Discrete?? Yes—Wumpus and Pits do not move Yes

Discrete??

Yes—Wumpus and Pits do not move Yes

Single-agent??at the level of actions Static?? Discrete?? Yes—Wumpus and Pits do not move Yes Artificial Intelligence

Wumpus World Characterization

Wumpus World Characterization Observable?? No—only local perception Deterministic?? Yes—outcomes exactly specified

Observable??

No—only local perception

Characterization Observable?? No—only local perception Deterministic?? Yes—outcomes exactly specified

Deterministic?? Yes—outcomes exactly specified

Episodic?? No—sequential at the level of actions No—sequential at the level of actions

Episodic?? No—sequential at the level of actions Static?? Discrete?? Yes—Wumpus and Pits do not move Yes

Static??

Episodic?? No—sequential at the level of actions Static?? Discrete?? Yes—Wumpus and Pits do not move Yes

Discrete??

Yes—Wumpus and Pits do not move

Yes

Single-agent??Static?? Discrete?? Yes—Wumpus and Pits do not move Yes feature Yes—Wumpus is essentially a natural Artificial

feature

Yes—Wumpus is essentially a natural

Exploring a Wumpus World

OK OK OK A
OK
OK
OK
A

Exploring a Wumpus World

Exploring a Wumpus World B OK A OK A OK Artificial Intelligence 07, 2004 – 7

B OK

A
A

OK

A
A

OK

Exploring a Wumpus World

Exploring a Wumpus World P? B OK P? A A OK OK Artificial Intelligence 07, 2004

P?

Exploring a Wumpus World P? B OK P? A A OK OK Artificial Intelligence 07, 2004

B

OK

P?

A
A
A
A

OK

OK

Exploring a Wumpus World

Exploring a Wumpus World P? B OK P? A A OK S OK A Artificial Intelligence

P?

Exploring a Wumpus World P? B OK P? A A OK S OK A Artificial Intelligence

B

OK

P?

A
A
A
A

OK

S OK

A
A

Exploring a Wumpus World

P? P B OK P? OK A OK S OK W A A
P?
P
B
OK
P?
OK
A
OK
S OK
W
A
A

Exploring a Wumpus World

P? P B OK P? OK A A OK S OK W A A
P?
P
B
OK
P?
OK
A
A
OK
S
OK
W
A
A

Exploring a Wumpus World

Exploring a Wumpus World P P? OK P? OK A A B OK OK A A

P

P?

OK

P?
P?

OK

A
A
A
A

B

OK

OK

A
A
A
A

OK

S

OK

W

Exploring a Wumpus World

Exploring a Wumpus World P P? OK P? OK A A B BGS OK A OK

P

P?

OK

P?
P?

OK

A
A
A
A

B

BGS

OK

A
A

OK

A
A
A
A

OK

S

OK

W

Wumpus State of Knowledge

1,4

2,4

3,4

4,4

1,3

2,3

3,3

4,3

1,2

2,2

3,2

4,2

 

OK

1,1

2,1

3,1

4,1

 
A
A

OK

 

OK

(a)

A
A

= Agent

B

=

Breeze

G

=

Glitter, Gold

OK

= Safe square

P

=

Pit

S

=

Stench

V

= Visited

W

=

Wumpus

1,4

2,4

3,4

4,4

1,3

2,3

3,3

4,3

1,2

2,2

3,2

4,2

 

P?

 

OK

 

1,1

2,1

A
A

3,1

P?

4,1

 

V

B

 

OK

OK

(b)

3,1 P? 4,1   V B   OK OK (b) The first step taken by the

The first step taken by the agent in the wumpus world

(a)

The initial situation, after percept [None,None,None,None,None]

(b)

After one move, with percept [None,Breeze,None,None,None]

Wumpus State of Knowledge 2

1,4

2,4

3,4

4,4

1,3

W!

2,3

3,3

4,3

1,2

A
A

2,2

3,2

4,2

S

OK

 

OK

1,1

2,1

B

3,1

P!

4,1

 

V

V

 

OK

OK

(a)

A
A

= Agent

B

=

Breeze

G

=

Glitter, Gold

OK

= Safe square

P

=

Pit

S

=

Stench

V

= Visited

W

=

Wumpus

1,4

2,4

3,4

4,4

 

P?

1,3

W!

2,3

A
A

3,3

P?

4,3

 

S

G

 
 

B

1,2

S

2,2

3,2

4,2

V

 

V

OK

 

OK

1,1

2,1

B

3,1

P!

4,1

 

V

V

 

OK

 

OK

(b)

P! 4,1   V V   OK   OK (b) Two later stages in the progress

Two later stages in the progress of the agent

(a)

After the third move, with percept [Stench,None,None,None,None]

(b)

After the fifth move, with percept [Stench,Breeze,Glitter,None,None]

Other Tight Spots

P? B OK P? P? A OK B OK P? A A
P?
B
OK
P?
P?
A
OK
B
OK
P?
A
A

Breeze in (1,2) and (2,1)Other Tight Spots P? B OK P? P? A OK B OK P? A A no

no safe actions

Assuming pits uniformly distributed, (2,2) has pit w/ prob 0.86, vs. 0.31B OK P? A A Breeze in (1,2) and (2,1) no safe actions S A Smell

S A

S

S A
S A
S A
A
A
S A
S A
S A

Smell in (1,1)distributed, (2,2) has pit w/ prob 0.86, vs. 0.31 S A Can use a strategy of

Can use a strategy of coercion : coercion:

cannot move

shoot straight ahead

wumpus was therea strategy of coercion : cannot move shoot straight ahead safe wumpus wasn’t there dead safe

safe

wumpus wasn’t thereof coercion : cannot move shoot straight ahead wumpus was there safe dead safe Artificial Intelligence

dead

safe

Logic in General

Logics are formal languages for representing information such that conclusions can be drawn are formal languages for representing information such that conclusions can be drawn

Syntax defines the sentences in the language defines the sentences in the language

Semantics define the “meaning” of sentences; i.e., define truth of a sentence in a world define the “meaning” of sentences; i.e., define truth of a sentence in a world

E.g., the language of arithmeticof sentences; i.e., define truth of a sentence in a world is a sentence; is true

of a sentence in a world E.g., the language of arithmetic is a sentence; is true

is a sentence;

is true iff the number

the number

is not a sentence is no less than

is true in a world where

is false in a world where

Entailment

Entailment means that one thing follows from another: means that one thing follows from another:

Knowledge baseEntailment means that one thing follows from another: entails sentence is true in all worlds where

entails sentence

is true in all worlds where

is true

if and only if

E.g., the KB containing “the Giants won” and “the Reds won” entails “Either the Giants won or the Reds won”sentence is true in all worlds where is true if and only if E.g., Entailment is

E.g.,won” entails “Either the Giants won or the Reds won” Entailment is a relationship between sentences

Entailment is a relationship between sentences (i.e., syntax ) that is based on semantics syntax) that is based on semantics

Note: brains process syntax (of some sort) syntax (of some sort)

entails

Models

Models Logicians typically think in terms of models , which are formally structured worlds with respect

Logicians typically think in terms of models, which are formally structured worlds with respect to which truth can be evaluated

We say

is a model of a sentence

if

is true in

be evaluated We say is a model of a sentence if is true in Then is

Then

is the set of all models of

if and only if

is true in Then is the set of all models of if and only if x
x x x x x x x x x M( ) x x x x
x
x
x
x
x
x
x
x
x
M(
)
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
xx
x
x
x
x
x
x
x
x
x
M(KB)
x
x
x
x
x
x
x

E.g.

= 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]Entailment in the Wumpus World Consider possible models for ?s assuming only pits ? ? B

Consider possible models for ?s assuming only pitsdetecting nothing in [1,1], moving right, breeze in [2,1] ? ? B ? A A 3

? ? B ? A A
?
?
B
?
A
A
possible models for ?s assuming only pits ? ? B ? A A 3 Boolean choices

3 Boolean choices

8 possible models

Wumpus Models

2 PIT 2 Breeze 1 Breeze 1 PIT 1 2 3 1 2 3 2
2
PIT
2
Breeze
1
Breeze
1
PIT
1
2
3
1
2
3
2
PIT
2
PIT
2
Breeze
1
PIT
Breeze
1
Breeze
1
1
2
3
1
2
3
1
2
3
2
PIT
PIT
2
PIT
Breeze
1
Breeze
1
PIT
2
PIT
PIT
1
2
3
1
2
3
Breeze
1
PIT
1
2
3

Wumpus Models

2 PIT 2 Breeze 1 Breeze 1 PIT 1 2 3 1 2 3 KB
2
PIT
2
Breeze
1
Breeze
1
PIT
1
2
3
1
2
3
KB
2
PIT
2
PIT
2
Breeze
1
PIT
Breeze
1
Breeze
1
1
2
3
1
2
3
1
2
3
2
PIT
PIT
2
PIT
Breeze
1
Breeze
1
PIT
2
PIT
PIT
1
2
3
1
2
3
Breeze
1
PIT
1
2
3
= wumpus-world rules + observations

Wumpus Models

2 PIT 2 Breeze 1 Breeze 1 PIT 1 2 3 1 2 3 KB
2
PIT
2
Breeze
1
Breeze
1
PIT
1
2
3
1
2
3
KB
1
2
PIT
2
PIT
2
Breeze
1
PIT
Breeze
1
Breeze
1
1
2
3
1
2
3
1
2
3
2
PIT
PIT
2
PIT
Breeze
1
Breeze
1
PIT
2
PIT
PIT
1
2
3
1
2
3
Breeze
1
PIT
1
2
3
= wumpus-world rules + observations
= “[1,2] is safe”,
, proved by model checking

Wumpus Models

2 PIT 2 Breeze 1 Breeze 1 PIT 1 2 3 1 2 3 KB
2
PIT
2
Breeze
1
Breeze
1
PIT
1
2
3
1
2
3
KB
2
PIT
2
PIT
2
Breeze
1
PIT
Breeze
1
Breeze
1
1
2
3
1
2
3
1
2
3
2
PIT
PIT
2
PIT
Breeze
1
Breeze
1
PIT
2
PIT
PIT
1
2
3
1
2
3
Breeze
1
PIT
1
2
3
= wumpus-world rules + observations

Wumpus Models 2 PIT 2 Breeze 1 Breeze 1 PIT 2 1 2 3 1
Wumpus Models
2
PIT
2
Breeze
1
Breeze
1
PIT
2
1
2
3
1
2
3
KB
2
PIT
2
PIT
2
Breeze
1
PIT
Breeze
1
Breeze
1
1
2
3
1
2
3
1
2
3
2
PIT
PIT
2
PIT
Breeze
1
Breeze
1
PIT
2
PIT
PIT
1
2
3
1
2
3
Breeze
1
PIT
1
2
3
PIT 2 PIT PIT 1 2 3 1 2 3 Breeze 1 PIT 1 2 3

= wumpus-world rules + observations

= “[2,2] is safe”,

Inference

Inference = sentence procedure Consequences of can be derived from by are a haystack; is a

= sentence

procedure

Consequences of

can be derived from

by

are a haystack;

is a needle.

Entailment = needle in haystack; inference = finding it

Soundness:

true that

Completeness:

also true that

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

is sound if whenever

, it is also

is complete if whenever

, it is

.

Follows vs. Entails

Representation

World

Sentences

Follows vs. Entails Representation World Sentences Sentence Semantics Entails Semantics Aspects of the real world

Sentence

Semantics Entails Semantics
Semantics
Entails
Semantics

Aspects of the real world

Semantics Entails Semantics Aspects of the real world Follows Aspect of the real world Artificial Intelligence

Follows

Aspect of the real world

Propositional Logic: Syntax

Propositional logic is the simplest logic—illustrates basic ideasPropositional Logic: Syntax The proposition symbols If etc are sentences , is a sentence, is a

The proposition symbolslogic is the simplest logic—illustrates basic ideas If etc are sentences , is a sentence, is

Iflogic—illustrates basic ideas The proposition symbols etc are sentences , is a sentence, is a sentence

etc are sentences

,

is a sentence,

is a sentence (negation)

are sentences , is a sentence, is a sentence ( negation ) If ( conjunction )

are sentences , is a sentence, is a sentence ( negation ) If ( conjunction )

are sentences , is a sentence, is a sentence ( negation ) If ( conjunction )

are sentences , is a sentence, is a sentence ( negation ) If ( conjunction )

If

(conjunction)

If

(disjunction)

If

(implication)

If

(biconditional)

and

are sentences,

and

are sentences,

and

are sentences,

and

are sentences,

is a sentence

is a sentence

is a sentence

is a sentence

Propositional Logic: Semantics

Each model specifies true/false for each proposition symbol, E.g.Propositional Logic: Semantics (8 possible models, can be enumerated) Rules for evaluating truth with respect to

(8 possible models, can be enumerated)

Rules for evaluating truth with respect to a modelsymbol, E.g. (8 possible models, can be enumerated) i.e., is true iff is true iff is

i.e.,

is true iff is true iff is true iff is true iff is false iff is true iff

is false is true and is true or is false or is true and is true and

:

is true

is true

is true

is false

is true

Simple recursive process evaluates an arbitrary sentence,or is true and is true and : is true is true is true is false

=

Truth Tables for Connectives

Truth Tables for Connectives Artificial Intelligence 07, 2004 – 20

Wumpus World Sentences

Wumpus World Sentences Let Let be true if there is a pit in . be true

Wumpus World Sentences Let Let be true if there is a pit in . be true

Let

Let

be true if there is a pit in

.

be true if there is a breeze in

.

“Pits cause breezes in adjacent squares”Let Let be true if there is a pit in . be true if there is

Wumpus World Sentences

Wumpus World Sentences Let Let be true if there is a pit in . be true

Wumpus World Sentences Let Let be true if there is a pit in . be true

Let

Let

be true if there is a pit in

.

be true if there is a breeze in

.

“Pits cause breezes in adjacent squares”if there is a pit in . be true if there is a breeze in .

“A square is breezy if and only if there is an adjacent pit” if and only if there is an adjacent pit”

Truth Tables for Inference

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

. .
.
.

.

.

. .
.
.

Inference by Enumeration

Inference by Enumeration Depth-first enumeration of all models is sound and complete for symbols; problem is
Depth-first enumeration of all models is sound and complete for symbols; problem is co-NP-complete Artificial
Depth-first enumeration of all models is sound and
complete
for
symbols; problem is co-NP-complete
Artificial Intelligence 07, 2004 – 23

Logical Equivalence

Logical Equivalence Two sentences are logically equivalent iff true in same models: if and only if

Two sentences are logically equivalent iff true in same

models:

if and only if

and

commutativity of commutativity of

associativity of associativity of

double-negation elimination

contraposition

implication elimination

biconditional elimina

de Morgan de Morgan

distributivity of

distributivity of

over

over

Validity and Satisfiability

Validity and Satisfiability A sentence is valid if it is true in all models, e.g., Validity

A sentence is valid if it is true in all models,

e.g.,

Validity is connected to inference via the Deduction Theorem:

,

,

,

if and only if

is valid

A sentence is satisfiable if it is true in some model

e.g.,

A sentence is unsatisfiable if it is true in no models

e.g.,

Satisfiability is connected to inference via the following:

,

if and only if

is unsatisfiable

i.e., prove

by reductio ad absurdum

Proof Methods

Application of inference rules Legitimate (sound) generation of new sentences from old Proof = a sequence of inference rule Legitimate (sound) generation of new sentences from old Proof = a sequence of inference rule applications Can use inference rules as operators in a standard search alg. Typically require translation of sentences into a normal form

Model checking truth table enumeration (always exponential in improved backtracking, e.g., Davis–Putnam–Logemann–Loveland heuristic truth table enumeration (always exponential in improved backtracking, e.g., Davis–Putnam–Logemann–Loveland heuristic search in model space (sound but incomplete) e.g., min-conflicts-like hill-climbing algorithms

space (sound but incomplete) e.g., min-conflicts-like hill-climbing algorithms ) Artificial Intelligence 07, 2004 – 26
space (sound but incomplete) e.g., min-conflicts-like hill-climbing algorithms ) Artificial Intelligence 07, 2004 – 26
space (sound but incomplete) e.g., min-conflicts-like hill-climbing algorithms ) Artificial Intelligence 07, 2004 – 26

)

space (sound but incomplete) e.g., min-conflicts-like hill-climbing algorithms ) Artificial Intelligence 07, 2004 – 26
space (sound but incomplete) e.g., min-conflicts-like hill-climbing algorithms ) Artificial Intelligence 07, 2004 – 26
space (sound but incomplete) e.g., min-conflicts-like hill-climbing algorithms ) Artificial Intelligence 07, 2004 – 26

Resolution

1. Conjunctive Normal Form (CNF—universal) conjunction of disjunctions of literals

E.g.,

clauses

P? P B OK P? OK A A OK S OK W A A
P?
P
B
OK
P?
OK
A
A
OK
S
OK
W
A
A

2. Resolution inference rule (for CNF): complete for proposi- tional logic

where

and

are complementary literals. E.g.,

3. Resolution is sound and complete for propositional logic

Conversion to CNF

1. Eliminate

,

replacing

with

2. Eliminate

, replacing

with

.

3. Move

inwards using de Morgan’s rules and

double-negation:

4. Apply distributivity law (

over

) and flatten:

.

PL Resolution

PL Resolution Proof by contradiction, i.e., show unsatisfiable Artificial Intelligence 07, 2004 – 29

Proof by contradiction, i.e., show

unsatisfiable

PL Resolution Proof by contradiction, i.e., show unsatisfiable Artificial Intelligence 07, 2004 – 29

Resolution Example

Resolution Example ¬P 2,1 ⁄ B 1,1 ¬B 1,1 ⁄ P 1,2 ⁄ P 2,1 ¬P
¬P 2,1 ⁄ B 1,1 ¬B 1,1 ⁄ P 1,2 ⁄ P 2,1 ¬P 1,2
¬P 2,1 ⁄
B 1,1
¬B 1,1 ⁄
P 1,2 ⁄
P 2,1
¬P 1,2 ⁄
B 1,1
¬B 1,1
P 1,2
P 1,2 ⁄
B 1,1
P 1,2 ⁄
P 2,1 ⁄
¬P 1,2
¬B 1,1 ⁄
P 2,1 ⁄
B 1,1
P 1,2 ⁄
P 2,1 ⁄
¬P 2,1
¬P 2,1
¬P 1,2

¬B 1,1

Forward and Backward Chaining

Horn Form (restricted) (restricted)

KB = conjunction of Horn clauses conjunction of Horn clauses

Horn clause =Horn Form (restricted) KB = conjunction of Horn clauses proposition symbol; or (conjunction of symbols) E.g.,

proposition symbol; orKB = conjunction of Horn clauses Horn clause = (conjunction of symbols) E.g., symbol Modus Ponens

(conjunction of symbols)of Horn clauses Horn clause = proposition symbol; or E.g., symbol Modus Ponens (for Horn Form):

E.g.,clause = proposition symbol; or (conjunction of symbols) symbol Modus Ponens (for Horn Form): complete for

symbol

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

Can be used with forward chaining or backward chaining . forward chaining or backward chaining.

These algorithms are very natural and run in linear time linear time

Forward Chaining

Q P M L A B
Q
P
M
L
A
B
Forward Chaining Q P M L A B Idea: fire any rule whose premises are satisfied

Idea: fire any rule whose premises are satisfied in the

, add its conclusion to the

, until query is found

PL Forward Chaining

PL Forward Chaining Artificial Intelligence 07, 2004 – 33

Forward Chaining Example

Q 1 P 2 M 2 L 2 2 A B
Q
1
P
2
M
2
L
2
2
A
B

Forward Chaining Example

Q 1 P 2 M 2 L 1 1 A B
Q
1
P
2
M
2
L
1
1
A
B

Forward Chaining Example

Q 1 P 2 M 1 L 1 0 A B
Q
1
P
2
M
1
L
1
0
A
B

Forward Chaining Example

Q 1 P 1 M 0 L 1 0 A B
Q
1
P
1
M
0
L
1
0
A
B

Forward Chaining Example

Q 1 P 0 M 0 L 1 0 A B
Q
1
P
0
M
0
L
1
0
A
B

Forward Chaining Example

Q
Q

0

P 0 M 0 L 0 0 A B
P
0
M
0
L
0
0
A
B

Forward Chaining Example

Q
Q

0

P 0 M 0 L 0 0 A B
P
0
M
0
L
0
0
A
B

Forward Chaining Example

Q
Q

0

P 0 M 0 L 0 0 A B
P
0
M
0
L
0
0
A
B

Proof of Completeness

FC derives every atomic sentence that is entailed by

1. FC reaches a fixed point where no new atomic sentences are derived

2. Consider the final state as a model true/false to symbols

3. Every clause in the original Proof: Suppose a clause

, assigning

is true in

is false in

Then

Therefore the algorithm has not reached a fixed point!

is true in

and

is false in

4. Hence

5.