Rule-Based Systems - homepages.gold.ac.uk

wastecypriotInternet and Web Development

Nov 10, 2013 (3 years and 8 months ago)

89 views

IS53024A
:

Artificial Intelligence


Rule
-
Based Systems



1. Rule
-
Based Systems


Rule
-
based systems

(RBS) provide automatic problem solving tools for
capturing the human expertise and decision making.


RBS are means for codifying the problem solving of huma
n experts.

Experts typically express most of their problem solving techniques in

terms of antecedent
-
consequent rules.


The
main properties of rule
-
based systems

are:


-

they incorporate practical human knowledge in if
-
then rules;

-

their skill increases
proportionally to the enlargement of their
knowledge;

-

they can solve a wide range of potentially complex problems by
selecting relevant rules and then combining the results;

-

they adaptively determine the best sequence of rules to examine;

-

they explain thei
r conclusions by retracting their lines of reasoning




Some of the RBS application areas are:




equipment maintenance
-

diagnosing faults and recommending repairs



component selection
-

eliciting requirements from electronics catalogs



computer operation
-

analyzing requirements, and operating software



product configuration
-

identifying parts that satisfy constraints



troubleshooting
-

suggesting treatments, and prescribing preventative
measures



process control
-

spotting problematic data and removing irregu
larities



quality assurance
-

assessing tasks, proposing practices



medical diagnosis





Rule
-
based systems (RBS) offer practical means of building automated
experts in application areas where job excellence requires consistent
reasoning and practical expe
rience.


The RBS directly incorporate rules that emulate the effective

reasoning characteristics of experienced professionals, while general
purpose deductive systems do not emulate experts and lack the

necessary efficiency for solving complex practical
problems.


RBS has two
distinguishing characteristics
:


-

the existing knowledge can be refined and new knowledge can be

added for incremental increase of the system performance;



-

they explain the line of reasoning making their logic transparent.


2
. Architecture of Rule
-
Based Systems


An RBS consists of a
knowledge base

and an
inference engine
. The

knowledge base contains
rules

and
facts
.



2.1. Rules





The rules contain several if
-
patterns (antecedents) and one or more




Then
-
patterns (consequ
ents). The interpretation of a rule is that if the




antecedent can be satisfied then the consequent is satisfied too.


When the consequent defines an action the effect of satisfying the
antecedent is to schedule the action for execution. When the conse
quent
defines a conclusion the effect is to infer the conclusion.


The rules specify chunks of analytic problem
-
solving knowledge. They
use symbolic descriptions to characterize relevant situations and
corresponding actions. The language used for these de
scriptions imposes
a conceptual framework on the problem and its solutions.




2.2. Facts


The
facts

express assertions about properties, relations, propositions,
etc.. In contrast to rules which the RBS interprets as imperatives, facts
are usually stati
c and inactive regarding the programmatic value of
knowledge.



2.3. Working Memory





The
knowledge base

that contains the rules is long
-
term store.




In addition to this static memory, the RBS uses a
working memory





(short
-
term store) to store temp
orary assertions.




These assertions record earlier rule
-
based inferences, thus the




contents of the working memory is problem
-
solving state information.





The working memory data adhere to the syntactic conventions for facts.





2.4. Inference En
gine





The basic function of the RBS is to produce outputs, which may be




a problem solution, an answer to a question, or an analysis of some data.








The main operating cycle of RBS consists of three phases:




match
,
select

and
act
.


When cert
ain triggering (firing) conditions occur the actions specified
by the rules are executed. The firing conditions are defined by the data




patterns in the working memory.





When the patterns in a rule are matched, the system selects this rule and




i
nterprets it so as to draw inferences that alter the working memory.





The most common RBS modes of operation are:

-

forward chaining (stimulus driven)

-

backward chaining (goal directed)

Knowledge Base
(Rule Base)
Data (patterns)
Working Memory
Rules Facts
Facts
Inference Engine
Match
Select
Act
Data (patterns)
Updates
Output (decisions)
Inputs






2.4.1. Forward Chaining





Forward chaining mode of
operation means that a rule is triggered




when changes in the working memory produce a situation that




matches all of its antecedents.


Forward chaining is the process of inferring then
-
patterns from if
-
patterns, that is consequents from antecedents.
When an antecedent
matches an assertion the antecedent is satisfied. When all antecedents

