33
© C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

Embed Size (px)

Citation preview

Page 1: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 1

COMP 4200: Expert SystemsCOMP 4200:

Expert Systems

Dr. Christel Kemke

Department of Computer Science

University of Manitoba

Page 2: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 2

OverviewOverview

Knowledge Representation for XPS Associative Nets and Frame Systems

(Jackson, Chapter 6)

Object-oriented Programming(Jackson, Chapter 7)

Page 3: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 3

Knowledge Representation 1 Knowledge Representation 1

Representation of • declarative knowledge (what, objects, structure)• procedural knowledge (how, actions, performance)

Representation Formalisms for• declarative knowledge

Frames, Semantic Nets, Inheritance Hierarchies, Schemata,...

• procedural knowledge

Algorithms, Procedures, Plans, Rules,...

Page 4: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 4

Knowledge Representation 2 Knowledge Representation 2 Representation of declarative knowledge: descriptions of objects, concepts:

relations between them e.g. has-parts, fatherfeatures e.g. number-of-legs, age

mechanisms to work with this knowledge:store, retrieve information (accessing KB)

e.g. TELL (KB1, IS-A (square,polygon))

KB1 is a knowledge base; in KB1 a square is a sub-concept or sub-class of the polygon-concept/class; TELL asserts this.

reason about objects (inferencing)if square(X) then polygon(X)if square(X) then number-of-sides (X)=4

If something is a square, it is also a polygon.A square thing has 4 sides.

Page 5: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 5

Graphs as Representations I: Nodes, Links, and what they represent

Graphs as Representations I: Nodes, Links, and what they represent

Semantic Networks (Quilian 1968)

nodes represent concepts, objects, eventse.g. person, John, restaurant

links (arcs) represent any kind of relation or association between concepts, objects, events

e.g. IS-A, owns, lives-at, name

This allows the representation of all kinds of semantic expressions BUT the semantics is not clearly defined (Woods 1975) -> epistemological confusion.

Page 6: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 6

Causal, Temporal, and Inheritance Networks

Causal, Temporal, and Inheritance Networks

Causal Networks (Jackson, Fig. 6.2, see next slide)nodes represent concepts, objects, eventslinks represent causal relationship between these

concepts, objects, eventsTemporal Networks

nodes represent eventslinks represent temporal relationship between events,

like ‘before’, ‘after’,...

Inheritance Networks (Terminologies, Taxonomies)nodes represent conceptslinks represent class-/subclass-relationship IS-A: superclass

– subclass or super-concept / sub-concept

Page 7: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 7

Causal Network – Example (Jackson, Fig. 6.2)

Causal Network – Example (Jackson, Fig. 6.2)

Page 8: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 8

Classification Hierarchy (Jackson, Fig. 6.3)

Classification Hierarchy (Jackson, Fig. 6.3)

Page 9: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 9

Graphs as Representations II: Nodes, Links, and what they represent

Graphs as Representations II: Nodes, Links, and what they represent

Semantics of Knowledge Representation Languages:

• formal semantics e.g. Predicate Logic Interpretation, derive meaning of complex expressions based on meaning of atomic expressions plus construction mechanism

• use / reasoning e.g. Spreading Activation positive or negative association between concepts; see Neural Networks

Page 10: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 10

Inheritance NetworksInheritance Networks

Inheritance Networks (Terminologies, Taxonomies)

nodes represent concepts (events, objects, actions,...)

links represent super-concept / sub-concept-relationships IS-A:

specialization / subsumption of concepts concept-instance-relationships instance-of relationships between concepts role (slot) attributes/features/properties of concept constraints attached to roles, e.g. number of fillers

Closely related to First-Order Predicate Logic.

Page 11: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 11

Terminological Network – ExampleTerminological Network – Example

Example:

Concepts: bird, robin, flying-animal, “Speedy”Feature: colorIS-A (robin,bird), IS-A (bird,flying-animal) Superclassinstance-of (“Speedy”, robin) Instancecolor (robin)=“grey” Feature

Task:Express that a typical elephant has legs, usually 4 of them, has a certain color, and there is a specific elephant named Clyde.

