Rules and Expert Systems

blessinghomoeopathAI and Robotics

Nov 30, 2013 (3 years and 6 months ago)

91 views

1

Chapter 9

Rules and Expert Systems



Expert System

(Rule Based Inference)

Bayesian Network

Fuzzy Theorem

Probability
(statistics)

Uncertainty
(cybernetics)

Machine Learning

Fuzzy, NN, GA, etc.



Diagnosis (Decision Making)



Advice (Recommendations)



Automatic Control

Pattern Recognition

Data Mining, etc.

Problem Solving

Predicate Logic

Reasoning/ Proof

Search Methods

2

Deduction over FOPC
---

Resolution

Barks_at(Snoopy,John)


䙡汳F

䑯D⡘⤠帠䵥整猨堬天M䑩獬楫敳⡘ⱙ⤠


䉡牫獟慴a堬X)

䑯D⡓湯潰y⤠帠䵥整猨卮M潰yⱊ潨n⥞)楳汩步i⡓湯opyⱊ,桮⤠


F

{X/Snoopy, Y/John}

T


䑯D⡓湯潰y)

䵥整猨卮M潰yⱊ潨n⥞䑩獬楫敳⡓湯潰yⱊ潨n⤠


䙡汳F

䍬潳敟瑯⡚ⱄ潲浇⤠


䵥整猨卮M潰yⰠ娩

䍬潳敟瑯⡊(桮ⱄ潲,G)幄楳^楫敳⡓i潯pyⱊ潨n⤠


䙡汳F

{Z/John}

True


䍬潳敟瑯⡊(桮Ⱐ䑯牭D)

䑩獬楫敳⡓湯潰yⱊ,桮⤠


䙡汳F

䵡渨䩯桮⤠


䙡汳F

{W/John}

True


䵡M⡊潨温

T牵攠


䙡汳F

Man(W)


䑩獬楫敳⡓湯潰yⱗ)

此為

“Implies” Normal Form

了解此法可以銜接

“Expert System”

Recall:

3

Refutation Proofs in Tree Form

P

Q

^

T牵r

P

Q

䙡汳l

True

Q

T牵r

䙡汳F

P, P

儠†卨S畬搠儠扥⁴牵政

¬
P
VQ

P

¬
Q

Q




兩種形式



皆有相關研究採用

Forward Chaining + Refutation

Recall:

^

P

䙡汳F

T牵r

䙡汳F

¬
P


Backward Chaining (Resolution)

Q

䙡汳F

P

Q

T牵r

P

¬
P
VQ

P

¬
Q

4

Chapter 9 Contents


Rules for Knowledge
Representation


Rule Based Production
Systems


Forward Chaining


Conflict Resolution


Meta Rules


Backward Chaining



The Architecture of
Expert Systems


Expert System Shells


The Rete Algorithm


Knowledge Engineering


CLIPS
:


C Language Integrated
Production System


Backward Chaining in
Expert Systems


CY
C System



5

Rules for Knowledge Representation


IF… THEN Rules can be used to represent
knowledge:


IF it rains, then you will get wet


Rules can also be recommendations:


IF it rains, then you should wear a coat




6

Example (Rule Based Inference)

rains_on(x)


wet(x)

rains_on(x) ^
¬
coat(x)


wet(x)

True

rains_on(John)

True

wet(John)

wet(John)

False

{x/John}

True

rains_on(John)

¬
coat(John)


wet(John)

{x/John}

¬

wet(John)

False

…wet(John)
是否成立
?


¬

wet(John)
如何能成立
?

p.s.
不穿雨衣一定溼,但穿雨衣不保證不溼

如果
¬
coat(John)
會導致

wet(John)
成立

Trure


¬
coat(John)

True

wet(John)

7

Rule Based Production Systems


A production system is a system that uses
knowledge in the form of rules

to provide
diagnoses or advice on the basis of input
data.


The system consists of a
database of rules
(knowledge base), a
database of facts
, and
an
inference engine

which reasons about
the facts using the rules.



8

Forward Chaining


Forward chaining is a reasoning model
that works from a set of facts and rules
towards a set of conclusions, diagnoses or
recommendations.


