Transcript X - Nectec

Introduction to
Knowledge-based
Systems
ดร.มารุ ต บูรณรัช [email protected]
269618: หัวข้อพิเศษด้านเทคโนโลยีสารสนเทศขั้นสู ง - เทคโนโลยีเว็บเชิ งความหมาย
(Special Topics in Advanced Information Technology – Semantic Web Technology)
ภาควิชาวิทยาการคอมพิวเตอร์และเทคโนโลยีสารสนเทศ
คณะวิทยาศาสตร์ มหาวิทยาลัยนเรศวร
ภาคการศึกษาที่ 2 ปี การศึกษา 2557
These slides are taken with some adaptations from
Expert Systems: Principles and Programming, 4th Edition by Joseph C. Giarratano & Gary D. Riley
Semantic Web Stack
Adapted from http://en.wikipedia.org/wiki/Semantic_Web_Stack
Outline

Introduction to Expert Systems
 History
 Components
 Functions
and Applications
 Expert systems vs. Imperative programming

Knowledge Representation and Logic
 Propositional
logic
 Predicate logic
 Inference Methods
3
Introduction to
Expert Systems
4
Artificial Intelligence

AI = “Making computers think like people.”
Artificial Intelligence (AI) is the part of computer science
concerned with designing intelligent computer systems,
that is, systems that exhibit the characteristics we associate
with intelligence in human behavior – understanding
language, learning reasoning, solving problems and so on.
Barr and Feigenbaum, 1981
Expert Systems: Principles and Programming, Fourth Edition
5
Areas of Artificial Intelligence
Expert Systems: Principles and Programming, Fourth Edition
6
What is an expert system?
“An expert system is a computer system that
emulates, or acts in all respects, with the decisionmaking capabilities of a human expert.”
Professor Edward Feigenbaum
Stanford University

Expert Systems = knowledge-based systems =
knowledge-based expert systems
Expert Systems: Principles and Programming, Fourth Edition
7
More definitions
“An expert system is a program that
attempts to mimic human expertise by
applying inference methods to a specific
body of knowledge.” (Darlington, 2000)
 “An expert system is a system that
employs human knowledge captured in a
computer to solve problems that ordinarily
require human expertise.” (Turban, 2001)

8
Expert system technology may include:



Special expert system languages – CLIPS
Programs
Hardware designed to facilitate the
implementation of those systems (e.g., in
medicine)
Expert Systems: Principles and Programming, Fourth Edition
9
Expert System Main Components

Knowledge base – obtainable from books,
magazines, knowledgeable persons, etc; or
expertise knowledge.

Inference engine – draws conclusions from
the knowledge base.
Expert Systems: Principles and Programming, Fourth Edition
10
Basic Functions of Expert Systems
Expert Systems: Principles and Programming, Fourth Edition
11
Problem Domain vs. Knowledge Domain





In general, the first step in solving any problem is
defining the problem area or domain to be solved.
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.
Expert system reasons from knowledge domain.
Expert Systems: Principles and Programming, Fourth Edition
12
Problem Domain vs. Knowledge Domain (2)

Example: infections diseases diagnostic
system does not have (or require) knowledge
about other branches such as surgery.
Expert Systems: Principles and Programming, Fourth Edition
13
Problem and Knowledge Domain Relationship
Expert Systems: Principles and Programming, Fourth Edition
14
Advantages of Expert Systems



Increased availability
Reduced cost
Reduced danger


Permanence


last for ever, unlike human who may die, retire, quit.
Multiple expertise


can be used in hazardous environment.
several experts’ knowledge leads to
Increased reliability
Expert Systems: Principles and Programming, Fourth Edition
15
Advantages of Expert Systems (2)

Explanation


Fast response


unlike human who may be inefficient because of stress or
fatigue.
Intelligent tutor


e.g. emergency situations
Steady, unemotional, and complete responses at all
times:


explain in detail how arrived at conclusions.
provides direct instructions (student may run sample
programs and explaining the system’s reasoning).
Intelligent database

access a database intelligently (e.g. data mining).
Expert Systems: Principles and Programming, Fourth Edition
16
Representing the Knowledge

The knowledge of an expert system can be
represented in a number of ways, including IFTHEN rules:
IF the light is red THEN stop
Expert Systems: Principles and Programming, Fourth Edition
17
Representing the Knowledge: Car
Failure Diagnosis
IF the selection is 2 "Run-Stable State"
AND the fuel is not burning well
AND the engine running cycle is ok
AND there is no blue gas
AND the advance is bad
THEN
There is a Dirt in the injections/carburetor
or The adjustment of ear and gasoline is
not good, clear injections/carburetor and
adjust the ear.
Expert Systems: Principles and Programming, Fourth Edition
18
Knowledge Engineering
The process of building an expert system:
1.
2.
3.
The knowledge engineer establishes a dialog with
the human expert to elicit knowledge.
The knowledge engineer codes the knowledge
explicitly in the knowledge base.
The expert evaluates the expert system and gives
a critique to the knowledge engineer.
Expert Systems: Principles and Programming, Fourth Edition
19
Development of an Expert System
Expert Systems: Principles and Programming, Fourth Edition
20
The Role of AI