elephant, color, legs, has (usually) 4 legs,”Clyde”

Page 12: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 12

Terminological Network - SolutionTerminological Network - Solution

Solution:Concepts: elephant, legs, “Clyde” (instance) or

Clyde (individual concept), (color and grey)

Roles: has-legs, (has-color)

Feature: color

Specific Representation of Clyde:

has-legs (elephant, legs, 4)

has-color (elephant, grey) or color (elephant) = “grey”

instance-of (“Clyde”, elephant) specific object “Clyde”

IS-A (Clyde, elephant) individual concept ‘Clyde’

Page 13: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 13

Frames concepts as record-like structures slots – relationships to other concepts, attributes fillers – values for slots (other concept or value)

Schema-Theory / Prototypes some objects are more typical for a certain class of

objects precise definition for concepts sometimes not possible,

then reference to prototypes

Frames, Schemas, PrototypesFrames, Schemas, Prototypes

Page 14: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 14

Typical bird is robin – take all “robin-features” as description for class ‘bird’. This forms a prototype.

Take typical chair as prototype. Other chairs are more or less similar to this prototypical chair.

The class of all chairs is fuzzy since there are no precise or exact boundaries for the class 'chair', i.e. to decide when something is a chair or not.

Frames, Schemas, PrototypesFrames, Schemas, Prototypes

Page 15: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 15

Frames, Defaults, and DemonsFrames, Defaults, and Demons

Frames – represent concepts as record-like structures• slots – relationships to other concepts, attributes• fillers – values for those slots• attached procedures – to determine slot-fillers

Defaults – represent standard values (fillers) for some attributes (slots) of a concept (frame)

Demons – are activated by a certain action or pattern • if-added demon - activated when value is added or

updated, e.g. re-calculate area-value if side-info changes

• if-needed demon - activated when value is accessed, e.g. calculate area-value based on default assumptions if this slot-filler is required

Page 16: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 16

DefaultsDefaults

Defaults represent standard-values for some attributes of a concept, e.g. the standard number of legs of an elephant is 4. (Inherited) defaults may be overwritten at lower-level concepts, or for individual concepts.

“Clyde” - the famous 3-legged AI-elephant.

Problem: If roles, attributes etc. in a concept description can be changed or cancelled, what is the definition of a concept. How can we classify? And reason?

Page 17: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 17

Multiple Inheritance and ViewsMultiple Inheritance and Views

Multiple inheritanceSub-Concept inherits descriptions from several

superconcepts.

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

ViewsDescription of concept from different viewpoints.

Inheritance of multiple, complementing descriptionse.g. view computer as machine or as equipment

Page 18: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 18

Multiple Inheritance - Views (Jackson, Fig. 6.7)

Multiple Inheritance - Views (Jackson, Fig. 6.7)

Page 19: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 19

Multiple Inheritance - Ambiguity (Jackson, Fig. 6.8)

Multiple Inheritance - Ambiguity (Jackson, Fig. 6.8)

Page 20: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 20

Object-Oriented ProgrammingObject-Oriented Programming

Objects – represent concepts similar to frames• structured declarative representation (like

record)• procedural methods define the (external)

behavior of object

Objects communicate via sending “messages” to other objects to invoke their methods.

Page 21: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 21

Object-Oriented Programming – ExampleObject-Oriented Programming – Example

Class Radio Class Robot

slots slots

power:{on,off} ...

volume:{1,...,10}

methods methods

v-control(V) - shut-down(...) –

set volume = V send (radio-1, switch(off))

switch(O) -

set power on/off

for O=on/off

radio-1 of-class Radio robot-1 of-class Robot

Page 22: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 22

Object-Oriented Programming (OOP) - Languages -

Object-Oriented Programming (OOP) - Languages -

SIMULA67, SmallTalk

...

KRL – Knowledge Representation Language

LOOPS – Lisp Object-Oriented Programming System

Flavors

CLOS – Common Lisp Object System

COOL – CLIPS Object-Oriented Language

...

C++ , Java, ...

Page 23: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 23

