Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 9. Rules and Expert Systems Fall 2013 Comp3710 Artificial Intelligence Computing Science Thompson Rivers University.

Similar presentations


Presentation on theme: "Chapter 9. Rules and Expert Systems Fall 2013 Comp3710 Artificial Intelligence Computing Science Thompson Rivers University."— Presentation transcript:

1 Chapter 9. Rules and Expert Systems Fall 2013 Comp3710 Artificial Intelligence Computing Science Thompson Rivers University

2 TRU-COMP3710 Rules and Expert Systems2 Course Outline Part I – Introduction to Artificial Intelligence Part II – Classical Artificial Intelligence Knowledge Representation Searching Knowledge Represenation and Automated Reasoning Propositinoal and Predicate Logic Inference and Resolution for Problem Solving Rules and Expert Systems Part III – Machine Learning Part IV – Advanced Topics

3 TRU-COMP3710 Rules and Expert Systems3 Chapter Objectives Rule-based expert systems Do forward chaining with example rules and facts Do backward chaining with example rules and facts Explain what a rule-based expert system consists of List the two parts in expert systems, which can not be easily solved

4 TRU-COMP3710 Rules and Expert Systems4 Chapter Outline 1. Rules for Knowledge Representation Rules for Knowledge Representation 2. Rule-Based Systems Rule-Based Systems 3. Forward Chaining Forward Chaining 4. Backward Chaining Backward Chaining 5. Rule-Based Expert Systems Rule-Based Expert Systems

5 TRU-COMP3710 Rules and Expert Systems5 Rules for Knowledge Representation Here are some interesting quotes. Each problem that I solved became a rule which served afterwards to solve other problems. - Rene Descartes As a rule we disbelieve all the facts and theories for which we have no use. - William James

6 TRU-COMP3710 Rules and Expert Systems6 Rules for Knowledge Representation Hell, there are no rules here -- we're trying to accomplish something. - Thomas A. Edison Get your facts first, and then you can distort them as much as you please. - Mark Twain If the facts don't fit the theory, change the facts. - Albert Einstein

7 TRU-COMP3710 Rules and Expert Systems7 Rules for Knowledge Representation [Q] How do you want to represent our knowledge? [Q] How do we do [logical] reasoning? Facts and rules: IF… THEN rules can be used to represent knowledge: IF it rains, THEN you will get wet Rules can also be recommendations or actions: IF it rains, THEN you should wear a coat

8 TRU-COMP3710 Rules and Expert Systems8 Rules for Knowledge Representation A rule consists of an antecedent and a consequence (action, conclusion). IF A THEN B, orA -> B When there are more than one antecedent, AND (&), OR (|), NOT (~),...or , , ,...(conjunction, disjunction) Truth table?(T  F)  (  T  F)T -> F ??? In general, the antecedent of a rule compares an object [variable] with a possible value, using an operator. I.e., the antecedent of a rule is a Boolean expression. IF x  3 IF name is “Bob” IF weather is cold IF name is “Bob”  weather is cold THEN tell “Bob” ‘Wear a coat’ Topics

9 TRU-COMP3710 Rules and Expert Systems9 Rule-Based Systems A rule-based system or production system is a system that uses knowledge in the form of rules to provide diagnoses or advice on the basis of input data (facts). 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 to draw conclusions. Conclusions are often derived using deduction (deductive reasoning). Forward chaining: using deduction to reach a conclusion from a set of antecedents (i.e., facts) Backward chaining: starts from a conclusion (i.e., hypothesis) and tries to show it by following a logical path backward from the conclusion to a set of antecedents that are in the database of facts Topics

10 TRU-COMP3710 Rules and Expert Systems10 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. Also known as data-driven reasoning 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. Take the facts from the database See if any combination of these matches all the antecedents of one of the rules in the database When all the antecedents of a rule are matched by facts, then this rule is triggered. When a rule is triggered, it is then fired, which means its conclusion is added to the facts database.

