PROUCTION SYSTEMS (PROUCTION RULES SYSTEMS) r. Hikmat Jaber
WHT ROUCTION SYSTEM IS USE OR? The production system describes the systems that represent knowledge in the form of rules for modeling human problem solving and for implementing search algorithms. EINITION production system is a system based on I THEN ules a d o sisti g of 3 parts: 1. Rule Set. 2. Working Memory. 3. Inference Engine.
ROUCTION SYSTEM 1. Rule Set: is the set of Production Rules: - If <condition> then action - nalogous to long term memory. 2. Working Memory: Inference Engine Working Memory - Maintains the facts that inference engine matches against. - The current state of the world. - nalogous to short term memory. Rule Set If then B If B then 3. Inference Engine: (Production System Interpreter) - way of choosing between rules (Conflict Resolution) and acting on rules (Recognize-ct Cycle).
1. PROUCTION production or a rule is condition-action pair presented in the following form: I condition THEN action Production is a single chunk of problem-solving knowledge. The condition part matched against working memory. The condition part of the rule is a pattern that determines when the rule may be applied to a problem. The process of matching the new or existing facts against Production Rules is called pattern matching, which is performed by the Inference Engine. The action part defines the associated problem-solving step if the condition is true.
2. WORKING MEMORY Working memory contains a description of the current state of the problem-solving. 3. INERENCE ENGINE Role to determine what to do i.e. implement search allowing the production system to move towards a goal within the set of rules (this is the role of Recognize-act cycle) I.e. to look at the current state of the world and then find from production rules the best to apply. By 1. Match find relevant rules. Those whose conditions match the current state of long term memory 2. Conflict Resolution choose between relevant rules 3. ct apply or fire the rule 4. Repeat
PTTERN-IRECTE SERCH Operations of the recognize-act cycle are based on the pattern-directed search 1. The working memory contains a pattern corresponding to the current state in the problem-solving process. 2. The pattern is matched against I or THEN part of rules (it depends on the direction of search) 3. If several rules match the pattern, the conflict set appears (i.e. conflict appears when many rules being true for the same fact). The production rules in the conflict set are said to be enabled. Selection of one rule from the conflict set is called conflict resolution.
PTTERN-IRECTE SERCH (cont.) 4. One of the enabled rules is fired and it changes the content of the working memory. 5. The control cycle repeats with the modified working memory. 6. The process terminates when no rules are matched by the content of the working memory. C-condition -action Working memory [Pattern] Knowledge base I C1 THEN 1 I C2 THEN 2 I Cn THEN n
CONTROL O SERCH IN PROUCTION SYSTEMS or real world problems a knowledge base typically i ludes a huge u e of I THEN ules. I o de to make search more effective, developers of intelligent systems must use heuristic control of search. There are 3 control strategies: 1. Control through choice of search strategy 2. Control through rule structure 3. Control through conflict resolution
CONTROL THROUGH CHOICE O SERCH STRTEGY It is possible to choose a direction of search in production systems: 1. ata-driven search (forward chaining) 2. Goal-driven search (backward chaining)
ORWR CHINING orward chaining or data-driven inference works by repeatedly: starting from the current state, matching the premises of the rules (the I parts), and performing the corresponding actions (the THEN parts) that usually update the knowledge base or working memory. The process continues until no more rules can be applied, or some cycle limit is met, e.g. CTS CTS B E execute match &B C& E C RULES CTS C B match &B C& RULES execute CTS E C B execute E C B match &B C& RULES
ORWR CHINING (cont.) In this example there are no more rules, so we can draw the inference chain: C B ata-driven search 1. Begins with a problem description (a pattern) added to the working memory 2. The recognize-act cycle compares matching of the pattern with I part of rules in the knowledge base 3. iring a rule, its THEN part is added to the working memory and the process continues 4. Search stops when the goal is found
ORWR CHINING (cont.) search Example: ata-driven B 1. I hmad is a student THEN h ad e jo s stude t s life C B 2. I h ad e jo s stude t s life THEN hmad meets friends N h ad pa ti ipates i u i e sit s e e ts C E E 3. I hmad meets friends THEN hmad needs money 4. I hmad needs money THEN hmad has a job C 5. I hmad meets friends N hmad participates in G u i e sit s e e ts THEN hmad has little free time G 6. I hmad has little free time N hmad has a job THEN H hmad is not successful in studies N hmad doesi not receive scholarship
ORWR CHINING (cont.) Example: ata-driven search Knowledge base 1. 2. 3. 4. 5. 6. I THEN B I B THEN C N I C THEN E I E THEN I C N THEN G I G N THEN H N I Iteration Working memory Start Goal I Conflict set ired rule 0 1 1 1, B 1, 2 2 2, B, C, 1, 2, 3, 5 5 3, B, C,, G 1, 2, 3, 5 3 4, B, C,, G, E 1, 2, 3, 5, 4 4 5, B, C,, G, E, 1, 2, 3, 5, 4, 6 6 6, B, C,, G, E,, H, I 1, 2, 3, 5. 4, 6 goal
BCKWR CHINING Backward chaining or goal-driven inference works towards a final state by looking at the working memory to see if the sub-goal states already exist there. If not, the actions (the THEN parts) of the rules that will establish the sub-goals are identified, and new sub-goals are set up for achieving the premises of those rules (the I parts). The previous example now becomes CTS CTS CTS CTS E E B C E E B C B C Want B C Want Want Get, Get B Get C, Get Get &B C& &B C& &B C& RULES RULES RULES RULES CTS E B C E B C Execute Execute &B C& CTS &B C& RULES Execute &B C& RULES
BCKWR CHINING (cont.) The first part of the chain works back from the goal until only the initial facts are required, at which point we know how to traverse the chain to achieve the goal state. B C Goal-driven search 1. goal (a pattern) is added to the working memory 2. The recognize-act cycle compares matching of the pattern with THEN part of rules in the knowledge base 3. iring a rule, its I part is added to the working memory and the process continues 4. Search stops when facts on problem are found
BCKWR CHINING (cont.) Example: Goal-driven search Knowledge base 1. 2. 3. 4. 5. 6. I p N q THEN goal I r N s THEN p I w N r THEN q I t N u THEN q I v THEN s I start THEN v N r N q Iteration Working memory Start goal Goal start Conflict set ired rule 0 goal 1 1 1 goal, p, q 1, 2, 3, 4 2 2 goal, p, q, r, s 1, 2, 3, 4, 5 3 3 goal, p, q, r, s, w 1, 2, 3, 4, 5 4 4 goal, p, q, r, s, w, t, u 1, 2, 3, 4, 5 5 5 goal, p, q, r, s, w, t, u, v 1, 2, 3, 4, 5, 6 6 6 goal, p, q, r, s, w, t, u, v, start 1, 2, 3, 4. 5, 6 stop
CONTROL THROUGH RULE STRUCTURE Human experts encode crucial heuristics within their rules of expertise. The order of conditions encodes important procedural information for solving the problem. It is important that this form be preserved in building an intelligent system that sol es p o le s like the e pe t. Whe a the e gi e o t tu he k the atte e ha i sa s if o e a d the lights do t o e o the, he/she is suggesti g a spe ifi se ue e of things to try. This form of the rules is critical in controlling search, making the system behave logically.
CONTROL THROUGH RULE STRUCTURE (cont.) RULE STRUCTURE + RULE ORER IN THE KNOWLEGE BSE efines search order and its effectiveness
CONTROL THROUGH RULE STRUCTURE (cont.) RULE STRUCTURE What is the content of I part? What is the content of THEN part? How several What will be the What will be the conditions will order of conditions order of actions if be connected if they are several? they are several? (N, OR)? I a & b & c THEN a & & I b & a & c THEN & a &
CONTROL THROUGH CONLICT RESOLUTION The simplest strategy is to choose the first rule that matches the content of the working memory and do not use recently fires rules. Common strategy: 1. Once a rule has fired, it may not fire again until the working memory elements that match its conditions have been modified, this discourages looping. 2. Rules whose conditions match with the patterns most recently added to the working memory are more preferred. This focuses the search on a single line of reasoning. 3. more specific problem-solving rule is preferred to a general rule. rule is more specific than another if it has more conditions. I a THEN c I a N b THEN c more specific
EXERCISE Consider the following set of rules: R1: I: engine does not turn N battery is not flat THEN: ask user to test starter motor R2: I: there is no spark THEN: ask user to check the points R3: I: engine turns N engine does not start THEN: ask user to check the spark R4: I: engine does not turn THEN: ask user to check the battery R5: I: battery is flat THEN: ask user to charge battery N EXIT Build a production system to formulate and resolve the above simple mechanical diagnosis problem of a vehicle. The production system should list the working memory (facts), the rule set (rules) and inference engine (recognize-act cycle and conflict set). Your system should specify and verify what search strategy is chosen (forward or backward reasoning). In addition, your answer should include: 1. The table that describes the working memory, conflict set and the rule triggered for each process iteration. 2. The figure that describes the rules, the facts, and the inference engine that apply the rules on the facts for firing the rules on the matched facts.