Rule-Based Systems

advertisement

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 human 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 the 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 their 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 irregularities

 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 experience.

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 (consequents). 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 consequent 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 descriptions 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 static 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 temporary 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 Engine

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

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

Inputs

Knowledge Base

(Rule Base)

Rules Facts

Data (patterns)

Inference Engine

Match

Working Memory

Facts

Data (patterns)

Updates

Select

Act

Output (decisions)

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 ifpatterns, 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

Example : 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 eyes ))

(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 backward 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 control 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 consequent 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 antecedents 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)(Animal 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=Animal )

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 eats 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) (Animal 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 practical 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-determinism in computations;

the changes in principles of operation 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 : Develop the backward chain for proving the goal ( C ) in a rule-based system using the following facts and rules in the given order:

(FACT 1 ( H ))

(FACT 2 ( B ))

(FACT 3 ( X ))

(FACT 4 ( Z ))

(FACT 5 ( D ))

(RULE 1 (IF (( Y ) and ( Z ) and ( H )) (THEN ( A ))))

(RULE 2 (IF (( A ) and ( B )) (THEN ( C ))))

(RULE 3 (IF (( D )) (THEN ( Y ))))

Solution:

step 1: to prove ( C )

select

RULE 2

: new subgoals

( A ), ( B )

step 2: to prove ( A )

select

RULE 1

: new subgoals

( Y ), ( Z ), ( H )

step 3: to prove

( Y )

select RULE 3 : new subgoal ( D ) , but D is FACT 5, hence RULE 3 fires

step 4: to prove

( Z )

but Z is FACT 4

step 5: to prove ( H )

but H is

FACT 1

, hence

RULE 1

fires

step 6: to prove ( B )

but B is FACT 2 , hence RULE 2 fires, Therefore the goal ( C ) is PROVEN !

Perform forward chaining with the same rules and facts as, and show the algorithmic steps.

Solution:

step 1:

RULE 3

fires, hence its right-hand side

is added to the working memory as (FACT 6 ( Y ))

step 2: RULE 1 fires, hence its right-hand side

is added to the working memory as

(FACT 7 ( A ))

step 3: RULE 2 fires, hence its right-hand side

is added to the working memory as (FACT 8 ( C ))

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.

Download