11 TRU-COMP3710 Rules and Expert Systems11 Forward Chaining Example of elevator Rule 1: IF floor = first & button = first THEN open door Rule 2: IF floor = first & button = second THEN goto second floor Rule 3: IF floor = first & button = third THEN goto third floor Rule 4: IF floor = second & button = first & going to third floor = T THEN remember to goto first floor Fact 1:floor = first Fact 2:button = third Fact 3:day = Tuesday The facts match Rule ??? and the conclusion ??? is added to the database of facts

12 TRU-COMP3710 Rules and Expert Systems12 Forward Chaining Example of elevator – cont Rule 1: IF floor = first & button = first THEN open door Rule 2: IF floor = first & button = second THEN goto second floor Rule 3: IF floor = first & button = third THEN goto third floor Rule 4: IF floor = second & button = first & going to third floor = T THEN remember to goto first floor Fact 1:floor = second (<- first) Fact 2:button = Fact 3:day = Tuesday Fact 4:going to third floor = T

13 TRU-COMP3710 Rules and Expert Systems13 Forward Chaining Example of elevator – cont Rule 1: IF floor = first & button = first THEN open door Rule 2: IF floor = first & button = second THEN goto second floor Rule 3: IF floor = first & button = third THEN goto third floor Rule 4: IF floor = second & button = first & going to third floor = T THEN remember to goto first floor Fact 1:floor = second (<- first) Fact 2:button = first Fact 3:day = Tuesday Fact 4:going to third floor = T

14 TRU-COMP3710 Rules and Expert Systems14 Forward Chaining Example of elevator – cont Rule 1: IF floor = first & button = first THEN open door Rule 2: IF floor = first & button = second THEN goto second floor Rule 3: IF floor = first & button = third THEN goto third floor Rule 4: IF floor = second & button = first & going to third floor = T THEN remember to goto first floor Fact 1:floor = second (<- first) Fact 2:button = first Fact 3:day = Tuesday Fact 4:going to third floor = T Rule 4 is fired. [Q] What if someone pressed the button on the second floor?

15 TRU-COMP3710 Rules and Expert Systems15 Forward Chaining Example of elevator – cont Fact 1:floor = third Fact 2:button = second Fact 3:button = first There are more than one possible conclusion, i.e., there can be multiple rules matching with the facts. Conflict resolution needs to be applied to decide which rule to fire.

16 TRU-COMP3710 Rules and Expert Systems16 Conflict Resolution Sometimes more than one rule will fire at once, and a conflict resolution strategy must be used to decide which conclusion[s] to use. Some ideas: 1. Give rules priorities and to use the conclusion that has the highest priority. 2. The rule with the longest antecedent is applied. 3. The rule that matches with the most recently added facts is applied.

17 TRU-COMP3710 Rules and Expert Systems17 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. Topics

18 TRU-COMP3710 Rules and Expert Systems18 Backward Chaining In cases where a particular conclusion, i.e., hypothesis, 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.

19 TRU-COMP3710 Rules and Expert Systems19 Backward Chaining Example: Rule 1A  B -> C Rule 2A -> D Rule 3C  D -> E Rule 4A  E  F -> G Rule 5 A  E -> H Rule 6D  E  H -> I Fact 1A Fact 2B Fact 3F [Q] What do we want to do with the above databases? Goalto prove H [Q] Do we humans use Forward Chaining or Backward Chaining?

20 TRU-COMP3710 Rules and Expert Systems20 Backward Chaining Rule 1A  B -> C Rule 2A -> D Rule 3C  D -> E Rule 4A  E  F -> G Rule 5 A  E -> H Rule 6D  E  H -> I Fact 1A Fact 2B Fact 3F Goalto prove H [Q] Which one is better??? [Q] Use both of them??? Using forward chaining: FactsRules triggeredRule fired A, B, F1, 21 A, B, C, F22 A, B, C, D, F33 A, B, C, D, E, F4, 54 A, B, C, D, E, F, G55 A, B, C, D, E, F, G, H6STOP Using backward chaining: FactsGoalsMatching rules A, B, FH5 A, B, FE3 A, B, FC, D1 A, B, C, FD2 A, B, C, D, F  STOP Topics

