introduction to articial intelligence logical...

94
Introduction to Artificial Intelligence Logical Agents (Logic, Deduction, Knowledge Representation) Bernhard Beckert U NIVERSITÄT KOBLENZ -L ANDAU Winter Term 2004/2005 B. Beckert: KI für IM – p.1

Upload: others

Post on 01-Jul-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Introduction to Artificial Intelligence

Logical Agents

(Logic, Deduction, Knowledge Representation)

Bernhard Beckert

UNIVERSITÄT KOBLENZ-LANDAU

Winter Term 2004/2005

B. Beckert: KI für IM – p.1

Page 2: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Outline

Knowledge-based agents

Wumpus world

Logic in general—models and entailment

Propositional (Boolean) logic

Equivalence, validity, satisfiability

Inference rules and theorem proving

– forward chaining– backward chaining– resolution

B. Beckert: KI für IM – p.2

Page 3: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Knowledge bases

Inference engine

Knowledge base domain−specific content

domain−independent algorithms

Knowledge base

Set of sentences in a formal language

Declarative approach to building an agent

Tell it what it needs to know

Then it can ask itself what to do—answers follow from the knowledge base

B. Beckert: KI für IM – p.3

Page 4: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Knowledge bases

Inference engine

Knowledge base domain−specific content

domain−independent algorithms

Knowledge base

Set of sentences in a formal language

Declarative approach to building an agent

Tell it what it needs to know

Then it can ask itself what to do—answers follow from the knowledge base

B. Beckert: KI für IM – p.3

Page 5: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Wumpus World PEAS description

Performance measuregold +1000, death -1000-1 per step, -10 for using the arrow

EnvironmentSquares adjacent to wumpus are smellySquares adjacent to pit are breezyGlitter iff gold is in the same squareShooting kills wumpus if you are facing itShooting uses up the only arrowGrabbing picks up gold if in same squareReleasing drops the gold in same square

ActuatorsLeft turn, Right turn,Forward, Grab, Release, Shoot

SensorsBreeze, Glitter, Smell

Breeze Breeze

Breeze

BreezeBreeze

Stench

Stench

BreezePIT

PIT

PIT

1 2 3 4

1

2

3

4

START

Gold

Stench

B. Beckert: KI für IM – p.4

Page 6: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Wumpus World Characterization

Observable

No – only local perception

Deterministic

Yes – outcome of action 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

B. Beckert: KI für IM – p.5

Page 7: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Wumpus World Characterization

Observable No – only local perception

Deterministic

Yes – outcome of action 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

B. Beckert: KI für IM – p.5

Page 8: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Wumpus World Characterization

Observable No – only local perception

Deterministic Yes – outcome of action 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

B. Beckert: KI für IM – p.5

Page 9: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Wumpus World Characterization

Observable No – only local perception

Deterministic Yes – outcome of action 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

B. Beckert: KI für IM – p.5

Page 10: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Wumpus World Characterization

Observable No – only local perception

Deterministic Yes – outcome of action 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

B. Beckert: KI für IM – p.5

Page 11: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Wumpus World Characterization

Observable No – only local perception

Deterministic Yes – outcome of action 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

B. Beckert: KI für IM – p.5

Page 12: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Wumpus World Characterization

Observable No – only local perception

Deterministic Yes – outcome of action 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

B. Beckert: KI für IM – p.5

Page 13: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Exploring a Wumpus World

A

OK

OKOK

B. Beckert: KI für IM – p.6

Page 14: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Exploring a Wumpus World

OK

OK OK

A

A

B

B. Beckert: KI für IM – p.6

Page 15: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Exploring a Wumpus World

OK

OK OK

A

A

B

P?

P?

B. Beckert: KI für IM – p.6

Page 16: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Exploring a Wumpus World

OK

OK OK

A

A

B

P?

P?

A

S

B. Beckert: KI für IM – p.6

Page 17: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Exploring a Wumpus World

OK

OK OK

A

A

B

P?

P?

A

S

OK

P

WB. Beckert: KI für IM – p.6

Page 18: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Exploring a Wumpus World

OK

OK OK

A

A

B

P?

P?

A

S

OK

P

W

A

B. Beckert: KI für IM – p.6

Page 19: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Exploring a Wumpus World

OK

OK OK

A

A

B

P?

P?

A

S

OK

P

W

A

OK

OK

B. Beckert: KI für IM – p.6

