Transcript
Page 1: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

A knowledge-based agent

• A knowledge-based agent includes a knowledge base and an inference system.

• A knowledge base is a set of representations of facts of the world.

• Each individual representation is called a sentence. • The sentences are expressed in a knowledge

representation language. • The agent operates as follows:

1. It TELLs the knowledge base what it perceives. 2. It ASKs the knowledge base what action it should

perform. 3. It performs the chosen action.

Page 2: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Knowledge-BasedAgent Function

TELL: adds a sentence to the KBASK: queries the KB

Page 3: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Architecture of a knowledge-based agent

• Knowledge Level. – The most abstract level: describe agent by saying what it knows. – Example: A taxi agent might know that the Golden Gate Bridge

connects San Francisco with the Marin County.

• Logical Level. – The level at which the knowledge is encoded into sentences. – Example: Links(GoldenGateBridge, SanFrancisco,

MarinCounty).

• Implementation Level. – The physical representation of the sentences in the logical level. – Example: ‘(links goldengatebridge sanfrancisco marincounty)

Page 4: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

The Wumpus World environment

• The Wumpus computer game• The agent explores a cave consisting of rooms

connected by passageways. • Lurking somewhere in the cave is the Wumpus, a

beast that eats any agent that enters its room. • Some rooms contain bottomless pits that trap any

agent that wanders into the room. • Occasionally, there is a heap of gold in a room.• The goal is to collect the gold and exit the world

without being eaten

Page 5: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

A typical Wumpus world

• The agent always starts in the field [1,1].

• The task of the agent is to find the gold, return to the field [1,1] and climb out of the cave.

Page 6: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Agent in a Wumpus world: Percepts

• The agent perceives

– a stench in the square containing the wumpus and in the adjacent squares (not diagonally)

– a breeze in the squares adjacent to a pit

– a glitter in the square where the gold is– a bump, if it walks into a wall

– a woeful scream everywhere in the cave, if the wumpus is killed• The percepts will be given as a five-symbol list: If there is a stench,

and a breeze, but no glitter, no bump, and no scream, the percept is

[Stench, Breeze, None, None, None] • The agent can not perceive its own location.

Page 7: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Wumpus actions• go forward • turn right 90 degrees• turn left 90 degrees• grab means pick up an object that is in the same square as the

agent• shoot means fire an arrow in a straight line in the direction the

agent is looking. The arrow continues until it either hits and kills the wumpus or hits the wall. The agent has only one arrow. Only the first shot has any effect.

• climb is used to leave the cave. Only effective in start field. • die, if the agent enters a square with a pit or a live wumpus. (No

take-backs!)

Page 8: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Wumpus goal

The agent’s goal is to find the gold and bring it back to the start as quickly as possible, without getting killed. – 1000 points reward for climbing out of

the cave with the gold– 1 point deducted for every action

taken– 10000 points penalty for getting killed

Page 9: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

The Wumpus agent’s first step

Page 10: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Later

Page 11: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Representation, reasoning, and logic

• The object of knowledge representation is to express knowledge in a computer-tractable form, so that agents can perform well.

• A knowledge representation language is defined by: – its syntax, which defines all possible sequences of

symbols that constitute sentences of the language. • Examples: Sentences in a book, bit patterns in computer memory.

– its semantics, which determines the facts in the world to which the sentences refer. • Each sentence makes a claim about the world. • An agent is said to believe a sentence about the world.

Page 12: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Logic as a KR language

Propositional Logic

First Order

Higher Order

Modal

FuzzyLogic

Multi-valuedLogic

ProbabilisticLogic

Temporal Non-monotonicLogic

Page 13: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Logic in general

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

• Syntax defines the sentences in the language• Semantics define the "meaning" of sentences;

– i.e., define truth of a sentence in a world

• E.g., the language of arithmetic– x+2 ≥ y is a sentence; x2+y > {} is not a sentence– x+2 ≥ y is true iff the number x+2 is no less than the number y– x+2 ≥ y is true in a world where x = 7, y = 1– x+2 ≥ y is false in a world where x = 0, y = 6

