dt228/3 intelligent systems development
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 PresentationTRANSCRIPT
Course Website: http://www.comp.dit.ie/bmacnamee
DT228/3 Intelligent Systems Development
Rule-Based Expert Systems
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
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
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
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>
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>
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
8of42
Rule-Based Expert System Model
Inference EngineProduction Rule
Long Term Memory
Fact
Working Memory
Explanation Facilities
User Interface
User
Production System
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
10of42
Production System Model
Inference(Reasoning)
Conclusion
Production Rule
Long Term Memory
Fact
Working Memory
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
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
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
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
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?
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
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
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
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
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
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
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
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
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
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?
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
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
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
?
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
?
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
?
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
?
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
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
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
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
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
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
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
? ?
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
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
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
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