Page 20: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Exploring a Wumpus World

OK

OK OK

A

A

B

P?

P?

A

S

OK

P

W

A

OK

OK

A

BGS

B. Beckert: KI für IM – p.6

Page 21: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Problematic Situations

A

B OK

OK OK

A

B

A

P?

P?P?

P?

Problem

Breeze in (1,2) and (2,1)⇒ no safe actions

Possible solution

Assuming pits uniformly distributed:

(2,2) has pit with probability 0.86(1,3) and (3,1) have pit with probab. 0.31

B. Beckert: KI für IM – p.7

Page 22: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Problematic Situations

A

B OK

OK OK

A

B

A

P?

P?P?

P?

Problem

Breeze in (1,2) and (2,1)⇒ no safe actions

Possible solution

Assuming pits uniformly distributed:

(2,2) has pit with probability 0.86(1,3) and (3,1) have pit with probab. 0.31

B. Beckert: KI für IM – p.7

Page 23: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Problematic Situations

A

S

Problem

Smell in (1,1)⇒ no safe actions

Possible solution

Strategy of coercion:

shoot straight aheadwumpus was there ⇒ dead ⇒ safewumpus wasn’t there ⇒ safe

B. Beckert: KI für IM – p.8

Page 24: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Problematic Situations

A

S

Problem

Smell in (1,1)⇒ no safe actions

Possible solution

Strategy of coercion:

shoot straight aheadwumpus was there ⇒ dead ⇒ safewumpus wasn’t there ⇒ safe

B. Beckert: KI für IM – p.8

Page 25: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Logic in General

Logics

Formal languages for representing information,such that conclusions can be drawn

Syntax

Defines the sentences in the language

Semantics

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

B. Beckert: KI für IM – p.9

Page 26: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Example: Language of Arithmetic

Syntax

x+2 ≥ y is a sentence

x2+ y > is not a sentence

Semantics

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

B. Beckert: KI für IM – p.10

Page 27: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Example: Language of Arithmetic

Syntax

x+2 ≥ y is a sentence

x2+ y > is not a sentence

Semantics

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

B. Beckert: KI für IM – p.10

Page 28: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Entailment

Definition

Knowledge base KB entails sentence αif and only if

α is true in all worlds where KB is true

Notation

KB |= α

Note

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

B. Beckert: KI für IM – p.11

Page 29: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Entailment

Definition

Knowledge base KB entails sentence αif and only if

α is true in all worlds where KB is true

Notation

KB |= α

Note

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

B. Beckert: KI für IM – p.11

Page 30: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Entailment

Example

The KB containing “the shirt is green” and “the shirt is striped”entails “the shirt is green or the shirt is striped”

Example

x+ y = 4 entails 4 = x+ y

B. Beckert: KI für IM – p.12

Page 31: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Models

Intuition

Models are formally structured worlds,with respect to which truth can be evaluated

Definition

m is a model of a sentence α if α is true in m

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

Note

KB |= α if and only if M(KB) ⊆ M(α)

B. Beckert: KI für IM – p.13

Page 32: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Models

Intuition

Models are formally structured worlds,with respect to which truth can be evaluated

Definition

m is a model of a sentence α if α is true in m

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

Note

KB |= α if and only if M(KB) ⊆ M(α)

B. Beckert: KI für IM – p.13

Page 33: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Models: Example

KB = The shirt is green and striped

α = The shirt is green

M( )

M(KB)

x

x

x

x

x

x

x x

x

x

xx

xx

xx

xx

x

xxxx

x x

xx

xx x

x

xx

x x x

x

xx

x

x

x

x

x

x

x

x

B. Beckert: KI für IM – p.14

Page 34: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Entailment in the Wumpus World

Situation after

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

Consider possible models for “?”s(considering only pits)

3 Boolean choices8 possible models

AA

B

??

?

B. Beckert: KI für IM – p.15

Page 35: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Wumpus Models

KB 6|= α2

1 2 3

1

2

Breeze

PIT

1 2 3

1

2

Breeze

PIT

1 2 3

1

2

Breeze

PIT PIT

PIT

1 2 3

1

2

Breeze

PIT

PIT

1 2 3

1

2

BreezePIT

1 2 3

1

2

Breeze

PIT

PIT

1 2 3

1

2

Breeze

PIT PIT

1 2 3

1

2

Breeze

KB = wumpus-world rules + observations

