Propositional Logic - Introduction to Artificial Intelligence | CS 440, Study notes of Computer Science

Material Type: Notes; Professor: Draper; Class: Introduction to Artificial Intelligence; Subject: Computer Science; University: Colorado State University; Term: Fall 2008;

Typology: Study notes

Pre 2010

Uploaded on 03/18/2009

koofers-user-h72
koofers-user-h72 🇺🇸

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Propositional Logic
Propositional Logic
(continued)
(continued)
Lecture #12
Lecture #12
10/02/08
10/02/08
Announcements
Announcements
Programming assignment #1 was due at
Programming assignment #1 was due at
noon
noon
Writing assignment #2 (part 1) is due
Writing assignment #2 (part 1) is due
Tuesday, Oct. 7
Tuesday, Oct. 7th
th.
.
Possible midterm dates:
Possible midterm dates:
Tuesday, Oct. 14
Tuesday, Oct. 14h
h
Thursdayday
Thursdayday, Oct. 16
, Oct. 16th
th
Read
Read Chapter 8 for Tuesday
Chapter 8 for Tuesday
The
The Wumpus
Wumpus World
World The
The Wumpus
Wumpus World
World
Performance measure
Performance measure
gold: +1000, death:
gold: +1000, death: -
-1000
1000
-
-1 per step,
1 per step, -
-10 for using the arrow
10 for using the arrow
Environment
Environment
Squares adjacent to
Squares adjacent to wumpus
wumpus: smelly
: smelly
Squares adjacent to pit: breezy
Squares adjacent to pit: breezy
Glitter
Glitter iff
iff gold is in the same square
gold is in the same square
Shooting kills
Shooting kills wumpus
wumpus if you are facing it
if you are facing it
Shooting uses up the only arrow
Shooting uses up the only arrow
Grabbing picks up gold if in same square
Grabbing picks up gold if in same square
Square [1,1] is empty
Square [1,1] is empty
Sensors:
Sensors: Stench, Breeze, Glitter, Bump
Stench, Breeze, Glitter, Bump
Actuators:
Actuators: Left turn, Right turn, Forward, Grab,
Left turn, Right turn, Forward, Grab,
Release,Shoot
Release,Shoot
Wumpus
Wumpus Logic
Logic
Let
Let P
Px,y
x,y be the proposition that square (
be the proposition that square (x,y
x,y) has a
) has a
pit.
pit.
Note that there are exactly 16 of thes e distinct symbols
Note that there are exactly 16 of thes e distinct symbols
Let
Let W
Wx,y
x,y be the proposition that the
be the proposition that the wumpus
wumpus is in
is in
square (
square (x,y
x,y)
)
Again, 16 distinct symbols.
Again, 16 distinct symbols.
Let
Let B
Bx,y
x,y be the proposition that a breeze is felt in
be the proposition that a breeze is felt in
square (
square (x,y
x,y)
)
Let
Let S
Sx,y
x,y be the proposition that a stench is
be the proposition that a stench is
detected in square (
detected in square (x,y
x,y)
)
A system with a total of 64 propositional symbols
A system with a total of 64 propositional symbols
Wumpus
Wumpus Axioms
Axioms
¬
¬W
W1,1
1,1
The
The wumpus
wumpus is not in square 1,1
is not in square 1,1
¬
¬P
P1,1
1,1
Square 1,1 does not contain a pit
Square 1,1 does not contain a pit
(W
(W1,1
1,1 v W
v W1,2
1,2 v
v
v W
v W4,3
4,3 v W
v W4,4
4,4)
)
A
A wumpus
wumpus exists
exists
W
W1,1
1,1
(
(¬
¬W
W1,2
1,2 ^
^ ¬
¬W
W1,3
1,3 ^
^
^
^ ¬
¬W
W4,3
4,3 ^
^ ¬
¬W
W4,4
4,4)
)
If the
If the wumpus
wumpus is somewhere, its nowhere else
is somewhere, its nowhere else
There are 16 of these rules
There are 16 of these rules
pf3
pf4

Partial preview of the text

Download Propositional Logic - Introduction to Artificial Intelligence | CS 440 and more Study notes Computer Science in PDF only on Docsity!

Propositional Logic

Propositional Logic

(continued)(continued)

Lecture #12Lecture

Announcements

Announcements

Programming assignment #1 was due at Programming assignment #1 was due at

noonnoon

Writing assignment #2 (part 1) is due Writing assignment #2 (part 1) is due

Tuesday, Oct. 7Tuesday, Oct. 7

thth

Possible midterm dates: Possible midterm dates:

  • – Tuesday, Oct. 14Tuesday, Oct. 14

