dt228/3 intelligent systems development

42
Course Website: http://www.comp.dit.ie/bmacnamee DT228/3 Intelligent Systems Development Rule-Based Expert Systems

Upload: kalkin

Post on 05-Jan-2016

47 views

Category:

Documents


2 download

DESCRIPTION

DT228/3 Intelligent Systems Development. Rule-Based Expert Systems. Contents. In this lecture we will review rule-based expert systems What do we mean by rule-based expert systems? Architecture of a rule-based expert system Inference in rule-based expert systems Forward chaining - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: DT228/3 Intelligent Systems Development

Course Website: http://www.comp.dit.ie/bmacnamee

DT228/3 Intelligent Systems Development

Rule-Based Expert Systems

Page 2: DT228/3 Intelligent Systems Development

2of42

Contents

In this lecture we will review rule-based expert systems

– What do we mean by rule-based expert systems?

– Architecture of a rule-based expert system– Inference in rule-based expert systems

• Forward chaining• Backward chaining

– Limitations of rule-based expert systems

Page 3: DT228/3 Intelligent Systems Development

3of42

What is an Expert System?

An expert system is a computer system that:– Performs functions similar to those normally

performed by a human expert – Uses a representation of human expertise in

a specialist domain to perform functions similar to a human domain expert

– Operates by applying an inference mechanism to a body of specialist expertise represented in a knowledge base

Page 4: DT228/3 Intelligent Systems Development

4of42

What is a Rule-Based Expert System?

If you had to explain to somebody how to cross a road you could do it with simple rules

Statements in this IF-THEN form are referred to as production rulesA rule-based expert system captures the knowledge of an expert in a set of production rules and combines these with observed data to generate inferences

IF: the traffic light is greenTHEN: the action is go

IF: the traffic light is redTHEN: the action is wait

Page 5: DT228/3 Intelligent Systems Development

5of42

Production Rules

Production rules– IF-THEN expressions– IF some condition(s) exists THEN perform

some action(s)

Condition-action pair– Condition: pattern that determines when a

rule may be applied to problem instance– Action: defines associated problem solving

step

Antecedent – Consequent– IF <antecedent> THEN <consequent>

Page 6: DT228/3 Intelligent Systems Development

6of42

Production Rules (cont…)

Rule can have multiple antecedents– Conjunction AND

– Disjunction OR

– Or a combination of both

IF <antecedent0> AND <antecedent1> … AND <antecedentn>THEN <consequent>

IF <antecedent0> OR <antecedent1> … OR <antecedentn>THEN <consequent>

IF <antecedent0> AND <antecedent1> … AND <antecedentn>OR <antecedent0> OR <antecedent1> … OR <antecedentn>THEN <consequent>

Page 7: DT228/3 Intelligent Systems Development

7of42

Production Rules (cont…)

Consequents can also have multiple clauses

Some production rule examples

IF <antecedent> THEN <consequent0>, <consequent1>,

…<consequentn-1>, <consequentn>

IF the fuel tank is emptyTHEN the car is dead

IF the season is autumnAND the sky is cloudyAND the forecast is drizzleTHEN advice is take an umbrella

IF patient has stomach pains AND (temperature > 98OR patient is nauseous)THEN diagnosis is appendicitis,

action is call the surgeon

Page 8: DT228/3 Intelligent Systems Development

8of42

Rule-Based Expert System Model

Inference EngineProduction Rule

Long Term Memory

Fact

Working Memory

Explanation Facilities

User Interface

User

Production System

Page 9: DT228/3 Intelligent Systems Development

9of42

Characteristics of a Rule-Based Expert System

Human Experts Expert Systems Conventional Programs

Use rules of thumb or heuristics to solve problems in a narrow domain

Use rules and inference to solve problems in a narrow domain

Process data and use algorithms to solve problems

Experts store their knowledge compiled in their brains

Provide a clear separation of knowledge from its processing

Do not separate knowledge from the control structures to process this knowledge

Capable of explaining a line of reasoning

Trace the rules fired to explain how a particular conclusion was reached and why particular data was needed

Do not explain how a particular result was obtained and why input data was needed

Use inexact reasoning and can deal with incomplete, uncertain and fuzzy information

Permit inexact reasoning and can deal with incomplete, uncertain and fuzzy data

