ai sem1 2012-13-w2-representation

68
CHAPTER 2 KNOWLEDGE REPRESENTATION

Upload: azimah-hashim

Post on 10-Jul-2015

230 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Ai sem1 2012-13-w2-representation

CHAPTER 2

KNOWLEDGE REPRESENTATION

Page 2: Ai sem1 2012-13-w2-representation

What is AI

AI Techniques

AI Applications

Page 3: Ai sem1 2012-13-w2-representation

- Raw facts

- Static

- E.g. Liza, S’pore

- Processed data

- Has some meaning and purposes

- E.g. Liza was born in S’pore

- Derived from information

- Stored in human brain

- What we know

Page 4: Ai sem1 2012-13-w2-representation

1. Introduction

2. Semantic Networks

3. Decision Tables

4. Decision Trees

5. Frames

6. Production Rules

7. Logic

a. Propositional Logic

b. Predicate Calculus

Learning Outcome

Analysis Representation

Coding Representation

Page 5: Ai sem1 2012-13-w2-representation

“The know-how to program a computer to mimic

the thought processes of an expert through an

appropriate representation scheme” is called

knowledge representation (KR)

It involves knowledge of a shell or a programming

language that will represent the expert

knowledge

Page 6: Ai sem1 2012-13-w2-representation

A number of KR schemes shares 2 common

characteristics:

a. They contain facts that can be used in

reasoning

b. They can be programmed with existing

computer languages

Page 7: Ai sem1 2012-13-w2-representation

There are generally 2 types of KR schemes:

a. Analysis representation

Support knowledge acquisition during scope

establishment and initial knowledge gathering

Most techniques are pictorial such as

-semantic networks - decision trees -tables

b. Coding representation

The working code of the ES either in the form of

-frames or - production rules

Page 8: Ai sem1 2012-13-w2-representation

Knowledge

Representation

Analysis

Representation

Coding

Representation

Inference

Frames

Production rules

Semantic networks

Decision tables

Decision trees

Selected KR Schemes

Key

Idea

Page 9: Ai sem1 2012-13-w2-representation

Analysis Coding

Semantic Networks

Decision Tables

Decision Trees

Page 10: Ai sem1 2012-13-w2-representation

Semantic networks are the most general representation scheme.

Represent a graphical representation of knowledge that show hierarchical relationships between objects.

Made up of a network of nodes and arc.

The nodes represent objects and the arc the relationships between objects.

KR Scheme 1

Node Arc

Page 11: Ai sem1 2012-13-w2-representation

Example:

KR Scheme 1

Page 12: Ai sem1 2012-13-w2-representation

Example:

License

Seal

Examination

Air

rescue

Emergency

landing

procedures

Olesek

Insignia

Shirt

sleeve

Two

Male

Harding

Person

Apparel

Uniform

Black

Cap

has-a

certifies

has-a

in-a in-an

has-

an

is-on

is-a

number-

of has-a

is-a

race-is

is-a

wears

is-a

is-an

KR Scheme 1

Page 13: Ai sem1 2012-13-w2-representation

Nodes represent the objects, concepts, or events in

the world.

Names of the arcs

correspond to names of relations

indicate which concepts or objects are linked by

the relations.

KR Scheme 1

Page 14: Ai sem1 2012-13-w2-representation

The 2 common arcs used are:

IS-A is used to show class relationship.

HAS-A is used to identify characteristics or

attributes of the object nodes

other arcs are used for definitional purpose only

KR Scheme 1

Page 15: Ai sem1 2012-13-w2-representation

Organized in a spreadsheet format, using columns

and rows

The table divided into two parts:

A list of attributes is developed and for each attribute,

all possible values are listed

A list of possible conclusions. The different

configurations of attributes are match against the

conclusion.

Attributes Conclusions

KR Scheme 2

Page 16: Ai sem1 2012-13-w2-representation

Decision Table for Gift Problem

Decision Factors Result

Money Age Gift

Much Adult Car

Much Child Computer

Little Adult Toaster

Little Childs Calculator

KR Scheme 2

Page 17: Ai sem1 2012-13-w2-representation

KR Scheme 2

Page 18: Ai sem1 2012-13-w2-representation

A hierarchical arranged semantic network and is

closely related to a decision table

It is composed of nodes representing goals and

links representing decisions

Rules can be extracted from the decision tree,

that can be executed by computer program

A major advantage can simplify knowledge

acquisition process

KR Scheme 3

Page 19: Ai sem1 2012-13-w2-representation

KR Scheme 3

Page 20: Ai sem1 2012-13-w2-representation

A decision tree for an electrical system diagnosis