B. Beckert: KI für IM – p.16

Page 36: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Wumpus Models

KB 6|= α2

1 2 3

1

2

Breeze

PIT

1 2 3

1

2

Breeze

PIT

1 2 3

1

2

Breeze

PIT PIT

PIT

1 2 3

1

2

Breeze

PIT

PIT

1 2 3

1

2

BreezePIT

1 2 3

1

2

Breeze

PIT

PIT

1 2 3

1

2

Breeze

PIT PIT

1 2 3

1

2

Breeze

KB

KB = wumpus-world rules + observations

B. Beckert: KI für IM – p.16

Page 37: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Wumpus Models

KB |= α1

KB 6|= α2

1 2 3

1

2

Breeze

PIT

1 2 3

1

2

Breeze

PIT

1 2 3

1

2

Breeze

PIT PIT

PIT

1 2 3

1

2

Breeze

PIT

PIT

1 2 3

1

2

BreezePIT

1 2 3

1

2

Breeze

PIT

PIT

1 2 3

1

2

Breeze

PIT PIT

1 2 3

1

2

Breeze

KB1

KB = wumpus-world rules + observations

α1 = “[1,2] is safe”B. Beckert: KI für IM – p.16

Page 38: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Wumpus Models

KB 6|= α2

1 2 3

1

2

Breeze

PIT

1 2 3

1

2

Breeze

PIT

1 2 3

1

2

Breeze

PIT PIT

PIT

1 2 3

1

2

Breeze

PIT

PIT

1 2 3

1

2

BreezePIT

1 2 3

1

2

Breeze

PIT

PIT

1 2 3

1

2

Breeze

PIT PIT

1 2 3

1

2

Breeze

KB

KB = wumpus-world rules + observations

B. Beckert: KI für IM – p.16

Page 39: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Wumpus Models

KB 6|= α2

1 2 3

1

2

Breeze

PIT

1 2 3

1

2

Breeze

PIT

1 2 3

1

2

Breeze

PIT PIT

PIT

1 2 3

1

2

Breeze

PIT

PIT

1 2 3

1

2

BreezePIT

1 2 3

1

2

Breeze

PIT

PIT

1 2 3

1

2

Breeze

PIT PIT

1 2 3

1

2

Breeze

KB2

KB = wumpus-world rules + observations

α2 = “[2,2] is safe”B. Beckert: KI für IM – p.16

Page 40: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Inference

Definition

KB `i α

means

sentence α can be derived from KB by inference procedure i

Soundness (of i)

Whenever KB `i α, it is also true that KB |= α

Completeness (of i)

Whenever KB |= α, it is also true that KB `i α

B. Beckert: KI für IM – p.17

Page 41: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Inference

Definition

KB `i α

means

sentence α can be derived from KB by inference procedure i

Soundness (of i)

Whenever KB `i α, it is also true that KB |= α

Completeness (of i)

Whenever KB |= α, it is also true that KB `i α

B. Beckert: KI für IM – p.17

Page 42: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Preview

First-order Logic

We will define a logic (first-order logic) that

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 followsfrom what is known by the KB.

B. Beckert: KI für IM – p.18

Page 43: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Propositional Logic: Syntax

Definition

Propositional symbols

A, B, P1, P2, ShirtIsGreen, etc.

are (atomic) sentences

If S,S1,S2 are sentences, then

¬S (negation)

S1 ∧S2 (con junction)

S1 ∨S2 (dis junction)

S1 ⇒ S2 (implication)

S1 ⇔ S2 (equivalence)

are sentences

B. Beckert: KI für IM – p.19

Page 44: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Propositional logic: Semantics

Propositional Models

Each model specifies true/false for each proposition symbol

Example A B Ctrue true false

(For three symbols, there are8 possible models)

Rules for evaluating truth with respect to a model

¬S is true iff S is false

S1 ∧S2 is true iff S1 is true and S2 is true

S1 ∨S2 is true iff S1 is true or S2 is true

S1 ⇒ S2 is true iff S1 is false or S2 is true

S1 ⇔ S2 is true iff S1 and S2 have the same truth value

B. Beckert: KI für IM – p.20

Page 45: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Propositional logic: Semantics

Propositional Models

Each model specifies true/false for each proposition symbol

Example A B Ctrue true false

(For three symbols, there are8 possible models)

Rules for evaluating truth with respect to a model

¬S is true iff S is false