OOP –Terminology and ConceptsOOP –Terminology and Concepts

objects: data structures + proceduresObjects are often called classes.

Procedures are often called methods.

Encapsulation: object-information can only be accessed by specifying the object and using the methods defined for this object ( message passing).

Message Passing: objects can send messages to other objects by addressing the object and one of it’s methods.

Distinction: private and public variables / procedures

Computation in OOP involves mainly communication between objects, and little or no global control.

Page 24: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 24

Basic Functions in OOPBasic Functions in OOP

CREATING Define a class, including data structures/slots and

methods. Define inheritance hierarchy, i.e. IS-A relationships. Create / Delete instances of a class.

WORKING Message passing. (COOL)In CLIPS: Application of rules.

Page 25: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 25

OOP – InheritanceOOP – Inheritance

Objects/classes arranged in inheritance hierarchy

Classes are also called generic objects / concepts Their methods are called generic methods / procedures Specific objects are instances of classes.

Inheritance of data structures (slots, fillers) and procedures (methods).

class ship

instance-of ship Titanic

class shipclass motorship IS-A ship

Page 26: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 26

OOP –Inheritance of Data StructuresOOP –Inheritance of Data Structures

Inheritance of data structures define data structures (slots) for super-class define defaults and common values (for slots) for super-class inherit to sub-classes and instances

Class motorship, as well as instance Titanic inherit all slot-specifications, defaults, etc. from ship.

class shipx-velocity INTEGERy-velocity INTEGER

... class motorship IS-A ship instance-of ship Titanic

Page 27: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 27

OOP – Inheritance of MethodsOOP – Inheritance of Methods

Inheritance of procedures (methods) define “generic” method for super-class inherit to sub-classes (and instances)

self is object itself; self:x-velocity refers to slot x-velocity of self.

Method calc-speed known for all ships; uses concrete values for x-velocity, y-velocity for instance of ship (e.g. Titanic) in actual calculation.

class ship

method calc-speed

.... (self:x-velocity, self:y-velocity) ...

instance-of ship Titanicsend Titanic calc-speed

Page 28: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 28

Multiple Inheritance and Method CombinationMultiple Inheritance and Method Combination

Inheritance of methods / procedures in multiple inheritance hierarchies (heterarchies).

Problem of method combination.

Use before- and after-methods ( e.g. Flavors) take main method (inherited from super-class); add special before and after methods (from class or super-

classes) which are executed before / after the main method.

before-method – preparation for main method after-method – clean-up and adjustments around-methods or wrappers and whoppers – additional

surrounding code

Page 29: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 29

Method Combination and Multiple InheritanceMethod Combination and Multiple Inheritance

Window withBorder

Window withLabel

Window withBorder and Label

Window

Inherit main methods (e.g. refresh) from Window, and add special methods as before- and after-methods from subclasses.

Page 30: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 30

Method Combination and Multiple Inheritance in CLIPS/COOL

Method Combination and Multiple Inheritance in CLIPS/COOL

Problem of method combination for multiple inheritance

1) Class Precedence List (CLOS, CLIPS/COOL) take methods as listed in their super-classes :

consult quaker first for inheritance; then republican.

2) before- and after-methods add special before and after methods

class republican-quaker

IS-A quaker and republican

Page 31: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 31

Meta-ClassesMeta-Classes

Meta-Classes are used to describe classes, e.g. create- and delete-functions, access-functions etc.

The members of Meta-Classes are classes.

Meta-Classes are classes themselves.

Page 32: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 32

Classes and Instances in COOL- Instance-Relation -

Classes and Instances in COOL- Instance-Relation -

MetaClass

Class

LinerShip

Titanic

Object

domain instances

domain classes

system classes

Page 33: © C. Kemke Knowledge Representation 1 COMP 4200: Expert Systems Dr. Christel Kemke Department of Computer Science University of Manitoba

© C. Kemke Knowledge Representation 33

Classes and Meta-Classes in COOL- IS-A Relation -

Classes and Meta-Classes in COOL- IS-A Relation -

Object

Class

Liner

Ship

Titanic

MetaClass

domain instances

domain classes

system classes