Rule-based Systems: Mechanisms - PowerPoint PPT Presentation

About This Presentation
Title:

Rule-based Systems: Mechanisms

Description:

'Join' bindings across antecedents. Selecting Assertions ... selects n projects n-1 joins n-1 projects. PER RULE! Also Joins very expensive - others linear ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 24
Provided by: ginal5
Category:

less

Transcript and Presenter's Notes

Title: Rule-based Systems: Mechanisms


1
Rule-based SystemsMechanisms Efficiency
  • Artificial Intelligence
  • CMSC 25000
  • January 10, 2002

2
Agenda
  • Rule-based systems
  • Backward-chaining II
  • Variables, unification, and search
  • RETE method
  • Relational model Databases
  • Efficient rule-based reasoning
  • Conclusions

3
Rule-based Systems
  • Represent knowledge as
  • Assertions (mother-of ?x ?y), (female ?x)
  • Rules
  • If (parent-of ?x ?y)
    Antecedent
  • (female ?x)
  • then (mother-of ?x)
    Consequent
  • Manipulate knowledge with
  • Rule interpreter
  • Forward-Chain Rules assertions gt New
    assertions
  • Backward-Chain Hypothesis (consequent)gtAnteceden
    ts

4
Rule Manipulation w/Variables
  • Forward-chaining
  • Match antecedents with variables to assertions
    WITHOUT variables
  • Match (bind) variables to constants
  • Backward-chaining
  • Match hypothesis to consequent
  • May contain variables e.g. (grandparent A ?x)
  • Match variables to constants AND variables!
  • Requires general unification

5
Backward Chaining with Variables
R1 if (parent ?x ?y) (parent ?y ?z)
then (grandparent ?x ?z) R2 if (father ?v1
?w1) then (parent ?v1 ?w1) R3 if (mother ?v2
?w2) then (parent ?v2 ?w2)
Hypothesis (grandparent A ?m)
(grandparent ?x ?z)
?xA ?z?m
?xA ?z?m ?y??
?xA ?z?m ?y?w1B
(parent ?x ?y)
(parent ?y ?z)
(parent ?v1 ?w1)
(parent ?v2 ?w2)
?xA?v1 ?z?m?w2 ?y?w1?v2B
?xA?v1 ?z?m ?y???w1
Assertions (father A B) (mother B C)
(father ?v1 ?w1)
(mother ?v2 ?w2)
?xA?v1 ?z?m ?y?w1B
?xA?v1 ?z?m?w2C ?yw1?v2B
(father A B)
(mother B C)
6
Unification Variable Renaming
  • Matching (grandparent A ?m) (grandparent ?x ?z)
  • No problem bind ?xA, ?z?m
  • If match hypothesis (grandparent A ?y)
  • (grandparent ?x ?z) gt (parent ?y ?y) Problem!!!
  • Just an artefact, though, so
  • Without loss of generality, rename variables
  • if (parent ?x1 ?y1)
  • (parent ?y1 ?z1)
  • then (grandparent ?x1 ?z1)

7
Unification Occurs Check
  • How do we unify
  • (?z likes ?z) (?y likes (house-of ?x))
  • Need (?z ?y) and (?z (house-of ?x)),
  • Implies (?y (house-of ?x)) FINE
  • Now, how do we unify
  • (?z likes ?z) (?x likes (house-of ?x))
  • Need (?z ?x) and (?z (house-of ?x))
  • Implies (?x (house-of ?x)) problematic.
  • In unification, a variable cannot be assigned to
    an expression where that variable occurs (called
    the occurs check).

8
RETE Method
  • Rule chaining problem Efficiency!
  • For each rule,
  • For each antecedent,
  • For each assignment of variables to assertions
  • Assert consequent
  • E.g. for grandparent example,
  • k2 antecedents, n4 assertions 16 steps
  • Worst case nk!!!!
  • Different representation implementation

9
Forward Chaining with variables
IF (parent ?x ?y) (parent A B)
(parent ?y ?z) (parent A C) THEN
(grand-parent ?x ?z) (parent B D)
(parent C E)
  • (parent ?x ?y) (parent ?y ?z) (grand-parent ?x
    ?z)
  • (xA yB) (yA zB) conflict in y
  • (yA zC) conflict in y
  • (yB zD) (xA yB zD)
  • (yC zE) conflict in y
  • (xA yC) (yA zB) conflict in y
  • (yA zC) conflict in y
  • (yB zD) conflict in y
  • (yC zE) (xA yC zE)
  • (xB yD) (yA zB) conflict in y
  • (yA zC) conflict in y
  • (yB zD) conflict in y
  • (yC zE) conflict in y
  • (xC yE) (yA zB) conflict in y

10
Rule System as Relational DB
  • Working memory relations in database table
  • Rules and rule interpretations as relational
    database operations

(parent A B) (parent A C) (parent B D) (parent C
E) (is A female)
R1 if (parent ?x ?y) (parent ?y ?z)
(is ?x female) then (grandmother ?x ?z)
11
Working Memory as Database Table
Columns Fields (Header field name) Rows
records assertions Relation Database Table
data
12
Pattern Matching as Relational DB Ops
  • Which rules triggered?
  • Which antecedents match? What bindings apply?
  • Select matching assertions
  • Project new bindings
  • Join bindings across antecedents

13
Selecting Assertions
(parent ?x ?y) gt Select data with First parent
14
Projecting Bindings
A1 Project result over Second and Third
15
Projecting Bindings
A2 Project Select Data with Firstparent over
Second and Third
16
Joining for Consistency
Join tables for consistency B1 Join A1 and
A2 with YY
17
Produce Consequent
X A
A3 Project Select Data with FirstIs and
ThirdFemale over Second
B2 Project Join B1 and A3 with X X over X
and Z
(Grandmother A D) (Grandmother A E)
18
Analysis
  • Relational database representation performs
    forward-chaining
  • Finds all new assertions based on rules,
    assertions
  • But, still expensive
  • n antecedents gt
  • n selects n projects n-1 joins n-1 projects
  • PER RULE!
  • Also Joins very expensive - others linear in table

19
Incremental Efficiency
  • Solution Compile out rulesinterpreter into
  • RETE Network to incrementally process each
    assertion
  • At any time, operate on SUBSET of relations
  • Steps
  • Each assertion/relation passed thru Select
    filters
  • Project to alpha node store in table
  • Joins represented by beta nodes
  • Only small of comparisons at each stage

20
Compiled Out Rete
Assertions
Select new with FirstParent
First 2nd 3rd
Select new with FirstParent
Parent A B
Select new with Firstis and 3rdfemale
A1
A2
A3
X Y A B
Y Z A B
X A
B1
B2
21
Compiled Out Rete
Assertions
Select new with FirstParent
First 2nd 3rd
Select new with FirstParent
Parent A C
Select new with Firstis and 3rdfemale
A1
A2
A3
X Y A B A C
Y Z A B A C
X A
B1
B2
22
Compiled Out Rete
Assertions
Select new with FirstParent
First 2nd 3rd
Select new with FirstParent
Parent B D
Select new with Firstis and 3rdfemale
A1
A2
A3
X Y A B A C B D
Y Z A B A C B D
X A
B1
B2
X Z A D
X Y Z A B D
ETC..
23
Summary
  • Rule-based systems Mechanisms
  • Unification supports matching patterns to
    constants AND variables
  • Variable renaming preserves generality
  • RETE method
  • Relational databases and operations
  • Incremental processing
  • Efficient rule-based reasoning
Write a Comment
User Comments (0)
About PowerShow.com