S1 ∧S2 is true iff S1 is true and S2 is true

S1 ∨S2 is true iff S1 is true or S2 is true

S1 ⇒ S2 is true iff S1 is false or S2 is true

S1 ⇔ S2 is true iff S1 and S2 have the same truth value

B. Beckert: KI für IM – p.20

Page 46: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Propositional logic: Semantics

Propositional Models

Each model specifies true/false for each proposition symbol

Example A B Ctrue true false

(For three symbols, there are8 possible models)

Rules for evaluating truth with respect to a model

¬S is true iff S is false

S1 ∧S2 is true iff S1 is true and S2 is true

S1 ∨S2 is true iff S1 is true or S2 is true

S1 ⇒ S2 is true iff S1 is false or S2 is true

S1 ⇔ S2 is true iff S1 and S2 have the same truth value

B. Beckert: KI für IM – p.20

Page 47: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Truth Tables for Connectives

A B ¬A A∧B A∨B A ⇒ B A ⇔ B

false false true false false true true

false true true false true true false

true false false false true false false

true true false true true true true

B. Beckert: KI für IM – p.21

Page 48: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Wumpus World Sentences

Propositional symbols

Pi, j means: “there is a pit in [i, j]”Bi, j means: “there is a breeze in [i, j]”

¬P1,1 ¬B1,1 B2,1

Sentences

“Pits cause breezes in adjacent squares”

P1,2 ⇒ (B1,1 ∧B1,3 ∧B2,2)

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

B1,1 ⇔ (P1,2 ∨P2,1)

B2,1 ⇔ (P1,1 ∨P2,2 ∨P3,1)

B. Beckert: KI für IM – p.22

Page 49: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Wumpus World Sentences

Propositional symbols

Pi, j means: “there is a pit in [i, j]”Bi, j means: “there is a breeze in [i, j]”

¬P1,1 ¬B1,1 B2,1

Sentences

“Pits cause breezes in adjacent squares”

P1,2 ⇒ (B1,1 ∧B1,3 ∧B2,2)

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

B1,1 ⇔ (P1,2 ∨P2,1)

B2,1 ⇔ (P1,1 ∨P2,2 ∨P3,1)

B. Beckert: KI für IM – p.22

Page 50: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Propositional Inference: Enumeration Method

Exampleα = A∨B KB = (A∨C)∧ (B∨¬C)

Checking that KB |= α

A B C A∨C B∨¬C KB αfalse false false

false true false false

false false true

true false false false

false true false

false true false true

false true true

true true

true false false

true true

true false true

true false false true

true true false

true true

true true true

true true

Note

Table has 2n rows for n symbols

B. Beckert: KI für IM – p.23

Page 51: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Propositional Inference: Enumeration Method

Exampleα = A∨B KB = (A∨C)∧ (B∨¬C)

Checking that KB |= α

A B C A∨C B∨¬C KB αfalse false false false

true false false

false false true true

false false false

false true false false

true false true

false true true true

true

true false false true

true

true false true true

false false true

true true false true

true

true true true true

true

Note

Table has 2n rows for n symbols

B. Beckert: KI für IM – p.23

Page 52: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Propositional Inference: Enumeration Method

Exampleα = A∨B KB = (A∨C)∧ (B∨¬C)

Checking that KB |= α

A B C A∨C B∨¬C KB αfalse false false false true

false false

false false true true false

false false

false true false false true

false true

false true true true truetrue false false true truetrue false true true false

false true

true true false true truetrue true true true true

Note

Table has 2n rows for n symbols

B. Beckert: KI für IM – p.23

Page 53: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Propositional Inference: Enumeration Method

Exampleα = A∨B KB = (A∨C)∧ (B∨¬C)

Checking that KB |= α

A B C A∨C B∨¬C KB αfalse false false false true false

false

false false true true false false

false

false true false false true false

true

false true true true true truetrue false false true true truetrue false true true false false

true

true true false true true truetrue true true true true true

Note

Table has 2n rows for n symbols

B. Beckert: KI für IM – p.23

Page 54: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Propositional Inference: Enumeration Method

Exampleα = A∨B KB = (A∨C)∧ (B∨¬C)

Checking that KB |= α

A B C A∨C B∨¬C KB αfalse false false false true false falsefalse false true true false false falsefalse true false false true false truefalse true true true true true truetrue false false true true true truetrue false true true false false truetrue true false true true true truetrue true true true true true true

