[email protected] CSM6120 Introduction to Intelligent Systems Knowledge representation.

38
[email protected] CSM6120 Introduction to Intelligent Systems Knowledge representation

Transcript of [email protected] CSM6120 Introduction to Intelligent Systems Knowledge representation.

Page 1: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

[email protected]

CSM6120Introduction to Intelligent

SystemsKnowledge representation

Page 2: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

What is knowledge?

Page 3: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Representation AI agents deal with knowledge (data)

Facts (believe & observe knowledge) Procedures (“how to” knowledge) Meaning (relate & define knowledge)

Right representation is crucial Early realisation in AI Wrong choice can lead to project failure Active research area

Page 4: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Choosing a representation For certain problem solving techniques

‘Best’ representation already known Often a requirement of the technique Or a requirement of the programming language (e.g.

Prolog)

Examples First order theorem proving… first order logic Inductive logic programming… logic programs Neural networks learning… neural networks

Some general representation schemes Suitable for many different (and new) AI applications

Page 5: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Knowledge representation Representation of

Declarative knowledge (what, objects, structure) Procedural knowledge (how, actions,

performance)

Representation formalisms Declarative knowledge

Frames, Semantic Networks, Inheritance Hierarchies, Schemata,...

Procedural knowledge Algorithms, Procedures, Plans, Rules,...

Page 6: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

What is a Logic? A language with concrete rules

No ambiguity in representation (may be other errors!) Allows unambiguous communication and processing Very unlike natural languages e.g. English

Many ways to translate between languages A statement can be represented in different logics And perhaps differently in same logic

Not to be confused with logical reasoning Logics are languages, reasoning is a process (may use

logic)

Page 7: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

What is a Logic? Knowledge can be represented using first-

order predicate logic More on this later in the module

Page 8: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Non-logical representations Logic representations have restrictions and can

be hard to work with Many AI researchers searched for better

representations

Non-logical Semantic networks Conceptual graphs Frames Scripts Production rules ...

Page 9: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

What we’ve ignored Objects in the world tend to be related to each

other Classes, superclasses & subclasses Part / whole hierarchies Properties are inherited across relationships

The state of the world can change over time Explicit representation of time Frame problem Non-monotonic reasoning

We must reason without complete knowledgeClosed world assumption

Not all knowledge is “black & white” (later modules on CSM…) Uncertainty Statistics, fuzzy logic

Page 10: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Classes “I want to buy a basketball”

I want to buy BB27341 (NO) I want to buy an object that is a member of the basketball

class (YES)

Objects organized into a hierarchy by class BB27341 basketballs basketballs balls

Facts (objects) & rules (classes) All balls are round All basketballs are <size> in diameter BB27341 is red, white and blue BB27341 is a basketball (Therefore BB27341 is round and <size> in diameter)

Page 11: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Inheritance If a property is true of a class, it is true of all

subclasses of that class

If a property is true of a class, it is true of all objects that are members of that class

(If a property is true of a class, it is true of all objects that are members of subclasses of that class)

There are exceptions (to be dealt with later…)

Page 12: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Part/whole inheritance A cow has 4 legs

Each leg is part of the cow The cow is in the field

All of the cow’s parts are also in the field The cow is (entirely) brown

All of the cow’s parts are brown The cow is happy

All of the cow’s parts are happy (?)

Note: some properties are inherited by parts, others are not. This is generally made explicit by rules, such as part-of(x,y) and location(y,z) -> location(x,z)

Page 13: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Defaults and exceptions Exception for a single object

Set a property of the object to the (exception) value

Default for a class Set a property of the class to the (default) value If there are multiple default values, the one “closest” to

the object wins

Page 14: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Example All birds can fly Birds with broken wings are birds, but cannot fly Penguins are birds, but they cannot fly Magical penguins are penguins that can fly

Who can fly? Tweety is a bird Peter is a penguin Penelope is a magical penguin

Note that beliefs can be changed as new information comes in that changes the classification of an object

Page 15: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Semantic networks Semantic networks are essentially a

generalization of inheritance hierarchies Each node is an object or class

Each link is a relationship is-a (the usual subclass or element relationship) has-part or part-of Any other relationship that makes sense in context

Note: semantic networks pre-dated OOP

Inheritance: follow one member-of link, as many subclass or other links as necessary

Page 16: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Graphical representation Graphs easy to store in a computer

To be of any use must impose a formalism

Jason is 15, Bryan is 40, Arthur is 70, Jim is 74 How old is Julia?

Page 17: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Semantic networks

Because the syntax is the same, we can guess that Julia’s age is similar to Bryan’s

Page 18: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Knowledge represented as a network or graph

subclasssubclass

has-part

subclass

instance

likes

size

Animal

Reptile

Elephant

Nellie

Mammal

apples

large

head

Africalives-in

Semantic networks

Page 19: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Semantic networks By traversing network we can find:

That Nellie has a head (by inheritance) That certain concepts related in certain ways (e.g., apples

and elephants)

But: meaning of semantic networks not always well defined Are all Elephants large, or just typical elephants? Do all Elephants live in the “same” Africa? Do all animals have the same head?

