0% found this document useful (0 votes)
16 views22 pages

Ai Chapter 3

The document discusses knowledge representation using rules. It covers procedural vs declarative knowledge, logic programming using Prolog, forward vs backward reasoning, and rule-based reasoning techniques like matching.

Uploaded by

321106410027
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views22 pages

Ai Chapter 3

The document discusses knowledge representation using rules. It covers procedural vs declarative knowledge, logic programming using Prolog, forward vs backward reasoning, and rule-based reasoning techniques like matching.

Uploaded by

321106410027
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

1 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree

Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering

Chapter-3
3. Knowledge Representation using rules
Representing Knowledge Using Rules
We discuss the use of rules to encode knowledge. This is particularly
important issue, since rule based reasoning systems played very important rule
in the evolution in AI.
We have been assuming that search control knowledge was maintained
completely, separately from the rules themselves. Consider a set of rules to
represent both knowledge about relationships in the world, as well as
knowledge about, how to solve problems using the content of rules.

1. Procedural Vs Declarative Knowledge (******)


A declarative representation is one, in which knowledge is specified, but
the use to which that knowledge is to be put is not given. To use a declarative
representation, we must augment it with a program that specifies what is to be
done to the knowledge and how.

A procedural representation is one in which the control information that is


necessary to use the knowledge is considered to be embedded in the knowledge
itself. To use a procedural representation, we need to augment it with an
interpreter that follows the instructions given in the knowledge.

The real difference between the Declarative & Procedural views of the
knowledge lies in where control information takes place.

For example, consider the knowledge base:


Man (Marcus)
Man (Caesar)
Person (Cleopatra)
x : man (x)  person(x)

Now consider trying to extract from this knowledge base the answer to the
question
y : person (y)

Here, we want to bind y to a particular value for which person is true. Our
knowledge base justifies any of the following answers:
y= Marcus y= Caesar y= Cleopatra

Because there is more than one value that satisfies the predicate, but only one
value is needed, the answer to the question will depend on the order in which
2 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering

the assertions are examined during the search for a response. If we view the
assertions as declarative, then they do not themselves say anything about how
they will be examined. If we view them as procedural then they do.

To see clearly, the difference between declarative and procedural


representations, consider the following assertions:
Man (Marcus)
Man (Caesar)
x : man (x)  person(x)
Person (Cleopatra)

2. Logic Programming(PROLOG) (******)


Logic programming is programming language paradigm in which logical
assertions are viewed as programs. There are several logic programming
systems in use today, the most popular of which is described as a series of
logical assertions, each of which is a Horn clause. A Horn clause is a clause
that has at most one positive literal. Thus p, ¬ p V q, and p  q are all Horn
clauses.
Advantages of the Horn Clause:
1. Because of the uniform representation, simple and efficient interpreter can be
written.
2. The logic of the Horn clause, system is decidable.
(i.e. full first order predicate logic statements are used).

x : pet (x) ^ small (x)  apartmentpet (x)


x : cat (x) V dog (x)  pet (x)
x : poodle (x)  dog (x) ^ small (x)
Poodle (fluffy)
A Representation in Logic

Apartmentpet (x) :- pet (x), small (x).


Pet (x) :- cat (x).
Pet (x) :- dog (x).
dog (x) :- poodle (x).
small (x) :- poodle (x).
poodle (fluffy).
A Representation in PROLOG

Figure : A Declarative and a Procedural Representation


Both of these representations contain two types of statements.
1. Facts : which contain only constants.
2. Rules : which contain varialbes and constants.
3 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering

Inheritable knowledge :
1. Facts : which represents statements about specific objects.
2. Rules : which represents statements about clauses of objects.
Fact is poodle (fluffy)
Rule is dog (x) :- poodle (x)

Syntactic differences between the logic and the PROLOG :


1. In logic, variables are explicitly quantified. In PROLOG, quantification is
provided implilcitly by the way the variables are interpreted. i.e., all variables
begin with uppercase letters and constants begin with lower case letters.
2. In logic, there are explicit symbols for and (^) and or ( V). In PROLOG, there
is an explicit symbol for and (,), but there is none of or.
3. In logic, implications of the form p implies q are written as p  q . In
PROLOG, the same implecation is written backward as q :- p.

The first two of these différences araise naturally from the fact. That
PROLOG programs are actually set of Horn clauses that have been transformed
as follows :
 If the Horn clause contains no negative literals, then leave it as it is.
 Otherwise, rewrite the Horn clause as an implication, combining all of the