Note

Table has 2n rows for n symbols

B. Beckert: KI für IM – p.23

Page 55: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Propositional Inference: Enumeration Method

Exampleα = A∨B KB = (A∨C)∧ (B∨¬C)

Checking that KB |= α

A B C A∨C B∨¬C KB αfalse false false false true false falsefalse false true true false false falsefalse true false false true false truefalse true true true true true truetrue false false true true true truetrue false true true false false truetrue true false true true true truetrue true true true true true true

Note

Table has 2n rows for n symbols

B. Beckert: KI für IM – p.23

Page 56: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Propositional Inference: Enumeration Method

Exampleα = A∨B KB = (A∨C)∧ (B∨¬C)

Checking that KB |= α

A B C A∨C B∨¬C KB αfalse false false false true false falsefalse false true true false false falsefalse true false false true false truefalse true true true true true truetrue false false true true true truetrue false true true false false truetrue true false true true true truetrue true true true true true true

Note

Table has 2n rows for n symbolsB. Beckert: KI für IM – p.23

Page 57: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Logical Equivalence

Definition

Two sentences are logically equivalent, denoted by

α ≡ β

iff they are true in the same models, i.e., iff:

α |= β and β |= α

Example

(A ⇒ B) ≡ (¬B ⇒¬A) (contraposition)

B. Beckert: KI für IM – p.24

Page 58: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Logical Equivalence

Definition

Two sentences are logically equivalent, denoted by

α ≡ β

iff they are true in the same models, i.e., iff:

α |= β and β |= α

Example

(A ⇒ B) ≡ (¬B ⇒¬A) (contraposition)

B. Beckert: KI für IM – p.24

Page 59: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Logical Equivalence

Theorem

If

– α ≡ β– γ is the result of replacing a subformula α of δ by β,

then γ ≡ δ

Example

A∨B ≡ B∨A

implies

(C∧ (A∨B)) ⇒ D ≡ (C∧ (B∨A)) ⇒ D

B. Beckert: KI für IM – p.25

Page 60: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Logical Equivalence

Theorem

If

– α ≡ β– γ is the result of replacing a subformula α of δ by β,

then γ ≡ δ

Example

A∨B ≡ B∨A

implies

(C∧ (A∨B)) ⇒ D ≡ (C∧ (B∨A)) ⇒ D

B. Beckert: KI für IM – p.25

Page 61: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Important Equivalences

(α∧β) ≡ (β∧α) commutativity of ∧

(α∨β) ≡ (β∨α) commutativity of ∨

((α∧β)∧ γ) ≡ (α∧ (β∧ γ)) associativity of ∧

((α∨β)∨ γ) ≡ (α∨ (β∨ γ)) associativity of ∨

(α∧α) ≡ α idempotence for ∧

(α∨α) ≡ α idempotence for ∨

¬¬α ≡ α double-negation elimination

(α ⇒ β) ≡ (¬β ⇒¬α) contraposition

(α ⇒ β) ≡ (¬α∨β) implication elimination

(α ⇔ β) ≡ ((α ⇒ β)∧ (β ⇒ α)) equivalence elimination

¬(α∧β) ≡ (¬α∨¬β) de Morgan’s rules

¬(α∨β) ≡ (¬α∧¬β) de Morgan’s rules

(α∧ (β∨ γ)) ≡ ((α∧β)∨ (α∧ γ)) distributivity of ∧ over ∨

(α∨ (β∧ γ)) ≡ ((α∨β)∧ (α∨ γ)) distributivity of ∨ over ∧

B. Beckert: KI für IM – p.26

Page 62: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

The Logical Constants true and false

Semantics

true evaluates to true in all models

false evaluates to false in all models

Important equivalences with true and false

(α∧¬α) ≡ false

(α∨¬α) ≡ true tertium non datur

(α∧ true) ≡ α(α∧ false) ≡ false

(α∨ true) ≡ true

(α∨ false) ≡ α

B. Beckert: KI für IM – p.27

Page 63: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

The Logical Constants true and false

Semantics

true evaluates to true in all models

false evaluates to false in all models

Important equivalences with true and false

(α∧¬α) ≡ false

(α∨¬α) ≡ true tertium non datur

(α∧ true) ≡ α(α∧ false) ≡ false

(α∨ true) ≡ true

(α∨ false) ≡ α

B. Beckert: KI für IM – p.27