When a fact matches the antecedent of a
rule, the rule
fires
, and the conclusion of
the rule is
added to

the database of facts.



9

Example
(
Forward Chaining
)

Man(W)


䑩D汩kes⡓湯(灹Ⱐ圩

{W/John}

T

䵡渨䩯桮)

T

䑩獬楫D猨卮潯灹Ⱐ䩯桮)

Close_to(Z,DormG)


䵥e瑳⡓湯(灹Ⱐ娩

{Z/John}

T

䍬潳C彴漨䩯桮Ⱐ䑯牭䜩

T

䵥M瑳⡓湯t灹Ⱐ,潨温

䑯木堩X帠䵥整e⡘ⱙ⥞䑩獬楫D猨堬天s


䉡牫獟慴⡘ⱙa

T

䑯木卮S潰y)

䵥M瑳⡓湯t灹ⱙ⥞䑩獬楫D猨卮潯灹ⱙ⤠


䉡牫獟慴⡓湯a灹ⱙ,

{Y/John}

Meets(Snoopy,John)


䉡牫獟慴⡓湯a灹ⱊ潨温

T

䉡牫獟慴⡓湯a灹ⱊ潨温

(1)

(2)

(3)

(4)

(5)

Barks_at(Snoopy,John)


䙡汳F

10

Conflict Resolution

牴觸的規則


Sometimes
more than one rule

will fire at once,
and a conflict resolution strategy must be used to
decide which conclusions to use.


One strategy is to give rules
priorities

and to use
the conclusion that has the highest priority.


Other strategies include applying the rule with the
longest antecedent
, or applying the rule that was
most recently

added to the database.



(1)
天氣好
,
睡得好
,
工作不忙


去打球;

vs.“
吃飽飯

不打球


(2)
男生
,
穿拖鞋
,
靠近女生宿舍

小花吠

vs.“
吃飯中

不吠人”

Priority?

11

Meta Rules


The rules that determine the conflict resolution
strategy are called meta rules.


Meta rules define knowledge about how the
system will work.


For example, meta rules might define that
knowledge from
Expert A

is to be trusted more
than knowledge from
Expert B
.


Meta rules are treated by the system like normal
rules, but are given higher priority.



12

Backward Chaining


In cases where a particular conclusion is to be
proved, backward chaining can be more
appropriate.


Works back from a conclusion towards the
original facts.


When a conclusion matches the conclusion of a
rule in the database, the antecedents of the rule
are compared with facts in the database.



13

Example
(Back
ward Chaining
)

Barks_at(Snoopy,John)


䙡汳F

䑯D⡘⤠帠䵥整猨堬天M䑩獬楫敳⡘ⱙ⤠


䉡牫獟慴a堬X)

䑯D⡓湯潰y⤠帠䵥整猨卮M潰yⱊ潨n⥞)楳汩步i⡓湯opyⱊ,桮⤠


F

{X/Snoopy, Y/John}

T


䑯D⡓湯潰y)

䵥整猨卮M潰yⱊ潨n⥞䑩獬楫敳⡓湯潰yⱊ潨n⤠


䙡汳F

䍬潳敟瑯⡚ⱄ潲浇⤠


䵥整猨卮M潰yⰠ娩

䍬潳敟瑯⡊(桮ⱄ潲,G)幄楳^楫敳⡓i潯pyⱊ潨n⤠


䙡汳F

{Z/John}

True


䍬潳敟瑯⡊(桮Ⱐ䑯牭D)

䑩獬楫敳⡓湯潰yⱊ,桮⤠


䙡汳F

䵡渨圩M


䑩獬楫敳⡓湯潰yⰠW)

䵡渨䩯桮⤠


䙡汳F

{W/John}

True


䵡渨䩯桮)

T牵攠


䙡汳F

14

Example
(
Forward Chaining
)

Man(W)


䑩D汩kes⡓湯(灹Ⱐ圩

{W/John}

T

䵡渨䩯桮)

T

䑩獬楫D猨卮潯灹Ⱐ䩯桮)

Close_to(Z,DormG)