21 TRU-COMP3710 Rules and Expert Systems21 Types of Expert Systems Rule-Based Systems in this textbook The 70s and 80s Neural Networks Belief (Bayesian) Networks Blackboard Systems Case-Based Reasoning...

22 TRU-COMP3710 Rules and Expert Systems22 Architecture of Expert Systems End users; domain experts; knowledge engineers An expert system uses expert knowledge derived from human experts to diagnose illnesses, provide recommendations and solve other problems.

23 TRU-COMP3710 Rules and Expert Systems23 Architecture of Expert Systems Knowledge base: database of rules (domain knowledge). Explanation system: explains the decisions the system makes. User Interface: the means by which the end user interacts with the expert system. Knowledge base editor: allows domain experts or knowledge engineers to edit the information in the knowledge base. Inference engine

24 TRU-COMP3710 Rules and Expert Systems24 Expert System Shells The part of an expert system that does not contain any domain specific or case specific knowledge is the expert system shell. A single expert system shell can be used to build a number of different expert systems. Examples of an expert system shell are CLIPS (C Language Interpreted Production System) and JESS (The Java Expert System Shell)

25 TRU-COMP3710 Rules and Expert Systems25 Example: CLIPS CLIPS is C Language Integrated Production System – an expert system shell. CLIPS uses a LISP-like notation to enter rules.

26 TRU-COMP3710 Rules and Expert Systems26 The Rete Algorithm One potential problem with expert systems is the number of comparisons that need to be made between rules and facts in the database, when there are many rules and facts. [Q] How to solve? Any good data structure? A rete is a directed, acyclic, rooted graph (a sort of tree). 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 (adding, updating, deleting) are propagated through the tree. This makes an efficient way for expert systems to deal with environments which change often.

27 TRU-COMP3710 Rules and Expert Systems27 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. [Q] Is it the most difficult part in the development of an expert system?

28 TRU-COMP3710 Rules and Expert Systems28 Backward Chaining in Expert Systems A common method for building expert systems is to use a rule-based system with backward chaining. Typically a user enters a set of facts into the system, and the system tries to see if it can prove any of the possible hypotheses using these facts. In some cases it will need additional facts, in which case the system will often ask the user questions, to ascertain facts that could enable further rules to fire. Backward chaining is often used in expert systems that are designed for medical diagnosis.

29 TRU-COMP3710 Rules and Expert Systems29 Backward Chaining in Expert Systems Algorithm: 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.

30 TRU-COMP3710 Rules and Expert Systems30 Backward Chaining in Expert Systems  Usually backward chaining is used in conjunction with forward chaining.  Forward chaining to derive new facts and asks questions in order to carry out its backward chaining analysis.  E.g.,  Rule 1:IF tired and headache THEN diagnose gladular fever  Rule 2:IF tired and sore throat THEN diagnose tonsilitis  Fact:headache  => Forward chainging -> Hypothesis 1: G.F. -> backward chaining  =>ask if tired

31 TRU-COMP3710 Rules and Expert Systems31 Example: 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.

32 TRU-COMP3710 Rules and Expert Systems32 The Last Questions [Q] Which part is difficult to implement? [Q] Have expert systems been successful? [Wikipedia] The expert system has a major flaw which explains its low success although the principle has existed for 70 years: knowledge collection and interpretation into rules, the knowledge engineering. Most developers have no method to perform this task. They work manually what opens to many possibilities for errors. [Q] How to handle uncertainty? E.g., IF name is “Bob”  weather is cold THEN tell “Bob” ‘Wear a coat’ Topics


Download ppt "Chapter 9. Rules and Expert Systems Fall 2013 Comp3710 Artificial Intelligence Computing Science Thompson Rivers University."

Similar presentations


Ads by Google