Download presentation
1
Rule-Based Reasoning Introduction UBI 517 Expert Systems
2
Introduction Rule based systems are going to be discussed with respect to the structure of rules, the two inference methods, Forward and backward reasoning the two basic architectures used to organize rules and perform inferencing. inference networks pattern matching UBI 517 Expert Systems
3
What are Rules? Rules represent knowledge using IF-THEN format
The IF portion of a rule is a condition, (also called a premise or an antecedent), which tests the truth value of set of facts. If these are found true, the THEN portion of a rule (also called the action, the conclusion or the consequent) is inferred as a new set of facts. UBI 517 Expert Systems
4
Production Systems and the Rules
The rule based systems are also called production systems. Simon and Newel developed the production system to model human problem solving. A production system consists of: An area of memory that is used to track the current state of the universe under consideration (working memory - database). A set of production rules :condition - action pairs (knowledge base). An interpreter (inference engine) recognizes and executes a production whose conditions has been satisfied. This control may be either data driven or goal driven. UBI 517 Expert Systems
5
Rule-based Inference Using search techniques and pattern matching, rule based systems automate reasoning methods and provide the logical progression from initial data to the desired conclusion. Thus the process of problem solving in knowledge based systems is to create a series of inferences that create a “path” between the problem definition and the solution This series of inferences is progressive in nature and is called an inference chain. UBI 517 Expert Systems
6
Example Suppose we are building a knowledge based system for forecasting the weather over the next 12 – 24 hours in Florida during the summer. Ambient: çevre UBI 517 Expert Systems
7
Assume the following facts are true: The ambient temperature is 920F
The relative humidity is 70% Rules 1 and 2 are fired and the following new facts are deduced The atmosphere is humid The weather is hot Which satisfy the premises of the rule 3, causing a new fact to be derived: Thunderstorms are likely to develop. UBI 517 Expert Systems
8
A single rule could have been written to reach the same conclusion:
Rule 1-A: IF the ambient temperature is above F and the atmospheric relative humidity > 65% THEN thunderstorms are likely to develop There may be other rules that use the facts “The weather is hot.” and “The atmosphere is humid.” UBI 517 Expert Systems
9
Rule based systems differ from logic in the following major ideas:
1. They are generally non-monotonic 2. They accept uncertainty in the deductive process. Non-monotonic reasoning is the concept by which derived facts can be retracted when they are no longer true. UBI 517 Expert Systems
10
The reasoning Process There are two means of progressing toward conclusions: Start with all the known data and progress to the conclusion (data driven or forward chaining) Select a possible conclusion and prove its validity by looking for supportive evidence (goal driven or backward chaining). UBI 517 Expert Systems
11
Example Suppose we have a task of identifying different varieties of fruit. Knowledge used in identification of fruits can be described through a set of rules. UBI 517 Expert Systems
12
R01:IF shape = long and color = green or yellow THEN fruit = banana
R02:IF shape = round or oblong and diameter > 4 inches THEN fruitclass = vine R03:IF shape = round and diameter < 4 inches THEN fruitclass = tree R04:IF seedcount = THEN seedclass = stonefruit R05:IF seedcount > THEN seedclass = multiple R06:IF fruitclass = vine and color = green THEN fruit=watermelon R07:IF fruitclass = vine and surface = smooth and color = yellow THEN fruit = honeydew R08:IF fruitclass = vine and surface = rough and color = tan THEN fruit = cantolope R09:IF fruitclass = tree and color = orange and seedclass = stonefruit THEN fruit = apricot R10:IF fruitclass = tree and color = orange and seedclass = multiple THEN fruit = orange R11:IF fruitclass = tree color = red and seedclass = stonefruit THEN fruit = cherry R12:IF fruitclass = tree and color = orange and seedclass = stonefruit THEN fruit = peach UBI 517 Expert Systems
13
The knowledge expressed in rules can be pictorially represented by a graph
The graphical format clearly details the connections that exist between the rules via the parameters. AND parameters OR parameters Intermediate parameters Generally these facts can be derived through the application of some rules rather than being requested directly from the user. R13:IF fruitclass = tree and color = red or yellow or green and seedclass = multiple THEN fruit = apple R14:IF fruitclass = tree and color = purple and seedclass = stonefruit THEN fruit = plum UBI 517 Expert Systems
14
Graphical Representation
UBI 517 Expert Systems
15
Data driven reasoning vs goal driven reasoning
Data driven reasoning is ideally suitable for problem domains involving synthesis such as design, configuration, planning, scheduling. In these cases many but equally acceptable solutions exist. Goal driven reasoning is ideally suited for diagnostic problems. In these cases there are small number of conclusions that can be drawn. UBI 517 Expert Systems
16
Conflict Resolution The patterns in working memory are matched against the conditions of the production rules this produces a subset of the productions called the conflict set whose conditions match the patterns in working memory. One of the productions in the conflict set is then selected (conflict resolution) and the production is fired. That is, the action of the rule is performed changing the contents of working memory. After the selected production rule is fired the control cycle repeats with the modified working memory. The process terminates when no rule conditions are matched by the contents of working memory. UBI 517 Expert Systems
17
Forward Reasoning Inference Process
New rules Knowledge Rules Applicable rules Ste2: Conflict Resolution Selected rules Step1: Match Step3: Execution Facts Facts New Facts UBI 517 Expert Systems
18
Forward Reasoning Rule interpretation in forward reasoning involves the repetition of the basic steps: Matching: Find all rules whose premises are true and mark them as being applicable Conflict Resolution: If more than one rule applies then select the rule with the highest priority (those whose premises have been satisfied). Action: Execute the action of the lowest numbered applicable rule. If none applies then halt. Reset: Reset the applicability of all rules and return to step 1. UBI 517 Expert Systems
19
Example Assume the database contains the following facts:
Diameter = 1 inch Shape = round Seedcount = 1 Color = red UBI 517 Expert Systems
20
Trace of Rule Based Forward Reasoning
UBI 517 Expert Systems
21
Backward Reasoning Backward reasoning corresponds very closely to depth first search. The system starts with an empty database of known facts. A list of goals (or conclusions) is provided for which the system attempts to derive values. For fruit identification problem initially: Known fact Base: ( ) Goals: (fruit) UBI 517 Expert Systems
22
Steps in Backward Reasoning
Form a stack initially composed of all the top level goals defined in the system. Consider the first goal from the stack. Gather all rules capable f satisfying this goal. For each of these rules: If all premises are satisfied, then execute this rule to derive its conclusion. Remove this goal from the stack and go to step to 2. If any premise of a rule is not satisfied, look for rules that derive the specified value for the parameter used in this premise. If any can be found, consider it as a subgoal and put it on top of the stack, return to step 2. UBI 517 Expert Systems
23
Steps in Backward Reasoning
If step above can’t find a rule to derive the specified value, then query the user for its value and add it to the database. If the premise is satisfied continue with the next premise, if not consider the next rule. If all rules that can satisfy the current goal have been attempted and all have failed, then this goal remains undetermined. Remove it from the stack and return to step 2. If the stack is empty, announce completion and halt. UBI 517 Expert Systems
24
Example- Fruit Identification Problem
Suppose that the fruit we are trying to identify is cherry. The top level goal: fruit Step2: Gather all rules that can derive this goal Rules 1, 6, 7, 8, 9, 10, 11, 12, 13 and 14 Execution starts with rule1 UBI 517 Expert Systems
25
Example- Fruit Identification Problem
R1: IF shape = long and color = green or yellow THEN fruit = banana There is no value for shape in database The inference mechanism asks the user: What is the value for shape? We respond with a value of round which is added to the database. Known Fact Base: ( (shape = round) ) Based on closed-world assumption rule1 fails. Execution proceeds torule6. UBI 517 Expert Systems
26
Example- Fruit Identification Problem
R6: IF fruitclass = vine and color = green THEN fruit = watermelon R2 and R3 are capable of deriving values for fruitclass. Add this subgoal to the stack Goals: ( (fruitclass) (fruit) ) R2: IF shape = round and diameter > 4 inches THEN fruitclass = vine R3: IF shape = round or oblong and diameter < 4 inches THEN fruitclass = tree UBI 517 Expert Systems
27
Example- Fruit Identification Problem
Shape = round (from the database) What is the value for the diameter? (queered) Known Fact Base: ( (shape = round) (diameter = 1) R2 fails R3 derives (fruitclass = tree) ) UBI 517 Expert Systems
28
Example- Fruit Identification Problem
R7 and R8 fail Fruitclass = vine What is the value for color? Respond :red R9 and R10 fail R9: IF fruitclass = tree and color = orange and seedclass = stonefruit THEN fruit = apricot UBI 517 Expert Systems
29
Example- Fruit Identification Problem
R11: IF fruitclass = tree and color = red and seedclass = stonefruit THEN fruit = cherry Seedclass= ? R4: IF seedcount = THEN seedclass = stonefruit What is the value for seedcount? Respond :1 UBI 517 Expert Systems
30
Example- Fruit Identification Problem
All premises of R11 are satisfied. R11 is fired and cherry is concluded for the fruit. Known Fact Base: ( ( shape = round) ( diameter = 1) ( fruitclass = tree) ( color = red) ( seedcount = 1) ( seedclass = stonefruit) ( fruit = cherry) ) UBI 517 Expert Systems
31
Rule Based Architectures
There are two basic structures to the knowledge contained within a rule based system: inference networks and pattern matching systems. UBI 517 Expert Systems
32
Inference Networks Inference network can be represented as a graph in which the nodes represent the parameters that are facts. Each fact can serve as an antecedent or consequent of a rule. The rules are represented by the interconnections between the various nodes. This knowledge is used by the inference process to propagate results throughout the network. UBI 517 Expert Systems
33
Sample Inference Networks
amb-temp rel-hum temp-cond hum-cond storm R1 R2 Mycin, Prospector and DeNAID successfully employed inference network. All interconnections between the nodes are known prior to execution Searching to Match facts with premises is minimized Implementation of the inference engine and explanation is simplified UBI 517 Expert Systems
34
Pattern Matching Systems
Pattern matching systems use extensive searches to match and execute the rules, deriving new facts. Relationships between rules and facts are formed at run-time based on the patterns that match the facts. A pattern matching system depends on matching the premises of a rule to existing facts to determine which rules have their premises satisfied by the facts and can, therefore execute. The premises of a rule are patterns. These patterns are satisfied when a search through the database of facts discovers any facts that match them. UBI 517 Expert Systems
35
Pattern Matching Systems
The typical features included within pattern matching systems are classified as one of the following five types: Pattern connectives – AND, OR Wildcard - ? $ Consider the following house example (type color number_of_stories square_footage) (contemporary brown ) (contemporary ? ? ?sq_footage) ;;a contemporary house with certain square footage, but don’t care about its color or number of stories. (contemporary $ ?sq_footage) ;; $ represents one or more fields. Contemporary: çağdaş UBI 517 Expert Systems
36
Example (deffacts people CLIPS> (person (name Jane)
(eyes blue) (hair red) ) (person (name Jack) (eyes blue) (hair black) ) (person (name Jeff) (eyes green) (hair brown) ) ) when run Jack has blue eyes Jane has blue eyes. CLIPS> (deftemplate person (slot name) (slot eyes) (slot hair)) (defrule find-blue-eyes (person (name ?name) (eyes blue)) (printout t ?name " has blue eyes." crlf)) t : terminal UBI 517 Expert Systems
37
Pattern Matching Systems
Field constraints (ranch ~red ? ?sq_footage) (contemporary gray|white ? ?sq_footage) Mathematical operators (defrule subtraction (numbers ?x ?y) (bind ?answer (- ?x ?y)) (fprintout t “the answer is “ ?answer crlf)) Test feature (if ((A = B) x y )) (fprintout t “the answer is “ ?answer crlf)) t: standard output terminal Crlf: carriage return – control feed UBI 517 Expert Systems
38
Example (defrule big-obj (width ?obj ?w) (length ?obj ?l)
(height ?obj ?h) (or (test (> ?w 50)) (test (> ?l 50)) (test (> ?h 50))) (fprintout t ?obj “is large object.” crlf)) UBI 517 Expert Systems
39
Evaluation of the Architectures
Rule based systems that use pattern matchers are flexible and powerful. They are more applicable for domains where the possible solutions are either unbound or large in numbers, such as design, planning and synthesis. The use of search to find applicable rules makes pattern matchers inefficient. Some knowledge based systems (XCON) and shells (OPS5, KEE, CLIPS) are based on pattern matching architectures UBI 517 Expert Systems
40
Evaluation of the Architectures
Inference networks are useful for domains where the number of different alternative solutions is limited (classification, diagnostic type of problems). Easier to implement Less powerful because all the relations need to be known beforehand. Allow explanation of solution easily. In pattern matching paths are generated dynamically and must be remembered for explanation UBI 517 Expert Systems
41
Disadvantages of Rule Based Systems
Major problems with rule based systems are: infinite chaining, addition of new, contradictory knowledge, modification of existing rules. UBI 517 Expert Systems
42
Infinite Chaining Results from the myth
“If the system does not work properly, all you need to do is to add more rules.” R23: IF anemia-risk(?person) THEN anemis-risk(son(?person)) R24: IF anemia-risk(father(?person)) THEN anemia-risk(?person) Sickle-cell: Hemoglobinopatiler, anormal yapıda hemoglobinlerle karakterize bir grup kalıtsal bozukluk Rule 23 derives sickle cell risk for all future generations (forward chaining) R24 is an example of infinite chaining for backward chaining. UBI 517 Expert Systems
43
Addition of New, Contradictory Knowledge
In rule based systems it is possible to introduce new knowledge to fix some problem in the knowledge base, which in turn introduces a contradiction. R107: IF it is raining THEN not(weather is sunny) R109: IF location is Florida THEN not(weather is cloudy) R24: IF time of day is late afternoon THEN weather is sunny or weather is cloudy FACTS:time of day is late afternoon location is Florida Conclusion is that the Weather is sunny. UBI 517 Expert Systems
44
Addition of New, Contradictory Knowledge
R107: IF it is raining THEN not(weather is sunny) R109: IF location is Florida THEN not(weather is cloudy) R96: IF time of day is late afternoon THEN weather is sunny or weather is cloudy R120: IF time of day is late afternoon and location is Florida THEN it is raining FACTS:time of day is late afternoon Rules , 109 work properly Rules 96, 109, 120 work properly UBI 517 Expert Systems
45
Modifications to Existing Rules
R302: IF organism = strep or organism = gonorrhea THEN prescription = penicillin Some people are allergic to penicillin R302: IF organism = strep or organism = gonorrhea THEN indicated-drug = penicillin R342: IF indicated-drug = penicillin and unknown(allergy-to = penicillin) THEN ask(allergy-to = penicillin) R367: IF indicated-drug = penicillin and not (allergy-to = penicillin) THEN prescription = penicillin UBI 517 Expert Systems
46
Modifications to Existing Rules
Patients may be allergic to other drugs. R342 and R367 can be generalized as follows R342: IF indicated-drug = ?drug and unknown(allergy-to = ?drug) THEN ask(allergy-to = ?drug) R367: IF indicated-drug = ?drug and not (allergy-to = ?drug) THEN prescription = ?drug UBI 517 Expert Systems
47
Disadvantages Additional disadvantages of rule based systems are:
Inefficiency During every cycle of inference mechanism each rule is examined to see whether it applies to the current situation Opacity It is very difficult to examine a developed knowledge base and determine what actions are going to occur when. Coverage of domain Some domains contain numerous variations of inputs which require the storage of tens of thousands of rules. The division of knowledge into small distinct packets, while making each rule easier to deal with individually creates a global perspective that is hard to comprehend. UBI 517 Expert Systems
48
Advantages of Rule Based Systems
Significant advantages of rule based systems are: Separation of knowledge and control Modularity Each rule is a distinct separate unit of knowledge that can be added, modified or removed independent of the other rules that are present in the knowledge base. Uniformity All knowledge in the system is expressed in exactly the same format. Naturalness Rules are a natural format for expressing knowledge UBI 517 Expert Systems
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.