32
Lecture 6-2 CS250: Intro to AI/Lisp Declaring Your Knowledge Lecture 6-2 November 4 th , 1999 CS250/350

Declaring Your Knowledge

Embed Size (px)

DESCRIPTION

Declaring Your Knowledge. Lecture 6-2 November 4 th , 1999 CS250/350. Keep your eye on the prize. Why did we study heuristic search? How else can we incorporate knowledge. Designing an Interplanetary Explorer. Goals for the explorer Actions we can take Situations that might arise. - PowerPoint PPT Presentation

Citation preview

Page 1: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Declaring Your Knowledge

Lecture 6-2

November 4th, 1999

CS250/350

Page 2: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Keep your eye on the prize

• Why did we study heuristic search?

• How else can we incorporate knowledge

Page 3: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Designing an Interplanetary Explorer

• Goals for the explorer

• Actions we can take

• Situations that might arise

Page 4: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Telling Your Computer about the World

• What you know

• How to go from what you know to what you don’t know

• Will Rogers

Page 5: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Knowledge Base

Knowledge base:Database :: Knowledge:Data

• KB stores what the computer knows about the world

• Knowledge representation language– How we encode knowledge about the

world– Each bit of knowledge is a sentence

Page 6: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

OuRover

• Goals– Gather core samples– Gather rocks– Video sequence of interesting places

• Actions– Drill to depth d– Move forward, backward– Rotate r degrees– Transmit audio/video

Page 7: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Getting through to your computer

• KB Interaction– Tell: Add new sentences to the KB– Ask: Query what’s known (or what follows

from what is known)

• Inference procedure goes from what’s unknown to what’s known

Page 8: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

How true is it?

• Valid– Necessarily true under all interpretations in

all worlds– Tautology

A A

• Satisfiable– True sometimes

A B

Page 9: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Knowledge-Based Agents

Agents perceive the world around them Perceptions are recorded in the KB Actions are chosen based on the KB Results of actions are recorded

Page 10: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Levels of Agents

• Knowledge level– What an agent knows– Planetary core samples must be taken at

least 100mm below the surface

• Logical level– Knowledge is encoded at this level– MinDepth(CoreSample,100)

• Implementation level– Inside the machine

Page 11: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Building Knowledge Agents

• Lean on the inference mechanism– Tell agent what it needs to know

• Declarative– Declare the state of the world, and let ‘er

rip

• Adding learning– Reacting to percepts

Page 12: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Separate Domain-Specific from the General

Page 13: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

A logic for every season

Increasing complexity, expressive power

Propositional Higher-orderFirst-order

Page 14: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Is this your world?

• if KB1 = then (KB1 KB2) =

Page 15: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Propositional Logic

• Syntax– Propositions– Connectives (, , , , )– ()’s

• Semantics– Implication causation– “A false proposition implies any proposition”

Page 16: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Jumping to propositional conclusions

• How do we reason from what we know to what we don’t?– Inference rules– In propositional logic:

• Modus ponens• And-elimination• And introduction• Double-negation elimination• Unit resolution• Resolution

Page 17: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Horn clauses

• Restricted form:P1 P2 P3 ... Pn Q

• Why is this an advantage?

Page 18: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Wumpus World

Page 19: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Specifying the Wumpus World

• Percepts?

• Actions?

• Goals?

Page 20: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Describing the Wumpus World

• Is the world…– Deterministic– Fully accessible– Static– Discrete

Page 21: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

One Environment is Easy

• If we know the environment well, can engineer it

• Range of environments?

Page 22: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Exploring the world

Perceive: [None, None, None, None, None]

Perception: Stench, Breeze, Glitter, Bump, Scream

Page 23: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Move Forward to 2,1

Page 24: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Perception after One Move

Stench: None

Breeze: Yes

Glitter: None

Bump: None

Scream: None

Page 25: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

What Does the World Look Like?

Page 26: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Knowledge Representation

• Not just computer readable…

…computer reasonable as well

• Syntax - Rules for building expressions

• Semantics - Relationship between facts in the world and sentences

• Examples?

Page 27: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Entailment

• What follows from what

• Entailment is relationship among sentences– KB entails a

• “Follows” is a relationship among facts in the world

• Inference procedures that generate only entailed sentences is sound

Page 28: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Logical Commitment

Page 29: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

;;;; Main Functions on KBs: Tell, Retract, Ask-Each, ;;;; Ask, Ask-Pattern[s]

;;; First we define a very simple kind of knowledge base,;;; literal-kb, that just stores a list of literal sentences.

(defstructure literal-kb "A knowledge base that just stores a set of literal sentences." (sentences '()))

Tell-Ask.lisp I

Page 30: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

;;; There are three generic functions that operate on;;; knowledge bases, and that must be defined as methods;;; for each type of knowledge base: TELL, RETRACT, and;;; ASK-EACH. Here we show the implementation for literal-kb;;;; elsewhere you'll see implementations for propositional,;;; Horn, and FOL KBs.

(defmethod tell ((kb literal-kb) sentence) "Add the sentence to the knowledge base." (pushnew sentence (literal-kb-sentences kb) :test #'equal))

(defmethod retract ((kb literal-kb) sentence) "Remove the sentence from the knowledge base." (deletef sentence (literal-kb-sentences kb) :test #'equal))

(defmethod ask-each ((kb literal-kb) query fn) "For each proof of query, call fn on the substitution that the proof ends up with." (declare (special +no-bindings+)) (for each s in (literal-kb-sentences kb) do (when (equal s query) (funcall fn +no-bindings+))))

Tell-Ask.lisp II

Page 31: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

;;; There are three other ASK functions, defined below,;;; that are defined in terms of ASK-EACH. These are ;;; defined once and for all here (not for each kind ;;; of KB)."

(defun ask (kb query) "Ask if query sentence is true; return t or nil." (ask-each kb (logic query) #'(lambda (s) (declare (ignore s)) (RETURN-FROM ASK t))))

;;; Omitted pattern-matching ASK’s

Tell-Ask.lisp III

Page 32: Declaring Your Knowledge

Lecture 6-2 CS250: Intro to AI/Lisp

Propositional logic: Straw man for the ages

• “Don’t take a core sample if you’re not on a stable surface”

• How hard is it to compute with propositional logic