Download presentation
Presentation is loading. Please wait.
Published byElise Jacocks Modified over 9 years ago
1
Rules, page 1 CSI 4106, Winter 2005 Representing knowledge with rules Points Definitions Production systems Conflict resolution strategies Examples A financial advisor Bagger XCON Animal classification in Prolog A forward-chaining engine Animal classification revisited
2
Rules, page 2 CSI 4106, Winter 2005 Rules... A rule, in its simplest form, is a pair conditions actions An action can be real (maybe software-simulated), or it can only add -- assert -- new conditions. A rule is not the same as an implication premises conclusions where false premises are allowed, but there are significant similarities. In rule-based systems, the basic rule form is enhanced with control information and, especially, with probabilities or confidence measures.
3
Rules, page 3 CSI 4106, Winter 2005... and applications One class of applications are rule-based expert systems. Despite their apparent simplicity, rules are quite expressive. There are two types of uses. Synthesis (to construct or configure): XCON is an example of a deployed system; our simple case study is Bagger. Analysis (to recognize or diagnose): MYCIN is the best-known (almost) success story; our simple case study is animal classification.
4
Rules, page 4 CSI 4106, Winter 2005 Forward-chaining production systems Rule memory (rules are called productions). Working memory (literals that represent the current state of the problem); actions change working memory. Rule selection and application mechanisms (rules are indexed by situations). Rule selection relies on pattern matching. A conflict arises if more than one rule has been selected to match the current situation. Conflict resolution procedures select one rule. This rule is fired if its conditions hold. Actions are performed, working memory updated.
5
Rules, page 5 CSI 4106, Winter 2005 Some conflict resolution strategies Order rules (partially) by specificity -- the more conditions, the more specific the rule; prefer more specific rules. Rank all rules; prefer rules with a higher rank. Rank all facts; prefer rules with more highly ranking facts. Record the time of changes to working memory; prefer rules that depend of recent additions.
6
Rules, page 6 CSI 4106, Winter 2005 Implementing forward chaining An agenda is a handy data structure for implementing forward chaining. It is "a list of things to do”, here -- candidate rules. Conditions are considered in some order; any rule that has the currently examined condition in its left-hand side becomes partially activated. Its copy, with the matched condition removed, goes on the agenda. A rule is selected for firing when it has become fully activated, that is, when all its left-hand side conditions have been matched. Otherwise the rule is kept for future use, just in case the remaining conditions become asserted later.
7
Rules, page 7 CSI 4106, Winter 2005 A financial “expert system” 1.saved(low) investIn(savings) 2.saved(high) ∧ income(adequate) investIn(stocks) 3.saved(high) ∧ income(inadequate) investIn(mixed) 4. ∀ x amountSaved(x) ∃ y (nbrDependents(y) x > y*5000) saved(high) 5. ∀ x amountSaved(x) ∃ y (nbrDependents(y) x ≤ y*5000) saved(low) 6. ∀ x earnings(x, steady) ∃ y (nbrDependents(y) x > 15000 + y*4000) income(adequate) 7. ∀ x earnings(x, steady) ∃ y (nbrDependents(y) x ≤ 15000 + y*4000) income(inadequate) 8. ∀ x earnings(x, unsteady) income(inadequate)
8
Rules, page 8 CSI 4106, Winter 2005 A financial “expert system” (2) 9.amountSaved(22000) 10.nbrDependents(3) 11.earnings(25000, steady) [12] and [13] match the conditions of [3]. Add a new fact: Given facts 9-11 and rules 1-8, we perform forward chaining. [9] and [10] match the conditions of [4] and [5], but only [4] passes the test. Add a new fact: 12.saved(high) 13.income(inadequate) 14.investIn(mixed) [10] and [11] match the conditions of [6] and [7], but only [7] passes the test. Add a new fact: Done.
9
Rules, page 9 CSI 4106, Winter 2005 Bagger: a robot that bags groceries The main idea is simple. (1)Bag the large items: put large heavy items one per bag; start a new bag when a large item does not fit in any partially filled bag. (2)Bag the mid-sized items: meat and frozen goods go in freezer bags; start a new bag when a mid-sized item does not fit in any partially filled bag. (3)Bag the small items: try to avoid bagging them with heavy items; start a new bag when a small item does not fit in any partially filled bag. What could be a good conflict resolution strategy for the following rules?
10
Rules, page 10 CSI 4106, Winter 2005 Bagger (2) (1)the step is bag-large & there is a large unbagged item & there is a large unbagged heavy item & there is a bag with < 6 large items bag the large heavy item (2)the step is bag-large & there is a large unbagged item & there is a bag with < 6 large items bag the large item (3)the step is bag-large & there is a large unbagged item start a new bag & bag the large item (4)the step is bag-large end the step bag-large & begin the step bag-medium
11
Rules, page 11 CSI 4106, Winter 2005 Bagger (3) (5)the step is bag-medium & there is a medium unbagged item & the medium item is a freezer-bag item & there is an unfilled bag put the medium item in a freezer bag & bag the medium item (6)the step is bag-medium & there is a medium unbagged item & there is an unfilled bag bag the medium item (7)the step is bag-medium & there is a medium unbagged item start a new bag & bag the medium item (8)the step is bag-medium end the step bag-medium & begin the step bag-small
12
Rules, page 12 CSI 4106, Winter 2005 Bagger (4) (9)the step is bag-small & there is a small unbagged item & there is an unfilled bag without large heavy items bag the small item (10)the step is bag-small & there is a small unbagged item & there is an unfilled bag bag the small item (11)the step is bag-small & there is a small unbagged item start a new bag & bag the small item (12)the step is bag-small end the step bag-medium & stop
13
Rules, page 13 CSI 4106, Winter 2005 XCON XCON configures DEC computing equipment. It is one of rather few (but well known!) examples of commercially successful expert systems. XCON is, in a sense, Bagger's big brother. Its general plan of action is quite simple: a sequence of steps. (There are, however, dozens of rules for each step...) The configuring operation includes selecting components to match the order, laying out the spatial arrangement of cabinets, filling the cabinets, and so on.
14
Rules, page 14 CSI 4106, Winter 2005 XCON (2) Major steps Check the order, look for missing or incompatible items. Lay out the processor in cabinets. Put boxes in the input/output cabinets, put components in those boxes. Put panels in the input/output cabinets. Lay out the floor plan. Plan the cabling.
15
Rules, page 15 CSI 4106, Winter 2005 A classification system in Prolog http://www.site.uottawa.ca/~nat/Courses/csi4106_2008/Material/animals.pl
16
Rules, page 16 CSI 4106, Winter 2005 Animal classification in a rule-based system http://www.site.uottawa.ca/~nat/Courses/csi4106_2008/Material/animals_rules The general rules
17
Rules, page 17 CSI 4106, Winter 2005 Animal classification (2) A session with the forward chainer http://www.site.uottawa.ca/~nat/Courses/csi4106_2008/Material/animals_session
18
Rules, page 18 CSI 4106, Winter 2005 Animal classification (3) The forward chainer in Prolog http://www.site.uottawa.ca/~nat/Courses/csi4106_2008/Material/forward_chainer.pl
19
Rules, page 19 CSI 4106, Winter 2005 A glimpse at expert systems Your reading for independent study : sections 8.1-8.2. Architecture of a typical expert system
20
Rules, page 20 CSI 4106, Winter 2005 A glimpse at expert systems (2) Guidelines to determine whether a problem is appropriate for expert system solution: 1.The need for the solution justifies the cost and effort of building an expert system. 2.Human expertise is not available in all situations where it is needed. 3.The problem may be solved using symbolic reasoning. 4.The problem domain is well structured and does not require commonsense reasoning. 5.The problem may not be solved using traditional computing methods. 6.Cooperative and articulate experts exist. 7.The problem is of proper size and scope.
21
Rules, page 21 CSI 4106, Winter 2005 A glimpse at expert systems (3) Exploratory development cycle
22
Rules, page 22 CSI 4106, Winter 2005 Later or much later More topics appear in the very useful chapter 8: planning (section 8.4) will be discussed later; case-based reasoning is left for another course .
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.