Some Thoughts to Consider 10 How does an inference engine decide which rule to run next? What are...

15
Some Thoughts to Consider 10 How does an inference engine decide which rule to run next? What are the various strategies? How many rules does it take to build a large knowledge base of expertise for a typical problem solution? When the knowledge base becomes large and complex, what does it take to validate the correctness of the rules?

Transcript of Some Thoughts to Consider 10 How does an inference engine decide which rule to run next? What are...

Page 1: Some Thoughts to Consider 10 How does an inference engine decide which rule to run next? What are the various strategies? How many rules does it take to.

Some Thoughts to Consider 10

• How does an inference engine decide which rule to run next? What are the various strategies?

• How many rules does it take to build a large knowledge base of expertise for a typical problem solution?

• When the knowledge base becomes large and complex, what does it take to validate the correctness of the rules?

Page 2: Some Thoughts to Consider 10 How does an inference engine decide which rule to run next? What are the various strategies? How many rules does it take to.

Rule Based System Resources

• JBoss Rules (Drools) - Tutorial-like documentation for rule-based systems and user manuals for JBoss Rules implementation.

• JESS: Java Expert System Shell - from Sandia National Laboratories.

• Java Rule Engine API (JSR94) - From Sun Developer Network point of view.

• The Rule MarkUp Initiative - an international collaboration.

• SWRL: A Semantic Web Rule Language Combining OWL and RuleML - A W3C submission.

• SWRL on Wikipedia - With some examples and links.

• javarules.org - The Java Business Rules Community.

• Semantics of Business Vocabulary and Business Rules (SVBR) - OMG specification - very comprehensive, with computational possibilities.

• FairIsaac Corporation - leader in decision management - Maker of the world-class Blaze Advisor rule-based system engines.

• Haley Limited - Acquirer of Paul Haley's technology and customers.

• Paul Haley's Personal Site - He is a pioneer in rule-based decision support, and a good technology critic.

Page 3: Some Thoughts to Consider 10 How does an inference engine decide which rule to run next? What are the various strategies? How many rules does it take to.

Rule Based System Development

• First Order Logic and Semantic Networks are not the only means for representing knowledge.

• Many expert systems and knowledge based systems have been developed using if-then rules to represent knowledge. Many claim that it is natural for experts to characterize their knowledge in terms of rules.

• Following are several examples of rule based knowledge represented in Narl:

• Getting to the Theater on Time rule base.

• Harmon & King’s Media Advisor - a version that implements each rule in a separate node.

• Harmon & King’s Media Advisor - a version that implements all rules in a single node, with separate nodes for the various cases, all of which inherit the same rules.

• Try out the various rule sets in either the Narl Browser or the NarlInterpreter. Observe what the various inferencing strategies have to be for various kinds of rule arrangements.

Page 4: Some Thoughts to Consider 10 How does an inference engine decide which rule to run next? What are the various strategies? How many rules does it take to.

GTTTOT Rules in Narl

;=========================================================; Model to handle rules for Getting to the Theater on Time;---------------------------------------------------------; Rules in English:; 1. If Distance > 5 miles; then Means is drive; 2. If Distance > 1 mile and Time < 15 minutes; then Means is drive; 3. If Distance > 1 mile and Time > 15 minutes; then Means is walk; 4. If Means is drive and Location is downtown; then Action is take a cab; 5. If Means is drive and Location is not downtown; then Action is drive your car; 6. If Means is walk and Weather is bad; then Action is take a coat and walk; 7. If Means is walk and Weather is good; then Action is walk;============================================(rule-model-root (a-kind-of (value model-root)));--------------------------------------------(rule-node (a-kind-of (value rule-model-root)))(theater-rule (instance-of (value rule-node)) (goal (value action)) (multivalued (value action)) (parameter (distance 3) (time 20) (location "downtown") (weather "good")))(rule_1 (instance-of (value theater-rule)) (rule (value {if {distance > 5} {then {set {theater-rule parameter means} "drive"}}})))(rule_2 (instance-of (value theater-rule)) (rule (value {if {distance > 1} {time < 15} {then {set {theater-rule parameter means} "drive"}}})))(rule_3 (instance-of (value theater-rule)) (rule (value {if {distance > 1} {time > 15} {then {set {theater-rule parameter means} "walk"}}})))