Work only on problems where data is complete and exact

Can make mistakes when data is incomplete or fuzzy

Can make mistakes when data is incomplete or fuzzy

Provide no solution at all or a wrong one when data is incomplete or fuzzy

Enhance the quality of problem solving via years of learning and practical training. This is slow, inefficient and expensive

Enhance the quality of problem solving by adding new rules or adjusting existing ones. This should be cheap and fast

Enhance the quality of problem solving by changing the program code

Page 10: DT228/3 Intelligent Systems Development

10of42

Production System Model

Inference(Reasoning)

Conclusion

Production Rule

Long Term Memory

Fact

Working Memory

Page 11: DT228/3 Intelligent Systems Development

11of42

Production System

Long-term memory– Stores the production rules used to make

inferences

Working memory– Current state of world– Pattern that is matched against the condition

part of rules to select appropriate problem-solving actions

– Actions may alter working memory

Page 12: DT228/3 Intelligent Systems Development

12of42

Production System (cont…)

Inference cycle (Recognize-Act Cycle)– Working memory is initialized at start of

reasoning– Current state is maintained as set of patterns

in working memory– Patterns matched against conditions in rules

to find a satisfied rule– Fire the selected rule

• An action is performed changing working memory

– Repeat until working memory no longer matches rule conditions

Page 13: DT228/3 Intelligent Systems Development

13of42

Data Driven Search Strategy

Forward Chaining: Begins with problem description and infers new knowledge from the dataApplies rules of inference to current description of world and adds inferred results to problem description

– Many rules may be executed that have nothing to do with the goal

Rule matching continues until the goal has been reached May not be efficient

Page 14: DT228/3 Intelligent Systems Development

14of42

Data-Driven: How Does it Work?

Data-driven search proceeds in cycles Inference cycle matches the current state of the world against the sets of production rules

– The current state of the world is the data that is assumed to be true or deduced as true from previously fired production rules

Action of a rule adds new fact(s) to the working memory when firedCycle stops when no further rules can be fired

Page 15: DT228/3 Intelligent Systems Development

15of42

Forward Chaining Example

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Suppose that we know the facts A, B, C, D, E and the rules shown in the knowledge base to the left

What facts can we infer from this?

Page 16: DT228/3 Intelligent Systems Development

16of42

Forward Chaining Example

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

X

Inference Cycle 1

Page 17: DT228/3 Intelligent Systems Development

17of42

Forward Chaining Example

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

X L

Inference Cycle 1

Page 18: DT228/3 Intelligent Systems Development

18of42

Forward Chaining Example

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

X L

Inference Cycle 1

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

X L

Inference Cycle 2

Page 19: DT228/3 Intelligent Systems Development

19of42

Forward Chaining Example

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

X L

Inference Cycle 1

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

X L

Inference Cycle 2

Y

Page 20: DT228/3 Intelligent Systems Development

20of42

Forward Chaining Example

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

X L

Inference Cycle 1

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

X L

Inference Cycle 2

Y

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

X L

Inference Cycle 3

Y

Page 21: DT228/3 Intelligent Systems Development

21of42

Forward Chaining Example

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

X L

Inference Cycle 1

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

X L

Inference Cycle 2

Y

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

X L

Inference Cycle 3

Y Z

Page 22: DT228/3 Intelligent Systems Development

22of42

Forward Chaining Example

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

X L

Inference Cycle 1

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

X L

Inference Cycle 2

Y

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

X L

Inference Cycle 3

Y Z

After inferring facts X, L, Y and Z there are no more rules

that can be fired

Page 23: DT228/3 Intelligent Systems Development

23of42

Goal-Driven Search Strategy

Backward Chaining: A desired goal is placed in working memory, inference cycle attempts to find evidence to prove it

Search knowledge base for rules that might lead to goal

– Rules that have the goal in their action parts

If condition of such rule matches fact in working memory then rule is fired and goal is proved

Page 24: DT228/3 Intelligent Systems Development

24of42

Goal Driven: How Does it Work?

Goal driven search proceeds in cycles

Stack rule– Set up sub-goal to prove condition– Search for rules to prove sub-goal– Continue process of stacking until no rules

found that can prove sub-goal

Most efficient when want to infer one particular fact

User may be asked to input additional facts

Page 25: DT228/3 Intelligent Systems Development