Terminals

Battery Voltage

Distributor Charger

Not

Loose

Loose

Tighten Terminals

<12 >12

OK OK Bad Bad

Check

Starter

Replace

Distributor

Replace

Charger

Replace

Battery

KR Scheme 3

Page 21: Ai sem1 2012-13-w2-representation

Analysis Coding

Frames

Production Rules

Logic

Page 22: Ai sem1 2012-13-w2-representation

A frame is a data structure for representing

common concepts and situations (stereotype

knowledge).

Like semantic nets, frames can be organized in a

hierarchy with general concepts near the top and

specific concepts placed at the lower levels.

General -top

Specific -lower

KR Scheme 4

Page 23: Ai sem1 2012-13-w2-representation

Unlike semantic nets, each frame or node in this

hierarchy can be very rich in supplementary

information.

KR Scheme 4

Page 24: Ai sem1 2012-13-w2-representation

Values that describe one object are grouped

together into single unit.

Knowledge partition into slots.

Each slot describes:

• declarative knowledge (colour of a car)

• procedural knowledge (activate a certain rule if

the value exceeds a certain value)

KR Scheme 4

Page 25: Ai sem1 2012-13-w2-representation

Frames describe an object in great detail. The

detail in form of slots that describe the various and

characteristic of the object or situation.

KR Scheme 4

Page 26: Ai sem1 2012-13-w2-representation

Basic frame design

Frame

Name:

Class:

Properties:

Frame1

**Eg: Bird

***2 ***Eg: No. of wings

***Worms ***Eg: Eat

Value2 Property2

Value1 Property1

KR Scheme 4

Page 27: Ai sem1 2012-13-w2-representation

Class frame

Represents general characteristics of some set of

common objects. For example Cars, Boats, and Birds.

Defines those properties that are common to all the

objects within the class, and possibly default property

values.

static: describe an object

feature whose value doesn’t

change

dynamic: is a feature whose value

is likely to change during

operation of the system

KR Scheme 4

Page 28: Ai sem1 2012-13-w2-representation

Example of Class Frame

Class Name:

Properties:

Bird

Try Flies

2 No Wings

Worms Eats

Unknown Color

Unknown Hungry

Unknown Activity

KR Scheme 4

Page 29: Ai sem1 2012-13-w2-representation

Class Name:

Properties:

KR Scheme 4

Page 30: Ai sem1 2012-13-w2-representation

An Instance of Frame

Describes a specific instance (sub-class or examples)

of a class frame.

The instance inherits both properties and property values

from its frame class.

The property values can be changed (recall: static/dynamic) to

tailor the object represented in the instance.

Many instances of the frame class can be created.

The instances immediately inherit the frame’s properties.

Can speed up system coding.

KR Scheme 4

Page 31: Ai sem1 2012-13-w2-representation

Instance frame

Frame Name:

Class Name:

Properties:

Tweety

Bird

False Flies

1 No Wings

Eats

Yellow Color

Hungry

Activity

Lives Cage

KR Scheme 4

Page 32: Ai sem1 2012-13-w2-representation

Frame Inheritance

From example, “Tweety” is an instance of Bird class.

Can allow an instance to accept the class default

values or provide values unique to the instance.

Like most bird Tweety eats worms, but has only one

wing and cannot fly.

Can also provide unique properties. e.g. if Tweety lives

in a cage.

KR Scheme 4

Page 33: Ai sem1 2012-13-w2-representation

Frame Inheritance

Inheriting behaviour

Beside inheriting descriptive information from its

class, an instance also inherits its behaviour.

Need to include a procedure (method) within class

frame that define some actions that the frame

performs.

KR Scheme 4

Page 34: Ai sem1 2012-13-w2-representation

A form of procedural knowledge that describe how to solve a problem.

The procedural and/or factual knowledge is represented as rules, called productions, in the form of condition-action pairs.

Are stated as follows: "IF this condition occurs, THEN do this action; or this

result (or conclusion or consequence) will occur.

KR Scheme 5

Page 35: Ai sem1 2012-13-w2-representation

Examples

IF flammable liquid was spilled,

THEN call the fire department.

IF the pH of the spill is less than 6,

THEN the spill material is an acid.

IF the spill material is an acid,

and the spill smells like vinegar,

THEN the spill material is acetic acid.

KR Scheme 5

Page 36: Ai sem1 2012-13-w2-representation

When the IF portion of a rule is satisfied by the

facts, the action specified by the THEN is

performed.

When this happens, the rule is said to "fire" or

"execute".

KR Scheme 5

Page 37: Ai sem1 2012-13-w2-representation