Page 5: Some Thoughts to Consider 10 How does an inference engine decide which rule to run next? What are the various strategies? How many rules does it take to.

GTTTOT Rules in Narl (cont.)

(rule_4

(instance-of (value theater-rule))

(rule (value {if {means = "drive"} {location = "downtown"}

{then {set {theater-rule parameter action} "Take a cab"}}}))

)

(rule_5

(instance-of (value theater-rule))

(rule (value {if {means = "drive"} {location != "downtown"}

{then {set {theater-rule parameter action} "Drive car"}}}))

)

(rule_6

(instance-of (value theater-rule))

(rule (value {if {means = "walk"} {weather = "bad"}

{then {set {theater-rule parameter action} "Walk with coat"}}}))

)

(rule_7

(instance-of (value theater-rule))

(rule (value {if {means = "walk"} {weather = "good"}

{then {set {theater-rule parameter action} "Walk"}}}))

)

Page 6: Some Thoughts to Consider 10 How does an inference engine decide which rule to run next? What are the various strategies? How many rules does it take to.

Media Advisor 1

;=========================================================; Model to handle rules for MediaAdvisor, a small; knowledge based system to provide advice relative to; the kind of media to use for particular training; situations. Adapted from Harmon and King, 1985.;---------------------------------------------------------; This version represents rules one per node, with all; reasoning parameters set in the parent node.;=========================================================(rule-model-root (a-kind-of (value model-root)));---------------------------------------------------------(rule-node (a-kind-of (value rule-model-root)))(mediadv-rule (instance-of (value rule-node)) (goal (value media-to-consider)) (multivalued (value media-to-consider))

(parameter (situation "reading") (stimulus-duration "brief") (response "reading") (instructional-feedback "no") (presentation-modification "per-course") (training-budget "medium")

(symbolic-list "graphics" "schematics" "numbers" "formulas" "symbolic") (verbal-list "listening" "conversation" "dialog" "reading" "textual-materials" "verbal") (vocal-list "saying-something" "talking" "speaking" "singing" "vocal") (motor-list "building" "assembling" "moving" "constructing" "arranging" "dancing" "motor=activity") (affect-list "emoting" "sympathizing" "empathizing" "feeling" "showing-affect") ))(rule_1 (instance-of (value mediadv-rule)) (rule (value {if {or {situation = "physical-model"} {situation = "structure"} {situation = "object"} {situation = "machine"} {situation = "tool"} {situation = "environmental"}} {then {set {mediadv-rule parameter stimulus-situation} "environmental"}}})))

Page 7: Some Thoughts to Consider 10 How does an inference engine decide which rule to run next? What are the various strategies? How many rules does it take to.

Media Advisor 1 (cont.)

(rule_2 (instance-of (value mediadv-rule)) (rule (value {if {or {situation = "picture"} {situation = "photograph"} {situation = "diagram"} {situation = "illustration"} {situation = "view"} {situation = "pictorial"}} {then {set {mediadv-rule parameter stimulus-situation} "pictorial"}}})))(rule_3 (instance-of (value mediadv-rule)) (rule (value {if {symbolic-list contains situation} {then {set {mediadv-rule parameter stimulus-situation} "symbolic"}}})))(rule_4 (instance-of (value mediadv-rule)) (rule (value {if {verbal-list contains situation} {then {set {mediadv-rule parameter stimulus-situation} "verbal"}}})))(rule_5 (instance-of (value mediadv-rule)) (rule (value {if {or {response = "listening"} {response = "reading"} {response = "observing"} {response = "meditating"} {response = "imagining"} {response = "thinking"} {response = "covert"}} {then {set {mediadv-rule parameter appropriate-response} "covert"}}})))(rule_6 (instance-of (value mediadv-rule)) (rule (value {if {or {response = "multiple-choice"} {response = "matching"} {response = "selective"}} {then {set {mediadv-rule parameter appropriate-response} "selective"}}})))(rule_7 (instance-of (value mediadv-rule)) (rule (value {if {or {response = "writing"} {response = "drawing"} {response = "typing"}} {then {set {mediadv-rule parameter appropriate-response} "constructed"}}})))

Page 8: Some Thoughts to Consider 10 How does an inference engine decide which rule to run next? What are the various strategies? How many rules does it take to.