䵥e瑳⡓湯(灹Ⱐ娩

{Z/John}

T

䍬潳C彴漨䩯桮Ⱐ䑯牭䜩

T

䵥M瑳⡓湯t灹Ⱐ,潨温

䑯木堩X帠䵥整e⡘ⱙ⥞䑩獬楫D猨堬天s


䉡牫獟慴⡘ⱙa

T

䑯木卮S潰y)

䵥M瑳⡓湯t灹ⱙ⥞䑩獬楫D猨卮潯灹ⱙ⤠


䉡牫獟慴⡓湯a灹ⱙ,

{Y/John}

Meets(Snoopy,John)


䉡牫獟慴⡓湯a灹ⱊ潨温

T

䉡牫獟慴⡓湯a灹ⱊ潨温

Recall:

15

Chapter 9 Contents


Rules for Knowledge
Representation


Rule Based Production
Systems


Forward Chaining


Conflict Resolution


Meta Rules


Backward Chaining



The Architecture of
Expert Systems


Expert System Shells


The Rete Algorithm


Knowledge Engineering


CLIPS
:


C Language Integrated
Production System


Backward Chaining in
Expert Systems


CY
C System



16

The Architecture of Expert Systems (1)


An expert system
uses expert
knowledge
derived from
human experts to
diagnose
illnesses, provide
recommendations
and solve other
problems.



17

The Architecture of Expert Systems (2)


Knowledge base:


database of rules (domain knowledge).


Explanation system:


explains the decisions the system makes.


Knowledge base editor:


allows the user to edit the information in the knowledge base.


User Interface:


the means by which the user interacts with the expert system.







18

Expert System Shells


The part of an expert system

(
內容不算
)



Neither

domain specific
n
or

case specific knowledge is
contained in
the expert system shell.


A single expert system shell can be used


to build
a number of different expert systems
.


An example of an expert system shell is


CLIPS.



19

The Rete Algorithm


A rete is a directed, acyclic, rooted
graph (
i.e.
a
“Search T
ree

).


A path from the root node to a leaf
represents the
left hand side of a rule
.


Each node stores details of which
facts have been matched so far.


As facts are
changed
, the changes are
propagated through the tree

from the
root to the leaves
.


This makes an efficient way for expert
systems to deal with environments
which change often.



root

recommendations

dog(S)

man(J)

¬
dog(S)

¬
man(J)

20

Knowledge Engineering


A knowledge engineer takes knowledge
from experts and inputs it into the expert
system.

(
擷取
)


A knowledge engineer will usually choose
which expert system shell to use.

(
實現
)


The knowledge engineer is also
responsible for entering meta
-
rules.

(
整合
)


Expert System

(Rule Based Production System)

只是後來所謂「知識工程」的一個小部份

21

CLIPS


CLIPS is C Language
Integrated Production
System


an expert
system shell.


CLIPS uses a LISP
-
like
notation to enter rules.




22

Backward Chaining in Expert Systems


Backward chaining is often used in expert
systems that are designed for medical diagnosis:


For each hypothesis, H:


If H is in the facts database, it is proved.


Otherwise, if H can be determined by asking a question, then enter
the user’s answer in the facts database. Hence, it can be
determined whether H is true or false, according to the user’s
answer.


Otherwise, find a rule whose conclusion is H. Now apply this
algorithm to try to prove this rule’s antecedents.


If none of the above applies, we have failed to prove H.


Usually backward chaining is used in conjunction
with forward chaining.

相輔相成

23

CYC


A frame based production system.


Uses a database of over 1,000,000 facts
and rules, encompassing all fields of
human knowledge.


CYC can answer questions about all kinds
of knowledge in its database, and can even
understand analogies, and other complex
relations.



24

Relevant Research

Expert System

(Rule Based Inference)

Bayesian Network

Fuzzy Theorem

Probability
(statistics)

Uncertainty
(cybernetics)

Machine Learning

Fuzzy, NN, GA, etc.



Diagnosis (Decision Making)



Advice (Recommendations)



Automatic Control

Pattern Recognition

Data Mining, etc.

Problem Solving

Predicate Logic

Reasoning/ Proof

Search Methods

評判

搜尋解答

邏輯推理

記憶

控制

學習

創作

weak

sub?

strong

Fuzzy,NN,GA

In my opinion: