Top Banner
Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1
48

Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Dec 16, 2015

Download

Documents

Ashlie Lamb
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Introduction to Expert System Chapter 11. Rule-Based AI

2013/5/2

1

Page 2: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

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

Page 3: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Expert System Main Components

• Knowledge base – obtainable from books, magazines, knowledgeable persons, etc.– An expert’s knowledge is specific to one problem

domain – medicine, finance, science, engineering, etc.

• Inference engine – draws conclusions from the knowledge base

3

Page 4: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Basic Functions of Expert Systems

4

Page 5: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

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

5

Page 6: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

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.

6

Page 7: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Figure 2.2 The Pyramid of Knowledge

7

Page 8: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Productions

A number of knowledge-representation techniques have been devised:

• Rules: IF-THEN rules• Semantic nets• Frames• Scripts• Logic• Conceptual graphs

8

Page 9: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

9

Page 10: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

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.

10

Page 11: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Development of an Expert System

11

Page 12: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Structure of aRule-Based Expert System

12

Page 13: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Elements of an Expert System

• User interface – mechanism by which user and system communicate.

• Explanation 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.

13

Page 14: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

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.

14

Page 15: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Direct Reasoning Modus Ponens

15

Page 16: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Some Rules of Inference

16

Page 17: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Rules of Inference

17

Page 18: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

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.

18

Page 19: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Chaining

• Chain – a group of multiple inferences that connect a problem with its solution

• A chain that is searched / traversed from a problem to its solution is called a forward chain.

• A chain traversed from a hypothesis back to the facts that support the hypothesis is a backward chain.

• Problem with backward chaining is find a chain linking the evidence to the hypothesis.

19

Page 20: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

General Methods of Inferencing

• Forward chaining – reasoning from facts to the conclusions resulting from those facts – best for prognosis, monitoring, and control.– data-driven

• 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.– goal driven

20

Page 21: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

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.

21

Page 22: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Figure 3.21 Causal Forward Chaining

22

Page 23: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

What is CLIPS?

• CLIPS is a multiparadigm programming language that provides support for:– Rule-based

– Object-oriented

– Procedural programming

• Syntactically, CLIPS resembles:– Eclipse

– CLIPS/R2

– JESS

23

Page 24: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Other CLIPS Characteristics

• CLIPS supports only forward-chaining rules.

• The OOP capabilities of CLIPS are referred to as CLIPS Object-Oriented Language (COOL).

• The procedural language capabilities of CLIPS are similar to languages such as:– C

– Ada

– Pascal

– Lisp

24

Page 25: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

CLIPS Characteristics

• CLIPS is an acronym for C Language Integrated Production System.

• CLIPS was designed using the C language at the NASA/Johnson Space Center.

• CLIPS is portable – PC CRAY.

25

Page 26: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

• (deftemplate goal (slot move) (slot on-top-of))

• (deffacts initial-state• (stack A B C)• (stack D E F)• (goal (move C) (on-top-of E))• (stack))

• (defrule move-directly• ?goal <- (goal (move ?block1) (on-top-of ?block2))

• ?stack-1 <- (stack ?block1 $?rest1)• ?stack-2 <- (stack ?block2 $?rest2)• =>• (retract ?goal ?stack-1 ?stack-2)• (assert (stack $?rest1))• (assert (stack ?block1 ?block2 $?rest2))• (printout t ?block1 " moved on top of "• ?block2 "." crlf)) 26

Page 27: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

• (defrule move-to-floor• ?goal <- (goal (move ?block1) (on-top-of floor))• ?stack-1 <- (stack ?block1 $?rest)• =>• (retract ?goal ?stack-1)• (assert (stack ?block1))• (assert (stack $?rest))• (printout t ?block1 " moved on top of floor."

crlf))

• (defrule clear-upper-block • (goal (move ?block1))• (stack ?top $? ?block1 $?)• =>• (assert (goal (move ?top) (on-top-of floor))))

• (defrule clear-lower-block• (goal (on-top-of ?block1))• (stack ?top $? ?block1 $?)• =>• (assert (goal (move ?top) (on-top-of floor))))

27

Page 28: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Advantages of Expert Systems

• Increased availability

• Reduced cost

• Reduced danger

• Performance

• Multiple expertise

• Increased reliability

28

Page 29: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Advantages Continued

• Explanation

• Fast response

• Steady, unemotional, and complete responses at all times

• Intelligent tutor

• Intelligent database

29

Page 30: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

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.

30

Page 31: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

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.

31

Page 32: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Chapter 11. Rule-Based AI

32

Page 33: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Real-time strategy simulation game

• Keep track of the player's current state of technology so that the computer opponent can plan and deploy offensive and defensive resources accordingly

• Send out scouts to collect information and then make inferences given the information as it is received

33

Page 34: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Real-time strategy

simulation game

34

Page 35: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Martial arts fighting game

• Anticipate the player's next strike so that the computer opponent can make the appropriate countermove, such as a counter strike, a dodge, or a parry

• For example, if during the fight the player throws a punch, punch combination, what will the player most likely throw next: a punch, a low kick, or a high kick?

35

Page 36: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

11.1 Rule-Based System Basics

• Working memory– stores known facts and assertions made by the

rules • Rules memory – stores known facts and assertions made by the

rules • As rules are triggered, or fired in rule-based

system lingo, they can trigger some action or state change

36

Page 37: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Example working memory

• enum TMemoryValue{Yes, No, Maybe, Unknown};

• TMemoryValue Peasants; • TMemoryValue Woodcutter;• TMemoryValue Stonemason;• TMemoryValue Blacksmith;• TMemoryValue Barracks; • …

37

Page 38: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Making rules

• The computer can gather facts on the player's current state of technology by sending out scouts and making observations

if(Woodcutter == Yes && Stonemason == Yes && Temple == Unknown)

Temple = Maybe;

38

Page 39: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Example priest rule

if(Priest == Yes) { Temple = Yes; Barracks = Yes; Woodcutter= Yes; Stonemason= Yes;

}

39

Page 40: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

• Write such rules and execute them continuously during the game to maintain an up-to-date picture of the computer opponent's view of the player's technology capabilities

• Use this knowledge in other AI subsystems to decide how to deploy its attack forces and defenses.

40

Page 41: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Forward Chaining

1. matching rules to facts stored in working memory

2. Conflict resolution – more than one rule can match a given set of

facts in working memory – matching rule, random, highest weight

3. Fire the rule• The whole process is repeated until no more

rules can be fired

41

Page 42: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Conflict resolution

• Refractotiness– A rule should not be allowed to fire more than

once on the same data

• Recency• Specificity

42

Page 43: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Backward Chaining

• Start with some outcome, or goal, and we try to figure out which rules must be fired to arrive at that outcome or goal

if(Blacksmith == Yes) Cavalry =Yes

43

Page 44: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

11.2 Fighting Game Strike Prediction

• Predict a human opponent's next strike in a martial arts fighting game – punch, low kick, or high kick – 27 rules to capture all possible three-strike

combinations

44

Page 45: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Working memory

enum TStrikes {Punch, LowKick, HighKick, Unknown};

struct TWorkingMemory { TStrikes strikeA; // previous, previous strike (data) TStrikes strikeB; // previous strike (data) TStrikes strikeC; // next, predicted, strike (assertion)

};

45

Page 46: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Rules

class TRule { public: TRule(); void SetRule(TStrikes A, TStrikes B, TStrikes C); TStrikes antecedentA; TStrikes antecedentB; TStrikes consequentC;

bool matched; int weight;

}; 46

Page 47: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

27 Rules

• void TForm1::Initialize(void) { – Rules[0].SetRule(Punch, Punch, Punch);– Rules[1].SetRule(Punch, Punch, LowKick); – Rules[2].SetRule(Punch, Punch, HighKick); – Rules[3].SetRule(Punch, LowKick, Punch); – Rules[4].SetRule(Punch, LowKick, LowKick); – Rules[5].SetRule(Punch, LowKick, HighKick); – Rules[6].SetRule(Punch, HighKick, Punch);– …

47

Page 48: Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1.

Strike Prediction

1. Populates the working memory 1. collect some data from the player

2. Processing the previous prediction– Reinforce the matched rule by increasing the rule's

weight(meta-knowledge)3. Find the rules that match the facts stored in

working memory, conflict resolution(most weighted)

• Experiments saw success rates from 33% up to 65-80%

48