Media Advisor 1 (cont.)

(rule_8

(instance-of (value mediadv-rule))

(rule (value {if {vocal-list contains response}

{then {set {mediadv-rule parameter appropriate-response}

"vocal"}}}))

)

(rule_9

(instance-of (value mediadv-rule))

(rule (value {if {motor-list contains response}

{then {set {mediadv-rule parameter appropriate-response}

"motor"}}}))

)

(rule_10

(instance-of (value mediadv-rule))

(rule (value {if {affect-list contains response}

{then {set {mediadv-rule parameter appropriate-response}

"affective"}}}))

)

(rule_11

(instance-of (value mediadv-rule))

(rule (value {if {stimulus-situation = "verbal"}

{stimulus-duration = "persistent"}

{appropriate-response = "covert"}

{instructional-feedback = "no"}

{presentation-modification = "none"}

{or {training-budget = "small"}

{training-budget = "medium"}}

{then {set {mediadv-rule parameter media-to-consider}

"book"}}}))

)

(rule_12

(instance-of (value mediadv-rule))

(rule (value {if {stimulus-situation = "verbal"}

{stimulus-duration = "persistent"}

{or {appropriate-response = "selective"}

{appropriate-response = "constructed"}}

{instructional-feedback = "yes"}

{or {presentation-modification = "per-response"}

{presentation-modification = "per-module"}}

{or {training-budget = "small"}

{training-budget = "medium"}

{training-budget = "large"}}

{then {set {mediadv-rule parameter media-to-consider}

"self-study-workbook"}}}))

)

Page 9: Some Thoughts to Consider 10 How does an inference engine decide which rule to run next? What are the various strategies? How many rules does it take to.

Media Advisor 1 (cont.)

(rule_13 (instance-of (value mediadv-rule)) (rule (value {if {stimulus-situation = "verbal"} {stimulus-duration = "brief"} {appropriate-response = "covert"} {instructional-feedback = "no"} {presentation-modification = "per-course"} {or {training-budget = "small"} {training-budget = "medium"}} {then {set {mediadv-rule parameter media-to-consider} "lecture"}}})))(rule_14 (instance-of (value mediadv-rule)) (rule (value {if {or {stimulus-situation = "verbal"} {stimulus-situation = "symbolic"} {stimulus-situation = "pictorial"}} {stimulus-duration = "brief"} {appropriate-response = "covert"} {instructional-feedback = "no"} {presentation-modification = "per-course"} {training-budget = "medium"} {then {set {mediadv-rule parameter media-to-consider} "lecture-with-slides"}}})))(rule_15 (instance-of (value mediadv-rule)) (rule (value {if {or {stimulus-situation = "verbal"} {stimulus-situation = "pictorial"}} {stimulus-duration = "brief"} {appropriate-response = "covert"} {instructional-feedback = "no"} {presentation-modification = "per-module"} {or {training-budget = "medium"} {training-budget = "large"}} {then {set {mediadv-rule parameter media-to-consider} "videocassette"}}})))(rule_16 (instance-of (value mediadv-rule)) (rule (value {if {stimulus-situation = "verbal"} {stimulus-duration = "brief"} {or {appropriate-response = "vocal"} {appropriate-response = "affective"}} {instructional-feedback = "yes"} {presentation-modification = "per-module"} {or {training-budget = "small"} {training-budget = "medium"}} {then {set {mediadv-rule parameter media-to-consider} "role-play-with-verbal-feedback"}}})))

Page 10: Some Thoughts to Consider 10 How does an inference engine decide which rule to run next? What are the various strategies? How many rules does it take to.

Media Advisor 1 (cont.)

