SCHOLAR Study Guide
SQA Higher Information Systems
Unit 3a: Expert Systems
David Bethune
Heriot-Watt University
Tom Kelly
Heriot-Watt University
Tom Liversidge
Heriot-Watt University
Heriot-Watt University
Edinburgh EH14 4AS, United Kingdom.
First published 2005 by Heriot-Watt University
This edition published in 2007 by Heriot-Watt University
Copyright c 2007 Heriot-Watt University
Members of the SCHOLAR Forum may reproduce this publication in whole or in part for
educational purposes within their establishment providing that no profit accrues at any stage,
Any other use of the materials is governed by the general copyright statement that follows.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system
or transmitted in any form or by any means, without written permission from the publisher.
Heriot-Watt University accepts no responsibility or liability whatsoever with regard to the
information contained in this study guide.
SCHOLAR Study Guide Unit 3a: Information Systems
1. Information Systems
Printed and bound in Great Britain by Graphic and Printing Services, Heriot-Watt University,
Edinburgh.
Acknowledgements
Thanks are due to the members of Heriot-Watt University’s SCHOLAR team who planned and
created these materials, and to the many colleagues who reviewed the content.
We would like to acknowledge the assistance of the education authorities, colleges, teachers
and students who contributed to the SCHOLAR programme and who evaluated these
materials.
Grateful acknowledgement is made for permission to use the following material in the
SCHOLAR programme:
The Scottish Qualifications Authority for permission to use Past Papers assessments.
The Scottish Executive for financial support.
All brand names, product names, logos and related devices are used for identification purposes
only and are trademarks, registered trademarks or service marks of their respective holders.
i
Contents
1 Expert Systems in context 1
1.1 Prior Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 What is an expert system? . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 Implications of expert systems . . . . . . . . . . . . . . . . . . . . . . . 6
1.5 Other information Systems . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.6 Categories of expert systems . . . . . . . . . . . . . . . . . . . . . . . . 11
1.7 Classical expert systems . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.9 End of topic test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2 Expert System structure 19
2.1 Prior Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.3 Expert System components . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.4 Expert System shells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.5 Data, information and knowledge . . . . . . . . . . . . . . . . . . . . . . 23
2.6 Facts and rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.8 End of topic test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3 Knowledge Representation 29
3.1 Prior Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.3 Factor tables, rules and decision trees . . . . . . . . . . . . . . . . . . . 32
3.4 Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.6 End of topic test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
4 How Expert Systems Work 47
4.1 Prior Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
4.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
4.3 The components of an expert system . . . . . . . . . . . . . . . . . . . 50
4.4 Backward Chaining Systems . . . . . . . . . . . . . . . . . . . . . . . . 56
4.5 Forward Chaining Systems . . . . . . . . . . . . . . . . . . . . . . . . . 63
4.6 Comparison of forward and backward chaining systems . . . . . . . . . 68
4.7 Conflict resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.8 The RETE algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
4.9 Certainty Factors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
ii CONTENTS
4.10 Structuring a Knowledge Base . . . . . . . . . . . . . . . . . . . . . . . 79
4.11 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
4.12 Revision Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
5 Expert Systems Development 85
5.1 Prior Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
5.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
5.3 The development process . . . . . . . . . . . . . . . . . . . . . . . . . . 88
5.4 Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
5.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
5.6 End of topic test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
6 Constructing an Expert System 103
6.1 Prior Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
6.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
6.3 Knowledge Acquisition . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
6.4 Knowledge representation . . . . . . . . . . . . . . . . . . . . . . . . . . 109
6.5 System Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
6.6 Evaluating your system . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
6.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
6.8 Revision Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Glossary 113
Answers to questions and activities 116
1 Expert Systems in context . . . . . . . . . . . . . . . . . . . . . . . . . 116
2 Expert System structure . . . . . . . . . . . . . . . . . . . . . . . . . . 120
3 Knowledge Representation . . . . . . . . . . . . . . . . . . . . . . . . . 121
4 How Expert Systems Work . . . . . . . . . . . . . . . . . . . . . . . . . 134
5 Expert Systems Development . . . . . . . . . . . . . . . . . . . . . . . 137
6 Constructing an Expert System . . . . . . . . . . . . . . . . . . . . . . 139
c H ERIOT-WATT U NIVERSITY 2006
1
Topic 1
Expert Systems in context
Contents
1.1 Prior Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 What is an expert system? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3.1 Functions of an expert system . . . . . . . . . . . . . . . . . . . . . . . 4
1.3.2 Applications of expert systems . . . . . . . . . . . . . . . . . . . . . . . 5
1.4 Implications of expert systems . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4.1 Advantages and benefits . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4.2 Limitations and drawbacks . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.4.3 Legal implications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.4.4 Social and ethical implications . . . . . . . . . . . . . . . . . . . . . . . 8
1.5 Other information Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.5.1 Expert Systems vs Management/Executive Information Systems . . . . 9
1.5.2 Expert Systems vs Databases . . . . . . . . . . . . . . . . . . . . . . . 9
1.5.3 Deductive databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.6 Categories of expert systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.6.1 Expert systems for advice . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.6.2 Expert systems for classification . . . . . . . . . . . . . . . . . . . . . . 11
1.6.3 Expert systems for diagnosis . . . . . . . . . . . . . . . . . . . . . . . . 12
1.6.4 Expert systems for planning . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.6.5 Classifying some expert systems . . . . . . . . . . . . . . . . . . . . . . 13
1.7 Classical expert systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.7.1 DENDRAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.7.2 MYCIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.7.3 ONCOCIN and INTERNIST . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.7.4 PROSPECTOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.7.5 R1/XCON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.7.6 OPS5 and STRIPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.9 End of topic test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Learning Objectives
After studying this topic, you should be able to:
2 TOPIC 1. EXPERT SYSTEMS IN CONTEXT
describe the purpose of expert systems
identify some applications of expert systems
describe some advantages and benefits of expert systems
describe some limitations and drawbacks of expert systems
describe some ethical, social and legal implications of expert systems
differentiate between expert systems, management information systems,
databases and deductive databases
identify and give examples of the main categories of expert system
describe some classical expert systems
c H ERIOT-WATT U NIVERSITY 2006
1.1. PRIOR KNOWLEDGE 3
1.1 Prior Knowledge
This topic assumes you have no background knowledge of Expert Systems. If you
have already studied Expert Systems at Intermediate 2 level, this topic will include
some revision of that learning as well as new material related to the Higher syllabus
arrangements.
There are no revision questions for this topic.
1.2 Introduction
One day, you are not feeling well, so you arrange to visit your doctor. When you are
called into the consulting room, instead of your doctor sitting there, you are faced with
a computer terminal. On the screen is a prompt for your name. You enter your name,
and the computer asks you why you have come. It prompts you to enter your symptoms,
how long you have been feeling like this, whether you have had these symptoms before,
and many other questions.
After some time, the computer says that you are suffering from bubonic plague. It
advises you to avoid contact with other people and to stay in bed for the next 2 weeks.
The printer spits out a prescription for you to take to the chemist, and the computer
screen advises you to return for a further consultation next month ....
Instead of consulting your doctor (a human expert), you have just used a computer
"expert system".
Fiction? At the moment, yes, but perhaps not too far away into the future.
In this first topic, you will learn about the background to expert systems - what they are,
what they can do, their advantages and disadvantages, and look at some examples.
c H ERIOT-WATT U NIVERSITY 2006
4 TOPIC 1. EXPERT SYSTEMS IN CONTEXT
1.3 What is an expert system?
Expert systems were the first major economically successful product resulting from the
study of Artificial Intelligence. Early AI research soon realised that success would be
achieved by developing focussed products rather than trying to emulate every aspect of
human intelligence.
An expert system is a computer program which can do the job of a human expert. That
is, it can give reliable advice in a limited area of expertise (its domain), and can explain
its reasoning. It is able to interact with any user in the same way that you might consult a
human expert, such as a doctor or lawyer or a specialist in the flora of Northern Canada!
An expert system can be defined as "a computer program which can draw reasoned
conclusions from a body of knowledge in a restricted domain".
Exploring Whale Watcher
While out in a boat off the west coast of Scotland, you spotted a whale. It was quite
small (less than 6m long), had a clearly visible dorsal fin, but didn’t blow or show its
flukes when it dived. What kind of whale was it?
Try to find the answer by consulting Whale Watcher at:
[Link]
Identifying suitable expert system domains
Which of the following might be suitable topics for an expert system?
Q1: General medical diagnosis
Q2: Diagnosing skin conditions
Q3: Identifying birds
Q4: Predicting winners in horse races
Q5: Advising dairy farmers on feed
Q6: Specifying mainframe computer systems
1.3.1 Functions of an expert system
An expert system represents the knowledge of one or more domain experts.
Within the program, knowledge about the domain is coded using some type of
knowledge representation language (KRL). This is usually in the form of facts and
rules, stored in a knowledge base. A simple expert system may represent the knowledge
of a single expert, but most commercial expert systems represent the knowledge on
many experts. The fact that an expert system can contain the combined knowledge of
several experts is one of their main advantages.
The purpose of an expert system is to provide advice to a user through a process of
consultation. As you have already seen, the expert system can provide this consultation
through a series of questions to the user.
A good expert system will also be able to explain to the user:
c H ERIOT-WATT U NIVERSITY 2006
1.3. WHAT IS AN EXPERT SYSTEM? 5
why certain questions are being asked
how it reached its conclusion.
The Whale Watcher expert system can certainly provide advice helping a user to identify
a whale, but it does not have any explanatory features in its user interface.
1.3.2 Applications of expert systems
Expert systems have been developed for a wide range of domains. These include
systems giving medical, legal or financial advice, but the range of domains is increasing.
Expert System Case Studies (1)
Look up the following URLs and find out the domain of each of the expert systems
described.
Name of expert Find out at: Domain
system
Shyster [Link]
Expertax [Link]
[Link]
Coal Quality [Link]
Expert
summaries/cqe/[Link]
SARAH [Link]
[Link] (then search for
SARAH expert system).
Datacab [Link]
Congresos/2002%20IECON%[Link]
Expert System Case Studies (2)
Look up the case studies at the following web address:
[Link]
From those listed, choose 4 case studies. You should choose one each from the
following categories:
Medical advice
Legal advice
Financial advice
and any one other
For each case study you have chosen, write a very brief report (a couple of sentences)
which should state the name of the system, its domain of expertise, and one reason why
c H ERIOT-WATT U NIVERSITY 2006
6 TOPIC 1. EXPERT SYSTEMS IN CONTEXT
it was developed.
1.4 Implications of expert systems
When the first computers were developed, most people thought they would only have
very specialised applications, mainly for research. However, they soon made an impact.
Firstly, they changed the way clerical and administrative work is done in offices. Next,
they made huge changes to manufacturing industry, as robots and automated machines
took over from human workers.
Expert systems are beginning to have a similar impact on the "knowledge industries".
They have the potential to replace human experts, or (at least) to supplement them. In
this sub-topic, we will consider some of the advantages and disadvantages of expert
systems, and some of the social, ethical and legal implications of their use.
1.4.1 Advantages and benefits
Why bother developing systems to replace human experts? There are a number of good
reasons.
Firstly, human experts are not 100% reliable; they may disagree with each other, or
forget to take a crucial factor into account before making a decision.
Secondly, they may not always be available! In a small company, the only expert on
some area may be ill or on holiday just when some advice is required. Your doctor may
not be able to see you until next week. Even worse, an expert may move to another job
(taking his expertise with him) or may retire. A new employee may take years to build up
the same level of expertise that his predecessor had.
Thirdly, an expert may have unsurpassed knowledge in the field, but be hopeless at
explaining it to someone else.
Finally, expertise does not come cheaply. An expert in a specialised field can expect a
high salary.
An expert system can overcome all these weaknesses of human experts.
An expert system (properly programmed) should be 100% reliable; that is, it will never
forget to take something into account, and will never give advice which it cannot justify
from the information it has been given. It can combine the expertise of several experts,
so that even an expert can benefit from consulting an expert system. An expert system
is always available; you can even take it with you if you have a portable computer, or
you could consult an expert system over the Internet. Once the knowledge has been
coded into the system, it is effectively preserved, and will not be lost if the human expert
leaves or dies. An expert system does not get tired, so it can be used for training
purposes. An expert system should be programmed to explain and justify any advice
it gives. Although an expert system may be expensive to develop, once it is there, its
running costs should be low, so there will be economic benefits for the company.
Another benefit of expert systems is that they can actually extend knowledge. As experts
are required to clarify their knowledge and make it explicit during the development
c H ERIOT-WATT U NIVERSITY 2006
1.4. IMPLICATIONS OF EXPERT SYSTEMS 7
process, this may uncover new or previously hidden, implicit knowledge.
This is an impressive list of benefits, and explains why expert systems are becoming
increasingly useful. However, as with all information systems, there are also some
limitations and disadvantages.
Advantages and benefits
Write a summary of the advantages and benefits of expert systems.
1.4.2 Limitations and drawbacks
Although they can be extremely useful, expert systems can only operate within a limited
domain. Many real life problems require the application of knowledge from more
than one domain, or for "common sense" to be used alongside domain expertise. In
such cases, expert systems can provide useful guidance, but may not be able to give
complete advice. However, within the restricted domain of any particular expert system,
they can provide reliable and useful advice.
We have already noted that expert systems may appear economically beneficial.
However, the development costs for a significant expert system can be very high.
As we shall see later, development of an expert system requires a number of personnel
working with a domain expert. The knowledge must be extracted from the expert and
coded into an appropriate knowledge representation language. Then extensive testing
will be required, especially as the system may be used in a safety-critical or life-and-
death situation.
Once completed, there will be ongoing maintenance costs. The system may need
adaptive maintenance to run on other platforms; it may require corrective maintenance to
amend hidden faults in its reasoning, or to extend its knowledge base as new knowledge
is uncovered by domain experts.
Limitations and drawbacks
Write a summary of the limitations and drawbacks of expert systems.
1.4.3 Legal implications
The main issues relating to expert systems are to do with the legal implications which
could arise if the advice given by an expert system leads to damage to equipment, loss
of earnings or even loss of life.
Consider, for example, the use of an expert system giving weather advice to round-the-
world-yachtsmen (or women). What if, following the advice to sail, the boat is wrecked
and the crew are lost at sea. Who is to blame, and who accepts responsibility (which
may lead to massive financial implications)?
c H ERIOT-WATT U NIVERSITY 2006
8 TOPIC 1. EXPERT SYSTEMS IN CONTEXT
Who is to blame
Either on your own, or with another student, brainstorm a list of people who might be
responsible when an expert system gives advice which leads to loss of life or damage
to property.
1.4.4 Social and ethical implications
There are also ethical issues about replacing human experts with expert systems,
leading to de-skilling and loss of jobs. On the other hand, expert systems are still being
developed, so there are new jobs for knowledge engineers too.
How would you feel about consulting an expert system rather than a doctor? You might
prefer the anonymity if you were embarrassed about the nature of your illness. Besides,
recent research has shown that medical diagnosis systems can give correct advice in
around 70% of cases. Are you happy with that level of good advice? No?
Other research shows that general practitioners only make a correct diagnosis in under
40% of cases!
Medical Expert Systems
Take a look at the following on-line medical diagnosis systems.
[Link]
[Link]
What precautions do they take to prevent any ethical or legal issues arising from users
consulting these systems?
1.5 Other information Systems
An expert system stores information, and can be queried to produce answers to
questions, often in the form of advice. This makes it similar in some ways to other
information systems that you have probably already met while studying the mandatory
units for this course, such as
management information systems (MIS)
c H ERIOT-WATT U NIVERSITY 2006
1.5. OTHER INFORMATION SYSTEMS 9
executive information systems
decision Support Systems
databases
Identifying the characteristics of information systems
Check your understanding of these 3 types of information system by completing the
table. If not sure, refer to the Using Information Unit in Higher Information Systems.
Management Information Executive Information Decision Support System
System System
Word Bank:
used at different levels used at strategic level used in planning, leading,
within an organisation organising and controlling
an organisation
analyse, compare and presents summaries analyse and report on
identify trends and what’s recorded in data
outcomes processing system
supports the tactical level suitable for unique and hypothetical modelling and
of the organisation non-recurring queries forecasting
generates customised used interactively
reports
1.5.1 Expert Systems vs Management/Executive Information Systems
Management and executive information systems are used at the strategic level within
and organisation. They produce reports based on data held in databases and data
processing systems. Managers and executives then make decisions based on the
reports obtained. They are largely non-intelligent systems. The intelligence comes from
the staff, who make decisions based on their expertise.
Expert systems can be used at different levels within an organisation, depending on
the domain of the program. For example, a machine fault diagnosis expert system
could be used at an operational level; a legal advisory system may be used at a
management level; a financial planning expert system may be used at a strategic level.
Expert systems can be considered to be intelligent systems, as they contain the coded
expertise of human experts.
Expert systems do not replace other information systems. They are simply another type
of tool available to support staff, providing reliable advice whenever it is needed.
1.5.2 Expert Systems vs Databases
Expert systems have similarities to databases.
c H ERIOT-WATT U NIVERSITY 2006
10 TOPIC 1. EXPERT SYSTEMS IN CONTEXT
A database contains stored data, which can be queried to find answers to questions.
An expert system contains coded knowledge, which can be consulted to obtain
advice.
There are two main differences - how the data/knowledge is stored, and how it is
extracted.
In a database, the data is stored in a tightly structured format, involving tables, records,
fields and relations. In an expert system, knowledge is stored as facts and rules, coded
in a knowledge representation language.
In a database, information is extracted by the user devising queries and reports which
will display the information required. In an expert system, advice and explanations are
provided by the system as a result of a consultation process.
Comparing databases and expert systems
Draw 2 simple diagrams to show the similarities and differences between databases and
expert systems.
1.5.3 Deductive databases
Recent developments in database and expert system technology have led to the
development of a system known as a deductive database, which combines features
of both.
A deductive database system is a database system which can make deductions based
on stored facts and rules . Deductive databases are similar to expert systems, but a
deductive database uses a database as its knowledge base. Expert systems usually
get their facts and rules from a real expert in their problem domain, whereas deductive
databases find their knowledge directly from the data.
A deductive database combines the inferencing power of an expert system with the
ability of a database to store large amounts of structured data.
c H ERIOT-WATT U NIVERSITY 2006
1.6. CATEGORIES OF EXPERT SYSTEMS 11
1.6 Categories of expert systems
So far, we have described expert systems as providing advice. However, there are many
different types of expert system, which can be classified under 4 broad headings: expert
systems which can be used for:
advice
classification
diagnosis
planning
1.6.1 Expert systems for advice
Expert systems can be designed to offer advice on a wide range of topics. Typical
examples include systems which advise
oil companies where to drill for oil with the best chance of success
company accountants on how to reduce their tax liabilities
industrial engineers on how to get the greatest efficiency from their machines
investors on which stocks and shares to buy or sell
Target 10 Online Consultant
Explore some of the on-line expert systems that you will find at
WebPages/OnlineConsultant?OpenDocument
Now answer these questions:
Q7: Who are likely to be the users of these on-line expert systems?
Q8: Who would be the domain experts who provided the expertise to create the
systems?
Q9: What knowledge domain do they cover?
Q10: What benefits might they provide for the users?
Q11: What limitations might the users find?
1.6.2 Expert systems for classification
Expert systems can be used for classifying (or identifying) objects.
Typical examples include systems which can classify
types of rock for geologists
the spectra of stars for astrophysicists
types of stone age tool for archaeologists
student’s assessments for lecturers
c H ERIOT-WATT U NIVERSITY 2006
12 TOPIC 1. EXPERT SYSTEMS IN CONTEXT
Identifying animals
You should find a simple classification expert system at
[Link]
Compare this with the Whale Watcher which you looked at earlier, which you will find at
[Link]
Now answer these questions about each of the expert systems:
Q12: Who is likely to be a user of this on-line expert system?
Q13: Who would be the domain experts who provided the expertise to create the
system?
Q14: What knowledge domain does it cover?
Q15: What benefits might it provide for the users?
Q16: What limitations might the users find?
1.6.3 Expert systems for diagnosis
Expert systems can are ideal for diagnosis. Typical examples include systems which
can diagnose:
medical problems (in a restricted domain)
machine faults
industrial plant fault analysis
instrument failures on the International Space Station
My car won’t start!
Consult the on-line expert system that you will find at:
[Link]
Now answer these questions:
Q17: Who are likely to be the users of this online expert systems?
Q18: Who would be the domain experts who provided the expertise to create the
system?
Q19: What knowledge domain does it cover?
Q20: What benefits might it provide for the users?
Q21: What limitations might the users find?
The expert system you have consulted is only a demo system. However, real systems
similar to this do exist. For example, the SBDC (Service Bay Diagnostic System) used
by Ford can diagnose a huge range of Ford car engine problems. You can read more
about it at [Link]
c H ERIOT-WATT U NIVERSITY 2006
1.7. CLASSICAL EXPERT SYSTEMS 13
1.6.4 Expert systems for planning
Most people think of expert systems being used for diagnosis, advice or classification.
However, many real world expert systems are used for planning.
One example is the PlanIT system used by KLM airlines to plan their staffing rotas. You
can explore this system at [Link]
1.6.5 Classifying some expert systems
Now that you have seen an example of each of the 4 main categories of expert system,
you should be able to classify some case studies.
Expert System Case Studies
Explore the case studies to be found at [Link]
Read the descriptions of the expert systems, and classify each of the expert system into
one of the 4 categories:
advice
classification
diagnosis
planning
1.7 Classical expert systems
The number of expert systems in use has grown enormously over the last few years,
and it would be impossible to list them all. However, you are expected to know a little
about several "classical" expert systems that are well-known, and played a significant
role in the development of expert system technology.
You should be able to classify, identify the domain and describe the main characteristics
of
DENDRAL
MYCIN
ONCOCIN
R1/XCON
INTERNIST
PROSPECTOR
OPS5
STRIPS
c H ERIOT-WATT U NIVERSITY 2006
14 TOPIC 1. EXPERT SYSTEMS IN CONTEXT
1.7.1 DENDRAL
DENDRAL is generally considered to be the first expert system. It was developed in
1971 by Edward Feigenbaum of Stanford University, sponsored by NASA. NASA were
planning an unmanned space probe to the planet Mars, and wanted a system to identify
chemical molecules in Martian soil samples by analysing mass spectrometer results.
Feigenbaum, along with Bruce Buchanan, invented a way of turning the chemical
expertise of Joshua Lederberg into a computer program in the form of rules.
The system was so successful that it was marketed commercially in the USA.
DENDRAL is essentially a classification system, and uses a method of reasoning called
forward chaining, which we will study in a later topic. It is reckoned that DENDRAL
took over 20 person-years to develop. Assuming a typical salary of 20K, this means
that DENDRAL cost almost half a million pounds to develop. Later, the use of expert
system shells enabled the development cost of expert systems to be kept lower.
1.7.2 MYCIN
MYCIN was Feigenaum’s next project, which he began in 1972, and completed in 1976.
Once again, like DENDRAL, it was based on the encoding of expert knowledge in the
form of rules. MYCIN, in fact, contained around 450 rules. This time the knowledge
domain was the diagnosis of blood infections. MYCIN proved to be very effective,
providing correct diagnoses at a level similar to specialist doctors, and performing
significantly better than unspecialised junior doctors.
MYCIN incorporated three new features not present in DENDRAL. These were
it included an explanation facility, which could justify any diagnosis it gave
it included certainty factors, to reflect the uncertainty in the knowledge domain
it separated the knowledge base from the reasoning system, allowing the
development of an expert system shell, called EMYCIN.
c H ERIOT-WATT U NIVERSITY 2006
1.7. CLASSICAL EXPERT SYSTEMS 15
Another difference from DENDRAL was that MYCIN used a type of reasoning called
backward chaining. We will study the difference between forward and backward
chaining in a later topic.
You can find out more about MYCIN, including some sample consultations, at
[Link]
1.7.3 ONCOCIN and INTERNIST
ONCOCIN and INTERNIST were two other early medical expert systems.
ONCOCIN was a rule-based medical expert system, designed to assist doctors with
the treatment of cancer patients receiving chemotherapy. ONCOCIN, developed in
he 1980s, was one of the first decision support systems which attempted to model
decisions and sequencing actions over time, combining diagnosis with planning.
Research results show that ONCOCIN could match or improve on the performance of
medical specialists.
INERNIST was a more general diagnosis system, developed in 1974, whose knowledge
base contained over 100,000 links between diseases and their symptoms. Its purpose
was to diagnose multiple internal diseases in the same patient and so assist doctors in
rural health clinics and other isolated locations without access to advanced diagnostic
equipment. The main long-term benefit of INTERNIST was its rule-base, which was
adapted and used in many later medical expert systems.
1.7.4 PROSPECTOR
PROSPECTOR was another early expert system, developed in the late 1970s at
Stanford Research Institute. It incorporated the expertise of nine experts in the field of
geology, and it purpose was to advise mineral exploration companies on the best places
to search for valuable deposits. PROSEPCTOR uses a combination of techniques,
including rules and pattern matching to existing models of successful exploration. It
incorporates uncertainty using Bayes method of combining uncertainties (an alternative
to the use of certainty factors).
PROSPECTOR proved its worth in 1980 when it identified Mount Tolman in Washington
State as a likely site for a molybdenum deposit. Subsequent drilling by a mining
company confirmed a deposit of ore worth over $100 million.
You can find out more about PROSPECTOR at
[Link]
1.7.5 R1/XCON
Like PROSPECTOR, XCON proved to be a highly successful commercial program.
XCON began its life as a research project called R1. Its domain of expertise was the
configuration of DEC VAX mainframe computer systems.
In the early 1980s, most computer systems were still hugely expensive and complex,
and designed to meet the exact needs of the client. The design and specification of
these systems was a very lengthy and complex task, often taking many hours or even
days. XCON was able to do the same task in seconds, so saving money for DEC. The
output from XCON included a series of diagrams, listing the components and how they
c H ERIOT-WATT U NIVERSITY 2006
16 TOPIC 1. EXPERT SYSTEMS IN CONTEXT
should be assembled to meet the customer’s needs. XCON also improved the accuracy
of orders. Humans configured orders correctly 70% of the time, XCON has an accuracy
of 98%.
XCON used forward chaining based on a knowledge base of thousands of rules. Due
to the nature of the domain, there was no need to represent uncertainty in XCON. The
rules were written in the knowledge representation language OPS5.
1.7.6 OPS5 and STRIPS
Neither OPS5 nor STRIPS are expert systems, but they are included here as they played
a significant role in the development of expert systems.
OPS5 is not an expert system, like those described earlier in this topic. It is a
knowledge representation language used to code the knowledge base for forward
chaining expert systems. Its most famous application was in the XCON expert system
used by DEC to configure VAX computers.
STRIPS is a methodology, for representing information about planning systems.
STRIPS-style planning originated in the Stanford Research Institute Problem Solver
(STRIPS) Project of the early 1970s. STRIPS was a general problem solver that gave
instructions to SHAKEY the robot as it navigated its way through different rooms, moving
objects from one room to another. It has influenced the development of expert systems
which are used for planning.
c H ERIOT-WATT U NIVERSITY 2006
1.8. SUMMARY 17
Classifying classical systems
Complete the following table, by putting the words below into the correct cells in the
table:
name domain year type characteristic
DENDRAL
MYCIN
ONCOCIN
INTERNIST
PROSPECTOR
XCON
Word Bank:
domain year type characteristic
configuring VAX 1980s diagnosis and Saved money by being faster
computer planning and more accurate than human
systems designers
Diagnosing 1971 planning Used forward chaining
blood disorders
Multiple medical Late 1970s diagnosis Produced a very useful large
conditions knowledge base of diseases
and symptoms
Mineral 1974 diagnosis Combined sequencing of
exploration actions with diagnosis
Soil sample Early 1980s classification Uses Bayesian probability to
analysis represent uncertainty
Cancer 1972 advice Used backward chaining,
treatment uncertainty factors and
separated knowledge base from
inference engine
1.8 Summary
the purpose of expert systems is
– to represent the knowledge of a domain expert
– to provide advice to a user through a consultation
– to provide explanations (how and why)
expert systems are used in a wide variety of applications, including medical, legal
and financial advice
advantages of expert systems include
– preservation of expertise
– dissemination of expert knowledge
– training
c H ERIOT-WATT U NIVERSITY 2006
18 TOPIC 1. EXPERT SYSTEMS IN CONTEXT
– combining the expertise of several experts
limitations of expert systems include
– restricted domain
– high development and maintenance costs
expert systems may lead to de-skilling, but most are used to support, rather than
replace, human experts
the legal responsibility for any harm resulting from the use of expert systems is
generally agreed to lie with the user of the system
expert systems differ from management and executive information systems in that
they are active or intelligent system
like management and executive information systems, expert systems are used for
decision support
a deductive database combines the storage of a database with the reasoning of
an expert system
four important categories of expert system are advice, classification, diagnosis
and planning
classical expert systems include
– MYCIN (diagnosing blood disorders)
– ONCOCIN (planning treatment for cancer sufferers)
– DENDRAL (classifying molecules from mass spectrometer results)
– PROSPECTOR (identifying sites for mineral explorations)
– XCON (specifying VAX computer systems)
– INTERNIST (diagnosing multiple medical conditions)
OPS5 is a knowledge representation language which can be used to create
forward chaining expert systems
STRIPS is a planning methodology
1.9 End of topic test
An online assessment is provided to help you review this topic.
c H ERIOT-WATT U NIVERSITY 2006
19
Topic 2
Expert System structure
Contents
2.1 Prior Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.3 Expert System components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.4 Expert System shells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.5 Data, information and knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.5.1 Data and Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.5.2 Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.6 Facts and rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.8 End of topic test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Learning Objectives
After studying this topic, you should be able to:
Identify and describe the main components of an expert system:
– Knowledge base
– Inference engine
– User interface
Explain what is meant by an expert system shell
Explain the difference between data, information and knowledge
Describe the main features of a knowledge base: facts and rules
Explain the need for a knowledge representation language (KRL)
20 TOPIC 2. EXPERT SYSTEM STRUCTURE
2.1 Prior Knowledge
This topic assumes you have had some experience of consulting expert systems, and
know that they are programs which can represent the knowledge of one or more
human experts, which provide advice to a user through a consultation, and can give
explanations to support their conclusions.
Before you study this topic, you should be able to
describe the functions of an expert system
Check your understanding by trying the revision questions.
Revision Questions
Q1: An expert system is a type of computer hardware.
a) true
b) false
Q2: An expert system represents the knowledge of one of more experts.
a) true
b) false
Q3: An expert system stores data in the same way as a database.
a) true
b) false
Q4: A user consults an expert system using queries.
a) true
b) false
Q5: An expert system provides advice through a process of consultation with the user.
a) true
b) false
Q6: An expert system can provide an explanation of how it reached its conclusion.
a) true
b) false
Q7: All expert systems are used for diagnosis.
a) true
b) false
Q8: Expert systems may be used in legal, financial and medical contexts.
a) true
b) false
Q9: Expert systems can be considered as intelligent programs.
c H ERIOT-WATT U NIVERSITY 2006
2.2. INTRODUCTION 21
a) true
b) false
Q10: The domain of an expert system is the expert who provided the knowledge.
a) true
b) false
2.2 Introduction
In the previous topic, you explored a number of simple on-line expert systems, and read
about a few important historical expert systems, so you should have a good idea of what
an expert system is like. Now we are going to take a look at how they are constructed
and what makes them work.
2.3 Expert System components
An expert system consists of 3 parts:
the user interface, allowing the user to input information in response to questions
generated by the system. The user interface will also be able to give advice and
(very importantly) explain why it is giving that advice.
the knowledge base, consisting of all the facts and information about the topic,
and all the rules and relationships between these facts. This information will have
been provided by one or more domain experts, and converted into an appropriate
form by a knowledge engineer.
the inference engine, which searches the knowledge base, generates questions
to the user, and uses the rules and relationships which have been programmed
into the knowledge base to come to conclusions which can be reported to the
user.
c H ERIOT-WATT U NIVERSITY 2006
22 TOPIC 2. EXPERT SYSTEM STRUCTURE
When an expert system is being used, the inference engine will generate new facts and
rules from the knowledge base and from the user’s responses. These are all held in
working memory.
2.4 Expert System shells
An expert system shell is an expert system with no knowledge base. It consists only
of a user interface and an inference engine. Expert system shells are used to create
expert systems. The programmer only has to code the knowledge base, as the user
interface and inference engine already exist.
It would be possible for a programmer to develop an expert system using a standard
software development environment. The programmer would need to develop a suitable
user interface, providing a means of dialogue between the system and the user. This
could be done using standard tools and libraries.
It would also be necessary somehow to code all the knowledge (facts, rules,
relationships) and include them in the software as a knowledge base. This might be
done using a knowledge representation language like Prolog.
Finally, it would be necessary to develop software which could interact with both the
user and the knowledge base to draw conclusions from the knowledge base - an
inference engine. Developing all 3 modules of this system would be a major and
complex software development task.
The breakthrough in the development of expert systems was the realisation that
these three components could be developed as independent modules, and that the
same user interface and inference engine could be used to develop many expert
systems. A user interface and inference engine without a knowledge base is called
an expert system shell.
Using an expert system shell to develop an expert system may be less flexible than
developing an expert system from scratch - for example, you have to use the user
interface provided - but it certainly reduces the time taken and the skills required. It
also reduces the chance of errors, as the user interface and inference engine will have
c H ERIOT-WATT U NIVERSITY 2006
2.5. DATA, INFORMATION AND KNOWLEDGE 23
been tested.
There are many expert system shells available, and you will use one later in this unit to
construct your own expert system. Here are some you might come across:
Intermodeller
Jess
CLIPS
Expert Builder
Flex
Visirule
MIKE
Sentence completion - expert systems
On the Web is a sentence completion task on Expert Systems. You should now complete
this task.
2.5 Data, information and knowledge
In this unit, you will often come across the three terms
Data
Information
Knowledge
In normal conversation, these are often used more or less interchangeably. However, in
the context of information systems, they each have their own specialised meaning, and
it is important to use them correctly.
2.5.1 Data and Information
Data can be regarded as raw facts and figures which can be coded, structured, and
organised for processing by computer. When processed, formatted and put in a context
with meaning, the data becomes information that can be interpreted and understood.
c H ERIOT-WATT U NIVERSITY 2006
24 TOPIC 2. EXPERT SYSTEM STRUCTURE
Today we live in an information age. The ’information explosion’ of the late 1990’s
witnessed the exponential growth of computer networks, digital telephony and satellite
communications to transmit data and information to a worldwide audience. Wireless
connectivity to the Internet, e-commerce and advances in mobile phone technologies
ensure that present day society is now sharing vast amounts of information and data
involving email, graphics, animations, audio files and video clips.
Data can best be defined as facts, statistics, figures, numbers, records, details,
observations, evidence etc. with little or no organisation. Sometimes this is called ’raw
data’ that is then processed by the computer into information.
Information can thus be described as data, processed and organised in such a manner
as to give it a sense of meaning.
c H ERIOT-WATT U NIVERSITY 2006
2.6. FACTS AND RULES 25
2.5.2 Knowledge
Let’s summarise what we know so far:
Data is raw, unprocessed facts and figures. Information is the result of data that is
processed to give it meaning and structure.
What about knowledge?
Knowledge is the result of applying reasoning to information. For example, by combining
pieces of information, new facts and conclusions can be derived.
This allows decisions to be made. This is what makes expert systems so much
more useful than simple databases (which deal with data) or management information
systems (which turn data into information). An expert system can reason using
information, leading to new learning and conclusions. An expert system is a knowledge-
based system.
2.6 Facts and rules
How is knowledge represented within an expert system?
The knowledge of the human domain expert is converted into a knowledge
representation language (KRL) by a knowledge engineer. It is mainly represented in
the form of facts and rules within the knowledge base of the expert system.
There are many different rule formats and KRLs which may be used.
Here are some examples:
c H ERIOT-WATT U NIVERSITY 2006
26 TOPIC 2. EXPERT SYSTEM STRUCTURE
Forward Rule in Intermodeller
IF colour = bronze AND
size (mm) = 18 AND
shape = round AND
symbol = fish THEN
value = 1H.
Backward Rule in Intermodeller
value = 1H IF
colour = bronze AND
size (mm) = 18 AND
shape = round AND
symbol = fish.
Forward Rule with certainty factor from MYCIN
IF the infection is pimary-bacteremia
AND the site of the culture is one of the sterile sites
AND the suspected portal of entry is the gastrointestinal tract
THEN there is suggestive evidence (0.7) that infection is bacteroid.
Rules in Prolog
A rule in JESS
(defrule library-rule-1
(book (name ?X) (status late) (borrower ?Y))
(borrower (name ?Y) (address ?Z))
=
(send-late-notice ?X ?Y ?Z))
Later in this Unit, you will construct some expert systems of your own. These are likely to
be fairly small systems, with 15 - 20 rules in the knowledge base. However, you should
remember that real expert systems may have thousands of interlinked rules and facts in
their knowledge bases.
c H ERIOT-WATT U NIVERSITY 2006
2.7. SUMMARY 27
2.7 Summary
the 3 main components of an expert system are:
– the knowledge base - containing all the facts and rules about the domain
– the inference engine - which carries out the reasoning based on the facts and
rules in the knowledge base, and provides conclusions and explanations
– the user interface - through which the user communicates with the system
an expert system shell is an expert system with no knowledge base
the use of an expert system shell reduces the time and cost of developing an
expert system
data is unprocessed facts and figures
information is data that has been processed to give it meaning and context
knowledge is the result of reasoning based on information
a knowledge base consists mainly of facts and rules
facts and rules are expressed using a knowledge representation language (KRL)
2.8 End of topic test
An online assessment is provided to help you review this topic.
c H ERIOT-WATT U NIVERSITY 2006
28 TOPIC 2. EXPERT SYSTEM STRUCTURE
c H ERIOT-WATT U NIVERSITY 2006
29
Topic 3
Knowledge Representation
Contents
3.1 Prior Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.3 Factor tables, rules and decision trees . . . . . . . . . . . . . . . . . . . . . . . 32
3.3.1 Creating a factor table - the Coins of Upper Scholaria . . . . . . . . . . 32
3.3.2 Creating rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.3.3 Using a decision tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.3.4 Order of questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.3.5 Eating out in Upper Scholaria . . . . . . . . . . . . . . . . . . . . . . . . 38
3.3.6 Sailing Ships . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.4 Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.4.1 Propositional (zero order) logic - introduction . . . . . . . . . . . . . . . 40
3.4.2 Propositional (zero order) logic - notation . . . . . . . . . . . . . . . . . 41
3.4.3 Predicate (1st order) logic - introduction . . . . . . . . . . . . . . . . . . 43
3.4.4 Predicate (1st order) logic - examples . . . . . . . . . . . . . . . . . . . 44
3.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.6 End of topic test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Learning Objectives
After studying this topic, you should be able to:
Represent knowledge in the form of
– factor tables
– forward rules
– backward rules
– decision trees
State the advantages and disadvantages of each form of knowledge
representation
Represent simple statements using
– Propositional (zero order) logic
– Predicate (1st order) logic
30 TOPIC 3. KNOWLEDGE REPRESENTATION
3.1 Prior Knowledge
This topic does not assume any subject-specific knowledge. However, it would be helpful
to have studied and understood the idea that an expert system can represent knowledge
in the form of facts and rules in its knowledge base. These facts and rules are written
using a knowledge representation language (KRL) .
Before you study this topic, you should be able to
state that an expert system represents knowledge in its knowledge base in the
form of facts and rules
recognise a typical knowledge base rule
Check your understanding by trying the revision questions.
Revision Questions
Q1: In which part of an expert system is the expert knowledge stored?
a) the inference engine
b) the knowledge base
c) the user interface
d) the shell
Q2: Which of these is NOT a rule?
a) IF sun is shining THEN go to the beach
b) Go to the beach IF sun is shining
c) go(beach):-sun(shining).
d) the sun is shining
Q3: A KRL is
a) a type of expert system
b) a language used to represent knowledge
c) a method of reasoning used in expert systems
d) a person who provides expert knowledge for a system
3.2 Introduction
This topic is all about how knowledge can be represented.
In normal life, knowledge is often represented using natural language, such as a news
report:
c H ERIOT-WATT U NIVERSITY 2006
3.2. INTRODUCTION 31
New Orleans starts to remove dead
Some 25,000 body bags have been sent to the New Orleans area, as authorities
begin to recover the dead in the city.
The official death toll stands at 83 in the city, including 30 elderly people found in a
flooded nursing home. But thousands are feared to have died. Bodies remain in the
stagnant flood waters as health fears grow for those remaining in the city.
Three people are also known to have died from contaminated flood water, in the
aftermath of Hurricane Katrina. They are believed to have contracted infections after
coming into contact with cholera-related bacteria in the toxic waters.
New Orleans’ mayor has ordered the forced evacuation of the city, but up to 10,000
residents may still remain.
[taken from [Link] 08/09/05]
However, this form of knowledge representation is often ambiguous, incomplete or
unclear.
Q4: From the news report above, give 3 examples of knowledge that is "ambiguous,
incomplete or unclear".
Knowledge can also be represented clearly in the form of diagrams, like this:
Internal
Processor
Contol
Bus
Unit
PC Address Bus
MAR
IR
Memory
Data Bus
MDR
GP
Registers
ALU Data Path
Control Path
Processor
Figure 3.1: Typical microprocessor design
The problem with diagrams is that they are not easily manipulated by an expert system,
as it is not possible to reason with a diagram.
c H ERIOT-WATT U NIVERSITY 2006
32 TOPIC 3. KNOWLEDGE REPRESENTATION
The problem of representing knowledge clearly and unambiguously is overcome by the
use of knowledge representation languages (KRLs) . In this topic, we will consider
how to convert knowledge presented as normal text into a representation which is
appropriate for an expert system’s knowledge base.
3.3 Factor tables, rules and decision trees
Starting from a paragraph or two of natural language, we will make use of a
factor table to extract clear and unambiguous knowledge. We will then use the factor
table to convert this knowledge into rules. Finally, we will look at the benefits of
presenting this knowledge as a decision tree.
3.3.1 Creating a factor table - the Coins of Upper Scholaria
As a travel agent, you are often asked by travellers about how to identify the coins
of Upper Scholaria. You decide it would be useful to develop an expert system which
customers could consult directly. You phone the local school to ask if any pupils studying
Higher Information Systems would like a temporary post as a knowledge engineer.
Shortly afterwards, Lucinda arrives. She explains that she has been studying Expert
Systems at school and will be pleased to develop the expert system for you.
Lucinda begins by analysing the problem. She searches the internet for websites about
Scholaria and finds some information about its monetary system. She makes notes
about the different types of coins. She is not clear about the difference between a 20H
coin and a 50H coin, so she phones a domain expert - the receptionist at La Hotel
Granda in the capital city of Scholaria. This soon clarifies the difference.
Here is a summary of Lucinda’s notes:
There are 7 different coins, with values 1H, 6H, 10H, 20H, 50H, 1J and 6J.
The 1H and 6H coins are made from bronze. All the rest are silver, except for the 6J
which is "two tone" (bronze in the centre with a silver edge around it).
The 1H, 6H, 10H and 50H are normal round coins. The 20H and 6J are 7-sided, and
the 1J is a bizarre triangular coin.
c H ERIOT-WATT U NIVERSITY 2006
3.3. FACTOR TABLES, RULES AND DECISION TREES 33
The 3 lowest value coins are all 18mm diameter, the 20H and 50H are 22mm, the 1J
(triangular) is 25mm across, and the 6J is the largest at 30mm across.
All ths coins have symbols on them. There is a fish on the 1H, 20H and 50H coins. The
10H has a flower, the 1J has a mountain, and the 6J has a bird.
Next, as the design stage of her project, she constructs a factor table of the information
she has discovered. Here is the partly completed table:
value colour size(mm)
1H bronze 18
6H bronze
10H
20H
50H
1J
6J
Scholarian coins factor table
Complete the table to include all the relevant information Lucinda has gathered.
value colour size(mm) shape symbol
1H
6H
10H
20H
50H
1J
6J
The column titles (value, colour, size ...) are known as attributes. For each coin, each
attribute has a value. So we have turned the information into 35 attribute-value pairs.
For example, the attribute-value pairs for the 1H coin are:
value = 1H
colour = bronze
size(mm) = 18
shape = round
symbol = fish
The next stage is to use the factor table to create rules.
3.3.2 Creating rules
There are 2 basic types of rules used in the knowledge representation languages of
Expert System Shells. These are known as:
Forward Rules (of the form IF condition(s) THEN conclusion)
c H ERIOT-WATT U NIVERSITY 2006
34 TOPIC 3. KNOWLEDGE REPRESENTATION
Backward Rules (of the form conclusion IF condition(s))
Each row of the factor table can be converted into a rule. The rules for the 1H coin might
look like this (the exact syntax depends on the expert system shell chosen):
Forward rule:
IF colour = bronze AND
size(mm) = 18 AND
shape = round AND
symbol = fish
THEN value = 1H.
Backward rule:
value = 1H IF
colour = bronze AND
size(mm) = 18 AND
shape = round AND
symbol = fish.
Scholarian coins rules
Write a complete set of forward rules to represent the knowledge about the 7 types of
coin.
Write a complete set of backward rules to represent the knowledge about the 7 types
of coin.
3.3.3 Using a decision tree
A decision tree is simply a graphical representation of the information in the factor table.
Here is a partly completed decision tree for the Scholarian coins:
c H ERIOT-WATT U NIVERSITY 2006
3.3. FACTOR TABLES, RULES AND DECISION TREES 35
colour
bronze silver two tone
size (mm) size (mm) size (mm)
18 18 22
shape shape shape
round
symbol
There are 3 colours, so there are 3 branches from the start at the top of the tree. This
point is called the root node.
The next level represents the size information. All the bronze coins are 18mm, so no
further branching of the leftmost branch. Silver coins come in 3 sizes, so there will be 3
branches from the middle branch (2 of them are shown above).
Completing a decision tree for the Scholarian coins
Copy and complete the tree. It is complete when the nodes at the bottom of the tree are
the names of coins.
Another decision tree
Draw a decision tree for the Scholarian coins, using the following order of attributes:
symbol, shape, colour, size.
3.3.4 Order of questions
We have seen that the Scholarian coins knowledge base can be represented in a variety
of ways. Even when using a single method, the representation depends on the order of
the attributes. This will be reflected by the order in which questions are asked when the
expert system is consulted.
Using a decision tree also helps to show which questions do NOT need to be asked.
Consider the original version of the Scholarian coins decision tree:
c H ERIOT-WATT U NIVERSITY 2006
36 TOPIC 3. KNOWLEDGE REPRESENTATION
colour
bronze silver two tone
size (mm) size (mm) size (mm)
18 18 22 25 30
shape shape shape shape shape
round round 7-sided round triangular 7-sided
symbol symbol symbol symbol symbol symbol
fish bird flower fish fish mountain bird
value = 1H value = 6H value = 10H value = 20H value = 50H value = 1J value = 6J
Based on this tree a consultation with the system might look like this:
System: What colour is the coin?
User: silver
System: What size is the coin?
User: 18mm
System: What shape is the coin?
User: round
System: What symbol is on the coin?
User: a flower
System: it is 10H coin
Q5: However, some of these questions are unnecessary. Can you see which ones,
and why?
You can see this clearly on the decision tree, as there are no branching nodes below the
size node on the branch leading to the 10H coin.
c H ERIOT-WATT U NIVERSITY 2006
3.3. FACTOR TABLES, RULES AND DECISION TREES 37
Pruning a decision tree
Simplify the decision tree by removing unnecessary nodes (ones where no user input
will be required).
Using this pruned decision tree, it is possible to simplify the rules that we created earlier:
Original list of rules Simplified set of rules
IF colour = bronze AND IF colour = bronze AND
size ( mm ) = 18 AND symbol = fish
shape = round AND THEN value = 1H.
symbol = fish
THEN value = 1H. IF colour = bronze AND
symbol = bird
IF colour = bronze AND THEN value = 6H.
size ( mm ) = 18 AND
shape = round AND IF colour = silver AND
symbol = bird symbol = flower
THEN value = 6H. THEN value = 10H.
IF colour = silver AND IF colour = silver AND
size ( mm ) = 18 AND size ( mm ) = 22 AND
shape = round AND shape = 7 sided
symbol = flower THEN value = 20H.
THEN value = 10H.
IF colour = silver AND
IF colour = silver AND size ( mm ) = 22 AND
size ( mm ) = 22 AND shape = round
shape = 7 sided AND THEN value = 50H.
symbol = fish
THEN value = 20H.
IF colour = silver AND
size ( mm ) = 22 AND
shape = round AND
symbol = fish
THEN value = 50H.
c H ERIOT-WATT U NIVERSITY 2006
38 TOPIC 3. KNOWLEDGE REPRESENTATION
Original list of rules Simplified set of rules
IF colour = silver AND IF colour = silver AND
size ( mm ) = 25 AND size ( mm ) = 25
shape = triangular AND THEN value = 1J.
symbol = mountain
THEN value = 1J. IF colour = two tone
THEN value = 6J.
IF colour = two tone AND
size ( mm ) = 30 AND
shape = 7 sided AND
symbol = bird
THEN value = 6J.
As you can see, the graphical representation of the knowledge in a decision tree can
help a knowledge engineer to decide on the order and complexity of rules, attributes
and questions in an expert system to make it as efficient as possible. For our simple
knowledge base about coins, efficiency is not very important, but a commercial expert
system may have thousands of rules, and is that case, efficiency is vital.
Decision trees are also useful in the branch of Artificial Intelligence known as machine
learning, where they can be used to structure knowledge so that a system can add new
knowledge to its knowledge base.
The main disadvantage of a decision tree when compared to a factor table is that it takes
up a lot of space, and it is more difficult to ensure that it is complete. For this reason,
decision trees are more useful alongside factor tables, rather than as an alternative to
them.
Some expert system shells (such as Visirule) allow you to create expert systems using
decision trees.
Some expert system shells (such as Intermodeller) allow you to convert a knowledge
base between representations. Intermodeller allows you to create a knowledge base
using factor tables, forward rules, backward rules or decision trees, and to convert
automatically between them.
Converting representations using Intermodeller (Optional)
If you have access to Intermodeller, enter the Scholarian coins knowledge base into the
shell by cutting and pasting the forward rules version given in the answer to the earlier
task in this topic. Then use the Transform command to convert it into each of the other
representations.
3.3.5 Eating out in Upper Scholaria
Now that you have mastered the complicated system of money used in Upper Scholaria,
you need some information about how to spend it. There are several eating places in
c H ERIOT-WATT U NIVERSITY 2006
3.3. FACTOR TABLES, RULES AND DECISION TREES 39
town, and you need to decide where to go. You chat to some locals, and note down their
recommendations...
"I like the Hobbit’s Hole, because it is cheap, serves traditional Scholarian food, and its
in the town centre. The décor is basic, and there is usually live music playing."
"You should try the Grand Palace Hotel. The food is haute cuisine, and it is just on the
edge of the town. It is a very stylish place, and often has a pianist playing classical
music in the background. It is very expensive, though ..."
"Depends what you want... The Scholarium is good if you like eating seafood. Its in
the centre of town, and the prices are reasonable. The only thing about it is that the
background music is modern popular stuff, which I don’t like much."
"Cheap and cheerful? Go down to The Seven Sided Coin in the town centre. It’s fast
food, low prices, no annoying music, and the décor is plain."
"For a classy eating experience, you could go to The Mountain Top or The Blue Villa.
They are both a few mile out of town, but are both very smart places to eat. The Mountain
Top serves traditional Scholarian food at reasonable prices, while The Blue Villa has a
wide range of international cuisine. It is definitely more expensive that The Mountain
Top."
Scholarian Cuisine Knowledge Base
Part 1
Use the information received from the locals to create a factor table.
Part 2
Convert each line of the factor table into a forward rule. (If you have Intermodeller, don’t
cheat by transforming the table automatically - but you can use it to check you solution
afterwards)
Part 3
Rewrite these rules as backward rules
Part 4
Create a decision tree to represent the knowledge.
Part 5
Prune the decision tree to remove unnecessary nodes.
Part 6
Use the pruned decision tree to simplify the set of backward rules you created earlier.
Part 7
If you have access to an expert system shell like Intermodeller, you can enter your
knowledge base into the shell, then consult it to make sure it gives the correct answers.
c H ERIOT-WATT U NIVERSITY 2006
40 TOPIC 3. KNOWLEDGE REPRESENTATION
3.3.6 Sailing Ships
If you have access to the Intermodeller shell, you will have seen how rules, factor tables
and decision trees can all be used to reperesent a knowledge base.
If not, you will find the next example particularly useful to consider.
Sailing Ships Example
Look at the Sailing Ships example at [Link]
Compare how the knowledge base is represented as
knowledge base rules
a decision tree
a decision (factor) table
attributes list.
Consult the system by choosing the "search" option.
3.4 Logic
Underlying the knowledge representation methods we have considered, there is a more
fundamental concept - logic.
Expert systems use logical reasoning to achieve conclusions based on the knowledge
in their knowledge base combined with the information provided by the user. The key
term in the last sentence is logical. Expert systems are reliable and useful because
their reasoning is based on the fundamental principles of logic.
Formal logic allows rules of reasoning to be defined which are independent of the
content. This is essential in an expert system built from a shell, where the inference
engine is completely independent from the knowledge base.
In this sub-topic, we will explore two types of logic, known as
Propositional (zero order) logic, and
Predicate (1st order) logic.
These each have their own notation and rules, and would require lengthy study to
understand them fully. In this course, we only need a basic understanding of them.
3.4.1 Propositional (zero order) logic - introduction
Propositional logic deals with statements (propositions) that are either true or false.
For example, these are all valid propositions:
a square has 4 sides
c H ERIOT-WATT U NIVERSITY 2006
3.4. LOGIC 41
George Washington was President of France
there is a cherry tree in the garden of Holyrood House
They are valid propositions because each one of them can be shown to be either true
or false:
The first one is definitely true.
The second is definitely false.
I don’t know whether the last is true or false, but it would be possible to go to
Holyrood House and find out.
Q6: Why are these 3 statements NOT valid propositions in propositional logic?
1. everything in this topic is untrue
2. spinach tastes better than cabbage
3. they are intelligent
3.4.2 Propositional (zero order) logic - notation
Propositional logic uses special symbols for common logical operators. The four that
you need to know are:
logical operator symbol
implies
and
or
not
(Note: the symbol ~ is also sometimes used for NOT)
For example, using these symbols, we can write
statement in English using logic symbols
If P is true then Q is true
P Q
If P and Q are true, then R is true
P Q R
If P or Q is true, then R is true PQR
If P is not true, then Q is true PQ
If P is true, then Q is not true PQ
In these examples, the letters P, Q and R can represent any propositions.
So, for example, if
P = I am hungry
Q = There is food in the fridge
R = The shops are open
S = I can eat
c H ERIOT-WATT U NIVERSITY 2006
42 TOPIC 3. KNOWLEDGE REPRESENTATION
T = I have money to spend
Then we could write:
P Q S as a shorthand for "If I am hungry and there is food in the fridge, then I can
eat", or
S meaning "If I am hungry and there is not food in the fridge, then I can not
P Q
eat"
Q7: S mean?
What would Q (R T)
Propositional logic is useful because it makes it possible to carry out reasoning using
symbols rather than complex sentences. There are rules which can be applied,
regardless of the content of the propositions.
For example, if A B is true,
then we can’t say for sure anything about the truth of BA,
but BA is certainly true.
Similarly, if AB is false,
then we can’t say for sure anything about the truth of BA,
but BA is certainly false.
Let’s apply this to the 2 propositions,
A = a Scholarian flag is a square
B = a Scholarian flag has 4 equal sides.
In this case AB is true (a Scholarian flag is a square, so it must have 4 equal sides).
What about BA? It may be true, or it may be false (If a Scholarian flag has 4 equal
sides, then it might be a square, but it might be a rhombus)
c H ERIOT-WATT U NIVERSITY 2006
3.4. LOGIC 43
The rules of logic state that B
A must be true. So If a Scholarian flag does NOT
have 4 equal sides, then it is NOT a square.
Logic example 1
Apply the reasoning above to the 2 propositions:
A = Bouncer is a dog
B = Bouncer is an animal
Representing statements using propositional logic
Let S represent "It is snowing"
Let F represent "It is below freezing"
Let G represent "I go out to play"
How would you represent the following statements:
a) It is not snowing
b) It is snowing and it is below freezing
c) If it is below freezing I do not go out to play
d) I go out to play if it is snowing
e) If it is snowing and it is not below freezing, I go out to play
f) If it is snowing or it is not below freezing, I go out to play
If you are interested in learning more about propositional logic, you will find a useful
tutorial at [Link]
However, this goes well beyond what you need to know for this course.
3.4.3 Predicate (1st order) logic - introduction
Propositional logic is very useful, and forms the basis for almost all other types of
logic. However, it has one serious weakness - it only deals with whole propositions
or sentences. The following example illustrates this:
Let P represent "All teachers are human"
Let Q represent "David is a teacher"
Let R represent "David is human"
In propositional logic, we can write that PQR is true (if all teachers are human, and
David is a teacher, then David is human).
What about Anne? or Seamus? or Khalid?
In propositional logic, we would need to write a new rule for each person. We have no
way of making a proposition general.
c H ERIOT-WATT U NIVERSITY 2006
44 TOPIC 3. KNOWLEDGE REPRESENTATION
It would be more useful, if we could write a rule to represent the statement "if all teachers
are human, and X is a teacher, then X is a human", where X can represent anyone at
all. Propositional logic does not allow this, but predicate (1st order) logic does.
For predicate logic, we will learn a new symbol:
Symbol Meaninig
for all
(this symbol is known as the universal quantifier)
Using this symbol, we can write P : teacher(P) human(P) which means, "for all P, it is
true that if P is a teacher, then P is human"
P can represent David, or Anne, or Seamus, or Khalid, or anyone else. We have a
general statement that applies to any named individual. This is equivalent to the use of
variables.
The programming language Prolog (Programming in Logic) is an implementation of
predicate logic, and forms the basis for many expert systems. In Prolog, the statement
"if P is a teacher, then P is human" could be written as human(P) :- teacher(P).
Predicates can have a single item within the bracket, for example: human(P) or
human(david). (Note that in Prolog, variables always begin with an upper case letter)
Predicates can also have 2 (or more) items within the bracket, for example: lives(david,
scotland) could be used to represent the statement "David lives in Scotland".
3.4.4 Predicate (1st order) logic - examples
In this course, you are only required to be able to represent simple statements using
predicate logic. We will use the symbols as well as the universal quantifier .
To relate this to expert system development, we will also learn to represent simple
statements in Prolog.
Study these examples:
English statement Predicate logic Prolog representation
representation
Bouncer is a dog with a dog(Bouncer) dog(bouncer),
long tail haslongtail(Bouncer) haslongtail(bouncer)
If Bouncer is a dog, he can dog(Bouncer) canbark(bouncer):-
bark. canbark(Bouncer) dog(bouncer)
All dogs can bark x : dog(x) canbark(x) canbark(X) :- dog(X).
No humans live on Mars x : human(x) not(livesonMars(X) :-
livesonMars(x) human(X).
Even number are whole x : whole(x) even(X) :- whole(X),
numbers divisible by 2 divbytwo(x) even(x) divbytwo(X).
Every boy likes football x : boy(x) likes(x, likes(X, football) :- boy(X).
football)
Two people are brothers if x,y : father(f,x) brothers(X,Y) :- father(F,X),
they have the same father father(f,y) brothers(x,y) father(F,Y).
c H ERIOT-WATT U NIVERSITY 2006
3.5. SUMMARY 45
Representing statements using predicate logic
Complete this table:
English statement Predicate logic representation
Dundee is a city with no castle
If Dundee is a city, it has many
inhabitants.
All cities have many inhabitants.
There are no cities on Mars.
A bungalow is a house with one floor.
Every woman likes flowers
Two people are cousins if they have the
same grandparent
Representing statements using Prolog
Complete this table:
English statement Prolog representation
Dundee is a city with no castle
If Dundee is a city, it has many
inhabitants.
All cities have many inhabitants.
There are no cities on Mars.
A bungalow is a house with one floor.
Every woman likes flowers
Two people are cousins if they have the
same grandparent
You probably found the last two tasks pretty difficult. Don’t worry! Any expert systems
you build will be built using an expert system shell, so you don’t need to figure out any
complicated logic, or write any Prolog.
If you are interested in finding out more about predicate logic, you will find a useful
tutorial at
[Link]
If you are interested in finding out more about programming in Prolog, you should look
at the SCHOLAR Higher Computing Artificial Intelligence Unit.
3.5 Summary
In everyday experience, knowledge is represented by natural language or by
diagrams, but these are often unclear, ambiguous or incomplete
c H ERIOT-WATT U NIVERSITY 2006
46 TOPIC 3. KNOWLEDGE REPRESENTATION
To represent knowledge in a clear and unambiguous way, knowledge engineers
use
– factor tables (showing attributes and their values in rows and columns)
– forward rules (IF conditions THEN conclusion)
– backward rules (conclusion IF conditions)
– decision trees (a graphical representation)
Factor tables are compact and easy to complete
Forward and backward rules can be written in knowledge representation
languages (KRLs) recognised by many expert system shells
Decision trees take up a lot of space, but are a useful way of seeing redundant
knowledge, allowing knowledge engineers to make systems more efficient
Simple true/false statements can be represented and manipulated using
propositional (zero order) logic
More general statements (including variables) can be represented using predicate
(1st order) logic
The special symbols used in logic include
– (implies)
– (and)
– (or)
– (not)
– (for all) (in predicate logic only)
The programming language Prolog is an implementation of predicate logic, and
can be used to create exeprt systems
3.6 End of topic test
An online assessment is provided to help you review this topic.
c H ERIOT-WATT U NIVERSITY 2006
47
Topic 4
How Expert Systems Work
Contents
4.1 Prior Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
4.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
4.3 The components of an expert system . . . . . . . . . . . . . . . . . . . . . . . 50
4.3.1 The knowledge base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
4.3.2 The user interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
4.3.3 The inference engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
4.4 Backward Chaining Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
4.4.1 Using an AND/OR graph . . . . . . . . . . . . . . . . . . . . . . . . . . 58
4.4.2 How a backward chaining system works . . . . . . . . . . . . . . . . . . 59
4.4.3 Advantages of backward chaining . . . . . . . . . . . . . . . . . . . . . 63
4.5 Forward Chaining Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
4.5.1 How a forward chaining system works . . . . . . . . . . . . . . . . . . . 65
4.5.2 Advantages of forward chaining system . . . . . . . . . . . . . . . . . . 67
4.6 Comparison of forward and backward chaining systems . . . . . . . . . . . . . 68
4.6.1 An inferencing tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
4.6.2 Summary of backward chaining . . . . . . . . . . . . . . . . . . . . . . . 68
4.6.3 Summary of Forward Chaining . . . . . . . . . . . . . . . . . . . . . . . 69
4.7 Conflict resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.7.1 Rule ordering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.7.2 Recency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.7.3 Specificity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.7.4 Refractoriness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
4.7.5 Data ordering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
4.7.6 Context limiting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
4.7.7 Summarising conflict resolution strategies . . . . . . . . . . . . . . . . . 74
4.8 The RETE algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
4.9 Certainty Factors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
4.9.1 Representing uncertainty . . . . . . . . . . . . . . . . . . . . . . . . . . 75
4.9.2 Calculating Certainty Factors for simple rules . . . . . . . . . . . . . . . 76
4.9.3 Calculating Certainty Factors for complex rules . . . . . . . . . . . . . . 78
4.9.4 Other methods of representing uncertainty . . . . . . . . . . . . . . . . 79
4.10 Structuring a Knowledge Base . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
4.10.1 Version 1 - simple rules . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
48 TOPIC 4. HOW EXPERT SYSTEMS WORK
4.10.2 Version 2 - multi-value questions . . . . . . . . . . . . . . . . . . . . . . 81
4.10.3 Version 3 - using parameterised rules . . . . . . . . . . . . . . . . . . . 82
4.10.4 Checking what your KRL can do . . . . . . . . . . . . . . . . . . . . . . 83
4.11 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
4.12 Revision Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Learning Objectives
After studying this topic, you should be able to:
describe the main functions of the user interface - displaying advice,
communicating with the user, justifying questions and answers
explain that the main function of an inferencing engine is to determine the order in
which rules are applied, and questions asked
describe and compare the two main inferencing methods
– backward chaining
– forward chaining
describe the advantages an disadvantages of forward and backward chaining
describe the main characteristics of a forward chaining system
– working memory
– conflict set
– conflict resolution
explain the need for conflict resolution in forward chaining systems
explain the following conflict resolution strategies
– rule ordering
– recency
– specificity / size ordering
– refractoriness
– data ordering
– context limiting / setting a rule agenda
description of the RETE algorithm
represent uncertainty using certainty factors
calculate the certainty factor of a conclusion
c H ERIOT-WATT U NIVERSITY 2006
4.1. PRIOR KNOWLEDGE 49
4.1 Prior Knowledge
This topic assumes a basic understanding of the structure of expert systems.
Before you study this topic, you should be able to
describe the main components of an expert system
– knowledge base, containing facts and rules
– inference engine
– user interface
distinguish between an expert system and an expert system shell
represent knowledge in the form of
– forward rules
– backward rule
Check your understanding by trying the following revision questions.
Revision Questions
Q1: Which part of an expert system searches the knowledge base, applies the rules
and reaches conclusions?
a) the expert system shell
b) the knowledge base
c) the user interface
d) the inference engine
Q2: In which part of an expert system would you find stored facts and rules?
a) the inference engine
b) the expert system shell
c) the knowledge base
d) the user interface
Q3: What are the 2 main parts of an expert system shell?
a) inference engine and knowledge base
b) inference engine and user interface
c) user interface and knowledge base
d) facts and rules
Q4: The following is found in the knowledge base of an expert system:
IF sky is blue AND
wind speed 5
THEN it will not rain today
This is an example of
a) a forward rule
c H ERIOT-WATT U NIVERSITY 2006
50 TOPIC 4. HOW EXPERT SYSTEMS WORK
b) a backward rule
c) a fact
d) a decision tree
Q5: The following is found in the knowledge base of an expert system:
it will not rain today IF
sky is blue AND
wind
This is an example of
a) a forward rule
b) a backward rule
c) a fact
d) a decision tree
4.2 Introduction
You have now consulted several example expert systems, and have explored how
knowledge can be stored in the knowledge base of a system. In this topic, you will study
how the system actually works - how it reaches conclusions and how it communicates
with the user.
We will go into more depth regarding the structure of an expert system, and have a
particularly close look at forward chaining systems. We will also study how an expert
system can represent and manipulate uncertain knowledge.
4.3 The components of an expert system
You should already know that an expert system consists of 3 parts:
the user interface, allowing the user to input information in response to questions
generated by the system. The user interface will also be able to give advice and
c H ERIOT-WATT U NIVERSITY 2006
4.3. THE COMPONENTS OF AN EXPERT SYSTEM 51
(very importantly) explain why it is giving that advice.
the knowledge base, consisting of all the facts and information about the topic,
and all the rules and relationships between these facts. This information will have
been provided by one or more domain experts, and converted into an appropriate
form by a knowledge engineer.
the inference engine, which searches the knowledge base, generates questions
to the user, and uses the rules and relationships which have been programmed
into the knowledge base to come to conclusions which can be reported to the
user.
Let’s now take a closer look at these three components.
4.3.1 The knowledge base
The knowledge base uses a knowledge representation language (KRL) to represent
knowledge in the form of facts and rules.
In the two knowledge bases you have worked with so far - the Scholarian coins, and
Where to eat in Scholaria - the number of rules has been quite limited. There have
been less than 10 rules in each case. Also, each individual rule has been capable of
generating a conclusion. There is no need for more than one rule to reach a conclusion.
In "real" exert systems, the knowledge base is likely to be much more complex.
Firstly, a commercial expert system is likely to have a very large knowledge base. For
example, XCON (the expert system used by DEC to configure mainframe computer
systems) had around 17,500 rules in its knowledge base. PIERS, a medical expert
system used to interpret clinical pathology reports at St. Vincent Hospital in Sydney,
has over 2000 rules.
Secondly, all but the most simple expert systems use rule chaining. That means that a
conclusion can only be determined by the use of several rules.
For example, an expert system for classifying animals might have the following rules in
its knowledge base:
Rule 1:
You are looking at a tiger
IF family is mammal
AND feeding type is carnivore
AND size(m) 2
AND appearance is yellow an black stripes
If all the rules are like this, then the system will start by asking the user "Does the animal
belong to the mammal family?"
If the user is not an expert, they may not know the answer. Similarly, the second question
could be "Is the feeding type carnivore?"
If the user cannot answer these questions, then the system will be unable to provide any
c H ERIOT-WATT U NIVERSITY 2006
52 TOPIC 4. HOW EXPERT SYSTEMS WORK
advice.
However, it is likely that a well designed expert system will have further rules, such as:
Rule 2:
Family is mammal
IF body covering is hair
AND gives birth to live young
Rule 3:
Feeding type is carnivore
IF eats meat
Now the exert system can proceed further. The first rule can use these other two rules
to determine whether or not the animal is a mammal, and whether the feeding type is
carnivore. This is an example of rule chaining.
There are two types of rule chaining - called forward chaining and backward chaining.
The example above shows backward chaining. We will study the difference between
forward and backward chaining later in this topic.
Note that some expert systems do not use rules to represent knowledge. Alternatives
include
frame-based systems
model-based systems, and
case-based systems
However, a knowledge of these types are not required for this unit.
4.3.2 The user interface
The user interface of an expert system is very important. It has 4 main functions. These
functions are
to ask questions and obtain answers from the user
to display advice or conclusions
to explain why it is asking a question
c H ERIOT-WATT U NIVERSITY 2006
4.3. THE COMPONENTS OF AN EXPERT SYSTEM 53
to explain how it reached a conclusion
Asking questions and obtaining answers
During a consultation, the expert system will require extra information from the user. It
may do so by displaying a question, and waiting for the user’s response. This can be
done in a variety of ways. Early expert systems, such as MYCIN, used a text-based
interface (see
[Link] for
an example). Most modern expert systems use a graphical user interface. Users may
be able to answer questions by typing a response, selecting options from a menu, or
clicking on an icon. In systems which allow for uncertainty, the user interface should
allow the user to give an indication of the certainty of the response being given.
Whatever method is used, the user’s response is added by the user interface to the
system’s working memory, where it can be processed by the inference engine.
Explaining why a question is being asked
During the consultation, the user may wonder why a particular question is being asked.
It may seem to have no relevance to the situation, or it may be that the user needs to
know why the question is being asked in order to give a useful answer. Most expert
systems provide this facility. This facility is also useful when testing the system. If the
system asks an unexpected question during testing, the tester should be able to ask
the system why it is asking this question. This is also useful when an expert system is
being used to train a person. Understanding why certain questions are asked helps the
trainee to get a better understanding of the important aspects of the subject.
Displaying advice or conclusions
At the end of a consultation with the user, the inference engine should be able to reach a
conclusion based on the knowledge in the knowledge base combined with the answers
provided by the user. The conclusion (or advice) is displayed to the user by the user
interface. The first conclusion may not be the only conclusion, so the user interface will
usually allow the user to ask for more advice or conclusions. In systems which allow for
uncertainty (which we will study later in this topic), the user interface should display the
certainty factor associated with the conclusion.
Explaining how the conclusion was reached
In everyday conversation, if someone makes a confident statement, the usual response
will be "How do you know that?" The same is true for expert systems. If the system
can provide an explanation of how it reached its conclusion, this will give additional
confidence to the user. This is also useful when an expert system is used for training
purposes, and during system testing.
c H ERIOT-WATT U NIVERSITY 2006
54 TOPIC 4. HOW EXPERT SYSTEMS WORK
The How? and Why? explanation facility are also called How? and Why? justification
features. Because they are such an important part of a good expert system user
interface, the user interface is sometimes called the explanatory interface.
Investigating User interfaces
Consult the following on-line demonstration expert systems. If you cannot access all
of these, your tutor may be able to provide you with some other expert systems to use
instead.
Whale watcher
Spa pool adviser
Wine advisor
Sailing ships
On-line doctor
Yourdiagnosis
Tree Identifier
Complete the table below to show the features of the user interface of each expert
system.
c H ERIOT-WATT U NIVERSITY 2006
4.3. THE COMPONENTS OF AN EXPERT SYSTEM 55
Expert System Graphical? Certainty Why? How?
factors? explanations explanations
Whale watcher
Spa Pool
adviser
Car won’t start
Sailing ships
On-line doctor
Your diagnosis
Tree Identifier
4.3.3 The inference engine
The inference engine is the intelligent part of the expert system. It makes use of the
knowledge represented in the knowledge base, and any information provided by the
user during a consultation. Using these raw materials, it is able to generate conclusions.
The inference engine determines the order in which rules are applied, and therefore the
order in which the user is asked questions. The order is especially important with large
commercial systems, where the number of rules is very large, and where rule chaining
is required.
There are two main types of chaining used by inference engines. These are known as
backward chaining and forward chaining.
Consider a patient who is unwell, and goes to visit the doctor. As soon as the doctor
looks at the patient, he thinks, "This person looks like they are suffering from high
blood pressure". So, the doctor gets out his instruments to measure the patient’s blood
pressure. It is normal! So the doctor thinks again. "Maybe the patient has a throat
infection". So the doctor asks the patient to "Open wide" and has a look down his throat.
But no, it looks quite normal...
Another patient consults a different doctor. This time, the patient sits down, and the
doctor asks the patient why he has come to see him. The patient replies, "I have been
having a lot of stomach pains recently". "Exactly where do you feel the pains?", asks the
doctor. The patient points high up on his chest. "When do you get the pain?", asks the
doctor. And so the consultation continues until the doctor has figure out what is wrong.
The first doctor described above is using backward chaining. He starts with a guess
(or hypothesis) about the patient, and asks questions and uses his knowledge to test
the hypothesis. If it is wrong, he tries another hypothesis, and so on.
The second doctor is using forward chaining. Instead of making a guess, this doctor
tries to build up as much information as he can. After some time, he will have enough
information to make a diagnosis, based on his expert knowledge.
Each system has its own advantages and disadvantages, depending on the context,
and this is also true of expert system inference engines. Some use backward chaining,
while others use forward chaining, and some use a combination of the two methods.
c H ERIOT-WATT U NIVERSITY 2006
56 TOPIC 4. HOW EXPERT SYSTEMS WORK
4.4 Backward Chaining Systems
Backward chaining systems operate by making a hypothesis, and then using rules to
determine whether or not the hypothesis is true. Because of this, they are well suited to
goal-driven problems.
Here is an example of a backward chaining system. The left hand column will be used
to explain the operation of the system. The middle and right hand columns illustrate an
implementation of the system in Intermodeller.
(Notice that the rules are written in the format of backward rules. This makes it easier to
follow the operation of a backward chaining system, but it is possible to have a backward
chaining system where the rules are written in the format of forward rules.)
Rules (numbered for Intermodeller easy Intermodeller standard
reference) b-rules backward rules
1. I can travel to work I can travel to work IF I can travel to work = true IF
IF I can walk to work I can walk to work I can walk to work = true
OR IF I can get the bus to I can travel to work IF I can travel to work = true IF
work
I can get the bus to work I can get the bus to work =
OR IF I can drive to work. true
I can travel to work IF
I can travel to work = true IF
I can drive to work
I can drive to work = true .
2. I can walk to work I can walk to work IF I can walk to work = true IF
IF the distance to work 3 the distance to work is less "the distance to work is less
miles than 3 miles AND than 3 miles" = true AND
AND I am fit I am fit AND I am fit = true AND
AND I have enough time. I have enough time I have enough time = true
3. I can get the bus to work I can get the bus to work IF I can get the bus to work =
true IF
IF there is a bus stop near there is a bus stop near
home home AND "there is a bus stop near
home" = true AND
AND IF there is a bus at there is a bus at the right
the right time time AND "there is a bus at the right
time" = true AND
AND IF I can afford the I can afford the fare
fare. I can afford the fare = true
c H ERIOT-WATT U NIVERSITY 2006
4.4. BACKWARD CHAINING SYSTEMS 57
Rules (numbered for Intermodeller easy Intermodeller standard
reference) b-rules backward rules
4. I can drive to work I can drive to work IF I can drive to work = true IF
IF I have access to a car I have access to a car AND I have access to a car =
true AND
AND IF the car is useable the car is useable AND
"the car is useable" = true
AND IF I have a valid I have a valid driving
AND
driving license. license
I have a valid driving
license = true
5. I have access to a car I have access to a car IF I have access to a car =
true IF
IF I own a car I own a car . I have access
to a car IF I own a car = true
OR IF I can borrow a car.
I can borrow a car
6. The car is useable the car is useable IF "the car is useable" = true
IF
IF the car is working the car is working AND
"the car is working" = true
AND IF the car has enough the car has enough petrol
AND
petrol
the car has enough petrol =
true
Rules (numbered for Intermodeller easy Intermodeller standard
reference) b-rules backward rules
7. The car has enough the car has enough petrol the car has enough petrol =
petrol IF true IF
IF the tank is at least the tank is at least half - full "the tank is at least half -
half-full full" = true
the car has enough petrol
OR IF I have enough IF the car has enough petrol =
money to fill the tank. true IF
I have enough money to fill
the tank I have enough money to fill
the tank = true
the car has enough petrol
IF the car has enough petrol =
true IF
the tank is at least half - full
"the tank is at least half -
the car has enough petrol
full" = true
IF
the car has enough petrol =
I have enough money to fill
true IF
the tank
I have enough money to fill
the tank = true
c H ERIOT-WATT U NIVERSITY 2006
58 TOPIC 4. HOW EXPERT SYSTEMS WORK
4.4.1 Using an AND/OR graph
To see how backward chaining works, it is useful to show these rules in the form of a
type of decision tree known as an AND/OR graph:
1 I can travel
to work
2 I can walk
to work
4 I can drive
to work
I have a
The distance to
work <3 miles
I am fit
I have
enough 5 I have access
to a car
6 the car is
usable
valid driving
time licence
I own a car I can borrow
a car the car is
working
7 the car has
enough petrol
I can get
3 the bus
to work
the tank is I have enough
at least money to fill
half full the tank
There is a bus There is a bus at I can afford
stop near home the right time the fare
The curved links represent an AND condition in a rule - where all of the linked conditions
have to be satisfied. Where there is no curve shown on the AND/OR graph, the
conditions are linked with an OR condition. For example:
I have access to a car IF I won a car OR I can borrow a car (no curve on the diagram)
The car is useable IF the car is working AND the car has enough petrol (curve on
diagram)
How does the system work?
Step 1
Using rule 1, "I can travel to work" is the first hypothesis. It will be true if any of its 3
conditions is true. The first condition is "I can walk to work"
Step 2
The rule base is searched from top to bottom for a rule which matches this condition.
Rule 2 matches this, so is considered next. Rule 2 will be true if all 3 of its conditions
are true. The first condition is "the distance to work 3 miles"
Step 3
Working memory is searched to see if this is a known fact. There is no such fact in
working memory. The rule base is searched from top to bottom for a rule which matches
this condition. There are no matching rules. The system therefore asks the user, "Is it
true that the distance to work 3 miles"? The user answers, "Yes", so the fact is added
to working memory.
c H ERIOT-WATT U NIVERSITY 2006
4.4. BACKWARD CHAINING SYSTEMS 59
Step 4
The system must now consider the 2nd condition of rule 2, "I am fit". Once again,
there are no matching rules, and "I am fit" is not a fact in working memory. The system
therefore asks the user, "Is it true that you are fit"? The user answers, "No", so rule 2
cannot be proved true.
Step 5
The system must return to rule 1, and consider the second condition, "I can get the bus
to work"
And so on until rule can be proved true, or false. The system can then advise the user
accordingly.
There is an animation of these steps on-line, which you should view now.
This method of inferencing, backward chaining, is exactly the same method that Prolog
uses to solve queries. It is also the method of inferencing used by Intermodeller.
4.4.2 How a backward chaining system works
To understand the principles of backward chaining, we will study another, more general,
example. In this example, we will use letters rather than "real life" conditions.
Here is the knowledge base that we will consider:
Z if Y & D (which means Z is true if Y is true and D is true)
Y if X & B & E
X if A
L if C
N if L & M
Z is a conclusion that should be reported to the user.
The system also begins with the following facts in its working memory (perhaps provided
by a user at an earlier stage in the consultation):
A, B, C and D
The following diagrams explain how the system will function:
c H ERIOT-WATT U NIVERSITY 2006
60 TOPIC 4. HOW EXPERT SYSTEMS WORK
Step 1 The inference engine starts by trying to prove
goal Z. It searches the knowledge base for a rule,
Working Memory
and find the rule Z if Y & D.
A B C D
Y and D must now be proved (or not). The first
rule is kept on the stack of active rules as it has
not yet been proved or disproved.
Z
Knowledge Base
Z if Y & D
Y if X & B & E
X if A
L if C
N if L & M
Goal: Z
Step 2 Y is set up as the new sub-goal to be proved.
Working Memory Y is not a fact in working memory, so the
knowledge base is searched for a rule.
A B C D
The rule Y if X & B & E is found, so X, B and E
? must all be tested.
The rule Y if X & B & E is added to the active stack
Y
Knowledge Base
Z if Y & D
Y if X & B & E
X if A
L if C
N if L & M
Sub-goal: Y
c H ERIOT-WATT U NIVERSITY 2006
4.4. BACKWARD CHAINING SYSTEMS 61
Step 3 X is the new sub-goal to be considered.
Working Memory X is not a fact in working memory, so the
knowledge base is searched for a rule.
A B C D
The rule X if A is found, so A must be tested.
?
X
Knowledge Base
Z if Y & D
Y if X & B & E
X if A
L if C
N if L & M
Sub-goal: X
Step 4 A is a known fact already in working memory, so
X is therefore true, and can be added as a fact to
Working Memory
working memory.
A B C D
The rule X if A can be removed from the active
X stack as it has been proved true.
Match Fire
Knowledge Base
Z if Y & D
Y if X & B & E
X if A
L if C
N if L & M
Sub-goal: X
c H ERIOT-WATT U NIVERSITY 2006
62 TOPIC 4. HOW EXPERT SYSTEMS WORK
Step 5 The inference engine returns to sub-goal Y, and
the rule Y if X & B & E
Working Memory supplied by
the user X and B are already known to be true, and in
A B C D E
working memory.
X Y
E must be tested. It is not in working memory, and
there is no rule for E, so the system asks the user
Match Fire if E is true.
Knowledge Base
The user confirms that E is true, so it is added to
Z if Y & D working memory.
All 3 conditions for sub-goal Y are satisfied, so Y
Y if X & B & E can be added to working memory, and the rule Y
if X can be removed from the active stack.
X if A
L if C
N if L & M
Sub-goal: Y
Step 6 The inference engine returns to the original goal,
and the rule Z if Y & D
Working Memory
Y and D are both now known facts in working
A B C D E
memory, so goal Z is satisfied, and Z can be
X Y Z added to working memory.
This can be communicated to the user.
Match Fire
Knowledge Base
Z if Y & D
Y if X & B & E
X if A
L if C
N if L & M
Goal: Z
Implementing a backward chaining system
Your task is to devise a simple backward chaining system, similar to the "I can go to
work" system described earlier.
Your theme should be "I can get a good job". You might have rules like:
I can get a good job IF I can get a university degree OR ......
I can get a university degree IF I have the entrance qualifications AND IF I graduate and
c H ERIOT-WATT U NIVERSITY 2006
4.5. FORWARD CHAINING SYSTEMS 63
so on.
Don’t make it too complicated - about the same as the "I can go to work" example. You
should make sure you include some rule chaining.
Part 1: Creating an AND/OR graph
Draw an AND/OR graph of your knowledge base
Part 2: Creating the knowledge base of rules
Convert your AND/OR graph into backward rules
Part 3: Implementing the system
If possible, enter your knowledge base into an expert system shell
Part 4: Testing the system
Run the system a few times. Does it behave as you would expect?
Alter the order of rules in your knowledge base. Can you explain the changes in how
the system now works?
4.4.3 Advantages of backward chaining
When designing a rule-based expert system, a choice must be made between forward
and backward chaining. The knowledge engineer will consider various factors in
making this decision. These include:
How does the domain expert tackle this problem? Does he/she use forward or
backward chaining? It makes sense for the system to mirror the way the domain
expert works.
What type of system is being created? Generally, backward chaining systems are
suited to theorem-proving or diagnostic contexts.
Are there a large number of rules which match the known facts? If so, backward
chaining may be more efficient as it narrows down the possibilities by working from
a chosen goal.
Backward chaining is appropriate where the data and facts are not known at the
start of the consultation, but can be acquired if and when they are required. For
example, medical test results - only those tests requested by the expert system
need to be carried out. MYCIN (one of the earliest successful expert systems)
used backward chaining to diagnose blood disorders.
4.5 Forward Chaining Systems
In many situations, backward chaining is inappropriate, as the goal is not clearly
identified at the start of the consultation. This is particularly true of expert systems used
for classification. DENDRAL (the early expert system for interpreting mass spectrometer
results to identify soil samples) used forward chaining to reach its conclusions.
c H ERIOT-WATT U NIVERSITY 2006
64 TOPIC 4. HOW EXPERT SYSTEMS WORK
How is a forward chaining system different from a backward chaining system?
Consider again the "I can travel to work" knowledge base we looked at earlier. This time
the rules have been written in forward rule format. (Note that the rules do NOT need
to be written in this format for forward chaining to be applied, but it helps to understand
how it works if they are written like this):
Rules How it works
1. IF I can walk to work This time, the system begins by
OR IF I can get the bus to work considering the facts it already has in its
working memory.
OR IF I can drive to work
Let’s assume that the system already
THEN I can travel to work
knows that
2. IF the distance to work 3 miles
AND I am fit I am fit
AND I have enough time I have enough time
THEN I can walk to work.
3. IF there is a bus stop near home The system checks all the rules. Are
these facts enough to satisfy the
AND IF there is a bus at the right conditions for any of the rules? If so, the
time rule will "fire". In this case, these 2 facts
AND IF I can afford the fare are not enough to fire any of the rules.
THEN I can get the bus to work. The system needs more facts, so it
questions the user.
4. IF I have access to a car
AND IF the car is useable In a simple system, it will question the
user in the order that rules are given. So,
AND IF I have a valid driving license
the consultation may go like this:
THEN I can drive to work.
System: "Can you get the bus to work?"
5. IF I own a car
User: "Don’t know"
OR IF I can borrow a car
System: "Can you drive to work?"
THEN I have access to a car
User: "No"
6. IF the car is working
System: "Is the distance to work 3
AND IF the car has enough petrol miles?"
THEN The car is useable.
User "Yes"
7. IF the tank is at least half-full This response adds the facts "The
OR IF I have enough money to fill distance to work 3 miles" to working
the tank memory.
THEN The car has enough petrol. Now the system has all 3 conditions for
rule 2, so rule 2 fires, adding the fact "I
can walk to work" to working memory.
The system can report this conclusion to
the user.
c H ERIOT-WATT U NIVERSITY 2006
4.5. FORWARD CHAINING SYSTEMS 65
Simple forward chaining expert system
The on-line version has an animation of a simple forward chaining medical diagnosis
expert system. If you have access to the on-line version, you should view this animation
now.
4.5.1 How a forward chaining system works
From the previous example, you can see that the workings of a forward chaining system
are very different from the workings of a backward chaining system. Once again, we will
consider the more general example:
Here is the same knowledge base that we considered earlier (this time the rules are
written in forward format):
Y&DZ (which means if Y is true and D is true, then Z is true)
X&B&EY
AX
CL
L&MN
Z is a conclusion that should be reported to the user.
The system also begins with the following facts in its working memory (perhaps provided
by a user at an earlier stage in the consultation):
A, B, C and D
The following diagrams explain how the system will function:
Cycle 1 Cycle 1: The inference engine searches the
knowledge base for rules which can be fired.
Working Memory
Rule 3 can be fired, since A is a known fact in
A B C D
working memory. It generates a new fact, X,
X which is added to working memory.
Match Fire
Knowledge Base
Y&D®Z
X&B&E®Y
A®X
C®L
L&M®N
c H ERIOT-WATT U NIVERSITY 2006
66 TOPIC 4. HOW EXPERT SYSTEMS WORK
Cycle 1: contd Similarly, rule 4 can be fired, since C is a known
fact in working memory. It generates a new fact,
Working Memory
L, which is added to working memory
A B C D
Rules 1, 2 and 5 do not fire, as their conditions
X L are not satisfied.
Match Fire
Knowledge Base
Y&D®Z
X&B&E®Y
A®X
C®L
L&M®N
Cycle 2 Cycle 2: Rules 3 and 4 are ignored, as they have
already fired.
Working Memory supplied by
the user None of rules 1, 2 or 5 can fire, unless further
A B C D E
information is obtained from the user.
X L Y
For rule 1 to fire, fact Y needs to be known. The
system asks the use if Y is true. The user
Match Fire responds "Don’t know".
Knowledge Base
For rule 2 to fire, fact E needs to be known (B and
Y&D®Z X are already in working memory).
The system asks if E is true. The user responds
X&B&E®Y "Yes". E is added to working memory.
A®X Rule 2 can now fire, adding Y to the known facts
in working memory.
C®L
L&M®N
c H ERIOT-WATT U NIVERSITY 2006
4.5. FORWARD CHAINING SYSTEMS 67
Cycle 3 Cycle 3: Rules 2, 3 and 4 are ignored as they
have already fired.
Working Memory
Rule 1 can now fire, adding fact Z to working
A B C D E
memory.
X L Y Z
Conclusion Z can be reported to the user.
Match Fire
Knowledge Base
Y&D®Z
X&B&E®Y
A®X
C®L
L&M®N
Creating a forward chaining system
Rewrite your backward chaining "I want a good job" knowledge base into forward rules
format.
If you have access to an expert system shell which supports forward chaining (such
as CLIPS), implement your system, and observe its behaviour. Does it behave as
predicted?
4.5.2 Advantages of forward chaining system
When designing a rule-based expert system, a choice must be made between forward
and backward chaining. The knowledge engineer will consider various factors in making
this decision. These include:
How does the domain expert tackle this problem? Does he/she use forward or
backward chaining. It makes sense for the system to mirror the way the domain
expert works.
What type of system is being created? Generally, forward chaining systems are
suited to analysis and classification contexts.
Is it difficult to formulate an initial hypothesis? If so, forward chaining is more
suitable
Backward chaining is appropriate where the data and facts are already known
at the start of the consultation. For example, DENDRAL was applied to mass
spectrometer results that were already available. Because of the context, there
might be multiple conclusions, but they could not be predicted in advance.
c H ERIOT-WATT U NIVERSITY 2006
68 TOPIC 4. HOW EXPERT SYSTEMS WORK
4.6 Comparison of forward and backward chaining systems
4.6.1 An inferencing tutorial
You have examined in detail how both forward and backward chaining inferencing
operate. It is important to get a good understanding of these two methods used by
inference engines. The following on-line tutorial illustrates and explains these well.
On-line tutorial
Go to [Link]
Follow through the tutorial by clicking on the [next] button.
You will see
a simulation of forward chaining (p. 2)
a simulation of backward chaining (p. 3)
a simulation of when backward chaining fails (p. 4)
a discussion comparing backward and forward chaining (p. 5)
Pages 6-10 are not relevant to you at the moment.
Note: there is also a tutorial on using e2gLite, a freely downloadable expert system
shell.
4.6.2 Summary of backward chaining
To determine if a conclusion is true, work backwards looking for justifications for
the conclusion.
Eventually, a conclusion must be justified by facts (already in the knowledge base,
or supplied by the user.
c H ERIOT-WATT U NIVERSITY 2006
4.6. COMPARISON OF FORWARD AND BACKWARD CHAINING SYSTEMS 69
4.6.3 Summary of Forward Chaining
Given some facts, work forward by firing rules until a conclusion is reached.
Discovers what conclusions can be derived from data.
Identifying features of forward and backward chaining
Complete this table using the words and phrases below, comparing forward and
backward chaining systems.
Backward chaining Forward chaining
Overall description Goal-driven data-driven
Strategy Starts with hypothesis, Starts with facts, uses
attempts to justify it from these to fire rules until
facts and rules conclusion is reached
Common rule format X if Y and Z If Y and Z then X
Applications Diagnostic, Analysis, classification
theorem-proving
Classical example MYCIN DENDRAL
Word Bank
Analysis, classification Diagnostic, theorem-proving
Starts with facts, uses these to fire rules MYCIN
until conclusion is reached
If Y and Z then X DENDRAL
Goal-driven X if Y and Z
data-driven Starts with hypothesis, attempts to justify
it from facts and rules
c H ERIOT-WATT U NIVERSITY 2006
70 TOPIC 4. HOW EXPERT SYSTEMS WORK
4.7 Conflict resolution
In the simple example explained Section 4.5, there were only 5 rules, and they were
tested in order. Because of the simplicity of the system, the order of rules was not really
very important, and it wouldn’t have mattered if the same rule had been fired twice in
different cycles.
In large commercial expert systems, with thousands of rules, it is important that the
system should be designed for efficiency. This means making decisions about which
rules to fire, and in which order.
In a real expert system, it is likely that at any time, there may be hundreds of rules which
could be fired. How does the system know which ones to fire and in what order?
The list of rules which could be fired at any one time within a forward chaining system
is called the conflict set. Notice that the conflict set will be continuously changing as
the data in working memory changes. The process of deciding which rule to fire next is
called conflict resolution.
There are a number of different conflict resolution strategies which are used either
alone or in combination. Some of them have rather frightening looking names, but don’t
be put off. Each one is explained below.
4.7.1 Rule ordering
Rule ordering (also known as first-come-first-served) is a pretty simple strategy. The
inference engine will try each rule in the conflict set in turn starting at the beginning of
the knowledge base. It will fire the first rule it comes to whose conditions are all satisfied.
For this to be efficient, it is important for the knowledge engineer to put the rules in a
sensible order in the knowledge base. Rules that are used often should be near the
start of the knowledge base. Rules that are less commonly required should be placed
near to the end of the knowledge base.
An alternative way of implementing this scheme is to assign each rule a priority factor.
The inference engine selects the rule with the highest priority in the conflict set wherever
it is in the knowledge base. This makes it easier to add new rules when required. Their
position in the knowledge base does not matter, so long as they have been assigned an
appropriate priority.
It could be argued that an expert system like this is not really an intelligent system.
It is the skill of the knowledge engineer and domain experts in assigning priorities, or
ordering the rules, which makes the system intelligent.
4.7.2 Recency
Recency is a conflict resolution strategy that allows the inference engine to react flexibly
to changes in working memory.
Whenever a new fact is added to working memory it has a time stamp added. When
a conflict arises, the inference engine fires the rule which uses data which was added
most recently.
For example, consider the following system:
c H ERIOT-WATT U NIVERSITY 2006
4.7. CONFLICT RESOLUTION 71
Knowledge base (conflict set in bold) Facts in working memory (brackets
indicate in which cycle they were
added)
rule 1: A&B&C D B (0)
rule 2: D&EY D (0)
rule 3: B&YZ and not D E (0)
rule 4: Z&Y X
In cycle 1, only rule 2 can fire, so there is no conflict. Rule 2 fires, and fact Y is added to
working memory:
Knowledge base (conflict set in bold) Facts in working memory (brackets
indicate in which cycle they were
added)
rule 1: A&B&C D B (0)
rule 2: D&EY D (0)
rule 3: B&YZ and not D E (0)
rule 4: Z&Y X Y (1)
In Cycle 2, the conflict set includes rules 2 and 3. Rule 3 depends on the latest fact
added to the working memory, so it fires rather than rule 2. This adds fact Z to working
memory, and removes fact D.
Knowledge base (conflict set in bold) Facts in working memory (brackets
indicate in which cycle they were
added)
rule 1: A&B&C D B (0)
rule 2: D&EY E (0)
rule 3: B&YZ and not D Y (1)
rule 4: Z&Y X Z (2)
In Cycle 3, the conflict set includes rules 3 and 4. Rule 2 has been removed from the
conflict set because fact D has been removed from working memory. Rule 4 depends
on the latest fact added to the working memory, so it fires rather than rule 3. This adds
fact X to working memory.
This technique is very useful in real-time expert systems, such as those used to control
industrial plants. In that case, facts may be supplied directly into working memory by
sensors, rather than by human users of the system. The inference engine will then
always respond to any sudden change which occurs. However, there is a danger that
system using recency as a strategy may never fire rules which have been in the conflict
set for a long time.
4.7.3 Specificity
This conflict resolution strategy selects and fires the rules with most conditions from the
conflict set. That is, it fires the rule that matches the most known facts. For example,
c H ERIOT-WATT U NIVERSITY 2006
72 TOPIC 4. HOW EXPERT SYSTEMS WORK
consider the following rules in a knowledge base:
1. A&B S
2. B T
3. A&C&D V and W
4. A&B&C&T&S W
5. A&B&CZ
If facts A, B and C are known to be true, then the conflict set contains rules 1, 2 and 5.
If specificity is applied, rule 5 will fire, as it has 3 conditions, while rules 1 and 2 have
only 2 and 1 conditions. This makes sense because rule 5 is the most specific, and is
more likely to narrow down the search towards a conclusion than the more general rules
1 and 2.
However, the strategy may not always be helpful. If rules 1 and 2 had fired, that would
have added T and S to working memory, then the very specific rule 4 could have been
fired.
Here is an example of the use of specificity in an expert system which controls a robot
which packs shopping. This is an example of an expert system being used for planning.
1. IF there is a large item to be bagged
AND there is a bag with 6 large items
THEN put the large item in the bag
2. IF there is a large item to be bagged
AND there is a large bottle to be bagged
AND there is a bag with 6 large items
THEN put the bottle in the bag
Big items go into bags that do not have too many items already, but the bottles, being
heavy, go in first. The extra condition in rule 2 ensures this ordering. When there is a
large bottle, both rules’ conditions will match, but rule 2 matches more facts, so it fires
before rule 1.
Specificity is also sometime known as size ordering, as big rules (with lots of conditions)
are given priority over small rules (with fewer conditions)
4.7.4 Refractoriness
Refractoriness is a big word with a simple meaning. It simply means, "Don’t fire the
same rule twice". This may seem to be obvious, but if any of the previous strategies (rule
ordering, recency or specificity) are applied blindly, then it is quite possible for the same
rule to be fired more than once. Ensuring that the same rule is not fired twice prevents
the system getting into an infinite loop. This is particularly important in expert systems
used for planning (see previous example), as otherwise it could lead to unnecessary
c H ERIOT-WATT U NIVERSITY 2006
4.7. CONFLICT RESOLUTION 73
repetition of actions.
In its strongest form, refractoriness prevents a fired rule being fired ever again during
a consultation. In its weaker form, rules can be fired again, but only if the data held in
working memory has changed since the last time.
4.7.5 Data ordering
We have already seen that it is possible to assign priorities to rules. It is also possible
to assign a priority to facts and data. Some pieces of information are simply more
important than others. If priorities are assigned to items of data in working memory,
then this strategy fires rules which depend on the most important data.
Recency is a special example of data ordering, where the importance of data depends
on how recently it was added to the working memory. Data ordering is a more general
version of the same idea. Data is given priority based on information provided by the
knowledge engineer, who can give an indication of what is most important.
For example, in an industrial control expert system, data from a temperature sensor
in the main cooling circuit may be much more important than data from production
schedules entered by the operator. By giving this data a high priority, if the temperature
sensor indicates a dangerously high temperature which could trigger a rule, this rule will
be selected from the conflict set because it is based on high priority data.
4.7.6 Context limiting
The final conflict resolution strategy you need to know about is called context limiting,
or setting a rule agenda. This is particularly important for very large knowledge bases.
It makes sense to divide a large knowledge base into groups of rules which are related
to each other. At any particular time, the inference engine will only consider rules which
are in a relevant group, and ignore the rest of the knowledge base.
For example, an expert system for identifying trees may have groups of rules related to
Geographical location
Size and shape of the tree
Leaf types
The habitat in which the tree is found
Other interesting features
During a consultation, the inference engine may start by limiting itself to rules from the
geographical location subgroup. Once it has established all the required facts about
geographical location, it may then move on to size and shape rules, ad so on. This
reduces the amount of searching that the inference engine needs to do at any particular
stage in the consultation.
Obviously, this is related to rule ordering, and requires some input from the domain
expert and the knowledge engineer.
c H ERIOT-WATT U NIVERSITY 2006
74 TOPIC 4. HOW EXPERT SYSTEMS WORK
4.7.7 Summarising conflict resolution strategies
In practice, most commercial expert systems will use a combination of
conflict resolution strategies relevant to the expert system being developed.
Summarising conflict resolution strategies
Complete this table matching conflict resolution strategies to their descriptions:
Conflict resolution strategy Description
Rule ordering Only fire rules that are in the currently
relevant group
Recency Fire the rule which depends on the newest
data in working memory
Specificity Fire the rule that depends on the most
important data
Refractoriness Put most important rules first
Data ordering Don’t fire the same rule twice
Context limiting Fire the rule that has the most conditions
4.8 The RETE algorithm
All of the conflict resolution strategies described above depend on the inference
engine being able to identify the conflict set, that is, all the rules which could be fired.
The conflict set is always changing as rules are fired, and the content of working memory
change. This means that the inference engine must recalculate the conflict set after
every cycle. For a small knowledge base, this is not a problem, but for a large knowledge
bases (with thousands of rules), this is a time consuming process which will slow down
the operation of the expert system. A method is required to make the process more
efficient.
The Rete algorithm was devised to solve this problem. Rete is the Latin word for net. It
uses a form of pattern matching based on the conditions required to satisfy each rule.
The basic idea is that, after each cycle, only a few of the facts in working memory will
change, so the conflict set only changes slightly. As a result of a new fact being added
to working memory, it may be that only 2 new rules join the conflict set, and 1 rule is
to be removed. The Rete algorithm is able to quickly and efficiently identify those rules
which have been added or removed from the conflict set. This means that the inference
engine no longer needs to check every rule after every cycle.
The Rete algorithm also makes use of the fact that many rules may have similar sets
of conditions. The algorithm can store a pattern of conditions, and associate that with
several rules. If that pattern is matched by a change in working memory, then all of the
matching rules can be added to the conflict set.
The Rete algorithm uses a large amount of memory, but results in significant
improvements in processing speed for inference engines.
c H ERIOT-WATT U NIVERSITY 2006
4.9. CERTAINTY FACTORS 75
4.9 Certainty Factors
4.9.1 Representing uncertainty
The Scholarian coins example is simple in many ways. In particular, there can be no
doubt about the identification of a coin - it is either a 10H or a 20H or one of the others.
However, not all problems are like this. For example, a consultation with a doctor may
lead to a less clear-cut diagnosis. The doctor may conclude that your headache is
probably just a hangover, but it might be the start of flu, and there is a very slim chance
that it could be a brain tumour or some other serious disease. Many domains contain
uncertain conclusions like this, and expert systems must be able to deal with this kind
of knowledge. They do this by using certainty factors.
Most expert system shells allow a certainty factor to be added to any fact or rule. One
method is to represent the degree of certainty as a number on a scale of -100 to +100,
as follows:
+100 definitely true
+50 probably true
0 unknown
-50 probably untrue
-100 definitely untrue
The number is called a certainty factor. It is added to the end of a fact or rule using the
abbreviation CF.
So, for example:
It will rain tomorrow in Scotland CF99
It will rain tomorrow in the Sahara Desert CF-99
IF I work hard THEN I will pass Higher Computing CF65
IF I do no work THEN I will fail Higher Computing CF100
There are 31 days in January CF100
There are 31 days this month CF58
As well as adding certainty factors to facts and rules in the knowledge base, they can
be added to any response you make during a consultation.
So, for example, the user interface might ask you : Do you like Christmas Pudding?
Your response might be "yes CF 75", indicating that you like it but not very definitely,
or "yes CF 100" if it is your favourite food.
Another example might be in a car diagnostic expert system, you might be asked "Has
this problem occurred before?". If you don’t know, you could answer with a certainty
factor of 0.
Note that some expert system shells use a scale from -1 to +1 instead of -100 to +100.
In a system like that, +1 represents absolute certainty, and -1 definitely untrue.
Before doing any practical work using an expert system shell, check the documentation
carefully to find out which system it uses.
c H ERIOT-WATT U NIVERSITY 2006
76 TOPIC 4. HOW EXPERT SYSTEMS WORK
Weather forecast expert system
Weather forecasting is notoriously uncertain. It is impossible to predict the weather
30 min exactly. However, today’s weather can be used as a rough guide to what it might be like
tomorrow.
Using the expert system shell with which you are familiar, create a knowledge base of
the following rules:
!"# $%
& '(
!"# $%
& ))
!"# $%
& (*
!"# $%
& +(
!"# $%
& ,*
You can add a few similar rules of your own.
Now consult the expert system you have created, and notice how the consultation and
any results differ from your Scholarian Coins Expert System.
4.9.2 Calculating Certainty Factors for simple rules
Consider the rule
IF the patient has a reddish colourisation of the skin
THEN condition is Scholarian Measles
CF40.
This means that the diagnosis of Scholarian Measles has a 40% or 0.40 probability of
being correct if the patient has a reddish colourisation of the skin.
But the condition - a reddish colourisation of the skin - is not very clearly defined.
c H ERIOT-WATT U NIVERSITY 2006
4.9. CERTAINTY FACTORS 77
Imagine a doctor with a patient.
The doctor has examined the patient, and is consulting his desktop Expert System for
advice. The Expert System is asking the question "Does the patient have a reddish
colourisation of the skin?" The doctor might look at a patient and think, "The patient’s
skin is certainly pink, but should it be described as reddish? And it is only pink on
some parts of the body - not over the whole body. Should I answer "yes" to the Expert
System?"
A good Expert System will allow the doctor to add a certainty factor to the reply, to
indicate the Doctor’s confidence in answering the question. So, instead of answering
"yes" or "no", the Doctor enters "Yes, CF 25", to indicate a 25% or 0.25 confidence in
the answer.
What answer will the Expert System give?
The answer should be
Condition is Scholarian Measles
CF10
Why 10?
This is calculated by combining the probability of the conclusion (40%) with the
confidence in the condition (25%). Simple multiplication 40% x 25% gives the answer
10%. If you prefer to work in decimals, the calculation is 0.4 x 0.25 = 0.10. A probability
of 0.10 is the same as a 10% chance of something happening.
Calculating Certainty Values for Simple Rules
Calculate the certainty factor for the conclusions of these rules, given the CF of the rule
and the CF of the condition being true:
Q6: IF the sky was red this morning
THEN it will rain today
CF 50.
(assuming the CF of the condition is 80)
Q7: IF pupil gets 5 Highers
THEN they will be offered a place at university
CF 99.
(assuming the teacher thinks a particular pupil has a 25% chance of getting 5 Highers)
Q8: as above, but the teacher thinks pupil B has an 80% chance of getting 5 Highers
Q9: IF pupil works hard
THEN they will get an A in Higher Information Systems
CF 0.8.
(assuming teacher believes there is a 0.5 chance of pupil working hard)
c H ERIOT-WATT U NIVERSITY 2006
78 TOPIC 4. HOW EXPERT SYSTEMS WORK
4.9.3 Calculating Certainty Factors for complex rules
Consider the rule
IF the pupil gets an A in Higher Information Systems
AND the pupil works hard throughout sixth year
THEN pupil should get an A in Advanced Higher
CF80.
This means that if a pupil gets an A in Higher Information Systems and works hard
throughout sixth year, there is an 80% chance they should get an A in Advanced Higher.
Now suppose that the teacher considers that the likelihood of the pupil getting an A in
Higher Information Systems is 50%, and that the likelihood of the pupil working hard
throughout sixth year is 40%, then what is the likelihood of the pupil getting an A in
Advanced Higher?
Simple probability theory suggest multiplying the three certainty factors together : 0.5
x 0.4 x 0.8, giving an answer of 0.16 (or 16%). However, this is only correct if the 2
conditions are completely independent of each other. In this case (and in many other
cases), the conditions are not independent. Worse still, it is not always clear how they
depend on each other. For example, in this case, getting an A in Higher might motivate
a pupil to work harder throughout sixth year than was expected. On the other hand,
having got an A at Higher, the pupil might relax, and not work as hard as expected.
There are ways of handling this type of interdependence, but they are complex and vary
from one situation to another. Fortunately, there is a simple method which can be used
to get an estimate for the result. The idea is to consider the CFs for all the conditions,
and simply to take the lowest value. This is then multiplied by the CF of the rule, to give
a CF for the conclusion.
As a formula, this can be written as:
CFconclusion = MIN(CFcond1 ,CFcond2 ,CFcond3 ...) x CFrule
Applying this to the example, we would get:
CFconclusion = MIN(0.5, 0.4) x 0.8
= 0.4 x 0.8
= 0.32
Research shows that this simplification gives reasonable results in most cases.
If anything, it tends to give slightly low estimates, but this is legally safer than
overestimating the answer. The first Expert System to use this method of combining
certainty factors was the highly successful MYCIN system for diagnosing blood
disorders.
Calculating Certainty Values for Complex Rules
Calculate the certainty factor for the conclusions of these rules, given the CF of the rule
and the CF of the condition being true, and assuming the formula:
c H ERIOT-WATT U NIVERSITY 2006
4.10. STRUCTURING A KNOWLEDGE BASE 79
CFconclusion = MIN(0.5, 0.4) x 0.8 = 0.4 x 0.8 = 0.32
Q10: IF the sky was red this morning (CF 60)
AND it rained yesterday (CF 75)
THEN it will rain today (CF 50).
Q11: IF a pupil gets an A in Higher English (CF 0.6)
AND the pupil gets an A in Higher Maths (CF 0.75)
AND the pupil gets an A in Higher Computing (CF 0.9)
THEN they will be offered a place at university (CF 0.8).
Q12: as above, but the teacher thinks pupil B has a 80% chance of an A in Higher
English, a 20% chance of A in Higher Maths and a 30% chance of A in Higher
Computing.
Q13: IF the sky is blue (CF 90)
AND people around are speaking French (CF 40)
AND there are lots of Renault cars (CF60)
THEN you are in France (CF 80)
4.9.4 Other methods of representing uncertainty
Certainty factors are not the only way of representing uncertainty in expert systems.
They are used because they are relatively simple to understand and implement.
However, the formula for combining certainty factors is only valid when conditions
are completely independent. In reality, this is not often the case, and more complex
mathematics may be required to give more accurate answers.
It’s also important to distinguish between certainty factors and so-called fuzzy logic.
Fuzzy logic is an important branch of Artificial Intelligence, with many useful
applications. It is used to represent attributes such as "tall", which are not clearly
defined. If my height is 2m, I am tall. If my height is 1.4m, then I am not tall. What
if I am 1.7m? To deal with concepts like this, fuzzy logic has been developed by
mathematicians. Although it sounds like some sort of vague reasoning, fuzzy logic is
actually a well-defined type of probabilistic reasoning.
Normal expert systems use classical logic, and may also use certainty factors to
represent uncertainty in facts and conclusions.
Fuzzy exert systems use "fuzzy logic" to deal with "fuzzy concepts".
4.10 Structuring a Knowledge Base
A typical burglar alarm has a warning lamp and a display which indicated a zone number.
Various combinations of warning lamp and zone number may be displayed, indicating
that something unusual has happened. The display is confusing, and it would be useful
to have an expert system to convert the information into a useful form.
The factor table for the system looks like this:
c H ERIOT-WATT U NIVERSITY 2006
80 TOPIC 4. HOW EXPERT SYSTEMS WORK
warning lamp zone reading advice
Check the front door and
on 1
windows
Check the back door and
on 2
windows
Check the upstairs
on 3
windows
off 1 System is primed and OK
off 2 System is not primed
There is system fault -
off 3
press reset button
We will consider 3 different ways of representing this knowledge in a knowledge base.
4.10.1 Version 1 - simple rules
A simple knowledge base to represent this knowledge might look like this:
ADVISE Check front door and windows IF
warning lamp is on AND
zone reading is 1.
ADVISE Check back door and windows IF
warning lamp is on AND
zone reading is 2.
ADVISE Check upstairs windows IF
warning lamp is on AND
zone reading is 3.
ADVISE System is primed and OK IF
warning lamp is off AND
zone reading is 1.
ADVISE System is not primed IF
warning lamp is off AND
zone reading is 2.
ADVISE System fault - press reset button IF
warning lamp is off AND
zone reading is 3.
This system will work correctly, but it is inefficient as it may need to repeat questions.
The user may be asked "Is the warning light on?" If the user replies "No", then the
system may ask "Is the warning light off?" In the same way, the system may have to ask
3 questions related to the zone reading.
c H ERIOT-WATT U NIVERSITY 2006
4.10. STRUCTURING A KNOWLEDGE BASE 81
Some simple KRLs do not have any way of dealing with this problem.
Better KRLs allow for multi-value questioning, which we will consider in the next sub-
topic.
4.10.2 Version 2 - multi-value questions
A better way to structure this knowledge might look like this:
ADVISE Check front door and windows IF
warning lamp is on AND
zone reading is 1.
ADVISE Check back door and windows IF
warning lamp is on AND
zone reading is 2.
ADVISE Check upstairs windows IF
warning lamp is on AND
zone reading is 3.
ADVISE System is primed and OK IF
warning lamp is off AND
zone reading is 1.
ADVISE System is not primed IF
warning lamp is off AND
zone reading is 2.
ADVISE System fault - press reset button IF
warning lamp is off AND
zone reading is 3.
warning lamp is on IF ANSWER TO QUESTION lamp IS on.
warning lamp is off IF ANSWER TO QUESTION lamp IS off.
zone reading is 1 IF ANSWER TO QUESTION zone IS 1.
zone reading is 2 IF ANSWER TO QUESTION zone IS 2.
zone reading is 3 IF ANSWER TO QUESTION zone IS 3.
QUESTION lamp
ASK Is the warning lamp on or off?
CHOOSE ONE OF [on, off].
QUESTON zone
ASK What is the reading on the zone display?
c H ERIOT-WATT U NIVERSITY 2006
82 TOPIC 4. HOW EXPERT SYSTEMS WORK
CHOOSE ONE OF [1,2,3].
This knowledge base is longer than the original one, but it will be more efficient in use, as
the multi-valued questions prevent repetition of similar questions. However, the middle
set of rules look very similar, and in a more complex system, there could be hundreds
of such rules.
Commercial KRLs allow for parameterised rules, which cut down the need fo many
similar rules.
4.10.3 Version 3 - using parameterised rules
Using parameterised rules, the knowledge base might look like this:
ADVISE Check front door and windows IF
warning lamp is : on AND
zone reading is : 1.
ADVISE Check back door and windows IF
warning lamp is : on AND
zone reading is : 2.
ADVISE Check upstairs windows IF
warning lamp is : on AND
zone reading is : 3.
ADVISE System is primed and OK IF
warning lamp is : off AND
zone reading is : 1.
ADVISE System is not primed IF
warning lamp is : off AND
zone reading is : 2.
ADVISE System fault - press reset button IF
warning lamp is : off AND
zone reading is : 3.
warning lamp is : S IF ANSWER TO QUESTION lamp IS S.
zone reading is : Z IF ANSWER TO QUESTION zone IS Z.
QUESTION lamp
ASK Is the warning lamp on or off?
CHOOSE ONE OF [on, off].
QUESTON zone
ASK What is the reading on the zone display?
c H ERIOT-WATT U NIVERSITY 2006
4.11. SUMMARY 83
CHOOSE ONE OF [1,2,3].
Using the variables S and Z, the 5 rules have been reduced to 2, thus simplifying the
knowledge base.
4.10.4 Checking what your KRL can do
You should now check the documentation of the KRL for the expert system shell you are
using, to see if it allows you to make use of
certainty factors
multi-valued questions
parameterised rules
4.11 Summary
the main functions of the user interface are: displaying advice, communicating with
the user, justifying questions and answers
the main function of an inference engine is to determine the order in which rules
are applied, and questions asked
the two main inferencing methods are
– backward chaining (goal-driven)
– forward chaining (data-driven)
a forward chaining system consists of
– a knowledge base of facts and rule
– working memory containing established facts
– a conflict set (all those rules which may be fired at any time)
– conflict resolution (a strategy for determining which rule to fire next)
thefollowing conflict resolution strategies may be used either alone or in
combination, to choose which rule to fire next
– rule ordering
– recency
– specificity / size ordering
– refractoriness
– data ordering
– context limiting / setting a rule agenda
the RETE algorithm improves the efficiency of an expert system by quickly
identifying the rules which have been added to or removed from the conflict set
certainty factors can be used to represent uncertainty in
c H ERIOT-WATT U NIVERSITY 2006
84 TOPIC 4. HOW EXPERT SYSTEMS WORK
– a user’s response
– a rule
– a conclusion
the certainty factor of a conclusion can be calculated using the formula
– CFconc = CFrule x min(CF cond1 , CF cond2 ....)
4.12 Revision Questions
An online assessment is provided to help you review this topic.
c H ERIOT-WATT U NIVERSITY 2006
85
Topic 5
Expert Systems Development
Contents
5.1 Prior Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
5.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
5.3 The development process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
5.3.1 Personnel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
5.3.2 Knowledge acquisition / elicitation . . . . . . . . . . . . . . . . . . . . . 92
5.3.3 Knowledge representation . . . . . . . . . . . . . . . . . . . . . . . . . . 94
5.3.4 System validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
5.3.5 Summary of expert system development process . . . . . . . . . . . . . 98
5.4 Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
5.4.1 Evaluation criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
5.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
5.6 End of topic test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Learning Objectives
After studying this topic, you should be able to:
describe the main stages of development of an expert system
– knowledge acquisition / elicitation
– knowledge representation
– system validation
describe the roles of the principal personnel involved in expert system
development
– domain expert
– knowledge engineer
– programmer
– user
describe the possible sources of error which can occur at each stage of
development
– incorrect knowledge supplied by domain expert
86 TOPIC 5. EXPERT SYSTEMS DEVELOPMENT
– misinterpretation of expert knowledge by knowledge engineer
– errors in programming and inferencing
– system providing advice beyond the limits of ignorance
describe methods of testing an expert system
– structured questions
– test cases
– use of how and why justification
critically evaluate expert systems in terms of
– purpose (type and domain)
– range and coverage
– quality of user interface
– quality of reasoning, and correctness of conclusions
– fitness for purpose
c H ERIOT-WATT U NIVERSITY 2006
5.1. PRIOR KNOWLEDGE 87
5.1 Prior Knowledge
This topic assumes a basic understanding of the structure of expert systems, typical
applications and uses of expert systems, and the way knowledge can be represented in
a knowledge base.
Before you study this topic, you should be able to
describe the main components of an expert system
– knowledge base, containing facts and rules
– inference engine
– user interface
distinguish between an expert system and an expert system shell
describe how expert systems can be used for planning, advice, diagnosis and
classification
describe how domain knowledge can be represented by facts and rules
Check your understanding by trying the revision questions.
Revision
Q1: Which of the following is NOT one of the functions of an expert system?
a) to allow managers to obtain expert summaries of sales data
b) to represent the knowledge of one or more domain experts
c) to provide advice to a user through a process of consultation
d) to provide explanations to the user to support its conclusions
Q2: The domain of an expert system is
a) the type of computer system required for it to run
b) the type of human expert whose knowledge it represents
c) the subject area in which it can give advice
d) the method of reasoning it uses to reach conclusions
Q3: In which part of an expert system would you find stored facts and rules?
a) the inference engine
b) the knowledge base
c) the user interface
d) the shell
Q4: The main function of an inference engine is
a) to store expert knowledge in the form of facts and rules
b) to display advice to users
c) to determine the order in which rules are applied
d) to justify questions and answers
Q5: What are the 2 main parts of an expert system shell?
c H ERIOT-WATT U NIVERSITY 2006
88 TOPIC 5. EXPERT SYSTEMS DEVELOPMENT
a) inference engine and knowledge base
b) facts and rules
c) user interface and knowledge base
d) inference engine and user interface
Q6: The 4 main groups into which expert systems can be classified are
a) advice, classification, diagnosis and planning
b) legal, classification, diagnosis and financial
c) financial, classification, diagnosis and planning
d) advice, legal, diagnosis and planning
5.2 Introduction
In the previous topics, we have studied the purpose and structure of expert systems. We
have seen how these have grown from experimental systems in the 1970s to become
a major range of commercial software by the beginning of the 21st century. Expert
systems are now used across a huge range of industries, scientific disciplines and
educational uses.
In this topic, we shall consider how expert systems are developed, and how they can be
tested to ensure that they are reliable.
5.3 The development process
An expert system is a type of software, and so the usual software development process
applies to the development of an expert system:
However, the stages are slightly different when considering expert systems. In the
following task, you should be able to use what you already know about the software
development process and about expert systems to match descriptions to stages.
c H ERIOT-WATT U NIVERSITY 2006
5.3. THE DEVELOPMENT PROCESS 89
In this topic, we will focus on the design, implementation and testing stages of the
software development process. Each of these stages involve specialised techniques
when applied to expert system development. The special stages used in expert system
development are
Knowledge acquisition / elicitation (during the design stage)
Knowledge representation (during the implementation stage)
System validation (during the testing stage)
Identifying the main stages of the software development process
Complete this table of the main stages and their descriptions.
Stage Description
Reviewing the expert system to identify
Analysis
strengths and weaknesses
Making sure the expert system produces
Design
appropriate results
Converting the expert knowledge into facts
and rules and coding it in a knowledge
Implementation representation language; creating the
user interface and inference engine (or
selecting a suitable expert system shell)
Adapting the expert system for new
Testing environments, adding new features and
extending the knowledge base
Agreeing the specification - what domain
Documentation
are will be covered
Planning the user interface, obtaining the
expert knowledge from the domain expert,
Evaluation deciding on the method of representing the
knowledge and the type of inferencing to
be used
Maintenance Writing a user guide and technical guide
5.3.1 Personnel
Before we look at the three stages in the development of expert system, we need to
clarify who is likely to be involved.
There are (at least) 4 different type of personnel required:
the domain expert
the knowledge engineer
the programmer
the user
c H ERIOT-WATT U NIVERSITY 2006
90 TOPIC 5. EXPERT SYSTEMS DEVELOPMENT
In addition, a project manager will coordinate the work of all these personnel.
[Link] Domain Expert
The domain expert is the person who has the expert knowledge about the domain.
In a medical expert system, this would probably be a doctor.
In a legal expert system, the domain expert would be a lawyer.
For a whale spotting classification expert system, the domain expert would be a marine
biologist, and so on ...
It is not enough for a domain expert to be an expert in the domain. There are many very
knowledgeable people who would not be suitable for this role. A good domain expert
should
have expert knowledge of the domain
be well-respected by other experts in the same field
be a good communicator, able to explain his/her knowledge to others
be prepared to commit significant time to the expert system development
Note that the domain expert does not need to know anything about computers or expert
systems, or how they work. It is also common for several domain experts to be involved
in the development of an exert system.
Identifying domain experts
Match the domain experts to the expert systems named below:
(note: if you can’t remember what domain is covered by each of the listed expert
systems, refer back to topic 1)
Expert system Domain expert
MYCIN Tax accountant
Prospector Computer engineers
Dendral Telecommunication engineer
Internist Marine biologist
R1/XCON Blood infection specialist
Whale watcher Research chemist
Shyster Australian law expert
Expertax Mineral geologist
SARAH Hygiene trainer
Datacab doctors
Think....
In what domains could you be the domain expert?
c H ERIOT-WATT U NIVERSITY 2006
5.3. THE DEVELOPMENT PROCESS 91
heavy metal music?
amusing your little sister?
route-finding in your town?
how to pass Int 2 Information Systems?
Scottish football teams?
Write a list of your own areas of expertise!
[Link] Knowledge Engineer
The knowledge engineer is responsible for several tasks:
deciding whether or not a problem would make a suitable expert system
application.
choosing a domain expert whose expertise will be modelled in the knowledge
base.
capturing the domain expert’s expertise and encoding this expertise as rules in a
knowledge base.
choosing a suitable inferencing strategy which is appropriate to the problem
testing the resulting system and making corrections and adjustments if required
What skills must a knowledge engineer possess?
Look at the following list of skills, and decide which ones are important for knowledge
engineers:
Q7: ability to write code in a programming language such as C++, Visual BASIC or
Pascal
Q8: ability to convert knowledge into facts and rules in a KRL (knowledge
representation language)
Q9: ability to communicate with colleagues
Q10: deep knowledge of the subject domain of the exert system being developed
Q11: some knowledge of the subject domain of the exert system being developed
Q12: good understanding of different inferencing methods, including forward and
backward chaining
Q13: good knowledge of the range of expert system shells available
Q14: able to work as part of a team
c H ERIOT-WATT U NIVERSITY 2006
92 TOPIC 5. EXPERT SYSTEMS DEVELOPMENT
[Link] Programmer
If an expert system shell is used to create the expert system, then there will be little need
for traditional programmers. All the work of converting the domain expert’s knowledge
into a KRL can be done by the knowledge engineer. The user interface and inference
engine will already exist within the shell.
However, if, for some reason, an expert system is unavailable or unsuitable, then a team
of programmers will be required. Their task will be to
develop a suitable user interface
develop an appropriate inference engine
integrate the user interface, knowledge base and inference engine into a coherent
program.
The programmers will probably use standard software development languages and tools
to create the user interface. The inference engine may be created using a standard
programming language, or a more specialised language such as Prolog.
The programmer will work in a team with the knowledge engineer, and project manager.
[Link] User
When developing an expert system, it is vital to consider who the end users will be. This
must be established right at the beginning, during the analysis stage, as it will influence
the design and implementation of the system.
There are many different types of end user.
Some expert systems are used to give support to other experts. For example, a doctor
may use an expert system to support his diagnosis and treatment plan for an unusual
illness. In this case, the end user already has considerable expert knowledge, but may
not be very skilled in computer use, so would require an easy to use interface.
Other expert systems are used for training. In these cases, it is important that the system
can give good How? and Why? explanations to justify its reasoning, so that the user
can learn form the system.
Users also play an important role during the testing or validation of an expert system.
Ultimately, an expert system must meet the needs of the user, so the knowledge
engineer should consult users at an early stage in development to identify their needs
clearly.
5.3.2 Knowledge acquisition / elicitation
Once the need for an expert system has been agreed (analysis stage), the team can
begin its design work. A major part of this is known as knowledge acquisition or
elicitation.
The two main players in this stage are the knowledge engineer and the
domain expert(s).
c H ERIOT-WATT U NIVERSITY 2006
5.3. THE DEVELOPMENT PROCESS 93
Firstly, the knowledge engineer must establish the sources of domain knowledge, and
decide on a strategy for extracting that knowledge.
Source of domain knowledge might include
domain experts
books and other documents
on-line sources of domain knowledge
other related software
The task of extracting knowledge will include extensive reading, many hours of
interviews with domain experts, and the important task of summarising and structuring
the knowledge obtained. It is not simply a matter of asking questions of the domain
expert - the interviewing process is a two-way process. Gradually, the knowledge
engineer will build up a structured representation of the knowledge using the tools we
considered earlier - factor tables, decision trees, semantic nets. As this is built up, the
knowledge engineer will need to repeatedly check it with the domain expert. In some
case, the domain expert may never have made his or her knowledge explicit before. The
ability to draw out implicit knowledge and convert it into an explicit format, is the key skill
of a knowledge engineer.
The knowledge engineer will not only be building up a representation of the basic domain
knowledge, but also building up an understanding of how the domain expert reasons
c H ERIOT-WATT U NIVERSITY 2006
94 TOPIC 5. EXPERT SYSTEMS DEVELOPMENT
with this knowledge to reach valid conclusions. This is necessary so that a suitable
inferencing method can be chosen. Does the domain expert use forward or backward
chaining, or a combination of both? Which facts or rules are most important? In what
order should questions be posed to the user? To answer this type of question, the
knowledge engineer might use observation of the domain expert at work in addition to
interviewing the expert.
The process of knowledge acquisition can be a difficult and lengthy one. For a
commercial real-world expert system, the knowledge engineer may be trying to elicit
from a domain expert a huge bank of knowledge which has been built up and defined
over decades. The task is made even more complex where several domain experts
are being used. Different domain experts may have different areas of expertise within
the domain which can be combined into the system. However, this can be tricky when
there are differences of emphasis, or even disagreements between experts. In most
domain areas, the knowledge engineer will also need to assign certainty factors (CFs)
to rules, by converting qualitative words such as "often", "sometimes", "perhaps" and
"occasionally", into numeric values.
Because of the complexity of the process, knowledge acquisition is almost always an
iterative process. That is, the knowledge engineer may construct a first draft of the
system based on knowledge provided so far by the domain expert(s). This will then be
reviewed by the domain experts to see how well it represents their expertise. Almost
certainly, this will require adjustments - adding or deleting rules, adding extra questions,
adjusting priorities of rules and data, adjusting certainty factors, and so on. This will
lead to further testing and further adjustments. This iterative process will continue until
the domain expert(s) and knowledge engineers are satisfied that the system is working
correctly at expert level.
Note: the terms knowledge acquisition and knowledge elicitation are often used
almost interchangeably to describe this stage. To be more precise, knowledge elicitation
usually refers to the process of extracting knowledge from human experts directly (by
interviewing and observation), while knowledge acquisition is a more general term
covering elicitation, analysis and organisation of knowledge from a wide range of
sources, both human and documentary sources.
5.3.3 Knowledge representation
The next stage of the process is knowledge representation. This corresponds roughly
to the implementation stage of the software development process.
If the knowledge acquisition stage has been conducted thoroughly and carefully, then
knowledge representation should be fairly straightforward. The knowledge engineer will
have constructed factor tables, decision trees and other forms of representation. All that
remains is to convert these into an appropriate knowledge representation language as
forward or backward rules. The use of an expert system shell means that the knowledge
engineer has only to write the rules that form the knowledge base, as the user interface
and inferencing engine already exist.
c H ERIOT-WATT U NIVERSITY 2006
5.3. THE DEVELOPMENT PROCESS 95
Once the rules have been written and stored in a knowledge base, they may need to be
prioritised to make sure the system works efficiently.
5.3.4 System validation
Once the iterative processes of knowledge acquisition and knowledge representation
have been completed, the next stage is system validation. System validation
corresponds roughly to the testing phase of the software development process.
In a commercial expert system, the knowledge base may consist of hundreds or even
thousands of rules. These rules are manipulated by a complex inferencing strategy. The
system allows the user to enter further information during a consultation. As a result of
these three factors, an expert system is much less deterministic in its behaviour than
a conventional program. This means that there are so many combinations of possible
inputs and outputs that it would be impossible to test every single possibility.
The purpose of system validation is to ensure that the expert system will always (or at
least in a very high percentage of occasions) give results which are:
correct (agree with the advice provided by human experts)
complete (provide all the possible relevant conclusions)
consistent (do not contradict other advice given by the system)
To ensure all of these, a program of structured tests is required. Before considering how
to test an expert system, we will look at some possible sources of error.
[Link] Sources of error
Due to the complexity of an expert system, there are many sources of possible error. It
is helpful to identify these, so that systems can be designed which avoid them as far as
possible.
Incorrect knowledge supplied by domain expert
The most obvious source of error is incorrect knowledge supplied by the domain expert.
c H ERIOT-WATT U NIVERSITY 2006
96 TOPIC 5. EXPERT SYSTEMS DEVELOPMENT
Human exerts are not infallible, and may supply incorrect information, which is coded in
good faith by the knowledge engineer. This is a particular problem in domains where the
knowledge may be subject to uncertainties, and where experts may disagree on the best
advice. This type of error can never be completely eradicated, but it can be minimised
by using more than one domain expert (or source of knowledge). If this is not possible,
it is advisable for the system to be tested by a different domain expert than the one who
supplied the knowledge.
Misinterpretation of expert knowledge
Even when the knowledge supplied by the domain expert(s) is correct, it is possible for
errors to be introduced by the knowledge engineer during the process of coding the
knowledge. The chances of this happening are reduced by extending the time allocated
to knowledge acquisition, so that the knowledge engineer has time to develop his/her
own understanding of the domain.
Programming errors
Programming errors can occur in several areas. Errors can occur while coding
knowledge into the KRL; this is most likely when using a language such as Prolog,
rather than a customised KRL such as those provided by most expert system shells.
Programming errors can also occur during the coding of the user interface or inference
engine. This is avoided by using an expert system shell, where these elements have
already been coded and thoroughly tested.
Inferencing errors
Even if an expert system shell is used, there may be bugs in the inferencing engine
which only appear under some unusual set of circumstances. Errors can also occur due
to unforeseen consequences of a conflict resolution strategy. For example, assigning
an incorrect priority to a rule may mean that it does not fire when it should. Complex
combinations of certainty factors can also lead to unreliable conclusions. Thorough
testing with a wide range of inputs can help uncover these types of error so that they
can be corrected before the system goes into regular use.
Limits of ignorance errors
Most human experts are aware of their own limitations, and will indicate when they are
unsure if their advice is reliable. Other experts may then be consulted, or the advice
ignored. Human experts are also likely to be aware of situations where their own logical
thinking leads to conclusions which do not make sense. A complex expert system may
use a chain of reasoning based on insecure evidence leading to a conclusion which is
on the boundary of reliability. The use of well-chosen certainty factors should help to
indicate this, as such a result should result in a low certainty factor.
[Link] Testing
Even a simple expert system, such as the one designed to identify Scholarian coins,
requires extensive testing to ensure that all possibilities are covered. As the size of an
expert system increases, it is important to have a structured test strategy.
A structure set of tests should ensure that
c H ERIOT-WATT U NIVERSITY 2006
5.3. THE DEVELOPMENT PROCESS 97
1. the system always gives a correct conclusion for a valid set of inputs
2. the system produces all the valid correct conclusions for a given set of inputs
3. the system does not produce any conflicting advice
4. the system provides a sensible output where no valid conclusion is possible
In the case of the Scholarian coins expert system, for example, you could carry out the
following tests:
1. check that the system correctly identifies each coin when the correct descriptions are
entered during a consultation
2. and 3. check that the system only gives one conclusion for each set of valid inputs
4. check that the system does not provide a conclusion if an invalid description is entered
(and check that the output is meaningful (e.g. "there are no Scholarian coins which fit
your description")
Testing the Scholarian Coins expert system
If you implemented the Scholarian coins expert system in topic 3, then run a set of tests
to validate the system.
Complete a table to show the results of your testing:
reason for colour size(mm) shape symbol expected result of comment
test result test
valid inputs bronze 18 round fish 1H
bronze 18 round bird 6H
silver 18 round flower 10H
silver 22 7 sided fish 20H
silver 22 round fish 50H
silver 25 triangular mountain 1J
two tone 30 7 sided bird 6J
Invalid bronze 18 round flower -
combinations
bronze 18 7 sided fish -
two tone 25 7 sided bird -
Invalid input bronze 18 square fish -
values
silver 10 triangular mountain -
Missing bronze 18 round - 1H or 6H
values
silver - - - 10H,
20H,
50H or
1J
c H ERIOT-WATT U NIVERSITY 2006
98 TOPIC 5. EXPERT SYSTEMS DEVELOPMENT
(Note that in this case, it is possible to test all the valid inputs, but it would be impossible
to test all the invalid inputs as there are so many combinations; in a larger expert system,
it would even be impossible to test all the valid inputs, so a selected sample would need
to be chosen)
Testing the Scholarian eating out advisor
Draw up a table of structured tests for the Scholarian eating out advisor (topic 3). If you
implemented this system, complete the table of tests, and comment on the results.
[Link] Use of How and Why justification in system validation
During testing, full use should be made of the How and Why justification features
provided by the system. These can be used in at least three ways.
They can be used during testing to confirm that the system’s reasoning is as expected
by the domain expert and knowledge engineer. Does the reasoning method used by the
system mirror the reasoning of the domain expert?
How and Why justification can also be used when debugging a system. If the system
gives an unexpected result, How justification can be used to trace how the system
arrived at that result. This should uncover the reason for the unexpected result, and
allow corrective action.
It is possible that an unexpected result is not incorrect. It may be that the system has
arrived at a conclusion which is correct, but had not been previously thought of by the
domain expert. In this case, How justification will reveal the new line of reasoning which
led to the conclusion. The domain expert may be able to learn form this, and increase
his/her own expertise as a result.
5.3.5 Summary of expert system development process
We have identified and described the 3 specialised stage of the expert system
development process
knowledge acquisition
knowledge representation
system validation
These correspond roughly to the design, implementation and testing stages of the
software development process. The development process for any type of software is
always an iterative process, and this is especially true for the development of large
expert systems.
c H ERIOT-WATT U NIVERSITY 2006
5.4. EVALUATION 99
Rather than a linear process.... expert system development is an iterative process:
knowledge knowledge
acquisition acquisition
knowledge
representation system knowledge
validation representation
system
validation
The process starts with knowledge acquisition. Once the knowledge engineer has a
framework of key points, he/she will create a first prototype of the system, which will
then be tested. This will show up any errors or areas where more detail is required. The
knowledge engineer will discuss these areas with the domain expert, and elicit further
knowledge. This will be coded and added to the prototype, which will then be tested
again. This process is repeated until the system is complete to the satisfaction of all
involved.
As with other software, end users should be involved in any testing of the system, both
during development and during final validation.
5.4 Evaluation
Following implementation and validation/testing of an expert system, suitable
documentation will be created, then the system should be evaluated.
c H ERIOT-WATT U NIVERSITY 2006
100 TOPIC 5. EXPERT SYSTEMS DEVELOPMENT
There are many criteria which could be applied when evaluating an expert system. We
will consider
purpose (type and domain)
range and coverage
quality of user interface
quality of explanation facilities
quality of reasoning and correctness of conclusions
fitness for purpose
5.4.1 Evaluation criteria
The following exemplifies the evaluation of an imaginary expert system according to the
criteria we have identified.
Name of Expert System
Dendrologex-UK 1.3
Purpose/Domain
Dendrologex-UK 1.3 is a classification system, to allow expert and interested amateurs
to identify any tree growing in the UK from descriptions of its features, location and
growth.
Range/Coverage
Dendrologex-UK 1.3 covers all tree species known to be growing in the UK, including
naturalised species and those grown in gardens, parks and research sites. It does not
cover any species which can only be grown indoors.
User Interface
The system has a graphical user interface. The initial screen displays the title of the
system, and the contact details of the software house. On screen windows are used
for consultation with the system. A menu of responses (e.g. yes, no, not sure) is
offered for each question asked. The correct response is selected using the mouse, or
cursor keys. Helpful pictures and diagrams are displayed to assist the user in answering
questions. Forward and back arrows are provided at the top of each screen to allow
the user to return to an earlier question to change a response. An "explain" button is
available whenever a question is being asked. A comprehensive on-line help feature is
always available. Conclusions are clearly displayed, with a "summary" button providing
an explanation of how the conclusion was reached. Four images of the tree (winter,
spring, summer, autumn) are displayed on the same screen as the conclusion. The
interface is easy to use, and suitable for both experts and amateurs.
Quality of explanation facilities
See above for description of "explain" and "summary" buttons.
Quality of reasoning and correctness of conclusions
The system uses forward chaining to reach conclusions. The conflict resolution strategy
c H ERIOT-WATT U NIVERSITY 2006
5.5. SUMMARY 101
is not known. It does not offer the use of certainty factors. These would be a useful
addition, as sometimes it is not easy to answer a question with complete certainty.
This would also allow the system to suggest alternative identifications in cases where
the conclusion is not 100% certain. The system has been validated by the botany
department of the University of Scholaria.
Fitness for purpose
Dendrologex-UK 1.3 is a useful tool for identifying the trees of the UK. It is easy to use
by a non-expert, but gives comprehensive coverage of rare species to suit an expert. It
requires Windows XP, with 4Mb of hard disc space and 387Mb or RAM. Dendrologex-UK
2.0 is due to be released next year, which will be available on-line.
Evaluation case study: evaluating 2 expert systems
You should now carry out an evaluation of 2 expert systems:
your implementation of the Scholarian Coins identifier
one of the on-line systems you have already viewed in an earlier topic
For each system, write an evaluation using the headings above. You could supplement
the evaluation with some screen shots illustrating the user interface and features of the
system.
5.5 Summary
the main stages of development of an expert system are
– knowledge acquisition / elicitation
– knowledge representation
– system validation
the principal personnel involved in expert system development are
– the domain expert(s) - provides the knowledge to be used
– knowledge engineer - elicits the knowledge from the domain expert and
codes it into a KRL
– programmer(s) - codes the user interface and inference engine
– user - consults the system and assists with testing and system validation
possible sources of error which can occur during expert system development
include
– incorrect knowledge supplied by domain expert
– misinterpretation of expert knowledge by knowledge engineer
– errors in programming and inferencing
– system providing advice beyond the limits of ignorance
c H ERIOT-WATT U NIVERSITY 2006
102 TOPIC 5. EXPERT SYSTEMS DEVELOPMENT
testing an expert system requires the use of
– structured questions
– test cases
– how and why justification
expert systems should be evaluated in terms of
– purpose (type and domain)
– range and coverage
– quality of user interface
– quality of reasoning, and correctness of conclusions
– fitness for purpose
5.6 End of topic test
An online assessment is provided to help you review this topic.
c H ERIOT-WATT U NIVERSITY 2006
103
Topic 6
Constructing an Expert System
Contents
6.1 Prior Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
6.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
6.2.1 Required practical skills . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
6.2.2 Practical skills checklist . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
6.3 Knowledge Acquisition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
6.3.1 Seagull Classification System . . . . . . . . . . . . . . . . . . . . . . . . 106
6.3.2 Bears Identifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
6.3.3 Plant Disease Adviser . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
6.3.4 Travel adviser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
6.4 Knowledge representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
6.5 System Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
6.6 Evaluating your system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
6.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
6.8 Revision Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Learning Objectives
After studying this topic, you should be able to:
derive suitable attribute-value pairs from an extended piece of unstructured text
represent attribute-value pairs as
– a factor table
– a decision tree
derive structured rules involving multiple conditions
– forward chaining rules
– backward chaining rules
exemplify parameterised rules
construct a rule base of at least 15 rules, chaining to at least 3 levels
derive structured questions to test an expert system
implement an expert system using an expert system shell
104 TOPIC 6. CONSTRUCTING AN EXPERT SYSTEM
6.1 Prior Knowledge
This topic assumes you are familiar with the structure of an expert system, have had
experience of knowledge representation techniques, and have an understanding of the
expert system development process. Before you study this topic, you should be able to
represent knowledge in the form of
– factor tables
– decision trees
– forward and backward rules
describe the 3 main stages of the expert system development process
– knowledge acquisition
– knowledge representation
– system validation
evaluate an expert system using appropriate criteria
Check your understanding by trying the revision questions.
Revision
Practical skills - tick the appropriate box if you are confident that you are able to
demonstrate the practical skill listed -if not, follow the reference to the learning materials
to revise that skill.
practical skill Yes No Link to learning materials
1 create a factor table Topic 3.3.1
2 create a decision tree Topic 3.3.3
3 create forward rules Topic 3.3.2
4 create backward rules Topic 3.3.2
5 test an expert system Topic [Link]
6 evaluate an expert system Topic 5.4.1
Q1: Match the following stages of the expert system development process to their
descriptions:
stage description
knowledge acquisition A series of structured tests are applied to ensure
that the system behaves correctly
knowledge representation The knowledge engineer extracts knowledge from
a domain expert through a series of interviews
system validation Applying a set of relevant criteria to assess how
successful a system is
system evaluation The knowledge engineer codes the knowledge
into facts and rules and stores them in a
knowledge base
c H ERIOT-WATT U NIVERSITY 2006
6.2. INTRODUCTION 105
6.2 Introduction
In the previous topics, you have covered a wide range of topics related to expert
systems, and you have learned how to represent knowledge to allow you to create a
knowledge base.
The purpose of this final topic is for you to use all that you have learned to design,
create, test and evaluate one or more expert systems.
6.2.1 Required practical skills
For SQA practical assessment of this Unit, you are required to demonstrate the following
4 skills:
1. finding solutions to given problems by consultation of expert systems for
advice, classification, diagnosis and planning
You should already have demonstrated this skill by completing the practical tasks in
Topic 1.3 (Whale Watcher), Topic 1.4.3 (easydiagnosis and yourdiagnosis), and Topic
1.6 (dairy farmer adviser, animal expert, my car won’t start, PlanIT)
2. structured testing and critical evaluation of an expert system
You should already have demonstrated this skill by completing the practical tasks in
Topic [Link] (testing Scholarian coins) and Topic 5.4.1 (evaluating 2 expert systems)
3. representing a limited domain of knowledge in a structured form (decision tree
or factor table)
You should already have demonstrated this skill by completing the practical tasks in
Topic 3.3.1 (creating a factor table) and Topic 3.3.3 (creating a decision tree)
4. construction of a working expert system given a limited domain of knowledge.
Although you have done this in Topic 3.3.2, the resulting system was probably not
sufficiently complex to meet the SQA requirements, which are as follows: the system
must
have at least 15 rules
have at least 2 rules with three or more conditions
use rule chaining to at least 3 levels
In this topic, you will fulfil all the requirements for the final practical skill.
6.2.2 Practical skills checklist
Print out this practical skills checklist. You should already be able to tick all the
checkboxes for skills 1 to 3. By the end of this topic, you will have demonstrated the
final skill.
c H ERIOT-WATT U NIVERSITY 2006
106 TOPIC 6. CONSTRUCTING AN EXPERT SYSTEM
skill task topic check
1 Whale watcher Topic 1.3
Easy diagnosis / Your diagnosis Topic 1.4
Dairy farmer / animal adviser / car starter / PlanIT Topic 1.6
2 Testing Scholarian coins / eating out adviser Topic
[Link]
Evaluating 2 expert systems Topic
5.4.1
3 Creating a factor table Topic
3.3.1
Creating a decision tree Topic
3.3.3
4 System has 15 rules Topic 6.4
Some rules have 3 or more conditions Topic 6.4
Rules chaining is required to at least 3 level Topic 6.4
6.3 Knowledge Acquisition
For this unit, you should be able to
derive suitable attribute-value pairs from an short piece of structured text, not
involving multi-values attributes (at Intermediate 2 level)
derive suitable attribute-value pairs from an extended piece of unstructured text,
involving some multi-values attributes (at Higher level)
represent these attribute-value pairs as a factor table and as a decision tree.
You have already tried this with some fairly simple examples. Now you are going to
tackle one or two more complex examples.
Browse the passages that are listed below, and choose one that you will process into
an expert system.
6.3.1 Seagull Classification System
There are 8 varieties of gull commonly found in the UK. The differ in appearance, habitat
and in the parts of Britain where they are to be found.
The Black Headed Gull is around 35cm in length, has a black or dark brown head, and
red legs and bill. Its wings are light grey with black tips. It is generally found in bogs or
marshes near water. They are fairly common throughout the UK and Ireland.
The Little Gull, as its name suggests, is the smallest gull found in the UK at a length of
28cm. It has a black or dark brown head, dark grey wings, and red legs and bill. It is
generally found near fresh water in bogs and marshes. It can be found in eastern areas
of Britain.
c H ERIOT-WATT U NIVERSITY 2006
6.3. KNOWLEDGE ACQUISITION 107
The Herring Gull is perhaps the most common gull in the UK. It grows to an average
length of 60cm. Herring Gulls have yellow legs and bills with white heads and light grey
wings with black tips. It generally inhabits sea cliffs and coastal dunes but can be seen
inland. Herring Gulls are common in all parts of the UK and Ireland.
The Lesser Black Back Gull grows to a length of 55cm, has dark grey or black wings, a
white head and yellow legs and bill. It is found in similar locations to the Herring Gull but
is more common in western areas of the UK and throughout Ireland.
The Greater Black Back Gull is larger than the Lesser Black Back, reaching a length of
70cm, but otherwise very similar in appearance. It is usually found near sea cliffs in any
area of the UK and Ireland.
The Glaucous Gull has light grey wings, pink legs and a yellow bill. The head is white.
Glaucous Gulls are found on rocky coasts in northern areas of the UK. The average size
of the Glaucous Gull is 75cm.
The Iceland Gull is similar in appearance to the Glaucous Gull but smaller at only 60cm.
It is found near both fresh and sea water on a variety of shores. It is only found in the
north of Britain.
The final variety is the Common Gull, which is relatively small at only 40cm. Its
appearance is very similar to the Herring Gull with white head, light grey wings with
black tips, yellow legs and yellow bill. It is found mainly near coasts on sand or shingle
beaches. The Common Gull is found all over the UK.
(Source: SQA)
6.3.2 Bears Identifier
In general, bears are heavy of body, with long thick fur, and are short-sighted because
of their small eyes. There are several species of bears, including Big brown bears,
American black bears, Asiatic black bears, Polar bears, Sun bears and Spectacled
bears.
Big brown bears have among them the world’s largest bears. For example, Alaskan
brown bears, such as the Kodiak bear, and the Grizzly bear. Alaskan brown bears are
found mostly on the mainland of Alaska, USA and on Kodiak Island off the south-eastern
coast of Alaska. Grizzlies get their name from the white hairs that grow in their brown
coats. Grizzlies live mainly in Alaska and western Canada.
American black bears are among the most common species. Not all black bears are
completely black. One type, called the Cinnamon bear, has a rusty brown coat. The
Kermode’s bear has creamy white fur and white claws. Black bears live in many large
wooded areas of North America.
Asiatic black bears are smaller than American black bears. Most Asiatic black bears are
black with a large white crescent-shaped mark on the chest. These bears live in forests
and brush regions throughout southern and eastern Asia.
Polar bears are only a little smaller than Big brown bears. The thick, heavy fur is creamy
white, with a hint of yellow. Polar bears live in regions bordering the Arctic Ocean.
Sun bears are the smallest species of bear. Most Sun bears have a black coat and a
greyish or orange nose. The bear gets its name from the white or yellow marks on its
c H ERIOT-WATT U NIVERSITY 2006
108 TOPIC 6. CONSTRUCTING AN EXPERT SYSTEM
chest. Sun bears live in the forests of Thailand.
Spectacled bears are the only South American bears. They have shaggy black or
blackish-brown fur. The spectacled bear is named after the large circles or half-circles
of white fur around its eyes. The circles look like spectacles. The bears live in the cool
mountain forests of South America.
(Source: SQA)
6.3.3 Plant Disease Adviser
Sunken black spots appearing on leaves may be caused by Anthracnose. Palms and
Ficus plants are particularly susceptible to this disease, which is encouraged by warm
and very moist conditions. The infected leaves must be removed and burnt. The plant
should be sprayed with a fungicide, and kept on the dry side for several weeks.
Grey, fluffy mould growing on leaves, stems, buds and flowers is usually a sign of
Botrytis. It affects all soft-leaved plants, including Begonia, Cyclamen, Gloxinia and
Saintpaulia. The affected parts must be removed and destroyed. The plant should be
sprayed with a fungicide, and watering should be reduced.
The "damping off" fungi attack the root and lower stems of seedlings. Affected plants rot
at ground level, and topple over. Collapsed seedlings must be removed. This disease
can be prevented by always using sterilised compost. An effective treatment is Cheshunt
Compound.
Hard corky growths on the underside of leaves are not usually a symptom of disease.
They result from waterlogged compost and low light levels. Badly effected leaves should
be removed, and the plant should be put in a brighter spot, and watering reduced.
Sooty Mould is a black sticky fungus which may appear on the upper surfaces of leaves.
It is not directly harmful to the plant, but it is unsightly. Affected leaves should be wiped
with a damp cloth. As this mould is spread by bugs such as aphids, plants should be
sprayed with a pesticide to prevent further attacks.
Powdery Mildew appears as a white powdery deposit on plant leaves. Its appearance
at first is similar to Botrytis, but it does not develop into the grey fluffy form, and is much
less harmful to the infected plants. Badly mildewed leaves should be removed, and the
plant sprayed with a fungicide. Ventilation around the plant should be increased.
The apearance of pale green or yellow spots on leaves may be due to a virus attack.
There is no cure. Infected plants must be removed and burned. However, spots on
leaves are more commonly the result of under or over watering or sun damage. A viral
attack can be identified by its progressive nature, causing the whole plant eventually to
die off.
6.3.4 Travel adviser
Scholarium Travel Agents like to believe that they have up-to-the-minute technology for
their customers. They would like a basic advice system to help their customers make up
their minds as to their holiday destination.
The have provided the following basic information on a few popular summer and winter
destinations.
c H ERIOT-WATT U NIVERSITY 2006
6.4. KNOWLEDGE REPRESENTATION 109
Many people enjoy a beach holiday in the summer sun. At the cheapest end of the
scale Turkey is a good all rounder. This doesn’t suit everyone, so some people opt for
the slightly more expensive option of Majorca. For those who really want to splash out,
the Caribbean offers sun, sea and sand all the year round.
For those who don’t like beaches, these destinations may whet a few appetites. Central
France is always missed but is accessible by car and can be fairly cheap. Moving up
in price, Germany is good for sightseeing, especially Bavaria. For a truly mesmerising
experience, Italy is not to be missed, but be prepared to spend as Italy is very expensive.
Winter holidays are a popular alternative. The most popular destinations are Switzerland
and Austria. Both are very expensive, particularly during the skiing season.
Believe it or not, a beach holiday to Florida in the winter months for all snow-haters can
be quite a bargain. However, cheaper still is the ever popular Tenerife which, in winter,
is still nice and warm.
(Source: SQA)
6.4 Knowledge representation
Follow through the 5 steps listed below to create a working expert system based on the
passage you have chosen.
Creating a Factor Table
Based on the information given in the passage you have chosen, draw up a factor table,
showing clearly the attributes you have chosen to use, and their values. You can remind
yourself of how to create a factor table by revising Topic 3.3.1.
Creating a Decision Tree
Consider carefully the order of the attributes. Select the order that can be implemented
most efficiently.
Once you have decided on an order for the attributes, convert the factor table into a
decision tree. You can remind yourself of how to create a decision tree by revising Topic
3.3.3.
You may then prune the decision tree to remove any unnecessary nodes, as you did in
Topic 3.3.4.
Deriving Structured Rules
Using your factor table and/or decision tree, create a set of structured rules to represent
the knowledge. Your rules may be expressed in either forward or backward form.
If appropriate (and possible in your expert system shell) you should represent any
uncertainty using certainty factors. You should create a rule base consisting of at
least 15 rules, some of which involving chaining to at least 3 levels.
c H ERIOT-WATT U NIVERSITY 2006
110 TOPIC 6. CONSTRUCTING AN EXPERT SYSTEM
Deriving Structured Questions
If your expert system shell allows it, you should include structured questions which
prevent the system from duplication of questions. An appropriate choice of attributes,
and the pruning of the decision tree should already have reduced the likelihood of this
occurring.
Implementing your Expert System
You should now enter your rules into an expert system shell.
6.5 System Validation
Now that you have completed building your expert system, it needs to be validated.
You should create a table of appropriate tests (as you did for the Scholarian coins in
Topic [Link]), something like this....
reason for colour size(mm) shape symbol expected result of comment
test result test
valid inputs bronze 18 round fish 1H
bronze 18 round bird 6H
silver 18 round flower 10H
silver 22 7 sided fish 20H
silver 22 round fish 50H
silver 25 triangular mountain 1J
two tone 30 7 sided bird 6J
Invalid bronze 18 round flower -
combinations
bronze 18 7 sided fish -
two tone 25 7 sided bird -
Invalid input bronze 18 square fish -
values
silver 10 triangular mountain -
Missing bronze 18 round - 1H or 6H
values
silver - - - 10H,
20H,
50H or
1J
c H ERIOT-WATT U NIVERSITY 2006
6.6. EVALUATING YOUR SYSTEM 111
Testing your system
Carry out the tests defined in your test table.
If necessary
make use of "How" and "Why" justification to debug any unexpected advice or
questions.
make any changes to the system which may be required
re-test after any changes
6.6 Evaluating your system
Once you are satisfied that your system is valid, it is time for it to be evaluated. If you
are working in a class group, it is a good idea to evaluate someone else’s system, and
to ask them to evaluate yours. This way, your evaluation will be more objective.
Evaluation report
Write an evaluation report, using the following criteria
purpose (type and domain)
range and coverage
quality of user interface
quality of explanation features
quality of reasoning and correctness of conclusions
fitness for purpose
6.7 Summary
In this topic, you have used all that you have learned about expert systems to
derive suitable attribute-value pairs from an extended piece of unstructured text
represent attribute-value pairs as
– a factor table
– a decision tree
derive structured rules involving multiple conditions
– forward chaining rules
c H ERIOT-WATT U NIVERSITY 2006
112 TOPIC 6. CONSTRUCTING AN EXPERT SYSTEM
– backward chaining rules
construct a rule base of at least 15 rules, chaining to at least 3 levels
derive structured questions to test an expert system
implement an expert system using an expert system shell
6.8 Revision Questions
As this topic has focussed on applying the knowledge and understanding gained in
earlier topics, there are no revision questions.
You should check with your teacher / tutor that your practical work in this and earlier
topics is appropriate for Higher level, and ensure that your practical skills checklist has
been completed:
skill task topic check
1 Whale watcher Topic 1.3
Easy diagnosis / Your diagnosis Topic 1.4
Dairy farmer / animal adviser / car starter / PlanIT Topic 1.6
2 Testing Scholarian coins / eating out adviser Topic
[Link]
Evaluating 2 expert systems Topic
5.4.1
3 Creating a factor table Topic
3.3.1
Creating a decision tree Topic
3.3.3
4 System has 15 rules Topic 6.4
Some rules have 3 or more conditions Topic 6.4
Rules chaining is required to at least 3 level Topic 6.4
c H ERIOT-WATT U NIVERSITY 2006
GLOSSARY 113
Glossary
Backward chaining
An inferencing strategy which starts with a possible conclusion, and works
backwards to determine whether the conditions are met for this conclusion to be
valid.
Certainty factor (CF)
A number used to represent the degree of probability associated with a fact, a rule
or a conclusion. This may be a number in the range -1 to +1, -100 to + 100, or 0
to 1.
Conflict resolution
A number of techniques used in forward chaining systems to determine which of
the possible rules to fire at a given time.
Conflict set
The list of rules in a forward chaining system which could be fired at any given time
Context limiting
A conflict resolution strategy used in forward chaining systems. The system only
considers rules within a currently relevant rule agenda.
Data ordering
A conflict resolution strategy used in forward chaining systems. The system fires
the rule which depends on the most important facts in working memory. Data and
facts are given a priority by the knowledge engineer.
Decision tree
A graphical representation of the knowledge to be represented in an expert
system.
Deductive database
A system which combines the inferencing power of an expert system with the
ability of a database to store large amounts of structured data
Domain
The area of knowledge within which an expert system can give reliable advice
Domain expert
A human who has expert knowledge within a domain (e.g. a specialist doctor for
a medical diagnosis system)
Expert system shell
An expert system with no knowledge base (i.e. a user interface and inferencing
engine). The sue of expert system shells greatly reduces the time and cost of
developing an expert system.
Factor table
A table showing all relevant attributes and their values, used during the analysis
and design stages of expert system development.
c H ERIOT-WATT U NIVERSITY 2006
114 GLOSSARY
Forward chaining
An inferencing strategy which starts with known facts in working memory. Rules
whose conditions are satisfied are then fired, adding new facts. The cycle is
repeated until a conclusion is reached.
Fuzzy logic
A form of logic which can be applied to attributes which are not binary in character
(e.g. tallness). Fuzzy logic is used in many applications including some expert
systems. It should not be confused with certainty factors.
Inference engine
The part of an expert system which determines the order of applying rules and
asking questions, and uses an inferencing strategy (type of logical reasoning) to
reach a conclusion.
Knowledge acquisition
A stage in the development of an expert system, during which a knowledge
engineer acquires knowledge from a domain expert or other sources.
Knowledge base
The part of an expert system where knowledge is stored, usually in the form of
facts and rules represented in a knowledge representation language (KRL).
Knowledge Elicitation
The process of obtaining knowledge from a human. This can involve the use of
interviews, observation, protocol analysis.
Knowledge engineer
A skilled person whose role is to acquire knowledge from a variety of sources, and
convert this into a suitable representation for entry into a knowledge base.
Knowledge representation
A stage in the development of an expert system, during which a knowledge
engineer converts domain knowledge into a for suitable for entry into a knowledge
base, using some form of knowledge representation language (KRL).
Knowledge representation language (KRL)
A formal language which can be used to represent facts and relationships within
an expert system knowledge base.
Proposition
A statement that can be either true or false
Recency
A conflict resolution strategy used in forward chaining systems. The system fires
the rule which depends on the most recently added facts in working memory.
Refractoriness
A conflict resolution strategy used in forward chaining systems. The system does
not fire a rule which has already been fired (unless a change has occurred in
working memory).
c H ERIOT-WATT U NIVERSITY 2006
GLOSSARY 115
Rule chaining
The use of rules which depend on other rules within an expert system.
Rule ordering
A conflict resolution strategy used in forward chaining systems. The system fires
the first rule (or the one assigned the highest priority) in the conflict set.
Specificity
A conflict resolution strategy used in forward chaining systems. The system fires
the rule which matches the greatest number of known facts in working memory.
System validation
A stage in the development of an expert system, during which systematic testing
is applied to ensure that the expert system is reliable.
User interface
The part of an expert system which allows the user to communicate with the
system.
Working memory
An area of memory allocated to an expert system during a consultation. It stores
all currently valid facts.
c H ERIOT-WATT U NIVERSITY 2006
116 ANSWERS: TOPIC 1
Answers to questions and activities
1 Expert Systems in context
Exploring Whale Watcher (page 4)
From your search of Whale Watcher, you should have identified that the whale was a
minke whale.
Identifying suitable expert system domains (page 4)
Q1: No: Domain too large for current systems
Q2: Yes: Limited domain
Q3: Yes: Limited domain
Q4: No: Results cannot be predicted reliably by human experts, due to large element
of chance
Q5: Yes: Limited domain
Q6: Yes: Limited domain
Expert System Case Studies (1) (page 5)
Name of expert Find out at: Domain
system
Shyster [Link] Australian case
law
Expertax [Link] Tax planning
[Link]
Coal Quality [Link] Reducing
Expert pollution from
summaries/cqe/[Link]
power stations
SARAH [Link] Training in
hygiene
[Link] (then search for
SARAH expert system).
Datacab [Link] Routing of
communication
Congresos/2002%20IECON%[Link]
cables
Who is to blame (page 8)
You might argue that any of the domain expert, the knowledge engineer, the programmer
of the expert system shell or the software company selling the product could be
c H ERIOT-WATT U NIVERSITY 2006
ANSWERS: TOPIC 1 117
held responsible. However, generally speaking, the user is considered to accept
responsibility by acting on the advice given by an expert system, just as the reader
of a book would be responsible if taking advice from a book. No doubt, the software
company’s lawyers will have carefully inserted no-responsibility clauses in the small print
of the software documentation.
Medical Expert Systems (page 8)
Warning messages at start of consultation
Advise users to consult a qualified medical practitioner
Require users to log-in (prevents casual use)
Identifying the characteristics of information systems (page 9)
Management Information Executive Information Decision Support System
System System
used in planning, leading, analyse, compare and suitable for unique and
organising and controlling identify trends and non-recurring queries
an organisation outcomes
supports the tactical level used at strategic level hypothetical modelling and
of the organisation forecasting
analyse and report on presents summaries used interactively
what’s recorded in data
processing system
generates customised used at different levels
reports within an organisation
c H ERIOT-WATT U NIVERSITY 2006
118 ANSWERS: TOPIC 1
Comparing databases and expert systems (page 10)
query
data Database
records System
fields
report
User passive
2-way
consultation
facts
Expert
questions, rules System
advice,
explanations
User active/intelligent
Target 10 Online Consultant (page 11)
Q7: dairy farmers in Australia
Q8: experienced farmers, or agricultural college staff
Q9: problems facing dairy farmers
Q10: easy (and free) access to advice if farming in a remote area
Q11: advice is very general, and may ignore specific features of the farm
Identifying animals (page 12)
Q12: For Animal Expert: students learning about Expert Systems
For Whale Watcher: tourists on a boat trip
Q13: For Animal Expert: the university lecturer
For Whale Watcher: marine biology experts
Q14: For Animal Expert: identifying common animals
For Whale Watcher: identifying common whales
Q15: For Animal Expert: not much - it is only a "toy" expert system to illustrate how one
works
For Whale Watcher: easy (and free) access to help identification if there is no expert or
book available
c H ERIOT-WATT U NIVERSITY 2006
ANSWERS: TOPIC 1 119
Q16: For Animal Expert: it doesn’t know about obscure animals
For Whale Watcher: the questions might be difficult to answer, if the observation wasn’t
clear
My car won’t start! (page 12)
Q17: normal car users - who don’t know anything about how a car works
Q18: experienced car mechanics
Q19: car starting problems
Q20: it might save them form having to call out a repair service
Q21: they might not understand the technical terms
Classifying classical systems (page 17)
name domain year type characteristic
DENDRAL Soil sample 1971 classification Used forward chaining
analysis
MYCIN Diagnosing 1972 diagnosis Used backward chaining,
blood uncertainty factors and
disorders separated knowledge
base from inference
engine
ONCOCIN Cancer 1980s diagnosis Combined sequencing of
treatment and planning actions with diagnosis
INTERNIST Multiple 1974 diagnosis Produced a very useful
medical large knowledge base of
conditions diseases and symptoms
PROSPECTORMineral Late 1970s advice Uses Bayesian probability
exploration to represent uncertainty
XCON configuring Early 1980s planning Saved money by being
VAX faster and more accurate
computer than human designers
systems
c H ERIOT-WATT U NIVERSITY 2006
120 ANSWERS: TOPIC 2
2 Expert System structure
Revision Questions (page 20)
Q1: b) false
Q2: a) true
Q3: b) false
Q4: b) false
Q5: a) true
Q6: a) true
Q7: b) false
Q8: a) true
Q9: a) true
Q10: b) false
c H ERIOT-WATT U NIVERSITY 2006
ANSWERS: TOPIC 3 121
3 Knowledge Representation
Revision Questions (page 30)
Q1: b) the knowledge base
Q2: d) the sun is shining
Q3: b) a language used to represent knowledge
Answers from page 31.
Q4:
The number of body bags is uncertain
What does it mean by "elderly people"?
The 3 people are "believed to have contracted infections"
Scholarian coins factor table (page 33)
value colour size(mm) shape symbol
1H bronze 18 round fish
6H bronze 18 round bird
10H silver 18 round flower
20H silver 22 7 sided fish
50H silver 22 round fish
1J silver 25 triangular mountain
6J two tone 30 7 sided bird
c H ERIOT-WATT U NIVERSITY 2006
122 ANSWERS: TOPIC 3
Scholarian coins rules (page 34)
Forward Rules Backward Rules
- . - 0"
. // - 0, - .
% - .// - 0,
/ - % -
!"# - 0" / -
- . - 1"
. // - 0, - .
% - .// - 0,
/ - % -
!"# - 1" / -
- - 0*"
. // - 0, -
% - .// - 0,
/ - % -
!"# - 0*" / -
- - +*"
. // - ++ -
% - ' .// - ++
/ - % - '
!"# - +*" / -
- - (*"
. // - ++ -
% - .// - ++
/ - % -
!"# - (*" / -
- - 02
. // - +( -
% - .// - +(
/ - / % -
!"# - 02 / - /
- - 12
. // - )* -
% - ' .// - )*
/ - % - '
!"# - 12 / -
c H ERIOT-WATT U NIVERSITY 2006
ANSWERS: TOPIC 3 123
Completing a decision tree for the Scholarian coins (page 35)
colour
bronze silver two tone
size (mm) size (mm) size (mm)
18 18 22 25 30
shape shape shape shape shape
round round 7-sided round triangular 7-sided
symbol symbol symbol symbol symbol symbol
fish bird flower fish fish mountain bird
value = 1H value = 6H value = 10H value = 20H value = 50H value = 1J value = 6J
Some people find this visual representation easier as a starting point. It also helps you to
understand how the system might operate (although this will depend on the inferencing
method used by the expert system).
Note that this is not the only tree that could have been created. The form of the tree will
depend on the order in which the attributes are considered. For example, if the attributes
are considered in the order - size, shape, colour, symbol - then the decision tree would
look like this:
c H ERIOT-WATT U NIVERSITY 2006
124 ANSWERS: TOPIC 3
size (mm)
18 22 25 30
shape shape shape shape
round 7-sided round triangular 7-sided
colour colour colour colour colour
bronze silver silver silver silver two tone
symbol symbol symbol symbol symbol symbol
fish bird flower fish fish mountain bird
value = 1H value = 6H value = 10H value = 20H value = 50H value = 1J value = 6J
c H ERIOT-WATT U NIVERSITY 2006
ANSWERS: TOPIC 3 125
Another decision tree (page 35)
symbol
fish bird flower mountain
shape shape shape shape
round 7-sided round 7-sided round triangular
colour colour colour colour colour colour
bronze silver silver bronze two tone silver silver
size (mm) size (mm) size (mm) size (mm) size (mm) size (mm) size (mm)
18 22 22 18 30 18 25
value = 1H value = 50H value = 20H value = 6H value = 6J value = 10H value = 1J
Answers from page 36.
Q5: The last 2 questions are unnecessary. Once the system knows that the coin in
silver and 18mm, it must be a 10H coin, as there are no others which fit this description.
c H ERIOT-WATT U NIVERSITY 2006
126 ANSWERS: TOPIC 3
Pruning a decision tree (page 37)
colour
bronze silver two tone
size (mm)
22
shape
18 25
symbol 7-sided round
fish bird
value = 1H value = 6H value = 10H value = 20H value = 50H value = 1J value = 6J
Scholarian Cuisine Knowledge Base (page 39)
Part 1
Part 2
IF Price = cheap AND
type of food = traditional Scholarian AND
position = town centre AND
decor = basic AND
music = live
c H ERIOT-WATT U NIVERSITY 2006
ANSWERS: TOPIC 3 127
THEN Name = Hobbit’s Hole .
IF Price = expensive AND
type of food = haute cuisine AND
position = edge of town AND
decor = stylish AND
music = classical pianist
THEN Name = Grand Palalce Hotel .
IF Price = reasonable AND
type of food = seafood AND
position = town centre AND
music = modern popular
THEN Name = Scholarium .
IF Price = cheap AND
type of food = fast food AND
position = town centre AND
decor = plain AND
music = none
THEN Name = Seven-sided Coin .
IF Price = reasonable AND
type of food = traditional Scholarian AND
position = out of town AND
decor = smart
THEN Name = Mountain Top .
IF Price = expensive AND
type of food = international AND
position = out of town AND
decor = smart
THEN Name = Blue Villa .
c H ERIOT-WATT U NIVERSITY 2006
128 ANSWERS: TOPIC 3
Note: other answers are possible, if you have put the attributes or values in a different
order
Part 3
Name = Hobbit’s Hole IF
Price = cheap AND
type of food = traditional Scholarian AND
position = town centre AND
decor = basic AND
music = live .
Name = Grand Palalce Hotel IF
Price = expensive AND
type of food = haute cuisine AND
position = edge of town AND
decor = stylish AND
music = classical pianist .
Name = Scholarium IF
Price = reasonable AND
type of food = seafood AND
position = town centre AND
music = modern popular .
Name = Seven-sided Coin IF
Price = cheap AND
type of food = fast food AND
position = town centre AND
decor = plain AND
music = none .
Name = Mountain Top IF
Price = reasonable AND
c H ERIOT-WATT U NIVERSITY 2006
ANSWERS: TOPIC 3 129
type of food = traditional Scholarian AND
position = out of town AND
decor = smart .
Name = Blue Villa IF
Price = expensive AND
type of food = international AND
position = out of town AND
decor = smart .
Part 4
price
cheap reasonable
expensive
type of food type of food type of food
traditional haute fast food international seafood traditional
scholarian cuisine scholarian
position position position position position position
town town edge of out of town out of
centre centre town town centre town
decor decor decor decor music decor
modern
basic plain stylish smart smart
popular
name = name = name =
music music music Blue Villa Scholarium Mountain Top
live none classical
pianist
name = name = Seven- name = Grand
Hobbits Hole sided coin Palace Hotel
Part 5
c H ERIOT-WATT U NIVERSITY 2006
130 ANSWERS: TOPIC 3
price
cheap reasonable
expensive
type of food type of food type of food
traditional haute fast food international seafood traditional
scholarian cuisine scholarian
name = name = Seven- name = Grand name = name = name =
Hobbits Hole sided coin Palace Hotel Blue Villa Scholarium Mountain Top
Part 6
c H ERIOT-WATT U NIVERSITY 2006
ANSWERS: TOPIC 3 131
Original backward rules Simplified backward rules
Name = Hobbit’s Hole IF Name = Hobbit’s Hole IF
Price = cheap AND Price = cheap AND
type of food = traditional Scholarian AND type of food = traditional Scholarian
position = town centre AND
decor = basic AND Name = Grand Palalce Hotel IF
music = live . Price = expensive AND
type of food = haute cuisine .
Name = Grand Palalce Hotel IF
Price = expensive AND Name = Scholarium IF
type of food = haute cuisine AND Price = reasonable AND
position = edge of town AND type of food = seafood.
decor = stylish AND
music = classical pianist . Name = Seven-sided Coin IF
Price = cheap AND
Name = Scholarium IF type of food = fast food .
Price = reasonable AND
type of food = seafood AND Name = Mountain Top IF
position = town centre AND Price = reasonable AND
music = modern popular . type of food = traditional Scholarian .
Name = Seven-sided Coin IF Name = Blue Villa IF
Price = cheap AND Price = expensive AND
type of food = fast food AND type of food = international .
position = town centre AND
decor = plain AND
music = none .
Name = Mountain Top IF
Price = reasonable AND
type of food = traditional Scholarian AND
position = out of town AND
decor = smart .
c H ERIOT-WATT U NIVERSITY 2006
132 ANSWERS: TOPIC 3
Original backward rules Simplified backward rules
Name = Blue Villa IF
Price = expensive AND
type of food = international AND
position = out of town AND
decor = smart .
Answers from page 41.
Q6:
1. this statement cannot be either true or false - if it is true, then it must be untrue - if
it is false, then it must be true!
2. this statement is a matter of opinion - some people will consider it true, some will
conside it false
3. the truth of this statement cannot be determined, because we do not know who
"they" are, and there is an agreed definition of "intelligent".
Answers from page 42.
Q7: "If there is food in the fridge, or the shops are open and I have money, then I can
eat"
Logic example 1 (page 43)
AB is true (if Bouncer is a dog then Bouncer is an animal)
BA is unprovable (if Bouncer is an animal then Bouncer may be a dog, but may be a
cat or something else!)
BA is true (if Bouncer is not an animal then Bouncer is not a dog)
Representing statements using propositional logic (page 43)
a) S
b) SF
c) FG
d) SG
e) SFG
f) SFG
c H ERIOT-WATT U NIVERSITY 2006
ANSWERS: TOPIC 3 133
Representing statements using predicate logic (page 45)
English statement Predicate logic representation
Dundee is a city with no castle city(Dundee) hascastle(Dundee)
If Dundee is a city, it has many city(Dundee)
inhabitants. manyinhabitants(Dundee)
All cities have many inhabitants. x : city(x) manyinhabitants(x)
There are no cities on Mars. x : city(x) onMars(x)
A bungalow is a house with one floor. x : house(x) onefloor(x)
bungalow(x)
Every woman likes flowers x : woman(x) likes(x, flowers)
Two people are cousins if they have the x,y : grandparent(g,x)
same grandparent grandparent(g,y) cousins(x,y)
Representing statements using Prolog (page 45)
English statement Prolog representation
Dundee is a city with no castle city(dundee), not(hascastle(dundee)).
If Dundee is a city, it has many manyinhabitants(dundee) :-
inhabitants. city(dundee).
All cities have many inhabitants. manyinhabitants(X) :- city(X).
There are no cities on Mars. not(onMars(X) :- city(X).
A bungalow is a house with one floor. bungalow(X) :- house(X), onefloor(X).
Every woman likes flowers likes(X, flowers) :- woman(X).
Two people are cousins if they have the cousins(X,Y) :- grandparent(G,X),
same grandparent grandparent(G,Y).
c H ERIOT-WATT U NIVERSITY 2006
134 ANSWERS: TOPIC 4
4 How Expert Systems Work
Revision Questions (page 49)
Q1: d) the inference engine
Q2: c) the knowledge base
Q3: b) inference engine and user interface
Q4: a) a forward rule
Q5: b) a backward rule
Investigating User interfaces (page 54)
Expert System Graphical? Certainty Why? How?
factors? explanations explanations
Whale watcher select from No No No
menu - helpful
graphics
provided
Spa Pool select from No No Summary
adviser menu report provided
Car won’t start click buttons to Yes Why ask button Explain button
select provided
Sailing ships select from No No No
menu - helpful
graphics
provided
On-line doctor click buttons to No Click on No
select question for
reason
Your diagnosis select from No Pop-up boxes No
menu - helpful provided for
graphics some questions
provided
Tree Identifier select from No Yes Yes (explain
menu - helpful button)
graphics
provided
c H ERIOT-WATT U NIVERSITY 2006
ANSWERS: TOPIC 4 135
Identifying features of forward and backward chaining (page 69)
Backward chaining Forward chaining
Overall description Goal-driven data-driven
Strategy Starts with hypothesis, Starts with facts, uses
attempts to justify it from these to fire rules until
facts and rules conclusion is reached
Common rule format X if Y and Z If Y and Z then X
Applications Diagnostic, Analysis, classification
theorem-proving
Classical example MYCIN DENDRAL
Summarising conflict resolution strategies (page 74)
Conflict resolution strategy Description
Rule ordering Put most important rules first
Recency Fire the rule which depends on the
newest data in working memory
Specificity Fire the rule that has the most conditions
Refractoriness Don’t fire the same rule twice
Data ordering Fire the rule that depends on the most
important data
Context limiting Only fire rules that are in the currently
relevant group
Calculating Certainty Values for Simple Rules (page 77)
Q6: It will rain today CF 40 (50% x 80% = 40%)
Q7: The pupil will be offered a place at university CF 24.75 (99% x 25% = 24.75%)
Q8: The pupil will be offered a place at university CF 79.2 (99% x 80% = 79.2%)
Q9: The pupil will get an A in Higher Information Systems CF 0.4 (0.5 x 0.8 = 0.4)
Calculating Certainty Values for Complex Rules (page 78)
Q10: It will rain today (CF 30).
(MIN(60%,75%) = 60%, 60% x 50% = 30%)
Q11: The pupil will be offered a place at university (CF 0.48). (
MIN(0.6, 0.75, 0.9) = 0.6, 0.6 x 0.8 = 0.48
c H ERIOT-WATT U NIVERSITY 2006
136 ANSWERS: TOPIC 4
Q12: The pupil will be offered a place at university (CF 0.16).
(MIN(80%, 20%, 30%) = 20%, 20% x 0.8 = 0.16
Q13: You are in France (CF 32)
(MIN(90%, 40%, 60%) = 40%, 40% x 80% = 32%)
c H ERIOT-WATT U NIVERSITY 2006
ANSWERS: TOPIC 5 137
5 Expert Systems Development
Revision (page 87)
Q1: a) to allow managers to obtain expert summaries of sales data
Q2: c) the subject area in which it can give advice
Q3: b) the knowledge base
Q4: c) to determine the order in which rules are applied
Q5: d) inference engine and user interface
Q6: a) advice, classification, diagnosis and planning
Identifying the main stages of the software development process (page 89)
Stage Description
Agreeing the specification - what domain
Analysis
are will be covered
Planning the user interface, obtaining the
expert knowledge from the domain expert,
Design deciding on the method of representing the
knowledge and the type of inferencing to
be used
Converting the expert knowledge into facts
and rules and coding it in a knowledge
Implementation representation language; creating the
user interface and inference engine (or
selecting a suitable expert system shell)
Making sure the expert system produces
Testing
appropriate results
Documentation Writing a user guide and technical guide
Reviewing the expert system to identify
Evaluation
strengths and weaknesses
Adapting the expert system for new
Maintenance environments, adding new features and
extending the knowledge base
c H ERIOT-WATT U NIVERSITY 2006
138 ANSWERS: TOPIC 5
Identifying domain experts (page 90)
Expert system Domain expert
MYCIN Blood infection specialist
Prospector Mineral geologist
Dendral Research chemist
Internist doctors
R1/XCON Computer engineers
Whale watcher Marine biologist
Shyster Australian law expert
Expertax Tax accountant
SARAH Hygiene trainer
Datacab Telecommunication engineer
Answers from page 91.
Q7: No. The knowledge engineer does not need to be able to program is these
languages, but must be able to code knowledge using a KRL.
Q8: Yes. The knowledge engineer must be able to create rules and facts in a KRL.
This is the knowledge engineer’s main task.
Q9: Yes. The knowledge engineer must be a good communicator, able to conduct
interviews with domain experts.
Q10: No. The domain expert provides the deep knowledge of the domain
Q11: Yes. The knowledge engineer must develop some knowledge of the domain, so
that he/she is able to communicate effectively with the domain expert
Q12: Yes. The knowledge engineer must select a suitable inferencing strategy for the
system
Q13: Yes. The knowledge engineer must select a suitable expert system shell
Q14: Yes. The knowledge engineer will be working in a team with a project manager,
domain expert(s), programmer(s), tester(s) and end users.
c H ERIOT-WATT U NIVERSITY 2006
ANSWERS: TOPIC 6 139
6 Constructing an Expert System
Revision (page 104)
Q1:
stage description
knowledge acquisition The knowledge engineer extracts knowledge from
a domain expert through a series of interviews
knowledge representation The knowledge engineer codes the knowledge
into facts and rules and stores them in a
knowledge base
system validation A series of structured tests are applied to ensure
that the system behaves correctly
system evaluation Applying a set of relevant criteria to assess how
successful a system is
c H ERIOT-WATT U NIVERSITY 2006