––

–•

–••

Page 14: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Propositional logic: Syntax

• Propositional logic is the simplest logic – illustrates basic ideas

• The proposition symbols P1, P2 etc are sentences

– If S is a sentence, S is a sentence (negation)– If S1 and S2 are sentences, S1 S2 is a sentence (conjunction)– If S1 and S2 are sentences, S1 S2 is a sentence (disjunction)– If S1 and S2 are sentences, S1 S2 is a sentence (implication)– If S1 and S2 are sentences, S1 S2 is a sentence (biconditional)

––––

Page 15: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Propositional logic: SemanticsEach model specifies true/false for each proposition symbol

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

false true false

With these symbols, 8 possible models, can be enumerated automatically.Rules for evaluating truth with respect to a model m:

S is true iff S is false S1 S2 is true iff S1 is true and S2 is trueS1 S2 is true iff S1is true or S2 is trueS1 S2 is true iff S1 is false or S2 is true i.e., is false iff S1 is true and S2 is falseS1 S2 is true iff S1S2 is true andS2S1 is true

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

P1,2 (P2,2 P3,1) = true (true false) = true true = true

Page 16: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

The connection between sentences and facts

Semantics maps sentences in logic to facts in the world.The property of one fact following from another is mirroredby the property of one sentence being entailed by another.

Page 17: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

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)• improved backtracking, e.g., Davis--Putnam-Logemann-Loveland

(DPLL)• heuristic search in model space (sound but incomplete)

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

••

•»

•–

»

Page 18: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Inference

• Inference is the process of checking correctness by procedures that preserve truth

• KB ├i α means – sentence α can be derived from KB by

procedure i• Soundness: i is sound means

– whenever KB ├i α, it is also true that KB╞ α

• Completeness: i is complete means– whenever KB╞ α, it is also true that KB ├i α

–––

Page 19: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Inference: the cheat sheet• We will define a logic expressive enough to say many

things of interest– Known as first-order logic

• For which there is an inference method which is– Sound – Complete – That is, the method will answer any question whose answer

follows from what is known by the KB

• Sounds too good to be true?– The fly in the soup:

• The method might go on forever• That is, it can’t tell us for sure if the question has a false answer• In fact, it’s possible to prove that no such method could exist

• But first, we define a weaker logic– Propositional Logic

Page 20: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

ValidityA sentence is valid means

it is true in all models,True, A A, A A, (A (A B)) B

Validity is connected with inference in a very useful way:KB ╞ α if and only if (KB α) is validThe Deduction Theorem

Page 21: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

SatisfiabilityA sentence is satisfiable means

it is true in some modelA B, C

A sentence is unsatisfiable means it is true in no models

AA

Satisfiability is also connected to inference :KB ╞ α if and only if (KB α) is unsatisfiable

Page 22: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Propositional logic: Syntax

• Propositional logic is the simplest logic– The proposition symbols P1, P2 etc are sentences– If S is a sentence, (S) is also (negation)– If S1 and S2 are sentences, (S1 S)) is also (conjunction)– If S1 and S2 are sentences, (S1 S2) is also (disjunction)– If S1 and S2 are sentences, S1 S2) is also (implication)– If S1 and S2 are sentences, S1 S2) is also

(biconditional)

• Since it often doesn’t matter, in many cases we will leave out the brackets– In digital logic, you might have seen ~ for , . for , + for

–––––

Page 23: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Propositional logic: Semantics

A model specifies true/false for each proposition symbolE.g. P1,2 P2,2 P3,1

false true falseWith these symbols, 8 possible models, can be enumerated automatically.Rules for evaluating truth with respect to a model m:

S is true iff S is false S1 S2 is true iff S1 is true and S2 is trueS1 S2 is true iff S1is true or S2 is trueS1 S2 is true iff S1 is false or S2 is true i.e., is false iff S1 is true and S2 is falseS1 S2 is true iff S1S2 is true andS2S1 is true