(rule_17 (instance-of (value mediadv-rule)) (rule (value {if {stimulus-situation = "verbal"} {stimulus-duration = "brief"} {or {appropriate-response = "vocal"} {appropriate-response = "affective"}} {instructional-feedback = "yes"} {presentation-modification = "per-module"} {or {training-budget = "medium"} {training-budget = "large"}} {then {set {mediadv-rule parameter media-to-consider} "role-play-with-video-feedback"}}})))(rule_18 (instance-of (value mediadv-rule)) (rule (value {if {stimulus-situation = "environmental"} {stimulus-duration = "persistent"} {appropriate-response = "motor"} {instructional-feedback = "no"} {or {presentation-modification = "per-module"} {presentation-modification = "per-course"}} {training-budget = "large"} {then {set {mediadv-rule parameter media-to-consider} "lab/workshop"}}})))(rule_19 (instance-of (value mediadv-rule)) (rule (value {if {stimulus-situation = "verbal"} {stimulus-duration = "brief"} {appropriate-response = "covert"} {instructional-feedback = "no"} {presentation-modification = "none"} {training-budget = "small"} {then {set {mediadv-rule parameter media-to-consider} "audio-cassette"}}})))(rule_20 (instance-of (value mediadv-rule)) (rule (value {if {or {stimulus-situation = "symbolic"} {stimulus-situation = "verbal"}} {stimulus-duration = "brief"} {or {appropriate-response = "covert"} {appropriate-response = "verbal"} {appropriate-response = "affective"}} {instructional-feedback = "yes"} {presentation-modification = "per-response"} {or {training-budget = "medium"} {training-budget = "large"}} {then {set {mediadv-rule parameter media-to-consider} "human-tutor"}}})))

Page 11: Some Thoughts to Consider 10 How does an inference engine decide which rule to run next? What are the various strategies? How many rules does it take to.

Media Advisor 2

