Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Introduction to Expert System Chapter 11. Rule-Based AI 2013/5/2 1."— Presentation transcript:

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

2 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

3 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

4 Basic Functions of Expert Systems 4

5 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

6 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

7 Figure 2.2 The Pyramid of Knowledge 7

8 Productions A number of knowledge-representation techniques have been devised: Rules: IF-THEN rules Semantic nets Frames Scripts Logic Conceptual graphs 8

9 9

10 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

11 Development of an Expert System 11

12 Structure of a Rule-Based Expert System 12

13 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

14 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

15 Direct Reasoning Modus Ponens 15

16 Some Rules of Inference 16

17 Rules of Inference 17

18 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

19 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

20 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

21 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

22 Figure 3.21 Causal Forward Chaining 22

23 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

24 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

25 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

26 (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

27 (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

28 Advantages of Expert Systems Increased availability Reduced cost Reduced danger Performance Multiple expertise Increased reliability 28

29 Advantages Continued Explanation Fast response Steady, unemotional, and complete responses at all times Intelligent tutor Intelligent database 29

30 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

31 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

32 Chapter 11. Rule-Based AI 32

33 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

34 Real-time strategy simulation game 34

35 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

36 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

37 Example working memory enum TMemoryValue{Yes, No, Maybe, Unknown}; TMemoryValue Peasants; TMemoryValue Woodcutter; TMemoryValue Stonemason; TMemoryValue Blacksmith; TMemoryValue Barracks; … 37

38 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

39 Example priest rule if(Priest == Yes) { Temple = Yes; Barracks = Yes; Woodcutter= Yes; Stonemason= Yes; } 39

40 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

41 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

42 Conflict resolution Refractotiness – A rule should not be allowed to fire more than once on the same data Recency Specificity 42

43 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

44 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

45 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

46 Rules class TRule { public: TRule(); void SetRule(TStrikes A, TStrikes B, TStrikes C); TStrikes antecedentA; TStrikes antecedentB; TStrikes consequentC; bool matched; int weight; }; 46

47 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

48 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


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

Similar presentations


Ads by Google