hh

  • – ThursdaydayThursdayday, Oct. 16, Oct. 16

thth

Read Chapter 8 for Tuesday ReadChapter 8 for Tuesday

The

The WumpusWumpus WorldWorld

The

The WumpusWumpus WorldWorld

Performance measurePerformance measure

  • – gold: +1000, death:gold: +1000, death: --1000 1000
  • – --1 per step,1 per step, --10 for using the arrow10 for using the arrow

EnvironmentEnvironment

  • Squares adjacent toSquares adjacent to wumpuswumpus: smelly: smelly
  • – Squares adjacent to pit: breezySquares adjacent to pit: breezy
  • – GlitterGlitter iffiff gold is in the same squaregold is in the same square
  • – Shooting killsShooting kills wumpuswumpus if you are facing itif you are facing it
  • – Shooting uses up the only arrowShooting uses up the only arrow
  • – Grabbing picks up gold if in same squareGrabbing picks up gold if in same square
  • – Square [1,1] is emptySquare [1,1] is empty

Sensors:

Sensors: Stench, Breeze, Glitter, BumpStench, Breeze, Glitter, Bump

Actuators:Actuators: Left turn, Right turn, Forward, Grab,Left turn, Right turn, Forward, Grab,

Release,ShootRelease,Shoot

Wumpus LogicWumpusLogic

LetLet PP x,yx,y

be the proposition that square (be the proposition that square (x,yx,y) has a) has a

pit.pit.

  • – Note that there are exactly 16 of these distinct symbolsNote that there are exactly 16 of these distinct symbols

Let

Let WW

x,y

x,y

be the proposition that the

be the proposition that the wumpuswumpus is inis in

square (

square (x,yx,y))

  • – Again, 16 distinct symbols.Again, 16 distinct symbols.

LetLet BB x,yx,y

be the proposition that a breeze is felt inbe the proposition that a breeze is felt in

square (square (x,yx,y))

Let

Let SS

x,y

x,y

be the proposition that a stench is

be the proposition that a stench is

detected in square (detected in square (x,yx,y))

A system with a total of 64 propositional symbolsA system with a total of 64 propositional symbols

WumpusWumpus AxiomsAxioms

¬ ¬WW

1,11,

  • TheThe wumpuswumpus is not in square 1,1is not in square 1,

¬ ¬PP

1,11,

  • – Square 1,1 does not contain a pitSquare 1,1 does not contain a pit

