You are on page 1of 20

Basic Architecture of an Expert System

1
• Knowledge base - contains the domain specific problem-solving
knowledge.
• Facts - represent what we know at any time about the problem
we are working at.
• Rules - represent relationships between the facts.
• Inference engine - is a general program that activates the knowledge
in the knowledge base.
• Interface enables the user to communicate with the expert system.

2
Rule-Based Expert Systems

• Based on the production system concept.

Rules
IF the engine is getting gas
AND the engine will turn over
THEN the problem is spark plugs
Facts
The engine is getting gas
Conclusion:
– action
– employ a particular model
– execute a procedure
– display a report
3
Inference Engine

(1) Selection of rule candidates: pattern matching

(2) Choice of one rule: conflict resolution

(3) Execution: deduction

4
• Backward chaining (goal driven): the inference engine works
backward from a conclusion to be proven to determine if there
are data in the workspace to prove the truth of the conclusion.

Example.
Rule base Workspace
R1: IF A AND B THEN D A,B
R2: IF B THEN C
R3: IF C AND D THEN E

5
Example. Expert system for diagnosing car problems.

Rule 1: IF the engine is getting gas


AND the engine will turn over
THEN the problem is spark plugs

Rule 2: IF the engine does not turn over


AND the lights do not come on
THEN the problem is battery or cables.

Rule 3: IF the engine does not turn over


AND the lights do come on
THEN the problem is the starter motor.

Rule 4: IF there is gas in the fuel tank


AND there is gas in the carburettor
THEN the engine is getting gas 6
Working space

The problem is X Rule 1


Rule 2
Rule 3
Rule 4

Working space

the engine is Rule 1


getting gas Rule 2
the engine will Rule 3
turn over Rule 4
the problem is
spark plugs
7
Working space

gas in fuel tank Rule 1


Rule 2
gas in carburettor Rule 3
the engine is Rule 4
getting gas
the engine will
turn over
the problem is
spark plugs

8
Explanation in Backward Chaining

Why?
gas in fuel tank?
yes
gas in carburettor?
yes
engine will turn over?
why
It has been established that:
1. the engine is getting gas,
therefore if
2. the engine will turn over,
then the problem is spark plugs

9
How?

how the engine is getting gas

This follows from rule 4:


IF there is gas in the fuel tank
AND there is gas in the carburettor
THEN the engine is getting gas
gas in fuel tank was given by the user
gas in carburettor was given by the user

10
Exercise.
Rule 1 IF blood pressure is likely to be high
THEN risk of heart failure is high
Rule 2 IF blood pressure is likely to be low
THEN risk of heart failure is low
Rule 3 IF alcohol consumption is high
AND patient salt intake is high
THEN blood pressure is likely to be high
Rule 4 IF alcohol consumption is low
AND patient salt intake is low
THEN blood pressure is likely to be low
Rule 5 IF units of alcohol per week are > 30
THEN alcohol consumption is high
Rule 6 IF units of alcohol per week are < 20
THEN alcohol consumption is low
Rule 7 IF units of alcohol per week are >= 20 AND <+ 30
THEN alcohol consumption is average

Goal: determine a patient's risk of heart failure


Questions: units of alcohol >30, 11
salt intake high
• Forward chaining (data driven): the inference engine works from
the initial content of the workspace towards the final conclusion.
Example.
Rule base Workspace
R1: IF A AND B THEN D A,B
R2: IF B THEN C
R3: IF C AND D THEN E

12
Example. Expert system for diagnosing car problems.

Working space
Rule 1
Rule 2
Rule 3
Rule 4

Working space

the engine Rule 1


turns over Rule 2
Rule 3
Rule 4
13
Working space

Rule 1
The engine is
Rule 2
getting gas
Rule 3
There is gas Rule 4
in the fuel tank
There is gas
in the carburettor
The engine
turns over

14
Explanation in Forward Chaining

Why?
• The current rule under consideration is presented.

How?
• More difficult than in backward chaining.

15
Example
R1: IF management competence is good
AND External credit rating is fair
AND Bank's credit rating is marginal
THEN Loan is rejected
R2: IF Loan type is seasonal
AND Profitability rating is high
AND Solvency rating is low
THEN Bank's credit rating is marginal
R3: IF Cash/current liabilities > 0.1
AND Tentative solvency rating is low
THEN Solvency rating is low
Bank's credit rating UNKNOWN
Cash/current liabilities 0.18
External credit rating FAIR
Loan SEASONAL
Loan type UNKNOWN
Management competence UNKNOWN
Profitability rating HIGH
Solvency rating UNKNOWN 16
Tentative solvency rating LOW
– Choosing between backward and forward chaining.

17
Hybrid Expert System Architecture

18
Example 1.
IF WEIGHT of MY-FORD > 3,000 pounds
THEN set DETOUR AROUND RICKETY BRIDGE

Example 2.
IF ?VEHICLE is instance-of AUTOMOBILES
AND ?VEHICLE has-a ?ENGINE
AND ?ENGINE is instance-of DIESEL
THEN set REFUEL of ?VEHICLE to TRUCKSTOP

19
SUMMARY

• The major components of an expert system are the knowledge base,


inference engine, and user interface.

• Rule-based expert systems are introduced.

• There are two approaches for controlling inference in rule-based


expert systems: forward chaining and backward chaining.

20

You might also like