Expert Systems
Department of Information
Technology
Ambo University
What is an expert system?
“An expert system is a computer system that
emulates, or acts in all respects, with the
decision-making capabilities of a human expert.”
Professor Edward Feigenbaum
Stanford University
2
Areas of Artificial Intelligence
3
Expert system technology
Special expert system languages – CLIPS
Programs
Hardware designed to facilitate the
implementation of those systems
4
Expert System Main Components
Knowledge base – obtainable from books,
magazines, knowledgeable persons, etc.
Inference engine – draws conclusions from the
knowledge base
5
Basic Functions of Expert Systems
6
Problem Domain vs. Knowledge Domain
An expert’s knowledge is specific to one problem
domain –
medicine, finance, science, engineering, etc.
The expert’s knowledge about solving specific
problems is called the knowledge domain.
The problem domain is always a superset of the
knowledge domain.
7
Problem and Knowledge Domain Relationship
8
Advantages of Expert Systems
Increased availability
Reduced cost
Reduced danger
Performance
Multiple expertise
Increased reliability
9
Advantages Continued
Explanation
Fast response
Steady, unemotional, and complete responses at
all times
Intelligent tutor
Intelligent database
10
Representing the Knowledge
The knowledge of an expert system can be
represented in a number of ways, including IF-
THEN rules:
IF you are hungry THEN eat
11
Knowledge Engineering
The process of building an expert system:
1. The knowledge engineer establishes a dialog
with the human expert to elicit knowledge.
2. The knowledge engineer codes the knowledge
explicitly in the knowledge base.
3. The expert evaluates the expert system and
gives a critique to the knowledge engineer.
12
Development of an Expert System
13
The Role of AI
An algorithm is an ideal solution guaranteed to
yield a solution in a finite amount of time.
When an algorithm is not available or is
insufficient, we rely on artificial intelligence
(AI).
Expert system relies on inference – we accept a
“reasonable solution.”
14
Uncertainty
Both human experts and expert systems must be
able to deal with uncertainty.
It is easier to program expert systems with
shallow knowledge than with deep knowledge.
Shallow knowledge – based on empirical and
heuristic knowledge.
Deep knowledge – based on basic structure,
function, and behavior of objects.
15
Limitations of Expert Systems
Typical expert systems cannot generalize through
analogy to reason about new situations in the way
people can.
A knowledge acquisition bottleneck results from
the time-consuming and labor intensive task of
building an expert system.
16
Early Expert Systems
DENDRAL – used in chemical mass
spectroscopy to identify chemical constituents
MYCIN – medical diagnosis of illness
DIPMETER – geological data analysis for oil
PROSPECTOR – geological data analysis for
minerals
XCON/R1 – configuring computer systems
17
Broad Classes of Expert Systems
18
Problems with Algorithmic Solutions
Conventional computer programs generally solve
problems having algorithmic solutions.
Algorithmic languages include C, Java, and C#.
Classic AI languages include LISP and
PROLOG.
19
Considerations for Building Expert Systems
Can the problem be solved effectively by
conventional programming?
Is there a need and a desire for an expert system?
Is there at least one human expert who is willing
to cooperate?
Can the expert explain the knowledge to the
knowledge engineer can understand it.
Is the problem-solving knowledge mainly
heuristic and uncertain?
20
Languages, Shells, and Tools
Expert system languages are post-third
generation.
Procedural languages (e.g., C) focus on
techniques to represent data.
More modern languages (e.g., Java) focus on data
abstraction.
Expert system languages (e.g. CLIPS) focus on
ways to represent knowledge.
21
Elements of an Expert System
User interface – mechanism by which user and
system communicate.
Exploration facility – explains reasoning of
expert system to user.
Working memory – global database of facts
used by rules.
Inference engine – makes inferences deciding
which rules are satisfied and prioritizing.
22
Elements Continued
Agenda – a prioritized list of rules created by the
inference engine, whose patterns are satisfied by
facts or objects in working memory.
Knowledge acquisition facility – automatic way
for the user to enter knowledge in the system
bypassing the explicit coding by knowledge
engineer.
23
Production Rules
Knowledge base is also called production
memory.
Production rules can be expressed in IF-THEN
pseudocode format.
In rule-based systems, the inference engine
determines which rule antecedents are satisfied
by the facts.
24
Structure of a
Rule-Based Expert System
25
General Methods of Inferencing
Forward chaining – reasoning from facts to the
conclusions resulting from those facts – best for
prognosis, monitoring, and control.
Backward chaining – reasoning in reverse from a
hypothesis, a potential conclusion to be proved to
the facts that support the hypothesis – best for
diagnosis problems.
26
Production Systems
Rule-based expert systems – most popular type
today.
Knowledge is represented as multiple rules that
specify what should/not be concluded from
different situations.
Forward chaining – start w/facts and use rules do
draw conclusions/take actions.
Backward chaining – start w/hypothesis and look
for rules that allow hypothesis to be proven true.
27
Forward/Backward Chaining
Forward chaining – primarily data-driven.
Backward chaining – primarily goal driven.
28
Post Production System
Basic idea – any mathematical / logical system is
simply a set of rules specifying how to change
one string of symbols into another string of
symbols.
Basic limitation – lack of control mechanism to
guide the application of the rules.
29
Markov Algorithm
An ordered group of productions applied in order
or priority to an input string.
If the highest priority rule is not applicable, we
apply the next, and so on.
An efficient algorithm for systems with many
rules.
30
Rete Algorithm
Functions like a net – holding a lot of
information.
Much faster response times and rule firings can
occur compared to a large group of IF-THEN
rules which would have to be checked one-by-
one in conventional program.
Takes advantage of temporal redundancy and
structural similarity.
Drawback is high memory space requirments.
31
Procedural Paradigms
Algorithm – method of solving a problem in a
finite number of steps.
Procedural programs are also called sequential
programs.
The programmer specifies exactly how a problem
solution must be coded.
32
Procedural Languages
33
Imperative Programming
Focuses on the concept of modifiable store –
variables and assignments.
During execution, program makes transition from
the initial state to the final state by passing
through series of intermediate states.
Provide for top-down-design.
Not efficient for directly implementing expert
systems.
34
Nonprocedural Paradigms
Do not depend on the programmer giving exact
details how the program is to be solved.
Declarative programming – goal is separated
from the method to achieve it.
Object-oriented programming – partly imperative
and partly declarative – uses objects and methods
that act on those objects.
Inheritance – (OOP) subclasses derived from
parent classes.
35
Nonprocedural Languages
36
The Representation of Knowledge
What is the study of logic?
Logic is the study of making inferences – given a
set of facts, we attempt to reach a true
conclusion.
An example of informal logic is a courtroom
setting where lawyers make a series of inferences
hoping to convince a jury / judge .
Formal logic (symbolic logic) is a more rigorous
approach to proving a conclusion to be true /
false.
38
Why is Logic Important
We use logic in our everyday lives – “should I
buy this car”, “should I seek medical attention”.
People are not very good at reasoning because
they often fail to separate word meanings with
the reasoning process itself.
Semantics refers to the meanings we give to
symbols.
39
The Goal of Expert Systems
We need to be able to separate the actual
meanings of words with the reasoning process
itself.
We need to make inferences w/o relying on
semantics.
We need to reach valid conclusions based on
facts only.
40
Knowledge vs. Expert Systems
Knowledge representation is key to the success
of expert systems.
Expert systems are designed for knowledge
representation based on rules of logic called
inferences.
Knowledge affects the development, efficiency,
speed, and maintenance of the system.
41
Arguments in Logic
An argument refers to the formal way facts and
rules of inferences are used to reach valid
conclusions.
The process of reaching valid conclusions is
referred to as logical reasoning.
42
How is Knowledge Used?
Knowledge has many meanings – data, facts,
information.
How do we use knowledge to reach conclusions
or solve problems?
Heuristics refers to using experience to solve
problems – using precedents.
Expert systems may have hundreds / thousands
of micro-precedents to refer to.
43
Epistemology
Epistemology is the formal study of knowledge .
Concerned with nature, structure, and origins of
knowledge.
44
Categories of Epistemology
•Philosophy •A priori
•A posteriori •Procedural
•Declarative •Tacit
45
A Priori Knowledge
“That which precedes”
Independent of the senses
Universally true
Cannot be denied without contradiction
46
A Posteriori Knowledge
“That which follows”
Derived from the senses
Now always reliable
Deniable on the basis of new knowledge w/o
the necessity of contradiction
47
Procedural Knowledge
Knowing how to do something:
• Fix a watch
• Install a window
• Brush your teeth
• Ride a bicycle
48
Declarative Knowledge
Knowledge that something is true or false
Usually associated with declarative statements
E.g., “Don’t touch that hot wire.”
49
Tacit Knowledge
Unconscious knowledge
Cannot be expressed by language
E.g., knowing how to walk, breath, etc.
50
Knowledge in Rule-Based
Systems
Knowledge is part of a hierarchy.
Knowledge refers to rules that are activated by
facts or other rules.
Activated rules produce new facts or conclusions.
Conclusions are the end-product of inferences
when done according to formal rules.
51
Expert Systems vs. Humans
Expert systems infer – reaching conclusions
as the end product of a chain of steps called
inferencing when done according to formal
rules.
Humans reason
52
Expert Systems vs. ANS
ANS does not make inferences but searches for
underlying patterns.
Expert systems
o Draw inferences using facts
o Separate data from noise
o Transform data into information
o Transform information into knowledge
53
Metaknowledge
Metaknowledge is knowledge about knowledge
and expertise.
Most successful expert systems are restricted to
as small a domain as possible.
In an expert system, an ontology is the
metaknowledge that describes everything known
about the problem domain.
Wisdom is the metaknowledge of determining
the best goals of life and how to obtain them.
54
The Pyramid of Knowledge
55
Productions
A number of knowledge-representation techniques
have been devised:
• Rules
• Semantic nets
• Frames
• Scripts
• Logic
• Conceptual graphs
56
Parse Tree of a Sentence
57
Semantic Nets
A classic representation technique for
propositional information
Propositions – a form of declarative knowledge,
stating facts (true/false)
Propositions are called “atoms” – cannot be
further subdivided.
Semantic nets consist of nodes (objects, concepts,
situations) and arcs (relationships between them).
58
Common Types of Links
IS-A – relates an instance or individual to a
generic class
A-KIND-OF – relates generic nodes to generic
nodes
59
Two Types of Nets
60
General Organization of a PROLOG
System
61
PROLOG and Semantic Nets
In PROLOG, predicate expressions consist of the
predicate name, followed by zero or more
arguments enclosed in parentheses, separated by
commas.
Example:
mother(becky,heather)
means that becky is the mother of heather
62
PROLOG Continued
Programs consist of facts and rules in the
general form of goals.
General form: p:- p1, p2, …, pN
p is called the rule’s head and the pi
represents the subgoals
Example:
spouse(x,y) :- wife(x,y)
x is the spouse of y if x is the wife of y
63
Object-Attribute-Value Triple
One problem with semantic nets is lack of
standard definitions for link names (IS-A, AKO,
etc.).
The OAV triplet can be used to characterize all
the knowledge in a semantic net.
64
Problems with Semantic Nets
To represent definitive knowledge, the link and
node names must be rigorously defined.
A solution to this is extensible markup language
(XML) and ontologies.
Problems also include combinatorial explosion of
searching nodes, inability to define knowledge
the way logic can, and heuristic inadequacy.
65
Schemata
Knowledge Structure – an ordered collection of
knowledge – not just data.
Semantic Nets – are shallow knowledge
structures – all knowledge is contained in nodes
and links.
Schema is a more complex knowledge structure
than a semantic net.
In a schema, a node is like a record which may
contain data, records, and/or pointers to nodes.
66
Frames
One type of schema is a frame (or script – time-
ordered sequence of frames).
Frames are useful for simulating commonsense
knowledge.
Semantic nets provide 2-dimensional knowledge;
frames provide 3-dimensional.
Frames represent related knowledge about
narrow subjects having much default knowledge.
67
Frames Continued
A frame is a group of slots and fillers that defines
a stereotypical object that is used to represent
generic / specific knowledge.
Commonsense knowledge is knowledge that is
generally known.
Prototypes are objects possessing all typical
characteristics of whatever is being modeled.
Problems with frames include allowing
unrestrained alteration / cancellation of slots.
68
Logic and Sets
Knowledge can also be represented by symbols
of logic.
Logic is the study of rules of exact reasoning –
inferring conclusions from premises.
Automated reasoning – logic programming in the
context of expert systems.
69
A Car Frame
70
Forms of Logic
Earliest form of logic was based on the syllogism
– developed by Aristotle.
Syllogisms – have two premises that provide
evidence to support a conclusion.
Example:
Premise: All cats are climbers.
Premise: Garfield is a cat.
Conclusion: Garfield is a climber.
71
Venn Diagrams
Venn diagrams can be used to represent
knowledge.
Universal set is the topic of discussion.
Subsets, proper subsets, intersection, union ,
contained in, and complement are all familiar
terms related to sets.
An empty set (null set) has no elements.
72
Venn Diagrams
73
Syllogism 三段論法
Premise: All men are
mortal
Premise: Socrates is a man
Conclusion: Socrates is mortal
Only the form is important.
Premise: All X are Y
Premise: Z is a X
Conclusion: Z is a Y
74
Categorical Syllogism
Syllogism: a valid deductive
argument having two premises and a
conclusion.
major premise: All M are P
minor premise: All S is M
Conclusion: All S is P
M middle term
P major term
S minor term
75
Categorical Statements
Form Schema Meaning
A All S is P universal affirmative
E No S is P universal negative
I Some S is P particular affirmative
O Some S is not P particular negative
76
Figure 1 2 3 4
Major Premise M P PM MP PM
Minor Premise S M SM MS MS
Mood
AAA-1 EAE-1 IAI-4
All M is P No M is P Some P is M
All S is M All S is M All M
is S
All S is P No S is P Some S is P
77
Propositional Logic
Formal logic is concerned with syntax of
statements, not semantics.
Syllogism:
• All goons are loons.
• Zadok is a goon.
• Zadok is a loon.
The words may be nonsense, but the form is
correct – this is a “valid argument.”
78
Intersecting Sets
79
Boolean Logic
Defines a set of axioms consisting of symbols to
represent objects / classes.
Defines a set of algebraic expressions to
manipulate those symbols.
Using axioms, theorems can be constructed.
A theorem can be proved by showing how it is
derived from a set of axioms.
80
Features of Propositional Logic
Concerned with the subset of declarative
sentences that can be classified as true or false.
We call these sentences “statements” or
“propositions”.
Paradoxes – statements that cannot be classified
as true or false.
Open sentences – statements that cannot be
answered absolutely.
81
Features Continued
Compound statements – formed by using logical
connectives (e.g., AND, OR, NOT, conditional,
and biconditional) on individual statements.
Material implication – p q states that if p is
true, it must follow that q is true.
Biconditional – p q states that p implies q and
q implies p.
82
Features Continued
Tautology – a statement that is true for all
possible cases.
Contradiction – a statement that is false for all
possible cases.
Contingent statement – a statement that is neither
a tautology nor a contradiction.
83
Truth Tables
84
Rule of Inference
Modus ponens, way assert
direct reasoning, law of detachment
assuming the antecedent
Modus tollens, way deny
indirect reasoning, law of
contraposition
assuming the antecedent
85
Modus Ponens
If there is power, the computer will
work
There is power
------------------------------
The computer will work
AB p, p ->q; q
A
--------------
B 86
Modus tollens
pq conditional p -> q
~q converse q -> p
-------------- inverse ~p ->
~q
~p contrapositive
~q -> ~p
87
Formal Logic Proof
Chip prices rise only if the yen rises.
The yen rises only if the dollar falls and
if the dollar falls then the yen rises.
Since chip prices have risen,
the dollar must have fallen.
CY C = chip prices rise
(Y D) ^ (D Y) Y = yen rises
C D = dollar falls
-------------------------
D
88
Formal Logic Proof
CY
(Y D) ^ (D Y)
C
D
1. C Y premise
2. (Y D) ^ (D Y) premise
3. C
4. Y == D 2 Equivalence
5. CD 1 Substitution
6. D 3,5 modus ponens
89
Resolution
Normal form
Conjunctive normal form
(P1vP2v…)^(Q1vQ2…)^…
(Z1vZ2…)
Kowalski clausal form
A1, A2, …., An B1, B2, ….,
Bm
Horn clause
A1, A2, …., An B
90
Method of Contradiction
Av B
(AvB)^(Av~B)
A v ~B A v (B^~B)
-------------- A
A
91
Forward Reasoning
T: A B
BC
CONCLUSION?
CD
A
Resolve by modus
ponens
92
Backward Reasoning
What if T is very large?
T may support all kinds of
inferences
which have nothing to do
with
the proof of our goal
Combinational explosion
Use Backward Reasoning
93
Resolution Refutation
To refute something is to prove it
false
Refutation complete:
Resolution refutation will
terminate in
a finite steps if there is a
contradiction
Example: Given the argument
AB
BC
CD
-------------
AD 94
Example
AB
BC
CD
-------------
AD
To prove that A D is a theorem by resolution refutation:
1. A D equ ~A v D convert to disjunction form
2. ~(~A v D) equ A ^ ~D negate the conclusion
3. A B equ ~A v B
B C equ ~B v C
C D equ ~C v D
4. (~A v B) ^ (~B v C ) ^ (~C v D) ^ A ^ ~D
resolution
=> nil false
95
Method of Contradiction
Av B
(AvB)^(Av~B)
A v ~B A v (B^~B)
-------------- A
A
96
Propositional Logic
Symbolic logic for manipulating
proposition
Proposition, Statement, Close
sentence:
a sentence whose truth value can
be
determined.
Open Sentence: a sentence which
contains variables
Combinational explosion
97
Predicate Logic
Predicates with arguments
on-top-of(A, B)
Variables and Quantifiers
Universal (x)(Rational(x) Real(x))
Existential (x)(Prime(x))
Functions of Variables
(x)(Satellite(x)) (y)(closest(y,
earth)^on(y,x))
(x)(man(x) mortal(x))
^ man(Socrates)
=> mortal(Socrates)
98
Universal Quantifier
The universal quantifier, represented by the
symbol means “for every” or “for all”.
(x) (x is a rectangle x has four sides)
The existential quantifier, represented by the
symbol means “there exists”.
(x) (x – 3 = 5)
Limitations of predicate logic – most quantifier.
99
First Order Predicate Logic
Quantification not over predicate or
function symbols
No MOST quantifier, (counting required)
Can not express things that are
sometime true
=> Fuzzy Logic
100
Syllogism in Predicate Logic
Type Scheme Predicate
Representation
A All S is P (x)(S(x) -> P(x))
E No S is P (x)(S(x) ->
~P(x))
I Some S is P (x)(S(x) ^ P(x))
A Some S is not P (x)(S(x) ^
~P(x))
101
Rule of Universal Instantiation
(x)p(x) => p(a) p: any
proposition or
propositional
function
a: an instance
102
Formal Proof
(x)(H(x)->M(x)) All men are mortal
H(s) Socrates is a man
Þ M(s) => Socrates is mortal
1. (x)(H(x)->M(x)) premise
2. H(s)
3. H(s)->M(s) universal
instantiation
4. M(s) 2,3 modus ponens
103
Well-formed Formula
1. An atom is a formula
2. If F and G are formula, then ~(F),
(FvG),
(F^G),(F->G), and (F<->G) are
formula
3. If F is a formula, and x is a free
variable in F, then (x)F and
(x)F are formula
4. Formula are generated only by a
finite number of applications of 104
Summary
We have discussed:
Elements of knowledge
Knowledge representation
Some methods of representing knowledge
Fallacies may result from confusion between
form of knowledge and semantics.
It is necessary to specify formal rules for expert
systems to be able to reach valid conclusions.
Different problems require different tools.
105