negative literals into the antecedent of the implication and leaving the
single positive literal as the consequent.

Problem :
Find a value of x, that satisfies the predicate apratment (x)
Apartment (x) :- pet (x), small (x)
Pet (x) :- cat (x)

Here cat (x) does not contain rules and also does not contain fact. So we go to
the backward . we take another rule for pet (x) (i.e., there exist another rule for
pet (x) )
Pet (x) :- dog (x)

Here dog (x) contain another rule.


Dog (x) :- poodle (x)
Here poodle (x) contain fact
Poodle (fluffy)
x is fluffy.
Pet (x) is true.
Small (x) contain rule.
Small (x) :- poodle (x) ,
4 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering

Poodle (fluffy) ,
Small (x) is true
Pet (x) and small (x) is true, so , therefore
Apartment (x) is true.
x is fluffy.

3. Forward Vs Backward Reasoning(******)


Search directions are two types. Those are
1. Forward, from the start states
2. Backward, from the goal states.

Forward Reasoning:
Consider the initial state as the root of the tree. Generate the next level of
the tree by finding all the rules whose left sides match the root node and using
their right side to create new configurations. Generate the next level by taking
each node generated at the previous level and applying it to all of the rules,
whose leftsides matched continue until a configuration that matches the goal
state is generated. Ex : Water Jug Problem, 8- Puzzle.

Backward Reasoning:
Consider the goal state as the root of the tree. Generate the next level of
the tree by finding all the rules, whose right sides match the root node and using
their left side to create new configuration. Generate the next level, by taking
each node generated at the previous level and applying it to all the rules, whose
right sides matched continue, untill a configuration that matches the initial state
is generated. Ex : Predicate Logic, PROLOG

To reason forward or Backward, consider the following points.


1. Are there more possible start states or goal states ? we would like to move
from the smaller set of states to the larger set of states.
2. In which direction is the branching factor. Branching factor is the average
no.of nodes, that can be reached directly from a single node.we would like to
proceed in the direction with the lower branching factor.
3. we will proceed in the direction that corresponds more closely with the way
the user will think.
4. If it is the arrival of new factor or new state, forward reasoning is better. If it
is a query to which a response is desired Backward reasoning is more natural
(Goal Directed Reasoning)

Bidirectional Search:
5 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering

We can also search both forward and backward simultaneously, until two
paths meet somewhere in between. This strategy is called Bidirectional Search.
Ex : Medical Diagnosis.

Both forward and backward reasoning, in practice it has proved useful to


define two classes of rules, each of which encodes a particular kind of
knowledge.
 Forward rules, which encode knowledge about how to respond to certain
input configurations.
 Backward rules, which encode knowledge about how to achieve
particular goals.

Backward-Chaining Rule Systems


In this systems, of which PROLOG is an example, are good for goal-
directed problem solving. For example, a query system would probably use
backward chaining to reason about and answer user questions.

Forward-Chaining Rule Systems


In this systems, left sides of rules are matched against the state
description Rules that match dump their right-hand side assertions into the state,
and the process repeats. Matching is more typically more complex for forward-
chaining systems than backward ones.

Combining Forward and Backward Reasoning


Some certain aspects of problem are best handled via forward chaining
and other aspects by backward chaining. Consider a forward-chaining medical
diagnosis program.

4. Matching techniques (******)


Matching is the process of comparing two or more structures to discover their
likenesses or differences. The structures may represent a wide range of objects
including physical entities, words or phrases in some language, complete classes
of things, general concepts, relations between complex entities, and the like.
The representations will be given in one or more of the formalisms like FOPL,
networks, or some other scheme, and matching will involve comparing the
component parts of such structures.
Matching is used in a variety of programs for different reasons. It may serve
to control the sequence of operations, to identify or classify objects, to
determine the best of a number of different alternatives, or to retrieve items
from a database. It is an essential operation such diverse programs as speech
recognition, natural language understanding, vision, learning, automated
6 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering

reasoning, planning, automatic programming, and expert systems, as well as


many others.
In its simplest form, matching is just the process of comparing two structures
or patterns for equality. The match fails if the patterns differ in any aspect. For
example, a match between the two character strings acdebfba and acdebeba fails
on an exact match since the strings differ in the sixth character positions.