25of42

Backward Chaining Example

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Suppose that we know the facts A, B, C, D, E and the rules shown in the knowledge base to the left

Can we infer the fact Z?

Page 26: DT228/3 Intelligent Systems Development

26of42

Backward Chaining Example

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Goal: Z

Z

Page 27: DT228/3 Intelligent Systems Development

27of42

Backward Chaining Example

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Goal: Z

Z

Page 28: DT228/3 Intelligent Systems Development

28of42

Backward Chaining Example

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Goal: Z

Z

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Sub-goal: Y

Y

?

Page 29: DT228/3 Intelligent Systems Development

29of42

Backward Chaining Example

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Goal: Z

Z

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Sub-goal: Y

Y

?

Page 30: DT228/3 Intelligent Systems Development

30of42

Backward Chaining Example

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Goal: Z

Z

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Sub-goal: Y

Y

?

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Sub-goal: X

X

?

Page 31: DT228/3 Intelligent Systems Development

31of42

Backward Chaining Example

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Goal: Z

Z

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Sub-goal: Y

Y

?

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Sub-goal: X

X

?

Page 32: DT228/3 Intelligent Systems Development

32of42

Backward Chaining Example

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Goal: Z

Z

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Sub-goal: Y

Y

?

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Sub-goal: X

X

Page 33: DT228/3 Intelligent Systems Development

33of42

Backward Chaining Example

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Goal: Z

Z

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Sub-goal: Y

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Sub-goal: X

XX Y

Page 34: DT228/3 Intelligent Systems Development

34of42

Backward Chaining Example

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Goal: Z

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Sub-goal: Y

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Sub-goal: X

XX YX Y Z

Page 35: DT228/3 Intelligent Systems Development

35of42

Backward Chaining Example

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Goal: Z

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Sub-goal: Y

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Sub-goal: X

XX YX Y Z

Backward chaining inferred Z from the facts and rules that

were available

Page 36: DT228/3 Intelligent Systems Development

36of42

Data Driven Vs. Goal Driven

Data-driven reasoning is appropriate when there exist many equally acceptable goal states, a narrow body of facts and rules and a single initial state

– Required facts are available– It is difficult to form a goal to verify

Goal directed inference is relevant when:-– Relevant data must be acquired during the

inference process– Large number of applicable rules exist – An obvious goal to verify is available

Page 37: DT228/3 Intelligent Systems Development

37of42

Conflict Resolution

What if more than one rule matches a in a particular situation?

We have actually already seen this in one of our examples

What should we do?

Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

Page 38: DT228/3 Intelligent Systems Development

38of42

Conflict Resolution

What if more than one rule matches a in a particular situation?

We have actually already seen this in one of our examples

What should we do?– The answer is referred to

as conflict resolution Y & D → Z

Knowledge Base

X & B & E → Y

A → X

C → L

L & M → N

Database

A BC D E

X L

? ?

Page 39: DT228/3 Intelligent Systems Development

39of42

Conflict Resolution (cont..)

What if more than one rule matches a in a particular situation?

– Patterns are matched against conditions in rules to produce a set of satisfied rules

• These rules are known as the conflict set

– Conflict Resolution• One rule is selected and fired• Action is performed which changes working

memory

– Repeat until working memory no longer matches rule conditions

Page 40: DT228/3 Intelligent Systems Development

40of42

Conflict Resolution (cont..)

How do you choose which rule from the conflict set to fire?

– Rule Ordering • Choose the first rule in the text, ordered top-to-

bottom.

– Recency• Prefers rules that use facts most recently added• Focuses on single line of reasoning

– Specificity• More specific rules are preferable to more general• A rule is more specific if it has more conditions -

implies a rule will match fewer potential working memory patterns

Page 41: DT228/3 Intelligent Systems Development

41of42

Conflict Resolution (cont..)

– Refraction• Once a rule has fired it may not fire again until

working memory elements that match its conditions have been modified

• Discourages looping

Structure of rules and the conflict resolution scheme used controls the fashion in which the space is searched

Allows us to encode heuristics into production rules

Page 42: DT228/3 Intelligent Systems Development

42of42

Summary

In this lecture we have covered– What is a rule-based expert systems?– Overall architecture of rule-based expert

systems– How inference works in a rule-based expert

system