1 / 21

Rule-based Systems

Rule-based Systems. A rule based system is also called a production system. A production rule is an: IF situation THEN action IF premise THEN conclusion IF antecedent THEN consequent Rule-based systems are the most popular type of expert systems.

arnon
Download Presentation

Rule-based Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Rule-based Systems • A rule based system is also called a production system. • A production rule is an: • IF situation THEN action • IF premise THEN conclusion • IF antecedent THEN consequent • Rule-based systems are the most popular type of expert systems. • Two inference methods are used in rule-based systems • Forward reasoning (Forward chaining, data driven reasoning) • start with known data and progress to a conclusion • Backward reasoning (Backward chaining, goal driven reasoning) start with a possible conclusion and try to prove its validity by searching for evidance.

  2. Why are rule-based systems more popular Modular nature(easy to expand) Explanation facilities easily implemented(by keeping track of the rules that fire) Similarity to human cognitive process(work of Newell and Simon)

  3. Forward Reasoning Forward Chaining Data Driven Reasoning

  4. A B C D E X X L Knowledge Base If Y and D then Z If X & B & E then Y If A then X If C then L If L and M then N Working Memory A B C D E Match Fire Knowledge Base If Y and D then Z If X & B & E then Y If A then X If C then L If L and M then N

  5. A B C D E Y X L Y Z Knowledge Base If Y and D then Z If X & B & E then Y If A then X If C then L If L and M then N A B C D E X L Knowledge Base If Y and D then Z If X & B & E then Y If A then X If C then L If L and M then N

  6. Forward Chaining Algorithm Start from a set of facts (data available) and check to see if the premises of any rules are satisfied. If there is a match then the rule fires (is executed). The steps followed in forward chaining are: • Matching: Compare rules with known facts and find rules that are • satisfied. • Conflict Resolution: More than one rule may be satisfied. Conflict • resolution is the process of selecting the one with highest priority • for execution. • Execution: The rule seleected is executed (fired). This may result • in a new fact(s) to be added and the process continues forward.

  7. Backward Reasoning Backward Chaining Goal Driven Reasoning

  8. A B C D E ? Z Y Knowledge Base If Y and D then Z If X & B & E then Y If A then X If C then L If L and M then N Working Memory A B C D E Knowledge Base If Y and D then Z If X & B & E then Y If A then X If C then L If L and M then N

  9. A B C D E X ? X Knowledge Base If Y and D then Z If X & B & E then Y If A then X If C then L If L and M then N A B C D E Knowledge Base If Y and D then Z If X & B & E then Y If A then X If C then L If L and M then N

  10. A B C D E Y X Y Z Knowledge Base If Y & D then Z If X & B & E then Y If A then X If C then L If L & M then N A B C D E X Knowledge Base If Y & D then Z If X & B & E then Y If A then X If C then L If L & M then N

  11. Backward Chaining This method of reasoning starts with a set of possible goals and tries to prove them. The following steps are followed in backward reasoning: • Form a stack consisting of all the possible goals. • Try to prove the first goal on the top of stack. Find all the rules that can satisfy this goal. • Examine the premises of each rule • a. if all premises of the rule are satisfied then fire the rule and remove the corresponding goal from the stack and then go to step 2. • b. if one or more of the premises can not be satisfied using the current facts then find rules that can satisfy the premise and put their action parts as subgoals on the top of the stack. And go to step 2. • c. if no rules can be found in b then ask the user and add that to the working memory if the value given by the user satisfies the premise otherwise try the next rule. • 4. If all the rules that can satisfy the goal have failed then remove the goal from the stack and go to 2. If stack empty then stop.

  12. Advantages of Rule Based Systems Modularity: Each rule is a separate unit. This makes adding, editing or removing of rules easily possible giving great flexibility to the system. Uniformity: The same format is used for representing all of the knowledge. Naturalness: In many domains rules are used to express the knowledge. Disadvantages of Rule Based Systems Infinite Chaining Addition of new contradictory knowledge Modification of existing knowledge Inefficiency (can be improved using algorithm such as Rete) Large number of rules needed to cover some domains(e.g. air traffic control)

  13. Rete Algorithm: Developed by C.L. Forgy A pattern matching algorithm used in OPS5 OPS83, ART and CLIPS You will hopefully write better rules after learning Rete. Rete is another word used fornet. It is more suitable for temporally redundant (as opposed to non-temporally redundant applications e.g. online signal processing) applications in which working memory does not change much between inference steps. The match (using a pattern matcher), conflict resolution and execute (recognize and act) cycle used in rule based systems is inefficient. Matching rule premises with facts took 90% of the execution time of typical OPS5 programs. If we have r rules with an average of p premises and f facts then r*f^p comparisons on each cycle to find rules to be fired. For a knowledge base with 100 rules and an average of 3 premises and 10 facts you will have 100,000 comparisons per cycle.

  14. Facts Rules Inference Engine Agenda Pattern Matching Rete algorithm is based on the fact that only a few facts are added, changed or removed at every step in the process of inference. Instead of doing all these comparisons every time only new facts added can be taken into consideration which is the approch taken in Rete algorithm. Rete looks for changes to match in each cycle. Unnecessary Computations Facts Change (Keep track of changes) Rules remain unchanged

  15. If two of the three premises of a rule are satisfied in one cycle, there is no need to check them again in the next cycle. Only the third premise is of interest. The matching process is updated when new facts are added or removed. This will speed up the process of matching if the number of new facts is small. Information about the premises of each rule which are satisfied(partial matches) must be stored. This information is called state information. Because of the need for memory space to store this information, Rete is said to be memory intensive. Two networks called a pattern network and a join network are used in Rete algorithm to store this information.

  16. Format of premises (animal-type color sizehair-lengthname) cat match value to ?c small match value to ?h match value to ?n1 dog match value to ?c match value to ?q medium match value to ?n2 Consider the following rule Rule 1: If ((cat ?c small ?h ?n1) (dog ?c ?q medium ?n2) (cat ?c large ?h ?n3) (dog ?c ?q long ?n4) Then … The pattern network is a set of trees formed from all of the premises of all the rules.

  17. cat match value to ?c Small match value to ?h match value to ?n1 dog match value to ?c match value to ?q medium match value to ?n2 large match value to ?h match value to ?n3 long match value to ?n4 When the partial tree for the third premise is constructed, the algorithm realizes that a tree starting with cat exists. When the partial tree for the fourth premise is constructed, the algorithm realizes that a tree starting with dog exists. Rule 1: If ((cat ?c small ?h ?n1) (dog ?c ?q medium ?n2) (cat ?c large ?h ?n3) (dog ?c ?q long ?n4) Then … Now the join network is constructed by the algorithm.

  18. cat match value to ?c Small match value to ?h match value to ?n1 dog match value to ?c match value to ?q medium match value to ?n2 join variable ?c join variables ?c and ?h join variables ?c The join network joins the various leaves of the tree and compares similarly named variables. large match value to ?h match value to ?n3 long match value to ?n4 Complete pattern and join networks

  19. If we had the following set of facts: • (cat yellow large short rebel) • (cat calico large short rubble) • (cat calico small short kitty) • (dog brown medium long charlie) • (cat brown small medium prince) • (dog brown small short sam) • (dog calico medium medium butcher) • (dog brown large medium star) • (dog calico medium long tramp) • Each of these facts is first parsed through the network. The network will then look as in the handout. • Everytime a fact is added or removed the network is updated. • Using the network, rules that can execute can be determined quickly in a forward reasoning system using Rete.

  20. Because sometimes several rules can execute, they will all have to be put on the agenda. Conflict resolution is then necessary to determine the rule to fire (execute). Several conflict resolution methods are possible. • Using the order of the rule • Select • lowest numbered rule • first applicable rule • Using the complexity of rules • A rule with a larger number of premises is more specific • and complex. Select a • less complex rule to find a general solution first • more complex rule to find a more specific solution • Using order of the data • Select rules matching • Older data • Newer data

  21. Now that we know how forward chaining works and how we can make it work more efficiently, let’s turn to CLIPS, a forward chaining shell using Rete. CLIPS is a rule-based forward reasoning knowledge based systems shell based on Rete pattern matching algorithm used originally in OPS5. CLIPS stands for: C Language Implementation Production System Developed by The AI section of the Johnson Space Center of NASA CLIPS supports Rule-based Object oriented (COOL: CLIPS Object Oriented Language) Procedural programming paaradigms. CLIPS Basic Programming Guide CLIPS User’s Guide

More Related