(W

(W

1,11,

v W

v W

1,21,

v

v …… v Wv W

4,34,

v W

v W

4,44,

  • – AA wumpuswumpus existsexists

W W

1,

1,

⇒⇒ ((¬¬WW

1,

1,

^^ ¬¬WW

1,

1,

^^ …… ^^ ¬¬WW

4,

4,

^^ ¬¬WW

4,

4,

  • If theIf the wumpuswumpus is somewhere, its nowhere elseis somewhere, its nowhere else
  • – There are 16 of these rulesThere are 16 of these rules……

Wumpus

Wumpus Axioms (II)Axioms (II)

S

S

2,22,

(W

(W

1,21,

v W

v W

3,23,

v W

v W

2,32,

v W

v W

2,12,

  • – If there is a stench, theIf there is a stench, the wumpuswumpus is in ais in a

neighboring cellneighboring cell

  • Once again, there are 16 of these rulesOnce again, there are 16 of these rules
  • – Boundary cases involve fewer disjunctionsBoundary cases involve fewer disjunctions

BB

2,22,

⇔⇔ (P(P

1,21,

v Pv P

3,23,

v Pv P

2,32,

v Pv P

2,12,

  • – If there is a breeze, a neighboring cell has aIf there is a breeze, a neighboring cell has a

pit

pit

  • – 16 rules and boundary cases16 rules and boundary cases……

WumpusWumpus Logic (II)Logic (II)

If sensors in square [1,1] detect neither

If sensors in square [1,1] detect neither

breeze nor smell, what do we know?

breeze nor smell, what do we know?

P

P

1,21,

Simplification

Simplification (

P

P

1,21,

^

^

P

P

2,12,

((¬¬PP

1,21,

^^ ¬¬ PP

2,12,

¬¬(P(P DeMorgansDeMorgans ))

1,21,

v Pv P

2,12,

¬ ¬PP

2,12,

((¬¬PP SimplificationSimplification

1,21,

^^ ¬¬ PP

2,12,

¬ ¬(P(P

1,21,

v Pv P

2,12,

ModusModus ))

Tollens

Tollens

¬¬BB

1,11,

B

B

1,11,

(P

(P

1,21,

v P

v P

2,12,

PrecedentPrecedent RuleRule ConsequentConsequent

Conjunctive Normal Form

Conjunctive Normal Form

A sentence is in CNF

A sentence is in CNF iffiff it is a conjunctionit is a conjunction

of disjunctions of propositions and negated

of disjunctions of propositions and negated

propositionspropositions

Example:

Example:

  • – (A v B v(A v B v ¬¬C) ^ (C) ^ (¬¬A v C) ^ BA v C) ^ B

Converting to CNF

Converting to CNF

Every sentence can be converted to

Every sentence can be converted to

CNF, by sequentially eliminating all otherCNF, by sequentially eliminating all other

symbols

symbols……

Replace

Replace α

α ⇔⇔ ββ with (

with ( α

α ⇒⇒ ββ )^(

)^(

β

β ⇒⇒ αα )

2.2. ReplaceReplace αα ⇒⇒ ββ with (with (¬¬ αα vv ββ))

3.3. MoveMove ¬¬ “inward“inward””

1.1. ReplaceReplace ¬¬((¬ α¬α) with) with αα

2.2. ReplaceReplace ¬¬((αα ^^ ββ) with () with (¬¬ αα vv ¬ β¬β))

Replace

Replace ¬

¬ (

( α

α v

v β

β ) with (

) with ( ¬

¬ αα ^

^ ¬

¬ ββ )

)

4.4. Replace (Replace (αα v (v (ββ ^^ γγ)) with ()) with (αα vv ββ)^()^(αα vv γγ))

Converting to CNF (II)Converting to CNF (II)

While converting expressions, note that

While converting expressions, note that

  • ((

(( α

α v

v β

β ) v

) v γ

γ ) is equivalent to

) is equivalent to (( α

α v

v β

β v

v γ

γ )

)

  • – ((((αα ^^ ββ) ^) ^ γγ) is equivalent to) is equivalent to ((αα ^^ ββ ^^ γγ))

Why does this algorithm work?Why does this algorithm work?

  • – BecauseBecause ⇒⇒ andand ⇔⇔ are eliminatedare eliminated
  • Because

Because ¬

¬ is always directly attached to simply

is always directly attached to simply

propositionspropositions

  • – Because what is left must be ^Because what is left must be ^’’s ands and vv’’ss, and the, and the

can be distributed over to makecan be distributed over to make CNFsCNFs

Converting to CNF (Example)Converting to CNF (Example)

Convert: (AConvert: (A⇒⇒B) v (BB) v (B⇔⇔C)C)

(A(A⇒⇒B) v ((BB) v ((B ⇒⇒C) ^ (CC) ^ (C ⇒⇒ B))B))

((¬¬A v B) v ((A v B) v ((¬¬B v C) ^ (B v C) ^ (¬¬C v B))C v B))

A v B) v (

A v B) v (

B v C)) ^ ((

B v C)) ^ ((

A v B) v (

A v B) v (

C v B))

C v B))

A v B v

A v B v

B v C) ^ (

B v C) ^ (

A v B v

A v B v

C)

C)

Question: are the first and last lines really

Question: are the first and last lines really

equivalent?

equivalent?

Example (cont.)

Example (cont.)

Now, apply resolution toNow, apply resolution to

(

( ¬

¬ A

A v B) ^ (v B) ^ ( ¬

¬ B v A) ^ (

B v A) ^ ( ¬

¬ A v C) ^ (B)

A v C) ^ (B) ^ (^ ( ¬

¬ C)

C)

  • – : (: (¬¬ A v C) ^ (A v C) ^(¬¬C)C) ├├ ((¬¬ A)A)

Repeat:Repeat:

(

( ¬

¬ B v A) ^

B v A) ^ (( ¬

¬ A)

A) ├

├ (

( ¬

¬ B

B )

)

Repeat:Repeat:

((¬¬ BB ) ^ (B)) ^ (B) ├├ {} : contradiction!{} : contradiction!

Example (III)

Example (III)

Or, alternatively, start with the first two Or, alternatively, start with the first two

clauses:clauses:

((¬¬ AA v B) ^ (v B) ^ (¬¬ B v A)B v A) ├├ (B) ^ ((B) ^ (¬¬ B)B)

(B) ^ ((B) ^ (¬¬ B)B) ├├ {}{}

What can resolution do?

What can resolution do?

It can determine whether any sentence

It can determine whether any sentence

can be proven from a set of axioms.

can be proven from a set of axioms.

  • – It isIt is completecomplete ..

It cannot enumerate the set of all entailed

It cannot enumerate the set of all entailed

sentences.sentences.

  • – You can enumerate such an (infinite) list byYou can enumerate such an (infinite) list by

enumerating all possible sentences andenumerating all possible sentences and

verifying each with resolution.

verifying each with resolution.