;=========================================================; Model to handle rules for MediaAdvisor, a small; knowledge based system to provide advice relative to; the kind of media to use for particular training; situations. Adapted from Harmon and King, 1985.;---------------------------------------------------------; This version represents cases one per node, with all; rules contained in the parent node, inheritable by; all the case nodes.;=========================================================(rule-model-root (a-kind-of (value model-root)));---------------------------------------------------------(media-advice (a-kind-of (value rule-model-root)) (goal (value media-to-consider)) (multivalued (value media-to-consider))

(parameter (symbolic-list "graphics" "schematics" "numbers" "formulas" "symbolic") (verbal-list "listening" "conversation" "dialog" "reading" "textual-materials" "verbal") (vocal-list "saying-something" "talking" "speaking" "singing" "vocal") (motor-list "building" "assembling" "moving" "constructing" "arranging" "dancing" "motor=activity") (affect-list "emoting" "sympathizing" "empathizing" "feeling" "showing-affect") ) (rule (value {if {or {situation = "physical-model"} {situation = "structure"} {situation = "object"} {situation = "machine"} {situation = "tool"} {situation = "environmental"}} {then {set stimulus-situation "environmental"}}}

{if {or {situation = "picture"} {situation = "photograph"} {situation = "diagram"} {situation = "illustration"} {situation = "view"} {situation = "pictorial"}} {then {set stimulus-situation "pictorial"}}}

{if {symbolic-list contains situation} {then {set stimulus-situation "symbolic"}}}

{if {verbal-list contains situation} {then {set stimulus-situation "verbal"}}}

Page 12: Some Thoughts to Consider 10 How does an inference engine decide which rule to run next? What are the various strategies? How many rules does it take to.

Media Advisor 2 (cont.)

{if {or {response = "listening"} {response = "reading"} {response = "observing"} {response = "meditating"} {response = "imagining"} {response = "thinking"} {response = "covert"}} {then {set appropriate-response "covert"}}}

{if {or {response = "multiple-choice"} {response = "matching"} {response = "selective"}} {then {set appropriate-response "selective"}}}

{if {or {response = "writing"} {response = "drawing"} {response = "typing"}} {then {set appropriate-response "constructed"}}}

{if {vocal-list contains response} {then {set appropriate-response "vocal"}}}

{if {motor-list contains response} {then {set appropriate-response "motor"}}}

{if {affect-list contains response} {then {set appropriate-response "affective"}}}

{if {stimulus-situation = "verbal"} {stimulus-duration = "persistent"} {appropriate-response = "covert"} {instructional-feedback = "no"} {presentation-modification = "none"} {or {training-budget = "small"} {training-budget = "medium"}} {then {set media-to-consider "book"}}}

{if {stimulus-situation = "verbal"} {stimulus-duration = "persistent"} {or {appropriate-response = "selective"} {appropriate-response = "constructed"}} {instructional-feedback = "yes"} {or {presentation-modification = "per-response"} {presentation-modification = "per-module"}} {or {training-budget = "small"} {training-budget = "medium"} {training-budget = "large"}} {then {set media-to-consider "self-study-workbook"}}}

Page 13: Some Thoughts to Consider 10 How does an inference engine decide which rule to run next? What are the various strategies? How many rules does it take to.

Media Advisor 2 (cont.)

{if {stimulus-situation = "verbal"} {stimulus-duration = "brief"} {appropriate-response = "covert"} {instructional-feedback = "no"} {presentation-modification = "per-course"} {or {training-budget = "small"} {training-budget = "medium"}} {then {set media-to-consider "lecture"}}}

{if {or {stimulus-situation = "verbal"} {stimulus-situation = "symbolic"} {stimulus-situation = "pictorial"}} {stimulus-duration = "brief"} {appropriate-response = "covert"} {instructional-feedback = "no"} {presentation-modification = "per-course"} {training-budget = "medium"} {then {set media-to-consider "lecture-with-slides"}}}

{if {or {stimulus-situation = "verbal"} {stimulus-situation = "pictorial"}} {stimulus-duration = "brief"} {appropriate-response = "covert"} {instructional-feedback = "no"} {presentation-modification = "per-module"} {or {training-budget = "medium"} {training-budget = "large"}} {then {set media-to-consider "videocassette"}}}

{if {stimulus-situation = "verbal"} {stimulus-duration = "brief"} {or {appropriate-response = "vocal"} {appropriate-response = "affective"}} {instructional-feedback = "yes"} {presentation-modification = "per-module"} {or {training-budget = "small"} {training-budget = "medium"}} {then {set media-to-consider "role-play-with-verbal-feedback"}}}

{if {stimulus-situation = "verbal"} {stimulus-duration = "brief"} {or {appropriate-response = "vocal"} {appropriate-response = "affective"}} {instructional-feedback = "yes"} {presentation-modification = "per-module"} {or {training-budget = "medium"} {training-budget = "large"}} {then {set media-to-consider "role-play-with-video-feedback"}}}

Page 14: Some Thoughts to Consider 10 How does an inference engine decide which rule to run next? What are the various strategies? How many rules does it take to.

Media Advisor 2 (cont.)

{if {stimulus-situation = "environmental"}

{stimulus-duration = "persistent"}

{appropriate-response = "motor"}

{instructional-feedback = "no"}

{or {presentation-modification = "per-module"}

{presentation-modification = "per-course"}}

{training-budget = "large"}

{then {set media-to-consider "lab/workshop"}}}

{if {stimulus-situation = "verbal"}

{stimulus-duration = "brief"}

{appropriate-response = "covert"}

{instructional-feedback = "no"}

{presentation-modification = "none"}

{training-budget = "small"}

{then {set media-to-consider "audio-cassette"}}}

{if {or {stimulus-situation = "symbolic"}

{stimulus-situation = "verbal"}}

{stimulus-duration = "brief"}

{or {appropriate-response = "covert"}

{appropriate-response = "verbal"}

{appropriate-response = "affective"}}

{instructional-feedback = "yes"}

{presentation-modification = "per-response"}

{or {training-budget = "medium"}

{training-budget = "large"}}

{then {set media-to-consider "human-tutor"}}}

) )

)

Page 15: Some Thoughts to Consider 10 How does an inference engine decide which rule to run next? What are the various strategies? How many rules does it take to.

Media Advisor 2 (cont.)

(case_0 (instance-of (value media-advice)) (parameter (situation "dialog") (stimulus-duration "persistent") (response "talking") (instructional-feedback "yes") (presentation-modification "per-resonse") (training-budget "large") ))(case_1 (instance-of (value media-advice)) (parameter (situation "reading") (stimulus-duration "persistent") (response "reading") (instructional-feedback "no") (presentation-modification "none") (training-budget "small") ))(case_2 (instance-of (value media-advice)) (parameter (situation "reading") (stimulus-duration "persistent") (response "writing") (instructional-feedback "yes") (presentation-modification "per-response") (training-budget "small") ))(case_3 (instance-of (value media-advice)) (parameter (situation "reading") (stimulus-duration "brief") (response "reading") (instructional-feedback "no") (presentation-modification "per-course") (training-budget "medium") ))