Page 64: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Validity

Definition

A sentence is valid if it is true in all models

Examples

A∨¬A, A ⇒ A, (A∧ (A ⇒ B)) ⇒ B

Deduction Theorem (connects inference and validity)

KB |= α if and only if KB ⇒ α is valid

B. Beckert: KI für IM – p.28

Page 65: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Validity

Definition

A sentence is valid if it is true in all models

Examples

A∨¬A, A ⇒ A, (A∧ (A ⇒ B)) ⇒ B

Deduction Theorem (connects inference and validity)

KB |= α if and only if KB ⇒ α is valid

B. Beckert: KI für IM – p.28

Page 66: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Satisfiability

Definition

A sentence is satisfiable if it is true in some model

Examples

A∨B, A, A∧ (A ⇒ B)

Definition

A sentence is unsatisfiable if it is true in no models,i.e., if it is not satisfiable

Example

A∧¬A

B. Beckert: KI für IM – p.29

Page 67: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Satisfiability

Definition

A sentence is satisfiable if it is true in some model

Examples

A∨B, A, A∧ (A ⇒ B)

Definition

A sentence is unsatisfiable if it is true in no models,i.e., if it is not satisfiable

Example

A∧¬AB. Beckert: KI für IM – p.29

Page 68: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Satisfiability

Theorem (connects validity and unsatisfiability)

α is valid if and only if ¬α is unsatisfiable

Theorem (connects inference and unsatisfiability)

KB |= α if and only if (KB∧¬α) is unsatisfiable

Note

Validity and inference can be proved by reductio ad absurdum

B. Beckert: KI für IM – p.30

Page 69: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Satisfiability

Theorem (connects validity and unsatisfiability)

α is valid if and only if ¬α is unsatisfiable

Theorem (connects inference and unsatisfiability)

KB |= α if and only if (KB∧¬α) is unsatisfiable

Note

Validity and inference can be proved by reductio ad absurdum

B. Beckert: KI für IM – p.30

Page 70: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Satisfiability

Theorem (connects validity and unsatisfiability)

α is valid if and only if ¬α is unsatisfiable

Theorem (connects inference and unsatisfiability)

KB |= α if and only if (KB∧¬α) is unsatisfiable

Note

Validity and inference can be proved by reductio ad absurdum

B. Beckert: KI für IM – p.30

Page 71: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Two Kinds of Proof Methods

1. Application of inference rules

Legitimate (sound) generation of new sentences from old

Construction of / search for a proof(proof = sequence of inference rule applications)

Properties

Typically requires translation of sentences into a normal form

Different kinds

Tableau calculus, resolution, forward/backward chaining, . . .

B. Beckert: KI für IM – p.31

Page 72: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Two Kinds of Proof Methods

1. Application of inference rules

Legitimate (sound) generation of new sentences from old

Construction of / search for a proof(proof = sequence of inference rule applications)

Properties

Typically requires translation of sentences into a normal form

Different kinds

Tableau calculus, resolution, forward/backward chaining, . . .

B. Beckert: KI für IM – p.31

Page 73: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Two Kinds of Proof Methods

1. Application of inference rules

Legitimate (sound) generation of new sentences from old

Construction of / search for a proof(proof = sequence of inference rule applications)

Properties

Typically requires translation of sentences into a normal form

Different kinds

Tableau calculus, resolution, forward/backward chaining, . . .

B. Beckert: KI für IM – p.31

Page 74: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Two Kinds of Proof Methods

2. Model checking

Construction of / search for a satisfying model

Different kinds

Truth table enumeration (always exponential number of symbols)

Improved backtracking search for modelse.g.: Davis-Putnam-Logemann-Loveland

Heuristic search in model space (sound but incomplete)e.g.: hill-climbing algorithms

B. Beckert: KI für IM – p.32

Page 75: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Two Kinds of Proof Methods

2. Model checking

Construction of / search for a satisfying model

Different kinds

Truth table enumeration (always exponential number of symbols)

Improved backtracking search for modelse.g.: Davis-Putnam-Logemann-Loveland

Heuristic search in model space (sound but incomplete)e.g.: hill-climbing algorithms

B. Beckert: KI für IM – p.32

Page 76: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Normal Forms

Literal

A literal is

– an atomic sentence (propositional symbol), or– the negation of an atomic sentence

Clause

A disjunction of literals