For machine processing these things must be defined

Page 20: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Frames Devised by Marvin Minsky, 1974

Incorporates certain valuable human thinking characteristics: Expectations, assumptions, stereotypes.

Exceptions. Fuzzy boundaries between classes

The essence of this form of knowledge representation is typicality, with exceptions, rather than definition

Page 21: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Frames Frames allow more convenient “packaging” of

facts about an object

We use the terms “slots” and “slot values”

mammal: subclass: animal

elephant: subclass: mammal size: large has-part: trunk

Nellie: instance: elephant likes: apples

Page 22: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Frames Frames often allowed you to say which things

were just typical of a class, and which were definitional, so couldn’t be overridden

Frames also allow multiple inheritance (Nellie is an Elephant and is a circus animal)

Elephant: subclass: mammal has-part: trunk * colour: grey * size: large

Page 23: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Frame representations Semantic networks where nodes have

structure Frame with a number of slots (age, height, ...) Each slot stores specific item of information

When agent faces a new situation Slots can be filled in (value may be another frame) Filling in may trigger actions May trigger retrieval of other frames

Inheritance of properties between frames Very similar to objects in OOP

Page 24: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Example: Frame representation

Page 25: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Flexibility in frames Slots in a frame can contain

Information for choosing a frame in a situation Relationships between this and other frames Procedures to carry out after various slots filled Default information to use where input is missing Blank slots: left blank unless required for a task Other frames, which gives a hierarchy

Can also be expressed in first order logic

Page 26: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

How frames are organised In the higher levels of the frame hierarchy, typical

knowledge about the class is stored The value in a slot may be a range or a condition

In the lower levels, the value in a slot may be a specific value, to overwrite the value which would otherwise be inherited from a higher frame

Note that a frames system may allow multiple inheritance but, if it does so, it must make provision for cases when inherited values conflict...

Page 27: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Multiple inheritance and views Multiple inheritance

Sub-concept inherits descriptions from several superconcepts

Possibly conflicting information ( = ambiguity) Skeptical reasoners: “don’t know” (no conclusion) Credulous reasoners: “whatever” (several conclusions)

Views Description of concept from different viewpoints Inheritance of multiple, complementing descriptions

e.g. view computer as machine or as equipment

Page 28: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Multiple inheritance - views

Page 29: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Multiple inheritance - ambiguity

Personsubclass

non-pacifist

Nixon

RepublicanQuakerpacifist

subclass

instanceinstance

Page 30: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Other varieties of structured object Knowledge representation researchers -

particularly Roger Schank and his associates - devised some interesting variations on the theme of structured objects

In particular, they invented the idea of scripts (1973) A script is a description of a class of events in terms of

contexts, participants, and sub-events

Page 31: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Scripts Rather similar to frames: uses inheritance and

slots; describes stereotypical knowledge (i.e. if the system isn't told some detail of what's going

on, it assumes the "default" information is true) but concerned with events

These are somewhat out of the mainstream of expert systems work More a development of natural-language-processing

research

Page 32: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Scripts Why represent knowledge in this way?

Because real-world events follow stereotyped patterns Human beings use previous experience to understand

verbal accounts; computers can use scripts instead

Because people, when relating events, leave large amounts of assumed detail out of their accounts People don't find it easy to converse with a system that

can't fill in missing conversational detail

Page 33: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Non-monotonic logic Once true (or false) does not mean always true (or

false)

As information arrives, truth values can change (Penelope is a bird, penguin, magic penguin)

Implementations Circumscription

Bird(x) and not abnormal(x) -> flies(x) We can assume not abnormal(x) unless we know abnormal(x)

Default logic “x is true given x does not conflict with anything we already

know”

Page 34: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Truth maintenance systems These systems allow truth values to be changed

during reasoning (belief revision)

When we retract a fact, we must also retract any other fact that was derived from it Penelope is a bird (can fly) Penelope is a penguin (cannot fly) Penelope is magical (can fly) Retract (Penelope is magical) (cannot fly) Retract (Penelope is a penguin) (can fly)

Page 35: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Types of TMS Justification-based TMS

For each fact, track its justification (facts and rules from which it was derived)

When a fact is retracted, retract all facts that have justifications leading back to that fact, unless they have independent justifications

Assumption-based TMS Represent all possible states simultaneously For each fact, use list of assumptions that make that fact

true; each world state is a set of assumptions When a fact is retracted, change state sets

Page 36: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Rule-based systems

Inference Engine

Knowledge Base

Rule: IF-THEN

Database

Fact

Explanation Facilities

User Interface

User

Page 37: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Structured objects: final comments At best, structured objects provide data &

control structures which are more flexible than those in conventional languages, and so more suited to simulating human reasoning

However, if we just want an AI system to act rationally (rather than think/act humanly), then logic might be better...

Page 38: Rkj@aber.ac.uk CSM6120 Introduction to Intelligent Systems Knowledge representation.

Resources A good introduction to the area:

http://www.cse.buffalo.edu/~shapiro/Papers/kr.pdf