In more complex cases the matching process may permit transformations in
the patterns in order to achieve an equality match. The transformation may be a
simple change of some variables to constants, or ti may amount to ignoring
some components during the match operation. For example, a pattern matching
variable such as ?x may be used to permit successful matching between the two
patterns (a b (c d ) e) and (a b ?x e) by binding ?x to (c, d). Such matching are
usually restricted in some way, however, as is the case with the unification of
two classes where only consistent bindings are permitted. Thus, two patterns
such as ( a b (c d) e f) and (a b ?x e ?x) would not match since ?x could not be
bound to two different constants.

In some extreme cases, a complete change of representational form may be


required in either one or both structures before a match can be attempted. This
will be the case, for example, when one visual object is represented as a vector
of pixel gray levels and objects to be matched are represented as descriptions in
predicate logic or some other high level statements. A direct comparison is
impossible unless one form has been transformed into the other.

In subsequent chapters we will see examples of many problems where exact
matches are inappropriate, and some form of partial matching is more
meaningful. Typically in such cases, one is interested in finding a best match
between pairs of structures. This will be the case in object classification
problems, for example, when object descriptions are subject to corruption by
noise or distortion. In such cases, a measure of the degree of match may also be
required.

Other types of partial matching may require finding a match between certain
key elements while ignoring all other elements in the pattern. For example, a
human language input unit should be flexible enough to recognize any of the
following three statements as expressing a choice of preference for the low-
calorie food item
I prefer the low-calorie choice.
I want the low-calorie item
The low-calorie one please.
7 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering

Recognition of the intended request can be achieved by matching against key


words in a template containing “low-calorie” and ignoring other words except,
perhaps, negative modifiers.

Finally, some problems may obviate the need for a form of fuzzy matching
where an entity’s degree of membership in one or more classes is appropriate.
Some classification problems will apply here if the boundaries between the
classes are not distinct, and an object may belong to more than one class.

