Академический Документы
Профессиональный Документы
Культура Документы
Rule-Based Systems
these can be logic based and use unication to determine rule satisfaction rules = denite horn clauses (multiple FOL conditions, single FOL assertion) facts = horn facts (FOL predicates with terms including variables)
or production systems that use pattern matching instead of unication rules can have multiple assertions as well as multiple conditions facts have no variables
production rules have a left-hand side (LHS) and a right-hand side (RHS) corresponding to a condition and action respectively. LHS is a conjunction of patterns with at least one pattern non-negated. RHS is a set of actions that modify working memory.
Sample Rules
(((agent
(location =x) (holding =a)) (arrow (name =a)) (wumpus (location (& =y !x))) (room (name =x) (adjacent =y)))
(((shoot
(location 1) (holding A)) (arrow (name A)) (wumpus (location 2)) (room (name 1) (adjacent 2))) (location 1) (holding nil)) (arrow (name A)) (wumpus (location 2)) (room (name 1) (adjacent 2)) (shoot (arrow A) (at 2))) (location 1) (holding nil)) (arrow (name A)) (wumpus (location 2) (status dead)) (room (name 1) (adjacent 2)))
(((shoot (arrow =x) (at =y)) (=object (location =y))) ((MODIFY 2 (status dead)) (REMOVE 1)) )
((agent
R1: Digital Equipment Corporations expert system for conguring large ACE: AT&T Bell Laboratories expert system for diagnosing telephone line
like Horn clause forward chaining (or backward chaining) algorithms, rule inference engines nd rules that are satised, re them, thus altering the working memory, enabling other rules to be satised (and red, etc...) rule inference engines repeat three steps:
match: determine which rules are satised by which facts in working memory producing the conict set of instantiations conict Resolution: select which instantiation is best act: Fire the instantiation, altering working memory
rule inference halts either when no rule matches or when an explicit halt action is red
Conict Resolution
recency: time tags on WMEs specicity: how many individual values matched conict resolution algorithms are linear
for each LHS, match each clause against each working memory
element (WME), maintaining variable binding consistency among clauses within the same LHS add the instantiation, that is, the pair (Rule, WME-set), to the conict set and all WMEs including changes
for each set of WMEs that successfully matches the clauses on a LHS, after conict resolution and act phases, repeat match with all LHSs
Observation
changes in WM result in changes in the conict set therefore, only the changes in WM should be addressed in an efcient match algorithm
precompile rules into a dataow network (rete) data structure nodes in the rete represent the match of one value nodes store partial instantiations leaves of the rete represent complete instantiations
P:(agent (location 1) (holding A)) Q:(arrow (name A)) R:(wumpus (location 2)) S:(room (name 1) (adjacent 2))
Sample Rete
(((agent (location =x) (holding =a)) (arrow (name =a)) (wumpus (location (& =y !x))) (room (name =x) (adjacent =y))) ((MODIFY 1 (holding nil)) (ASSERT shoot (arrow =a) (at =y))) )
class: arrow
class: agent
class: wumpus
class: room
P
location: =x
R
location: =y !x
S
name: =x
P: =x 1
name: =a holding: =a
R: =y 2
S: =x 1
Q: =a A
P: =a A
P,R: =x 1, =y 2
adjacent: =y
S: =y 2
P,Q: =a A
P,R,S: =x 1, =y 2 R,S: =y 2
P,Q,R,S: =a A, =x 1, =y 2