Вы находитесь на странице: 1из 12

Rule-Based Expert Systems

Rule-Based Systems

rule-based systems are structured as two memories

knowledge base of rules working memory of facts

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

Structure of Production Rules

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)))

((MODIFY 1 (holding nil)) (ASSERT shoot (arrow =a) (at =y))) )

(((shoot

(arrow =x) (at =y)) (=object (location =y)))

((MODIFY 2 (status dead)) (REMOVE 1)) )

Sample Working Memories


((agent ((agent
(((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))) )

(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

Early Ground-Breaking Rule-Based Systems

MYCIN: bacterial infection diagnosis including explanation system.


backward chaining.

Dendral: elucidation of the molecular structure of unknown organic


computer systems a sales force tool to accurately meet customer requirements. forward chaining. repairs based on trouble tickets. forward chaining.

compounds taken from known groups of such compounds. backward chaining.

R1: Digital Equipment Corporations expert system for conguring large ACE: AT&T Bell Laboratories expert system for diagnosing telephone line

Rule Inference Engines

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

many alternative algorithms to select which instantiation


should re

two factors often used to sort and then select the


instantiation are recency and specicity

recency: time tags on WMEs specicity: how many individual values matched conict resolution algorithms are linear

Inefcient Match Algorithm

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

Rete 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

Вам также может понравиться