INFERENCE
ENGINE
DESIGN
PART 2
ITS661: KNOWLEDGE-BASED SYSTEMS
Control Strategies
How the system’s knowledge can best be controlled - asking the expert
to work through a typical problem.
Forward Control Backward
Chaining Chaining
Strategy
Control Strategies
Forward Chaining
◦ Data driven
◦ Is appropriate if the expert first collects information about the problem and
then sees what can be concluded.
◦ the amount of data < than the number of solutions
Backward chaining
◦ Goal driven
◦ If expert first considers some conclusion or goal, then attempts to prove it by
searching for support information.
◦ Concern with proving some hypothesis or recommendation.
◦ If the number of goals < than the amount of data.
Selecting Control Strategies
INFERENCE
PROBLEM TYPE
BACKWARD FORWARD
Control Low High
Design Low High
Diagnosis High Low
Instruction High Low
Interpretation Avg. High
Monitoring Low High
Planning Low High
Prediction Avg. High
Prescription Avg. Avg.
Selection High Low
Simulation Low High
CONTROL STRATEGIES
Two common strategies:
1. Forward Chaining
2. Backward Chaining
Start with known Execute
Forward Chaining fact (data) topmost rule
When fired, new fact
•Also known as data-driven added to working
Any rule
technique. memory executed once
Forward Chaining
(Step-by-step)
Let the rules be : Database Database Database Database
Rule 1 : Y & D → B A B C D E A B C D E A B C D E A B C D E
Rule 2 : X & B & E Y X X L X L Y X L Y Z
Rule 3 : A X
Match Fire Match Fire Match Fire Match Fire
Rule 4 : C L Knowledge Base Knowledge Base Knowledge Base Knowledge Base
Y&D Z Y&D Z Y&D Z Y&D Z
Rule 5 : L & M N X&B&E Y X&B&E Y X&B&E Y X&B&E Y
A X A X A X A X
C L C L C L C L
Known facts: L&M N L&M N L&M N L&M N
A, B, C, D, E
Cycle 1 Cycle 2 Cycle 3
Forward Chaining
(Step-by-step)
Finally, Z is fired. Database Database Database Database
Disadvantage of FC: A B C D E A B C D E A B C D E A B C D E
• Many rules may executed that X X L X L Y X L Y Z
having nothing to do with the
goal
Match Fire Match Fire Match Fire Match Fire
Knowledge Base Knowledge Base Knowledge Base Knowledge Base
Y&D Z Y&D Z Y&D Z Y&D Z
X&B&E Y X&B&E Y X&B&E Y X&B&E Y
A X A X A X A X
C L C L C L C L
L&M N L&M N L&M N L&M N
Cycle 1 Cycle 2 Cycle 3
Forward Chaining (Summary)
Database Database Database Database
A B C D E A B C D E A B C D E A B C D E
X X L X L Y X L Y Z
Match Fire Match Fire Match Fire Match Fire
Knowledge Base Knowledge Base Knowledge Base Knowledge Base
Y&D Z Y&D Z Y&D Z Y&D Z
X&B&E Y X&B&E Y X&B&E Y X&B&E Y
A X A X A X A X
C L C L C L C L
L&M N L&M N L&M N L&M N
Cycle 1 Cycle 2 Cycle 3
Backward Chaining
Also known as goal-driven reasoning.
The knowledge base is If found, and IF
searched for the part matches
desired solution (goal) data, fire the rule.
If found, IF part no
matches, stack the rule,
set up new subgoal with
the IF part
Repeat the
process
Backward Chaining
(Step-by-step)
Pass 1 Pass 2 Pass 3
Database Database Database
A B C D E A B C D E A B C D E
? ?
Z Y X
Knowledge Base Knowledge Base Knowledge Base
Y & D Z Y & D Z Y & D Z
X & B & E Y X & B & E Y X & B & E Y
A X A X A X
C L C L C L
L & M N L & M N L & M N
Goal: Z Sub-Goal: Y Sub-Goal: X
Pass 4 Pass 5 Pass 6
Database Database Database
A B C D E A B C D E A B C D E
X X Y X Y Z
Match Fire Match Fire Match Fire
Knowledge Base Knowledge Base Knowledge Base
Y & D Z Y & D Z Y & D Z
X & B & E Y X & B & E Y X & B & E Y
A X A X A X
C L C L C L
L & M N L & M N L & M N
Sub-Goal: X Sub-Goal: Y Goal: Z
Backward Chaining
(Step-by-step)
Pass 1 Pass 2 Pass 3
Database Database Database
A B C D E A B C D E A B C D E
? ?
Z Y X
Knowledge Base Knowledge Base Knowledge Base
Y & D Z Y & D Z Y & D Z
X & B & E Y X & B & E Y X & B & E Y
A X A X A X
C L C L C L
L & M N L & M N L & M N
Goal: Z Sub-Goal: Y Sub-Goal: X
Pass 4 Pass 5 Pass 6
Database Database Database
A B C D E A B C D E A B C D E
X X Y X Y Z
Match Fire Match Fire Match Fire
Knowledge Base Knowledge Base Knowledge Base
Y & D Z Y & D Z Y & D Z
X & B & E Y X & B & E Y X & B & E Y
A X A X A X
C L C L C L
L & M N L & M N L & M N
Sub-Goal: X Sub-Goal: Y Goal: Z
Backward Chaining
(summary)
Pass 1 Pass 2 Pass 3
Database Database Database
A B C D E A B C D E A B C D E
? ?
Z Y X
Knowledge Base Knowledge Base Knowledge Base
Y&D Z Y&D Z Y&D Z
X&B&E Y X&B&E Y X&B&E Y
A X A X A X
C L C L C L
L&M N L&M N L&M N
Goal: Z Sub-Goal: Y Sub-Goal: X
Pass 4 Pass 5 Pass 6
Database Database Database
A B C D E A B C D E A B C D E
X X Y X Y Z
Match Fire Match Fire Match Fire
Knowledge Base Knowledge Base Knowledge Base
Y&D Z Y&D Z Y&D Z
X&B&E Y X&B&E Y X&B&E Y
A X A X A X
C L C L C L
L&M N L&M N L&M N
Sub-Goal: X Sub-Goal: Y Goal: Z
MEDIA ADVISOR (rule-
based)
Rule: 1 Rule: 3
if the environment is papers if the environment is machines
or the environment is manuals or the environment is buildings
or the environment is documents
or the environment is tools
or the environment is textbooks
then the stimulus_situation is 'physical
then the stimulus_situation is verbal object'
Rule: 2 Rule: 4
if the environment is pictures if the environment is numbers
or the environment is illustrations
or the environment is formulas
or the environment is photographs
or the environment is 'computer programs'
or the environment is diagrams
then the stimulus_situation is symbolic
then the stimulus_situation is visual
MEDIA ADVISOR (rule-
based)
Rule: 5 Rule: 7
if the job is lecturing if the job is writing
or the job is advising or the job is typing
or the job is counselling or the job is drawing
then the stimulus_response is oral then the stimulus_response is documented
Rule: 6 Rule: 8
if the job is building if the job is evaluating
or the job is repairing or the job is reasoning
or the job is troubleshooting or the job is investigating
then the stimulus_response is 'hands-on‘ then the stimulus_response is analytical
MEDIA ADVISOR (rule-
based)
Rule: 9 Rule: 11
if the stimulus_situation is 'physical object' if the stimulus_situation is visual
and the stimulus_response is 'hands-on' and the stimulus_response is documented
and feedback is required and feedback is not required
then medium is workshop then medium is videocassette
Rule: 10 Rule: 12
if the stimulus_situation is symbolic if the stimulus_situation is visual
and the stimulus_response is analytical and the stimulus_response is oral
and feed back is required and feedback is required
then medium is 'lecture - tutorial‘ then medium is ‘lecture – tutorial’
MEDIA ADVISOR (rule-
based)
Rule: 13 Perform forward chaining with
if the stimulus_situation is verbal following facts:
and the stimulus_response is analytical 1. Environment is machine
and feedback is required
2. Job is repairing
then medium is 'lecture - tutorial'
3. Feedback is required
Rule: 14
if the stimulus_situation is verbal
and the stimulus_response is oral
and feedback is required
Perform backward chaining to
then medium is 'role-play exercises’ prove the medium is workshop.
EXERCISE
You are given a set of rules for this question: Should we buy a house or not?
Rule 1: IF inflation is low,
THEN interest rates are low,
ELSE interest rates are high.
Rule 2: IF interest rates are high,
THEN housing prices are high.
Rule 3: IF housing prices are high,
THEN do not buy a house,
ELSE buy a house.
◦ Run backward chaining for goal do not buy house with a high inflation rate as
given.
◦ Run forward chaining with a low inflation rate as given.
EXERCISE
Forward chaining
◦ Fact: High inflation rate
◦ Start with Goal in R3, premise should be false in order to buy;
◦ Premise: "price of house" -- not known; go to R2 in its conclusion part; not known;
◦ Premise of R2: "interest rate" -- not known; go to R1 in conclusion--not known;
◦ Premise of R1: "inflation rate is high" -- fact. Then: interest rate is high, price of
house is high.
◦ Conclusion: Do not buy.
Backward chaining
◦ Fact: low inflation rate (R1) will lead to R2 and then to R3
◦ Conclusion: buy.
EXERCISE
Have everyone in the group consider the fairly easy task of doing
laundry. Individually, write down all the motions you use in sorting
clothes, loading the washer and dryer, and folding the clothes. Compare
notes.
Are any members of the group better at the task than others? For
simplicity, leave out details such as “go to the Laundromat.” Code the
doing-laundry facts in a rule base. How many exceptions to the rules did
you find?