of a rule are satisfied the rule is triggered. In deduction systems all
triggered rules are allowed and may fire.





Forward Chaining Algorithm





Repeat






For

each rule do







-

Match
all its antecedents to








the facts from the Working memory





-

if all antecedents of a rule are matched,







Execute

is consequents



until

no rule produces a new assertion, or the goal is satisfied


Exam
ple
: A deduction system for identification of animals:


(RULE 1 (IF ( ?x has hair ))


(THEN ( ?x is mammal )))


(RULE 2 (IF ( ?x gives milk ))


(THEN ( ?x is mammal )))


(RULE 3 (IF ( ?x has feathers ))


(THEN ( ?x is bird
)))


(RULE 4 (IF ( ?x flies )&( ?x lays eggs ))


(THEN ( ?x is bird )))


(RULE 5 (IF ( ?x is mammal )&( ?x eats meat ))


(THEN ( ?x is carnivore )))


(RULE 6 (IF ( ?x is mammal )&( ?x has teeth )&( ?x has claws )&( ?x has sharp eye
s ))


(THEN ( ?x is carnivore )))


(RULE 7 (IF ( ?x is mammal )& ( ?x has hoofs ))


(THEN ( ?x is ungulate )))


(RULE 8 (IF ( ?x is mammal )&( ?x chews cud ))


(THEN ( ?x is ungulate )))


(RULE 9 (IF ( ?x is carnivore )&( ?
x has tawny color )&( ?x has dark spots ))


(THEN ( ?x is cheetah )))


(RULE 10 (IF ( ?x is mammal )&( ?x is carnivore )&( ?x has tawny color )&( ?x has black stripes ))


(THEN ( ?x is tiger )))


(RULE 11 (IF ( ?x is ungulate )&( ?x has

long legs )&( ?x has tawny color )&( ?x has long neck ))


(THEN ( ?x is giraffe)))


(RULE 12 (IF ( ?x is ungulate )&( ?x has black stripes ))


(THEN ( ?x is zebra )))


(RULE 13 (IF ( ?x is bird )&( ?x does not fly )&( ?x has long neck
)&( ?x is black and white ))


(THEN ( ?x is ostrich )))


(RULE 14 (IF ( ?x is bird )&( ?x does not fly )&( ?x swims )&( ?x is black and white ))


(THEN ( ?x is penguin )))


(RULE 15 (IF ( ?x is bird )&( ?x is good flyer ))



(THEN ( ?x is albatross )))



Consider the following working memory:

WM

= (
(Animal has hair)(Animal chews cud)(Animal has long legs)


(Animal has long neck)(Animal has tawny color)


(Animal has dark spots )

)



Running the forward chaining algorithm
produces the steps:



Fires

R1: (Animal has hair)


with binding

?x=Animal
,


adds new assertion:
( Animal is mammal )




Fires

R8: (Animal is mammal)&(Animal chews cud)


with binding

?x=Animal
,


adds new assertion:
( Animal is

ungulate )



Fires

R11: (Animal is ungulate )&( Animal has long legs )&


(Animal has tawny color )&(Animal has long neck)


with binding

?x=Animal
,


adds new assertion:
( Animal is giraffe )



2.4.2. Backward Chaining


The back
ward chaining mode of operation means that the systems
begins with a goal and successively examines any rules with matching
consequents. These candidate rules are considered one at a time. The

unmet conditions are in turn reintroduced as new goals. The con
trol
procedure then shifts attention recursively toward the new goal. The
effort terminates when the top goal is finally satisfied.





Backward Chaining Algorithm





Repeat






For

each hypothesis do


For
each rule whose conseq
uent matches this hypothesis






-

try to
Match

each of the rule antecedents with the







facts from the working memory, or using backward







chaining through another rule, thus,







creating new hypotheses







-

if all of the rule antec
edents are supported then success



until

all hypotheses have been tried, and none have been supported,





or until the goal is satisfied


WM

= (
(Animal has dark spots )(Animal has tawny color )


(Animal has hair)(Anima
l has sharp eyes)


(Animal has claws)(Animal has teeth)
)


Running the backward chaining algorithm produces the steps:


Goal hypothesis

: (Animal is cheetah)



Using
R9
: the new Subgoal hypotheses that have to be proven are (
?x=Anim
al
)