A simple recursive process evaluates any sentence, e.g.P1,2 (P2,2 P3,1) = true (true false) = true true = true

Page 24: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Ontology and epistemology

• Ontology is the study of what there is, an inventory of what exists. An ontological commitment is a commitment to an existence claim.• Epistemology is major branch of philosophy that concerns the forms, nature, and preconditions of knowledge.

Page 25: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Truth tables for connectives

Page 26: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Example

• ((P v H)^ H’)=> P

P H P v H (P v H)^H’ ((P v H)^H’) => p

F F F F T

F T T F T

T F T T T

T T T F T

Page 27: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

No independent access to the world

• The reasoning agent often gets its knowledge about the facts of the world as a sequence of logical sentences and must draw conclusions only from them without independent access to the world.

• Thus it is very important that the agent’s reasoning is sound!

Page 28: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Models

Page 29: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Inference Rules• Inference rules allow us to deduce new true sentences from

previous ones. There are many possible sets, the set below are taken under fair dealing use from http://en.wikipedia.org/wiki/Propositional_logic

• Double negative elimination– From the sentence ¬ ¬ φ, we may infer φ

• Conjunction introduction– From any sentences φ and ψ, we may infer ( φ ∧ ψ ).

• Conjunction elimination– From any sentence ( φ ∧ ψ ), we may infer φ and ψ

• Disjunction introduction– From any sentence φ, we may infer (φ ∨ ψ) and (ψ ∨ φ), where ψ

is any sentence.

Page 30: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Inference Rules• Disjunction elimination

– From sentences ( φ ∨ ψ ), ( φ χ ), and ( ψ χ ), we may infer χ.

• Biconditional introduction– From sentences ( φ ψ ) and ( ψ φ ), we may infer ( φ ψ ).

• Biconditional elimination– From the sentence ( φ ψ ), we may infer ( φ ψ ) and ( ψ

φ ).

• Modus ponens• From sentences φ and ( φ ψ ), we may infer ψ.• Conditional proof

– If ψ can be derived by assuming φ, we can infer ( φ ψ ).

• Reductio ad absurdum– If we can derive both ψ and ¬ ψ by assuming φ, we may infer ¬ φ.

Page 31: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

a b r a v b ~b v r a v r

F

F

F

F

T

T

T

T

F

F

T

T

F

F

T

T

F

T

F

T

F

T

F

T

F

F

T

T

T

T

T

T

T

T

F

T

T

T

F

T

F

T

F

T

T

T

T

T

Page 32: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Properties of our Inference Rules• Good

– Sound• We can’t derive invalid sentences

– Complete• We will always be able to derive valid sentences

– Readily used by people• People can readily use these rules to derive proofs

– People are good at choosing the right rules to use

• Not so good– Not so effective for automated use

• It’s not easy to get machines to choose the right rules to make a proof

Page 33: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

SAT is NP-complete

(1) SAT is an NP algorithm.

(2) SAT is NP-hard:– Every NP algorithm can be transformed in

polynomial time to SAT [Horowitz 1998] such that SAT is satisfiable if and only if the answer for the original NP problem is “YES”.

– That is, every NP problem SAT .

• By (1) and (2), SAT is NP-complete.

Page 34: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Proof of NP-Completeness

• To show that A is NP-complete

(I) Prove that A is an NP problem.

(II) Prove that B NPC, B A.

A NPC

• Why ?

Page 35: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Models and Entailmentin the Wumpus World

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

Consider possible models for KB assuming only pits

3 Boolean choices 8 possible models

Page 36: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

Propositional Logic (PL)

• PL: logic that consists of proposition symbols and connectives

• Each symbol is either true or false• Syntax: describes how the symbols and

connectives form sentences• Semantics: describes rules for determining

the truth of a sentence wrt to a model

Page 37: A knowledge-based agent A knowledge-based agent includes a knowledge base and an inference system. A knowledge base is a set of representations of facts

• Function propositional-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))• For each action in the list of possible actions do• if ask(KB.make-agent-query(t,action)) then• tt +1• Return action• end


Top Related