ARTIFICIAL INTELLIGENCE Russell & Norvig Chapter 7. Logical - - PowerPoint PPT Presentation

artificial intelligence
SMART_READER_LITE
LIVE PREVIEW

ARTIFICIAL INTELLIGENCE Russell & Norvig Chapter 7. Logical - - PowerPoint PPT Presentation

ARTIFICIAL INTELLIGENCE Russell & Norvig Chapter 7. Logical Agents Knowledge bases Knowledge base = set of sentences in a formal language Declarative approach to building an agent (or other system): Tell it what it needs to know


slide-1
SLIDE 1

ARTIFICIAL INTELLIGENCE

Russell & Norvig Chapter 7. Logical Agents

slide-2
SLIDE 2

Knowledge bases

  • Knowledge base = set of sentences in a formal language
  • Declarative approach to building an agent (or other system):
  • Tell it what it needs to know
  • Then it can Ask itself what to do - answers should follow from the KB
  • Tell it what action the agent will take
  • Agents can be viewed at the 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
slide-3
SLIDE 3

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
slide-4
SLIDE 4

Wumpus World PEAS description

  • Performance measure
  • gold +1000, death -1000
  • 1 per step, -10 for using the arrow
  • Environment
  • 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: Stench, Breeze, Glitter, Bump, Scream
  • Actuators: Left turn, Right turn, Forward, Grab, Release, Shoot
slide-5
SLIDE 5

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

slide-6
SLIDE 6

Exploring a wumpus world

slide-7
SLIDE 7

Exploring a wumpus world

slide-8
SLIDE 8

Exploring a wumpus world

slide-9
SLIDE 9

Exploring a wumpus world

slide-10
SLIDE 10

Exploring a wumpus world

slide-11
SLIDE 11

Exploring a wumpus world

slide-12
SLIDE 12

Exploring a wumpus world

slide-13
SLIDE 13

Exploring a wumpus world

slide-14
SLIDE 14

What is logic?

  • Logic is a formal system for manipulating facts so that true

conclusions may be drawn

  • Syntax: rules for constructing valid sentences
  • E.g., x + 2 ≥ y is a valid arithmetic sentence, ≥x2y + is not
  • Semantics: “meaning” of sentences, or relationship between logical

sentences and the real world

  • Specifically, semantics defines truth of sentences
  • E.g., x + 2 ≥ y is true in a world where x = 5 and y = 7
slide-15
SLIDE 15

Propositional logic: Syntax

  • Propositional logic is the simplest logic – illustrates basic ideas
  • The proposition symbols P1, P2, True, False, 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)
slide-16
SLIDE 16

Propositional logic: Semantics

  • A model specifies the true/false status of each proposition

symbol in the knowledge base

  • E.g., P is true, Q is true, R is false
  • With three symbols, there are 8 possible models, and they can be

enumerated exhaustively

  • Rules for evaluating truth with respect to a model:

¬P is true iff P is false P ∧ Q is true iff P is true and Q is true P ∨ Q is true iff P is true or Q is true P ⇒ Q is true iff P is false or Q is true P ⇔ Q is true iff P ⇒ Q is true and Q ⇒ P is true

slide-17
SLIDE 17

Truth tables

  • A truth table specifies the truth value of a

composite sentence for each possible assignments of truth values to its atoms

  • The truth value of a more complex sentence can

be evaluated recursively or compositionally

slide-18
SLIDE 18

Logical equivalence

  • Two sentences are logically equivalent} iff true in same

models: α ≡ ß iff α╞ β and β╞ α

slide-19
SLIDE 19

Wumpus world sentences

Let Pi,j be true if there is a pit in [i, j]. Let Bi,j be true if there is a breeze in [i, j].

¬ P1,1 ¬B1,1 B2,1

  • "Pits cause breezes in adjacent squares"

B1,1 ⇔

(P1,2 ∨ P2,1)

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

slide-20
SLIDE 20

Truth tables for inference

slide-21
SLIDE 21

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

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

slide-22
SLIDE 22

Entailment

  • Entailment means that a sentence follows from

the premises contained in the knowledge base: KB ╞ α

  • Knowledge base KB entails sentence α if and only

if α is true in all models where KB is true

  • E.g., x = 0 entails x * y = 0
  • KB ╞ α iff (KB ⇒ α) is valid
  • KB ╞ α iff (KB ∧¬α) is unsatisfiable
slide-23
SLIDE 23

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.

slide-24
SLIDE 24

Inference

  • How can we check whether a sentence α is entailed by KB?
  • How about we enumerate all possible models of the KB (truth

assignments of all its symbols), and check that α is true in every model in which KB is true?

  • Is this sound?
  • Is this complete?
  • Problem: if KB contains n symbols, the truth table will be of

size 2n

  • Better idea: use inference rules, or sound procedures to

generate new sentences or conclusions given the premises in the KB

slide-25
SLIDE 25

Proof methods

  • Proof methods divide into (roughly) two kinds:
  • Application of inference rules
  • 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 algorithm

  • Typically require transformation of sentences into a normal form
  • Model checking
  • truth table enumeration (always exponential in n)
  • heuristic search in model space (sound but incomplete)

e.g., min-conflicts-like hill-climbing algorithms

slide-26
SLIDE 26

Inference rules

  • Modus Ponens
  • And-elimination

β α β α , ⇒

α β α ∧

premises conclusion

slide-27
SLIDE 27

Inference rules

  • And-introduction
  • Or-introduction

β α α ∨ β α β α ∧ ,

slide-28
SLIDE 28

Inference rules

  • Double negative elimination
  • Unit resolution

α β β α ¬ ∨ , α α ¬¬

slide-29
SLIDE 29

Resolution

  • Example:

α: “The weather is dry” β: “The weather is rainy” γ: “I carry an umbrella”

γ α γ β β α ∨ ∨ ¬ ∨ , γ α γ β β α ∨ ⇒ ∨ ,

  • r
slide-30
SLIDE 30

Resolution is complete

  • To prove KB╞ α, assume KB ∧ ¬ α and derive a contradiction
  • Rewrite KB ∧ ¬ α as a conjunction of clauses,
  • r disjunctions of literals
  • Conjunctive normal form (CNF)
  • Keep applying resolution to clauses that contain complementary

literals and adding resulting clauses to the list

  • If there are no new clauses to be added, then KB does not

entail α

  • If two clauses resolve to form an empty clause, we have a

contradiction and KB╞ α

γ α γ β β α ∨ ∨ ¬ ∨ ,

slide-31
SLIDE 31

Complexity of inference

  • Propositional inference is co-NP-complete
  • Complement of the SAT problem: α ╞ β if and only if the sentence

α ∧ ¬ β is unsatisfiable

  • Every known inference algorithm has worst-case exponential running

time

  • Efficient inference possible for restricted cases