1)
(Animal is carnivore)


2)
(Animal is tawny color)


3)
(Animal has dark spots)


Goal hypothesis

: (Animal is carnivore)

Using
R5
: the new Subgoal hypotheses that have to be proven are (
?x=Animal
)



1)
(Animal is mammal
)



2)
(Animal eats meat)


Goal hypothesis

: (Animal is mammal)

Using
R1
: the new Subgoal hypotheses that have to be proven are (
?x=Animal
)



1)
(Animal has hair)>> R1
PROVED

(Fires)

(Animal is mammal)

R5

fails because can not prove:
(Animal e
ats meat)


Using
R6
: the new Subgoal hypotheses that have to be proven are (
?x=Animal
)



1)
(Animal is mammal)



2)
(Animal has teeth)


3)
(Animal has claws)


4)
(Animal has sharp eyes)


>> R6
PROVED

(Fires)

(Ani
mal is carnivore)

>> R9
PROVED (Fires)

(Animal is cheetah)


3. Non
-
deterministic Computations


The operating concept of RBS differs radically from von Neumann

computer architectures.


Intelligent
problem solving with RBS

involves an iterative cycle of:

-

identifying from experience the heuristic rules that bear on


a problem at hand;

-

applying one of these rules to solve or simplify the given problem.


The technology for building RBS supports this cycle by providing a dynamic
working memory for prac
tical results, a device to identify relevant rules, and
selective means for applying desirable rules.

The RBS performs non
-
deterministically the actions based on the

currently available data and heuristic rules, that is their sequential

behavior is not
known in advance, unlike conventional computational
processing systems.


The RBS address a number of shortcomings in conventional

programming technology:

-

the non
-
specifiability of programs (non
-
determinism in computations);

-

the changes in principles of o
peration that can arise during development;

-

the lack of expert participation in the definition of the operations;

-

the lack of experimental
development

for computer
-
based competence.

Example
: Consider the following rules for the monkey and bananas problem:

A hungry monkey is standing at the doorway to a room. In the middle of the room there is a bunch of bananas
suspended from the ceiling on a rope out of monkeys reach. There is a chain near the door which is light enough
for the monkey to push, and tall en
ough to reach the bananas. Assume that the monkey holds a ball, and can hold
only one thing at a time. The problem is to become not hungry.


(RULE 1 “
Climb on the chair



(IF (chair at middle) & (in middle) & (on floor))



(THEN (DELETE (in middl
e)) & (DELETE (on floor))


(ADD (bananas)) & (ADD (on chair))))



(RULE 2 “
Push chair from door to middle



(IF (chair at door) & (at door))



(THEN (DELETE (chair at door)) & (DELETE (at door))


(ADD (chair at mid
dle)) & (ADD (in middle))))



(RULE 3 “
Grasp bananas



(IF (empty handed) & (bananas))



(THEN (DELETE (empty handed))


(ADD (has bananas))))



(RULE 4 “
Climb on the chair



(IF (has bananas))



(THEN (DELETE (has banana
s)) & (DELETE (hungry))


(ADD (empty handed)) & (ADD (not hungry))))



(RULE 5 “
Walk from door to middle



(IF (at door) & (on floor))



(THEN (DELETE (at door))


(ADD (in middle))))



(RULE 6

(IF (has ball))




(THEN (DELETE (has ball))


(ADD (empty handed))))

and the following working memory:


WM

= (
(at door)(chair at door)(on floor)(has ball)(hungry)

)


Running the forward chaining algorithm produces the steps:



Fires

R2:
delete
s assertions:
(chair at door)(at door)


adds assertions:
(chair at middle)(in middle)




Fires

R1:

deletes assertions:
(in middle)(on floor)


adds assertions:
(bananas)(on chair)




Fires

R6:

deletes
assertion:
(has ball)


adds assertion:
(empty handed)




Fires

R3:

deletes assertion:
(empty handed)


adds assertion:
(has bananas)




Fires

R4:

deletes assertions:
(has bananas)(hungry)



adds assertions:
(empty handed)(not hungry)



References
:


Winston,P.H. (1992). “Artificial Intelligence”, Addison
-
Wesley Publ.Co..


Hayes
-
Roth,F. (1985). “Rule
-
Based Systems”, Communications of the ACM,

vol.28, N:9, pp.921
-
932.