Relationship

IF The battery is dead

THEN The car will not start

Recommendation

IF The car will not start

THEN take a cab

Directive

IF The car will not start

AND the fuel is okay

THEN check out the electrical system

KR Scheme 5

Page 38: Ai sem1 2012-13-w2-representation

Strategy

IF The car will not start

THEN first check out the fuel system then check

out electrical system

Heuristic

IF The car will not start

AND The car is a 1957 Ford

THEN check the float

KR Scheme 5

Page 39: Ai sem1 2012-13-w2-representation

Uncertain Rules

IF inflation is high

THEN Almost certainly interest rates are high

Can assign Certainty Factors:

IF inflation is high

THEN interest are high CF=0.8

KR Scheme 5

Page 40: Ai sem1 2012-13-w2-representation

Meta-Rules

A rule that describe how other rules should be used.

IF the car will not start

AND the electrical system is operating normally

THEN use rules concerning the fuel system

KR Scheme 5

Page 41: Ai sem1 2012-13-w2-representation

Rules are easy to understand

Inference and explanation are easy to derive

Modifications and maintenance are relatively easy

Uncertainty is easily combined with rules

Each rule is usually independent of all others

KR Scheme 5

Page 42: Ai sem1 2012-13-w2-representation

The oldest form of knowledge representation in a computer is logic

Logic is concerned with the truthfulness of a chain of statements.

An argument is true if and only if, when all assumptions are true, then all conclusions are also true.

2 kinds of logic:

Propositional Logic

Predicate Calculus

Both use symbols to represent knowledge and operators applied to the symbols to produce logical reasoning

KR Scheme 6

Page 43: Ai sem1 2012-13-w2-representation

Propositional logic represents and reasons with propositions.

PL assigns symbolic variable to a proposition such as A = The car will start

In PL, if we are concern with the truth of the statement, we will check the truth of A.

KR Scheme 6a

Page 44: Ai sem1 2012-13-w2-representation

KR Scheme 6a

Page 45: Ai sem1 2012-13-w2-representation

Propositions that are linked together with connectives, such as AND, OR, NOT, IMPLIES, and EQUIVALENT, are called compound statements.

Example:

IF The students work hard

AND Always come to lectures

AND Do all their homework

THEN They will get a good grade

Using logic symbols: A B C -> D

Propositional logic is concerned with the truthfulness of compound statements, depending on the connectives.

KR Scheme 6a

Page 46: Ai sem1 2012-13-w2-representation

F F F F T T

F T F T T F

T F F T F F

T T T T F T

Truth Table

KR Scheme 6a

Page 47: Ai sem1 2012-13-w2-representation

Implies Operator: C = A B (C is A implies B)

For an implication of C, if A is true, then B is implied to be true

(A B) ( A B)

The implies return an F when A is TRUE and B is FALSE

Otherwise it returns TRUE.

A B A B

F F T

F T T

T F F

T T T

KR Scheme 6a

Page 48: Ai sem1 2012-13-w2-representation

Example to illustrate Implies

IF The battery is dead (A)

THEN The car won’t start (B)

A B A B

F F T

F T T

T F F

T T T

KR Scheme 6a

Page 49: Ai sem1 2012-13-w2-representation

PL offers techniques for capturing facts or rules in

a symbolic form and then operates on them

through use of logical operators.

PL provides methods for managing statements

that are either TRUE or FALSE.

KR Scheme 6a

Page 50: Ai sem1 2012-13-w2-representation

Some PL weakness:

1. Limited ability to express knowledge and lose much

of their meanings.

The Pacific Ocean contains water.

Florida is a state within the USA.

Only assigning a true value without making any

statement about ‘oceanhood’ or ‘statehood’.

KR Scheme 6a

Page 51: Ai sem1 2012-13-w2-representation

Some PL weakness:

2. Not all statements can be represented.

All men are mortals.

Some dogs like cats.

Thus, need a more general form of logic that

capable of representing the details.

Therefore Predicate Calculus is introduced.

KR Scheme 6a

Page 52: Ai sem1 2012-13-w2-representation

Enhances processing by allowing the use of

variables and functions.

Use symbols that represent

• constants

• predicates

• variables

• functions