Expert system relies on inference – we
accept a “reasonable solution.”
Expert Systems: Principles and Programming, Fourth Edition
21
Limitations of Expert Systems

Uncertainty



Having limited knowledge (more than possible outcomes)
Both human experts and expert systems must be able to deal
with uncertainty.
Limitation 1: most expert systems deals 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.
Expert Systems: Principles and Programming, Fourth Edition
22
Limitations of Expert Systems (2)

Limitation 2: typical expert systems cannot
generalize through analogy to reason about
new situations in the way people can.
 Solution:
repeating the cycle of interviewing the
expert.
 Limitation: A knowledge acquisition bottleneck
results from the time-consuming and labor
intensive task of building an expert system.
Expert Systems: Principles and Programming, Fourth Edition
23
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
Expert Systems: Principles and Programming, Fourth Edition
24
Broad Classes of Expert Systems
Expert Systems: Principles and Programming, Fourth Edition
25
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.
Expert Systems: Principles and Programming, Fourth Edition
26
Considerations for Building Expert Systems





Can the problem be solved effectively by conventional
programming? (expert systems are suited for illstructured problems- problems with no efficient
algorithmic solution)
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 in a way that can understand it.
Is the problem-solving knowledge mainly heuristic and
uncertain?
Expert Systems: Principles and Programming, Fourth Edition
27
Elements of an Expert System

User interface
 mechanism
by which user and system
communicate.

Exploration facility
 explains

Working memory
 global

reasoning of expert system to user.
database of facts used by rules.
Inference engine
 makes
inferences deciding which rules are
satisfied and prioritizing.
Expert Systems: Principles and Programming, Fourth Edition
28
Elements of an Expert System (2)

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.
Expert Systems: Principles and Programming, Fourth Edition
29
Structure of a Rule-Based Expert System
Expert Systems: Principles and Programming, Fourth Edition
30
Production Rules



Knowledge base is also called production
memory.
Production rules can be expressed in IFTHEN pseudocode format.
In rule-based systems, the inference engine
determines which rule antecedents are
satisfied by the facts.
Expert Systems: Principles and Programming, Fourth Edition
31
Inference engine operates on
recognize-act cycle
While not done
conflict resolution:
act:
match:
check for halt:
End-while
Expert Systems: Principles and Programming, Fourth Edition
32
Inference engine operates on
recognize-act cycle (2)

Conflict resolution


Act


sequentially perform the actions. Update the working
memory. Remove the fired activations.
Match


if there are activations then select the one with the highest
priority. Else done.
Update the agenda by checking if there are activation or
remove activations if there LHS is no longer satisfied.
Check for halt

if an halt action is performed or break command given, then
done.
Expert Systems: Principles and Programming, Fourth Edition
33
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.
Expert Systems: Principles and Programming, Fourth Edition
34
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.
Expert Systems: Principles and Programming, Fourth Edition
35
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.
Expert Systems: Principles and Programming, Fourth Edition
36
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.
Expert Systems: Principles and Programming, Fourth Edition
37
Procedural Languages
Expert Systems: Principles and Programming, Fourth Edition
38
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.
Expert Systems: Principles and Programming, Fourth Edition
39
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.
Expert Systems: Principles and Programming, Fourth Edition
40
Nonprocedural Languages
Expert Systems: Principles and Programming, Fourth Edition
41
What are Expert Systems?

Can be considered declarative
languages:
 Programmer
does not specify how to achieve a
goal at the algorithm level.

Induction-based programming – the
program learns by generalizing from a
sample.
Expert Systems: Principles and Programming, Fourth Edition
42
Knowledge
Representation &
Logic
43
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.
Expert Systems: Principles and Programming, Fourth Edition
44
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.
Expert Systems: Principles and Programming, Fourth Edition
45
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.
Expert Systems: Principles and Programming, Fourth Edition
46
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.
 The
process of reaching valid conclusions is
referred to as logical reasoning.
Expert Systems: Principles and Programming, Fourth Edition
47
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.
Expert Systems: Principles and Programming, Fourth Edition
48
A Priori Knowledge




“That which precedes”
Independent of the senses
Universally true
Cannot be denied without contradiction
Expert Systems: Principles and Programming, Fourth Edition
49
A Posteriori Knowledge




“That which follows”
Derived from the senses
Not always reliable
Deniable on the basis of new knowledge
w/o the necessity of contradiction
Expert Systems: Principles and Programming, Fourth Edition
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.
Expert Systems: Principles and Programming, Fourth Edition
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
Expert Systems: Principles and Programming, Fourth Edition
52
Expert Systems vs. ANS