Fig 8.1 illustrates the general match process where an input description is
being compared with other descriptions. As stressed earlier, their term object is
used here in a general sense. It does not necessarily imply physical objects. All
objects will be represented in some formalism such a s a vector of attribute
values, prepositional logic or FOPL statements, rules, frame-like structures, or
other scheme. Transformations, if required, may involve simple instantiations or
unifications among clauses or more complex operations such as transforming a
two-dimensional scene to a description in some formal language. Once the
descriptions have been transformed into the same schema, the matching process
is performed element-by-element using a relational or other test (like equality or
ranking). The test results may then be combined in some way to provide an
overall measure of similarity. The choice of measure will depend on the match
criteria and representation scheme employed.
The output of the matcher is a description of the match. It may be a simple yes
or no response or a list of variable bindings, or as complicated as a detailed
annotation of the similarities and differences between the matched objects.
`
To summarize then, matching may be exact, used with or without pattern
variables, partial, or fuzzy, and any matching algorithm will be based on such
factors as Choice of representation scheme for the objects being matched,
Criteria for matching (exact, partial, fuzzy, and so on),
Choice of measure required to perform the match in accordance with the
chosen criteria, and
Type of match description required for output.

In the remainder of this chapter we examine various types of matching


problems and
their related algorithms. We bin with a description of representation structures
and measures commonly found in matching problems. We next look at various
matching techniques based on exact, partial, and fuzzy approaches. We
conclude the chapter with an example of an efficient match algorithm used in
some rule-based expert systems.
8 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering

Fig Typical Matching Process

Matching:
It is a process of extracting the rules that can be applied at a given point from
the entire collection of rules. It requires some kind of matching between current
state and preconditions of the rules or current state to the next state. Some of the
matching techniques are

1. Indexing:
One way to select applicable rules is to do a simple search, through all the
rules, comparing each ones preconditions to the current state and extracting all
the ones that match. But there are two problems in the simple solution.
 It is necessary to use a large number of rules, scanning through all of
them at every step of the search.
 It is not always immediately obvious whether a rule’s preconditions are
satisfied by a particular state.
Some times there are easy ways to deal with the first of these problems.
Instead of searching through the rules, use the current state as an index into the
rules and select the matching ones immediately. Ex: Water Jug Problem.
Some times, indexing cannot be helpful, even when taking the larger set of
rules stated high level predicates. Finally despite, some limitations of this
approach. Indexing is very important in the efficient of Rule Based System.

2. Matching with Variables:


The problem of selecting rules is made more difficult, when
preconditions are not stated as exact descriptions of particular situations, but
rather describe properties that the situation must have. It is possible to apply
unification repeatedly over the cross product of preconditions and state
9 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering

description rules are matched against many elements in the state description
simultaneously.
One efficient way in many to many match algorithms is called
RETE which gains efficiency from the three major sources.
1. Temporal nature of data. Rules usually do not alter the state descriptions
radically, instead a rule will typically add one or two elements or perhaps delete
one or two, but most of the state descriptions remain the same.
2. Structural similarity in rules. Different rules share a large no. of
preconditions. For ex: consider rules for identifying the wild animals. One rule
concludes
1. Jaguar (x)  mammal (x), feline (x), carnivorous (x), has-spots (x)
2. Tiger (x)  mammal (x), feline (x), carnivorous (x), has-stripes (x)
If we match the two rules independently, we will repeat a lot of
work unnecessarily. RETE stores the rules, so that they store structures in
memory.
3. Persistence of variable binding consistency. While the entire individual
preconditions of a rule might be met. There may be variable binding conflicts
that prevent the rule from firing. Fortunately it is not necessary to compute
binding consistency from scratch. Every time, a new condition is satisfied.
RETE remembers its previous calculations and is able to merge new binding
information efficiently.
Ex: son (x, y) ^ son (y, z)  grandparent(x, z)

3. Complex and Approximate Matching:


A more complex matching process is required, when the
preconditions of a rule specify required properties, which are not stated
explicitly in the description of the current state. In this case, a separate set of
rules must be used to describe, how some properties can be inferred from others.
An even more complex matching process is required, if rules
should be applied, if their preconditions approximately match the current
situation. There is so much variability in the physical signal as a result of
background noise, differences in the way individuals speak and soon. That one
can hope to find only an approximate match between the rule and current state.
Approximate matching is particularly difficult to deal with because
as we increase the tolerance allowed in the match, we also increase the no. of
rules that will match, this increasing the size of main search process, but
approximate matching is nevertheless superior to the exact matching. Ex:
Conversation between two persons.

4. Conflict Resolution:
The result of the matching process is a list of rules, whose
antecedents have matched the current state description along with whatever
10 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering

variables binding were generated by the matching process. It is the job of the
search method to decide on the orders, in which rules will be applied. But
sometimes, it is useful to incorporate, some of the decision making into the
matching process. This phase of matching process is called the conflict
resolution.

There are three basic approaches to the problem of conflict resolution.


1. Assign a preference based on the rule matched. Ex: Water Jug Problem,
PROLOG
2. Assign a preference based on the objects that matched. Ex: Conversations
b/w two persons.
3. Assign a preference based on the action that the matched rule would perform.
Ex: states.

5. Partial Matching (******)


 For many AI applications complete matching between two or more
structures is inappropriate
 For example, input representations of speech waveforms or visual scenes
may have been corrupted by noise or other unwanted distortions.
 In such cases, we do not want to reject the input out of hand. Our systems
should be more tolerant of such problems
 We want our system to be able to find an acceptable or best match
between the input and some reference description
 Compensating for Distortions
 Finding an object in a photograph given only a general description of the
object is a common problems in vision applications
 For example, the task may be to locate a human face or human body in
photographs without the necessity of storing hundreds of specific face
templates
 A better approach in this case would be to store a single reference
description of the object
 Matching between photographs regions and corresponding descriptions
then could be approached using either a measure of correlation, by
altering the image to obtain a closer fit
 If nothing is known about the noise and distortion characteristics,
correlation methods can be ineffective or even misleading. In such cases,
methods based on mechanical distortion may be appropriate
 For example, our reference image is on a transparent rubber sheet. This
sheet is moved over the input image and at each location is stretched to
get the best match alignment between the two images
11 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering

 The match between the two can then be evaluated by how well they
correspond and how much push-and-pull distortion is needed to obtain
the best correspondence
 Use the number of rigid pieces connected with springs. This pieces can
correspond to low level areas such as pixels or even larger area segments

Fig Discrete version of stretchable overlay image

To model any restrictions such as the relative positions of body parts,
nonlinear cost functions of piece displacements can be used
 The costs can correspond to different spring tensions which reflect the
 constraints
 For example, the cost of displacing some pieces might be zero for no
displacement, one unit for single increment displacements in any one of
the permissible directions, two units for two position displacements and
infinite cost for displacements of more than two increments. Other pieces
would be assigned higher costs for unit and larger position displacements
when stronger constraints were applicable
 The matching problem is to find a least cost location and distortion
pattern for the reference sheet with regard to the sensed picture
 Attempting to compare each component of some reference to each
primitive part of a sensed picture is a combinatorially explosive problem
 In using the template-spring reference image and heuristic methods to
compare against different segments of the sensed picture, the search and
match process can be made tractable
 Any matching metric used in the least cost comparison would need to
take into account the sum of the distortion costs Cd , the sum of the costs
for reference and sensed component dissimilarities Cc , and the sum of
penalty costs for missing components Cm . Thus, the total cost is given
by Ct = Cd + Cc + Cm
12 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering

 Finding Match Differences


 Distortions occurring in representations are not the only reason for partial
matches
 For example, in problem solving or analogical inference, differences are
expected.

In such cases the two structures are matched to isolate the differences in order
that they may be reduced or transformed. Once again, partial matching
techniques are appropriate
 In visual application, an industrial part may be described using a graph
structure where the set of nodes correspond to rectangular or cylindrical
block subparts
 The arc in the graph correspond to positional relations between the
subparts
 Labels for rectangular block nodes contain length, width and height,
while labels for cylindrical block nodes, where location can be above, to
the right of, behind, inside and so on

In Fig 8.5 illustrates a segment of such a graph

In the fig the following abbreviations are used


 Interpreting the graph, we see it is a unit consisting of subparts, mode up
of rectangular and cylindrical blocks with dimensions specified by
attribute values
 The cylindrical block n1 is to the right of n2 by d1 units and the two are
connected by a joint
 The blocks n1 and n2 are above the rectangular block n3 by d2 and d3
units respectively, and so on
13 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering

 Graphs such as this are called attributed relational graphs (ATRs). Such a
graph G is defined as a sextuple G = (N, B, A, Gn, Gb)
Where N = { n1, n2, . . ., nk}is a set of nodes, A = {a n1, an2, . . . , ank}
is an alphabet of node attributes, B = { b1, b2, . . . , bm}is a set of
directed branches (b = (ni, nj)), and Gn and Gb are functions for
generating node and branch attributes respectively
 When the representations are graph structures like ARGs, a similarity
measure may be computed as the total cost of transforming one graph into
the other

For example, the similarity of two ARGs may be determined with the
following steps:
 Decompose the ARGs into basic subgraphs, each having a depth of one
 Compute the minimum cost to transform either basic ARG into the other
 one subgraph-by-subgraph
 Compute the total transformation cost from the sum of the subgraph costs

An ARG may be transformed by the three basic operations of node or branch
deletions, insertions, or substitutions, where each operation is given a cost based
on computation time or other factors

6. RETE Matching Algorithm(******)


 One potential problem with expert systems is the number of comparisons
that need to be made between rules and facts in the database.
 In some cases, where there are hundreds or even thousands of rules,
running comparisons against each rule can be impractical.
 The Rete Algorithm is an efficient method for solving this problem and is
used by a number of expert system tools, including OPS5 and Eclipse.
 The Rete is a directed, acyclic, rooted graph.
 Each path from the root node to a leaf in the tree represents the left-hand
side of a rule.
 Each node stores details of which facts have been matched by the rules at
that point in the path. As facts are changed, the new facts are propagated
through the Rete from the root node to the leaves, changing the
information stored at nodes appropriately.
 This could mean adding a new fact, or changing information about an old
fact, or deleting an old fact. In this way, the system only needs to test
each new fact against the rules, and only against those rules to which the
new fact is relevant, instead of checking each fact against each rule.
 The Rete algorithm depends on the principle that in general, when using
forward chaining in expert systems, the values of objects change
14 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering

relatively infrequently, meaning that relatively few changes need to be


made to the Rete.
 In such cases, the Rete algorithm can provide a significant improvement
in performance over other methods, although it is less efficient in cases
where objects are continually changing.
The basic inference cycle of a production system is match, select and execute
as indicated in Fig 8.6. These operations are performed as follows

Fig Production system components and basic cycle

Match:
 During the match portion of the cycle, the conditions in the LHS of the
rules in the knowledge base are matched against the contents of working
memory to determine which rules have their LHS conditions satisfied
with consistent bindings to working memory terms.
 Rules which are found to be applicable are put in a conflict set
Select:
 From the conflict set, one of the rules is selected to execute. The selection
strategy may depend on recency of useage, specificity of the rule or other
criteria
Execute:
15 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering

 The rule selected from the conflict set is executed by carrying the action
or conclusion part of the rule, the RHS of the rule. This may involve an
I/O operation, adding, removing or changing clauses in working memory
or simply causing a halt
 The above cycle is repeated until no rules are put in the conflict set or
until a stopping condition is reached

The main time saving features of RETE are as follows


1. In most expert systems, the contents of working memory change very little
from cycle to cycle. There is persistence in the data known as temporal
redundancy. This makes exhaustive matching on every cycle unnecessary.
Instead, by saving match information, it is only necessary to compare working
memory changes on each cycle. In RETE, addition to, removal from, and
changes to working memory are translated directly into changes to the conflict
set in Fig . Then when a rule from the conflict set has been selected to fire, it is
removed from the set and the remaining entries are saved for the next cycle.
Consequently, repetitive matching of all rules against working memory is
avoided. Furthermore, by indexing rules with the condition terms appearing in
their LHS, only those rules which could match. Working memory changes need
to be examined. This greatly reduces the number of comparisons required on
each cycle.

Fig Changes to working memory are mapped to the conflict set

2. Many rules in a knowledge base will have the same conditions occurring in
their LHS. This is just another way in which unnecessary matching can arise.
Repeating testing of the same conditions in those rules could be avoided by
grouping rules which share the same conditions and linking them to their
common terms. It would then be possible to perform a single set of tests for all
the applicable rules shown in Fig below
16 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering

Fig Typical rules and a portion of a compiled network

7. AI Programming Languages: Overview of LISP and


PROLOG (******)

Overview of LISP:

Lisp is one of the oldest (developed in 1958) and prominent language created
by the Dr. John MaCarthy, who coined the term ‘Artificial Intelligence’.
17 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering

Although it is not used much these days, the language is both flexible and
extendable.

It was originally developed for Lambda Calculus computation, and since its
inception it has evolved a lot. The language introduced many ideas in computer
science, such as recursion, dynamic typing, higher-order functions, automatic
storage management, self hosting compiler and tree data structure.

Lisp is used for developing Artificial Intelligence software because it


supports the implementation of program that computes with symbols very well.
Symbolic expression and computing with those is what Lisp is good at.

Also, Lisp consists of a macro system, well-developed compiler that can


produce efficient code, and a library of collection types,
including hashtables and dynamic-size lists.

There are thousands of AI applications developed in Lisp, some of them are –


 American Express Authorizer’s Assistant that checks transactions (credit
card)
 METAL, a natural language translation system
 Macsyma, first large computer algebra system
 ACL2, a theorem prover used by AMD

Advantages
 Fast and efficient in coding as it is supported by compilers instead of
interpreters.
 Automatic memory manager was invented for LISP, therefore, it has
a garbage collection.
 LISP offers specific control over systems resulting to their maximum use.

Disadvantages

 Few developers are well acquainted with Lisp programming.


 Being a vintage programming language artificial intelligence, LISP requires
configuration of new software and hardware to accommodate it use.
18 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering

Overview of PROLOG:

The first PROLOG program was written in Marseille, France, in the early
1970s as part of a project in natural language processing.

Prolog is a logic programming language and semantic inference engine,


associated with computational linguistic and artificial intelligence. It has a
flexible and powerful framework that is widely used for theorem proving, non-
numerical programming, natural language processing and AI in general.

It’s a declarative language with formal logic. AI developers value it for its
pre-designed search mechanism, no determinism, backtracking mechanism,
recursive nature, high level abstraction and pattern matching.

Prolog is well suited for problems involving structured objects and relations
between them. For instance, in Prolog, it is easier to express spatial relationships
between object, like green triangle is behind the blue one. It is also simple to
state a general rule – if object A is closer to the person than object B, and B is
closer than C, then A should be closer than C.

Prolog’s nature makes it simple and straightforward to implement facts and


rules. If fact, everything in Prolog is fact or a rule. It allows you to query the
database even when you have thousand of these facts and rules.

Prolog supports development of graphical user interface, administrative and


network applications. It is well suited for projects like voice control systems and
filling templates.
19 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering

Advantages
 Prolog has a built-in list handling essential in representing tree-based data
structures.
 Efficient for fast prototyping for AI programs to be released modules
frequently.
 Allows database creation simultaneous with running of the program.

Disadvantages
 Despite prolog old age, it has not been fully standardized in that some features
differ in implementation making the work of the developer cumbersome.

8. Production Systems in PROLOG(******)


20 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering
21 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering
22 సర్ సి ఆర్ రెడ్డి కాలేజ్ ఆఫ్ ఇంజనీరంగ్, ఏలూరు Sree
Database Management Systems-Chapter-3 (1-22) Dept. of Computer Science & Engineering

You might also like