Operate on these symbols using PL operators (

.

KR Scheme 6b

Page 53: Ai sem1 2012-13-w2-representation

Specific objects or properties about a problem.

Begin with lower case.

Example: ahmad, elephant and temperature

KR Scheme 6b

Page 54: Ai sem1 2012-13-w2-representation

Divide a proposition into 2 parts:

predicate: assertion about object

argument: represents the object

To represent a statement “John likes Mary.” in a

predicate calculus.

likes(john, mary)

A predicate Arguments

KR Scheme 6b

Page 55: Ai sem1 2012-13-w2-representation

Represents general classes of objects or properties.

Written as symbols beginning with upper case.

likes(john, X)

KR Scheme 6b

Page 56: Ai sem1 2012-13-w2-representation

Permits symbols to be used to represent functions.

A function denotes a mapping from entities of a

set to a unique element of another set.

father_of(john) mother_of(john)

Can be also used within predicates. For

example: married(father_of(john), mother_of(john))

KR Scheme 6b

Page 57: Ai sem1 2012-13-w2-representation

PC uses the same operators as in PL.

Proposition:

David is John’s father. father(david, john)

Jane is John’s mother. mother(jane, john)

If X is John’s father and Y is John’s mother then X is Y’s

husband.

father(X, john) mother(Y, john) husband(X, Y)

KR Scheme 6b

Page 58: Ai sem1 2012-13-w2-representation

PC introduces 2 symbols called variable

quantifiers.

1. universal quantifier: for all

2. existential quantifier: there exist

KR Scheme 6b

Page 59: Ai sem1 2012-13-w2-representation

indicates an expression is TRUE for all values of

designated variable.

Example:

X likes (X, mary)

means for all values of X, X likes Mary.

“Everyone likes Mary.”

KR Scheme 6b

Page 60: Ai sem1 2012-13-w2-representation

indicates an expression is TRUE for some values of

the variable; at least one value existed that makes

the statement is true:

Example:

X likes (X,mary)

means there exist X where X likes Mary.

“Someone likes Mary.”

KR Scheme 6b

Page 61: Ai sem1 2012-13-w2-representation

Parentheses are used to indicate the scope of

quantification

X (likes(X,mary) nice(mary) nice (X))

determines all instances of X who like Mary and if

Mary is nice, then it is implied that those who like

Mary are nice too.

X (man(X) mortal(X))

All men are mortal. Man(X)

KR Scheme 6b

Page 62: Ai sem1 2012-13-w2-representation

PC can provide reasoning capability to intelligent

systems

Reasoning requires the ability to infer conclusions

from available facts.

One simple form of inference is modus ponens:

IF A is true

AND A B is true

THEN B is true

Based on the available facts below:

X (man(X) mortal(X))

man(socrates)

We can infer a conclusion of mortal(socrates)

KR Scheme 6b

Page 63: Ai sem1 2012-13-w2-representation

father(david, john)

mother(jane, john)

father(X, john) mother(Y, john) husband(X, Y)

Who is X?

Who is Y?

Who is Y’s husband?

From the above facts and rule, we can infer some more conclusions …..

KR Scheme 6b

Page 64: Ai sem1 2012-13-w2-representation

The semantic network and its equivalent predicate calculus.

is_a(E1,elephant)

name(E1, clyde)

num_trunk(elephant, 1)

tail(elephant, 1)

num_legs(elephant, 4)

skin_colour(elephant, grey)

Page 65: Ai sem1 2012-13-w2-representation

Convert the predicate calculus below into its equivalent semantic networks.

has_size(bluebird, small)

has_covering(bird, feathers)

has_colour(bluebird, blue)

has_property(bird, flies)

is_a(bluebird, bird)

is_a(bird, vetebrate)

Page 66: Ai sem1 2012-13-w2-representation

Represent the following English sentences in predicate calculus:

1. Monkeys like bananas.

2. Dogs chase cats.

3. John doesn’t like ice-creams.

4. If weather is good, I go jogging.

Page 67: Ai sem1 2012-13-w2-representation

Prepare a frame of an automobile that you

know, show 2 levels of hierarchy. Fill some

property and property values. (static and

dynamic)

Page 68: Ai sem1 2012-13-w2-representation

Try to crank the starter. If it is dead or cranks slowly, turn on the headlights. If the headlights are bright (or dim only slightly), the trouble is either in the starter itself, the solenoid, or in the wiring. To find the trouble, short the two large solenoid terminals together (not to ground). If the starter cranks normally, the problem is in the wiring or in the solenoid; check them up to the ignition switch. If the starter does not work normally, check the bushings (see section 7-3 of the manual for instructions). If the bushings are good send the starter to the test station or replace it. If the headlights are out or very dim, check the battery (see section 7-4 for instructions). If the battery and connecting wires are not at fault, turn the headlights on and try to crank the starter. If the lights dim drastically, it is probably because the starter is shorted to the ground. Have the starter tested or replace it. (Based on Carrice et al. [5]).