Artificial Neural System (ANS) does not
make inferences but searches for underlying
patterns.
Expert systems
o
o
o
o
Draw inferences using facts
Separate data from noise
Transform data into information
Transform information into knowledge
Expert Systems: Principles and Programming, Fourth Edition
53
Productions

A number of knowledge-representation
techniques have been devised:
•
•
•
•
•
•
Rules
Semantic nets
Frames
Scripts
Logic
Conceptual graphs
Expert Systems: Principles and Programming, Fourth Edition
54
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
Expert Systems: Principles and Programming, Fourth Edition
55
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:
 Premise:
 Conclusion:
All cats are climbers.
Garfield is a cat.
Garfield is a climber.
Expert Systems: Principles and Programming, Fourth Edition
56
Venn Diagrams
Expert Systems: Principles and Programming, Fourth Edition
57
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
Expert Systems: Principles and Programming, Fourth Edition
58
Categorical Syllogism

Syllogism: a valid deductive argument
having two premises and a conclusion.
major premise:
minor premise:
Conclusion:
All M are P
All S is M
All S is P
M middle term
P major term
S minor term
Expert Systems: Principles and Programming, Fourth Edition
59
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
Expert Systems: Principles and Programming, Fourth Edition
60
Figure
1
Major Premise M P
2
3
4
PM MP PM
Minor Premise S M
SM MS MS
Mood
AAA-1
All M is P
All S is M
All S is P
EAE-1
IAI-4
No M is P
All S is M
No S is P
Some P is M
All M is S
Some S is P
Expert Systems: Principles and Programming, Fourth Edition
61
Syllogisms vs. Rules

Syllogism:
 All
basketball players are tall.
 Jason is a basketball player.
 => Jason is tall.

IF-THEN rule:
IF
All basketball players are tall and
Jason is a basketball player
THEN Jason is tall.
Expert Systems: Principles and Programming, Fourth Edition
62
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.
Expert Systems: Principles and Programming, Fourth Edition
63
Propositional Logic (2)


Compound statements – formed by using
logical connectives (e.g., AND, OR, NOT,
conditional, and biconditional) on individual
statements.
Material implication
 q states that if p is true, it must follow that q
is true.
p

Biconditional
p
 q states that p implies q and q implies p.
Expert Systems: Principles and Programming, Fourth Edition
64
Propositional Logic (3)
Syllogisms address only a small portion of
the possible logical statements.
 Propositional logic offers another means of
describing arguments.

65
Rule of Inference

Modus ponens
 Direct
reasoning
 ‘Assert’

Modus tollens
 Indirect
reasoning
 ‘Deny’
Expert Systems: Principles and Programming, Fourth Edition
66
Modus ponens
If there is power, the computer will work
There is power
-----------------------------The computer will work
AB
A
-------------B
p, p ->q; q
Expert Systems: Principles and Programming, Fourth Edition
67
Direct Reasoning: Modus Ponens
Expert Systems: Principles and Programming, Fourth Edition
68
Modus tollens
pq
~q
-------------~p
conditional p -> q
converse q -> p
inverse ~p -> ~q
contrapositive
~q -> ~p
Expert Systems: Principles and Programming, Fourth Edition
69
Limitations of Propositional Logic

If an argument is invalid, it should be interpreted
as such – that the conclusion is necessarily
incorrect.
 An
argument may be invalid because it is poorly
created.

An argument may not be provable using
propositional logic, but may be provable using
predicate logic.
Expert Systems: Principles and Programming, Fourth Edition
70
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)
Expert Systems: Principles and Programming, Fourth Edition
71
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.
Expert Systems: Principles and Programming, Fourth Edition
72
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
Expert Systems: Principles and Programming, Fourth Edition
73
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))
Expert Systems: Principles and Programming, Fourth Edition
74
Rule of Universal Instantiation
The Rule of Universal Instantiation states
that an individual may be substituted for
a universe.
(x)p(x) => p(a)
Expert Systems: Principles and Programming, Fourth Edition
p: any proposition or
propositional function
a: an instance
75
Formal Proof
(x)(H(x)->M(x))
H(s)
 M(s)
All men are mortal
Socrates is a man
=> Socrates is mortal
(x)(H(x)->M(x))
2. H(s)
3. H(s)->M(s)
4. M(s)
premise
1.
universal instantiation
2,3 modus ponens
Expert Systems: Principles and Programming, Fourth Edition
76
Summary

Expert systems or Knowledge-based
systems
 captured
human knowledge in a computer
 apply inference methods to the knowledge
 solve problems that normally required human
expertise

Expert systems uses declarative language
(rules) rather than procedural language
(algorithms)
Expert Systems: Principles and Programming, Fourth Edition
77
Summary

It is necessary to specify formal rules for expert
systems to be able to reach valid conclusions
from given facts.
 Propositional


Rules of inference
Determine true of false of statements (proposition)
 Predicate


logic
logic or First-order logic
Formula that can contains variables that can be quantified
Can allow for formal proof
78