Conjunctive Normal Form (CNF)

A conjunction of disjunctions of literals,i.e., a conjunction of clauses

Example

(A∨¬B) ∧ (B∨¬C∨¬D)

B. Beckert: KI für IM – p.33

Page 77: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Normal Forms

Literal

A literal is

– an atomic sentence (propositional symbol), or– the negation of an atomic sentence

Clause

A disjunction of literals

Conjunctive Normal Form (CNF)

A conjunction of disjunctions of literals,i.e., a conjunction of clauses

Example

(A∨¬B) ∧ (B∨¬C∨¬D)

B. Beckert: KI für IM – p.33

Page 78: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Normal Forms

Literal

A literal is

– an atomic sentence (propositional symbol), or– the negation of an atomic sentence

Clause

A disjunction of literals

Conjunctive Normal Form (CNF)

A conjunction of disjunctions of literals,i.e., a conjunction of clauses

Example

(A∨¬B) ∧ (B∨¬C∨¬D)B. Beckert: KI für IM – p.33

Page 79: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Resolution

Inference rule

P1 ∨·· ·∨Pi−1 ∨Q∨Pi+1 ∨ . . .∨Pk R1 ∨·· ·∨R j−1 ∨¬Q∨R j+1 ∨ . . .∨Rn

P1 ∨·· ·∨Pi−1 ∨Pi+1 ∨ . . .∨Pk ∨ R1 ∨·· ·∨R j−1 ∨R j+1 ∨ . . .∨Rn

Example

P1,3 ∨P2,2 ¬P2,2

P1,3OK

OK OK

A

A

B

P?

P?

A

S

OK

P

W

A

B. Beckert: KI für IM – p.34

Page 80: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Resolution

Inference rule

P1 ∨·· ·∨Pi−1 ∨Q∨Pi+1 ∨ . . .∨Pk R1 ∨·· ·∨R j−1 ∨¬Q∨R j+1 ∨ . . .∨Rn

P1 ∨·· ·∨Pi−1 ∨Pi+1 ∨ . . .∨Pk ∨ R1 ∨·· ·∨R j−1 ∨R j+1 ∨ . . .∨Rn

Example

P1,3 ∨P2,2 ¬P2,2

P1,3OK

OK OK

A

A

B

P?

P?

A

S

OK

P

W

A

B. Beckert: KI für IM – p.34

Page 81: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Resolution

Correctness theorem

Resolution is sound and complete for propositional logic,

i.e., given a formula α in CNF (conjunction of clauses):

α is unsatisfiableiffthe empty clause can be derived from α with resolution

B. Beckert: KI für IM – p.35

Page 82: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Conversion to CNF

0. Given

B1,1 ⇔ (P1,2 ∨P2,1)

1. Eliminate ⇔, replacing α ≡ β with (α ⇒ β)∧ (β ⇒ α)

(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)

B. Beckert: KI für IM – p.36

Page 83: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Conversion to CNF

0. Given

B1,1 ⇔ (P1,2 ∨P2,1)

1. Eliminate ⇔, replacing α ≡ β with (α ⇒ β)∧ (β ⇒ α)

(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)

B. Beckert: KI für IM – p.36

Page 84: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Conversion to CNF

0. Given

B1,1 ⇔ (P1,2 ∨P2,1)

1. Eliminate ⇔, replacing α ≡ β with (α ⇒ β)∧ (β ⇒ α)

(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)

B. Beckert: KI für IM – p.36

Page 85: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Conversion to CNF

0. Given

B1,1 ⇔ (P1,2 ∨P2,1)

1. Eliminate ⇔, replacing α ≡ β with (α ⇒ β)∧ (β ⇒ α)

(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)

B. Beckert: KI für IM – p.36

Page 86: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Conversion to CNF

0. Given

B1,1 ⇔ (P1,2 ∨P2,1)

1. Eliminate ⇔, replacing α ≡ β with (α ⇒ β)∧ (β ⇒ α)

(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)

B. Beckert: KI für IM – p.36

Page 87: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Resolution Example

Given

KB = (B1,1 ⇔ (P1,2 ∨P2,1))∧¬B1,1

α = ¬P1,2

Resolution proof for KB |= α

Derive empty clause 2 from KB∧¬α in CNF

P1,2

P1,2

P2,1

P1,2 B1,1

B1,1 P2,1 B1,1 P1,2 P2,1 P2,1P1,2B1,1 B1,1

P1,2B1,1 P2,1B1,1P2,1 B1,1

P1,2 P2,1 P1,2

B. Beckert: KI für IM – p.37

Page 88: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Resolution Example

Given

KB = (B1,1 ⇔ (P1,2 ∨P2,1))∧¬B1,1

α = ¬P1,2

Resolution proof for KB |= α

Derive empty clause 2 from KB∧¬α in CNF

P1,2

P1,2

P2,1

P1,2 B1,1

B1,1 P2,1 B1,1 P1,2 P2,1 P2,1P1,2B1,1 B1,1

P1,2B1,1 P2,1B1,1P2,1 B1,1

P1,2 P2,1 P1,2

B. Beckert: KI für IM – p.37

Page 89: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Resolution Example

Given

KB = (B1,1 ⇔ (P1,2 ∨P2,1))∧¬B1,1

α = ¬P1,2

Resolution proof for KB |= α

Derive empty clause 2 from KB∧¬α in CNF

P1,2

P1,2

P2,1

P1,2 B1,1

B1,1 P2,1 B1,1 P1,2 P2,1 P2,1P1,2B1,1 B1,1

P1,2B1,1 P2,1B1,1P2,1 B1,1

P1,2 P2,1 P1,2

B. Beckert: KI für IM – p.37

Page 90: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Summary

Logical agents apply inference to a knowledge baseto derive new information and make decisions

Basic concepts of logic

– syntax: formal structure of sentences– semantics: truth of sentences w.r.t. models– entailment: necessary truth of one sentence given another– inference: deriving sentences from other sentences– soundess: derivations produce only entailed sentences– completeness: derivations can produce all entailed sentences

Wumpus world requires the ability to representpartial and negated information, reason by cases, etc.

Resolution is sound and complete for propositional logic

Propositional logic lacks expressive power

B. Beckert: KI für IM – p.38

Page 91: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Summary

Logical agents apply inference to a knowledge baseto derive new information and make decisions

Basic concepts of logic

– syntax: formal structure of sentences– semantics: truth of sentences w.r.t. models– entailment: necessary truth of one sentence given another– inference: deriving sentences from other sentences– soundess: derivations produce only entailed sentences– completeness: derivations can produce all entailed sentences

Wumpus world requires the ability to representpartial and negated information, reason by cases, etc.

Resolution is sound and complete for propositional logic

Propositional logic lacks expressive power

B. Beckert: KI für IM – p.38

Page 92: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Summary

Logical agents apply inference to a knowledge baseto derive new information and make decisions

Basic concepts of logic

– syntax: formal structure of sentences– semantics: truth of sentences w.r.t. models– entailment: necessary truth of one sentence given another– inference: deriving sentences from other sentences– soundess: derivations produce only entailed sentences– completeness: derivations can produce all entailed sentences

Wumpus world requires the ability to representpartial and negated information, reason by cases, etc.

Resolution is sound and complete for propositional logic

Propositional logic lacks expressive power

B. Beckert: KI für IM – p.38

Page 93: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Summary

Logical agents apply inference to a knowledge baseto derive new information and make decisions

Basic concepts of logic

– syntax: formal structure of sentences– semantics: truth of sentences w.r.t. models– entailment: necessary truth of one sentence given another– inference: deriving sentences from other sentences– soundess: derivations produce only entailed sentences– completeness: derivations can produce all entailed sentences

Wumpus world requires the ability to representpartial and negated information, reason by cases, etc.

Resolution is sound and complete for propositional logic

Propositional logic lacks expressive power

B. Beckert: KI für IM – p.38

Page 94: Introduction to Articial Intelligence Logical Agentsbeckert/teaching/KI-fuer-IM-WS0405/07LogicalAgents.pdfIntroduction to Articial Intelligence Logical Agents (Logic, Deduction, Knowledge

Summary

Logical agents apply inference to a knowledge baseto derive new information and make decisions

Basic concepts of logic

– syntax: formal structure of sentences– semantics: truth of sentences w.r.t. models– entailment: necessary truth of one sentence given another– inference: deriving sentences from other sentences– soundess: derivations produce only entailed sentences– completeness: derivations can produce all entailed sentences

Wumpus world requires the ability to representpartial and negated information, reason by cases, etc.

Resolution is sound and complete for propositional logic

Propositional logic lacks expressive powerB. Beckert: KI für IM – p.38