You are on page 1of 67

Artificial Intelligence, VII SEM, CSE, Module - II

MODULE II

Chapter 4

KNOWLEDGE REPRESENTATION ISSUES


 REPRESENTATION AND MAPPINGS

To solve the complex problems come across in artificial intelligence, it needs both a large amount
of knowledge and some mechanisms for manipulating that knowledge to create solutions to new
problems. A variety of ways of representing knowledge (facts) have been exploited in AI programs.
We must consider the point that pertains to all types of representation namely dealing with two
different kinds of entities:

 Facts: Truths in some relevant world and these are the things we want to represent.
 Representations of facts in some chosen formalism and these are the things will be able to
manipulate.
 Structuring these entities is done at two levels:
– The knowledge level, at which facts (behaviors and current goals) are described.
– The symbol level, at which representations of objects at the knowledge level are defined in
terms of symbols that can be manipulated by programs.

Figure 1: Mappings between Facts and Representations

 Mappings between facts and Representations are shown in figure above. Here, focus is on
facts, on representations, and on the two-way mappings that must exist between them and
these links are called representation mappings. The forward representation mapping maps
from facts to representations. The backward representation mapping goes from
representations to facts. Here, also have mapping functions from English sentences to the
representation and back to sentences. Figure above shows how these three kinds of objects
relate to each other.
 Figure below shows an expanded view of the starred part of the above Figure. The dotted
line across the top represents the abstract reasoning process that a program is intended to model.
The solid line across the bottom represents the concrete reasoning process that a particular
Dept. of CSE, RNSIT 66
Artificial Intelligence, VII SEM, CSE, Module - II

program performs. This program successfully models the abstract process to the extent that,
when the backward representation mapping is applied to the program’s output, the appropriate
final facts are actually generated.

Figure 2: Representation of Facts

 Simple example using mathematical logic as the representational formalism, Consider the
English sentence:
o Spot is a dog.
The fact represented by English sentence can also be represented in logic as: dog (Spot)
o Suppose that we also have a logical representation of the fact that all dogs have tails:
✯ x : dog(x) → hastail(x)
o Then, using the deductive mechanisms of logic, we may generate the new representation
object: hastail (Spot)
o Using an appropriate backward mapping function, we could then generate the English
sentence: Spot has a tail
o For example, the two sentences “All dogs have tails” and “Every dog has a tail” could
both represent the same fact, namely, that every dog has at least one tail.

The starred links of Figure 1 above are key components of the design of any knowledge-based
program. A well-known example of this occurs in the context of the mutilated checker board
problem, which can be stated as follows:

The Mutilated Checker board Problem: Consider a normal checker board from which two
squares, in opposite corners, have been removed. The task is to cover all the remaining squares
exactly with dominoes, each of which covers two squares. No overlapping, either of dominoes on
top each other or of dominoes over the boundary of the mutilated board are allowed. Can this task
be done?

One way to solve this problem is to try to enumerate, exhaustively, all possible tilings to see if it
works. But suppose one wants to be cleverer. Figure below shows three ways in which the mutilated
checker board could be represented (to a person).The first representation does not directly suggest

Dept. of CSE, RNSIT 67


Artificial Intelligence, VII SEM, CSE, Module - II

the answer to the problem. The second may suggest and the third does, when combined with the
single additional fact that each domino must cover exactly one white square and one black
square. Even for human problem solvers a representation shift may make an enormous difference in
problem-solving effectiveness.

Figure: Three Representations of a Mutilated Checker board

 APPROACHES TO KNOWLEDGE REPRESENTATION

A good Knowledge Representation enables fast and accurate access to Knowledge and understanding
of the concept/content. A good system for the representation of knowledge in a particular domain
should possess the following four properties:

 Representational Adequacy: The ability to represent all of the kinds of knowledge that are
needed in that domain.
 Inferential Adequacy: The ability to manipulate the representational structures in such a
way as to derive new structures corresponding to new knowledge inferred from old.
 Inferential Efficiency: The ability to incorporate additional information into the knowledge
structure that can be used to focus the attention of the inference mechanisms in the most
promising directions.
 Acquisitional Efficiency: Ability to acquire new knowledge using automatic methods /
programs whatever possible rather than reliance on human intervention.

Here it is noted that, to date, no signal system can optimizes all of the above properties.

 Knowledge Representation Schemes / Approaches


There are four types of knowledge representation schemes/approaches: Relational, Inheritable,
Inferential and Declarative / procedural.

 Simple Relational Knowledge

The simplest way to represent declarative facts is as a set of relations of the same sort used in
database systems. Figure below shows an example of such a relational system.
Dept. of CSE, RNSIT 68
Artificial Intelligence, VII SEM, CSE, Module - II

Figure: Simple Relational Knowledge and a sample fact in prolog

 Made up of objects with attributes and their corresponding values.


 Provides a framework to compare two objects based on equivalent attributes.
 It associates elements of one domain with another domain.
 Result of this knowledge type is a mapping of elements among different domains is
possible.
 Provides little opportunity for inference. But allows simple queries to be answered.

 Inheritable Knowledge

 It prescribes a structure in which new objects can be created which may inherit all or a
subset of attributes from existing objects.
 Here, Knowledge elements inherit attributes from their parents.
 Knowledge is embodied in the design hierarchies found in the functional, physical and
process domains.
 Within the hierarchy, elements inherit attributes from their parents, but in many cases not all
attributes of the parent elements be prescribed to the child elements.
 Inheritance is a powerful form of inference, but not adequate. The basic Knowledge
representation (KR) needs to be augmented with inference mechanism.
 Semantic Networks / A collection of frames / Slot–and-filler structures show property
inheritance and way for insertion of additional Knowledge.
 The objects or elements of specific classes inherit attributes and values from more general
classes. The classes are organized in a generalized hierarchy.

In order to support property inheritance, objects must be organized into classes and classes must
be arranged in a generalization hierarchy. Figure 3 shows some additional baseball knowledge
inserted into a structure that is so arranged. Lines represent attributes. Boxed nodes represent
objects and values of attributes of objects. These values can also be viewed as objects with
attributes and values, and so on. The arrows on the lines point from an object to its value along
the corresponding attribute line. The structure shown in the Figure 3 is a slot-and-filler
structure. It may also be called a semantic network or a collection of frames.

Dept. of CSE, RNSIT 69


Artificial Intelligence, VII SEM, CSE, Module - II

Figure 3: Inheritable Knowledge

Figure 4 below shows the node for baseball player displayed as a frame.

Figure 4: Viewing a Node as a Frame

Algorithm: Property Inheritance

To retrieve a value V for attribute A of an instance object O:

1. Find O in the knowledge base.


2. If there is a value, which is there for the attribute A, report that value.
3. Otherwise, see if there is a value for the attribute instance. If not, then fail.
4. Otherwise, move to the node corresponding to that value and look for a value for the attribute
A. If one is found, report it.
5. Otherwise, do until there is no value for the isa attribute or until an answer is found:
a) Get the value of the isa attribute and move to that node.
b) See if there is a value for the attribute A. If there is, report it.
Dept. of CSE, RNSIT 70
Artificial Intelligence, VII SEM, CSE, Module - II

We can apply this procedure to our example knowledge base to derive answers to the following
queries:

 team (Pee-Wee-Reese)=Brooklyn-Dodgers.
This attribute had a value stored explicitly in the knowledge base.
 Batting-average (Three-Finger Brown) = 0.106
Since there is no value for batting average stored explicitly for Three Finger Brown, we
follow the instance attribute to Pitcher and extract the value stored there. Now we observe
one of the critical characteristics of property inheritance, namely that it may produce default
values that are not guaranteed to be correct but that represent “best guesses” in the face of a
lack of more precise information.
 hight (Pee-Wee-Reese)=6-1
This represents another default inference. Notice here that because we get to it first, the
more specific fact about the height of baseball players overrides a more general fact about
the height of adult males.
 bats (Three-Finger-Brown)=Right
To get a Value for the attribute bats required going up the isa hierarchy to the class
Baseball-Player. But what we have found there was not a value but a rule for computing a
value. This rule required another value (that for handed) as input. So the entire process
must be begun again recursively to find a value for handed.

 Inferential Knowledge

 Inferential Knowledge is a powerful form of inference. Sometimes all the power of traditional
logic is necessary to describe the inferences that are needed.
 Knowledge is inferred from objects through relations among objects.
 Example: a word alone is a simple syntax, but with the help of other words in phrase, the
reader may infer more from a word. This inference within linguistic is called semantics.
 Uses inference mechanism to generate new knowledge from the given knowledge.
 Many inference rules / procedures like modus ponen’s chain rule, modus tollen’s,
Resolution principle, resolution by refutation are used to draw inferences in predicate logic.

Example: 1. Tommy is a dog


dog (Tommy)
2. All dogs are animals
✯𝗑 dog (𝗑) → animal (𝗑)
3. All animals either live on land or in water
✯ animal (𝗑) → live (𝗑, land) v live (𝗑, water)

From the above statements, we can infer that


“Tommy lives either on land or in water”

Dept. of CSE, RNSIT 71


Artificial Intelligence, VII SEM, CSE, Module - II

 Declarative / Procedural Knowledge

 Any declarative sentence/statement specifies knowledge.


 Example: Tendulkar, Laws, it is raining, and there is class.
 Example of baseball knowledge has concentrated on relatively static, declarative facts. But
another, equally useful, kind of knowledge is operational or procedural knowledge.
 In procedural Knowledge, Knowledge may be a mapping process between domains that
specify “what to do when” and “how to make it”.
 The procedural knowledge may have inferential efficiency, but no inferential adequacy and
acquisitional efficiency.
 These are represented as small programs that know how to do specific things and how to
proceed.
 Example: A parser in a natural language has the Knowledge that a noun phrase may contain
articles, adjectives, and nouns. It thus accordingly calls routines and they know how to
process articles, adjectives and nouns.
 The most commonly used technique for representing procedural knowledge in AI programs is
the use of production rules. Figure below shows an example of a production rule that
represents a piece of operational knowledge typically possessed by a baseball player.
 Example: Procedural Knowledge as Rules

If: Internal marks is minimum of 12 out of 20 and external marks is 35% of 80, i.e., 28, leads
to 40% of 100 marks
Then: Result of the subject is pass – E grade

 ISSUES IN KNOWLEDGE REPRESENTATION

The goal of Knowledge Representation is to facilitate inferencing / to draw conclusions from the
knowledge. We need to know several issues in knowledge representation before discussion of
specific mechanisms that have been used to represent various kinds of real-world knowledge:

 Important Attributes
 The attributes of objects that are basic and common occur in almost every problem domain?
If such attributes exist, what are they?
– There are two attributes: Instance and IS-A
– Example: IS-A and Instance attributes are important because they support inheritance.
 Relationships among Attributes
 Are there important relationships that exist among object attributes?
 There are four such mentioned here:
– Inverses
– Existence in an IS-A hierarchy
– Techniques for reasoning about values
– Single-valued attributes
Dept. of CSE, RNSIT 72
Artificial Intelligence, VII SEM, CSE, Module - II

Inverses
Refer Figure 3: Inheritable Knowledge in page 5: we used the attributes instance, isa and
team. Each of these is shown in the figure with a directed arrow, originating at the object
that was being described and terminating at the object representing the value of the specified
attribute. These relationships are Binary relationships.

For example, the assertion:

team (Pee-Wee-Reese, Brooklyn-Dodgers)

The second approach is to use attributes that focus on a single entity but to use them in pairs,
one the inverse of the other. In this approach, we would represent the team information with
two attributes:

One associated with Pee Wee Reese:


team=Brooklyn-Dodgers
One associated with Brooklyn Dodgers:
team-members=Pee-Wee-Reese,…
This is the approach that is taken in semantic net and frame-based systems.

An Isa Hierarchy of Attributes


As there are classes of objects and specialized subsets of those classes, there are attributes
and specializations of attributes. Consider, for example, the attribute height. It is actually a
specialization of the more general attribute physical-size which is, in turn, a specialization of
physical-attribute.

Techniques for Reasoning about Values


Sometimes values of attributes are specified explicitly when a knowledge base is created. But
often the reasoning system must reason about values it has not been given explicitly. Several
kinds of information can play a role in this reasoning, including:

o Information about the type of the value. For example, the value of height must be a
number measured in a unit of length.
o Constraints on the value often stated in terms of related entities. For example, the age of
a person cannot be greater than the age of either of that person’s parents.
o Needs Rules for computing the value when it is required. We showed an example of such
a rule in Figure 3 for the bats attribute. These rules are called backward rules. Such
rules have also been called if-needed rules.
o Rules that describe actions that should be taken if a value ever becomes known. These
rules are called forward rules, or sometimes if-added rules.

Single-Valued Attributes
A specific but very useful kind of attribute is one that is guaranteed to take a unique value.
For example a baseball player can, at any one time, have only a single height and be a
member of only one team.
Dept. of CSE, RNSIT 73
Artificial Intelligence, VII SEM, CSE, Module - II

Knowledge-representation systems have taken several different approaches to providing


support for single-valued attributes, including:

o Introduce an explicit notation for temporal interval. If two different values are ever
asserted for the same temporal interval, signal a contradiction automatically.
o Assume that the only temporal interval that is of interest is now. So if a new value is
asserted, replace the old value.
o Provide no explicit support. Logic-based systems are in this category. But in these
systems, knowledge-base builders can add axioms that state if an attribute has one value
then it is known not to have all other values.

 Choosing the Granularity of Representation


 Deals with at what level of detail should the knowledge be represented?
 It is necessary to answer the question – At what level of detail should the Knowledge be
represented? Should there be a small number of low-level ones or should there be a larger
number covering a range of granularities?
 Example 1: Suppose we are interested in the following fact:

John spotted Sue.


We could represent this as
spotted(agent(John).
object(Sue))
Such a representation would make it easy to answer questions such as: Who spotted Sue?
But now suppose we want to know:
Did John see Sue?
The obvious answer is yes, but given only the one fact we have, we cannot discover that
answer, we could, add other facts, such as
spotted(x, y) → saw(x, y)
We could then infer the answer to the question.

An alternative solution to this problem is to represent the fact spotting is really a special
type of seeing explicitly in the representation of the fact. we might write as:

saw(agent(John),
object(Sue),
timespan(briefly))
In this representation, we have broken the idea of spotting apart into more primitive concepts
of seeing and timespan. Using this representation, the fact that John saw Sue is immediately
accessible.

 If knowledge is initially presented to the system in a relatively high-level form, such as


English, then substantial work must be done to reduce the knowledge into primitive form.

Dept. of CSE, RNSIT 74


Artificial Intelligence, VII SEM, CSE, Module - II

Example 2: There exists at least one obvious set of primitives: mother, father, son, daughter,
and brother and sister. But now suppose we are told that Mary is Sue’s cousin. An attempt to
describe the cousin relationship in terms of the primitives could produce any of the following
interpretations:

o Mary = daughter(brother(mother(Sue)))
o Mary = daughter(sister(mother(Sue)))
o Mary = daughter(brother(father(Sue)))
o Mary = daughter(sister(father(Sue)))

The other way to solve this problem is to change our primitives. We could use the set:
parent, child, sibling, male and female. Then the fact that Mary is Sue’s cousin could be
represented as
Mary = child (sibling (parent (Sue)))

Example 3: In less well-structured domains, even more problems arise. For example, given
just the fact
John broke the window.
A program would not be able to decide if John’s actions consisted of the primitive sequence:
1. Pick up a hard object.
2. Hurl the object through the window.
or the sequence:
1. Pick up a hard object.
2. Hold onto the object while causing it to crash into the window.
or the single action:
1. Cause hand (or foot) to move fast and crash into the window.
or the single action:
1. Shut the window so hard that the glass breaks.

 Representing Sets of Objects


 How set of objects be represented?. Here, it is important to represent sets of objects. One is
that there are some properties that are true of sets that are not true of the individual
members of a set.
 Examples: consider the assertions that are being made in the sentences “There are more
sheep than people in Australia” and “English speakers can be found all over the world”.
 There are two ways to state a definition of a set and its elements. The first is to list the
members. Such a specification is called an extensional definition. The second is to provide a
rule that, when a particular object is evaluated, returns true or false depending on whether the
object is in the set or not. Such a rule is called an intensional definition. For example, an
extensional description of the set of Sun’s planets on which people live is {Earth}. An
intensional description is {x: sun_planet(x) V human_inhabited(x)}.

Dept. of CSE, RNSIT 75


Artificial Intelligence, VII SEM, CSE, Module - II

 The extensionally defined set {Earth} has many intensional definitions in addition to the one
given above. others include:
{x: sun_ planet(x) nth_farthest_from_sun(x, 3)}
{x: sun_ planet(x) nth_biggest(x, 5)}

 Finding the Right Structures as Needed


 Here, is to find right structure for accessing relevant parts of knowledge.
 For example, suppose we have a script (a description of a class of events in terms of
contexts, participants, and subevents) that describes the typical sequence of events in a
restaurant. This script would enable us to take a text such as

John went to Steak and Ale last night. He ordered a large rare steak, paid his bill, and
left.
And answer “yes” to the question, Did John eat dinner last night?

 In order to have access to the right structure for describing a particular situation, it is
necessary to solve all of the following problems.
– How to perform an initial selection of the most appropriate structure.
– How to fill in appropriate details from the current situation.
– How to find a better structure if the one chosen initially turns out not to be appropriate.
– What to do if none of the available structure is appropriate.
– When to create and remember a new structure.

Selecting an Initial Structure

Selecting candidate knowledge structures to match a particular problem-solving situation is a


hard problem. There are several ways in which it can be done. Three important approaches
are the following:
 Index the structure directly by the significant English words that can be used to
describe them. For example, let each verb have associated with it a structure that
describes its meaning. For example, the word “fly” has a different meaning in each of the
following sentences:
o John flew to New York. (He rode in a plane from one place to another.)
o John flew a kite. (He held a kite that was up in the air.)
o John flew down the street. (He moved very rapidly.)
o John flew into a rage. (An idiom)
 Consider each major concept as a pointer to all of the structures in which it might be
involved. This may produce several sets of prospective structure. For example, the
concept Steak might point to two scripts, one for restaurant and one for supermarket.
The concept Bill might point to a restaurant and a shopping script. Take the
intersection of those sets to get the structure(s), that involves all the content words.

Dept. of CSE, RNSIT 76


Artificial Intelligence, VII SEM, CSE, Module - II

 Locate one major clue in the problem description and use it to select an initial
structure. As other clues appear, use them to refine the initial selection or to make a
completely new one if necessary.

Revising the Choice When Necessary

Once we find a candidate knowledge structure, we must attempt to do a detailed match of it


to the problem at hand. Depending on the representation we are using, the details of the
matching process will vary. The process of instantiating a structure in a particular situation
often does not proceed smoothly. There are a variety of things that can be done:
 Select the fragments of the current structure that do correspond to the situation and match
them against candidate alternatives. Choose the best match.
 Make an excuse for the current structure’s failure and continue to use it. For example, a
proposed chair with only three legs might simply be broken. Or there might be another
object in front of it which occludes one leg. For example, a person with one leg is more
plausible than a person with a tail.
 Refer to specific stored links between structures to suggest new directions in which to
explore.
 If the knowledge structures are stored in an isa hierarchy, traverse upward in it until a
structure is found that is sufficiently general that it does not conflict with the evidence.

 THE FRAME PROBLEM

 Another issue concerns how to represent efficiently sequences of problem states that arise
from a search process. Consider the world of a household robot. There are many objects and
relationships in the world, and a state description must somehow include facts. One strategy is
to store each state description as a list of such facts.
 This whole problem of representing the facts that change as well as those that do not is
known as the frame problem.
 To support this kind of reasoning, some systems make use of an explicit set of axioms called
frame axioms.
 When a particular operator is applied in state n to produce state n+1 then it does not change
anything. (The things that do change must be mentioned as part of the operator itself). Thus, in
the robot domain, we might write axioms such as
Color(x, y, s1) V move(x, s1, S2) → color(x, y, S2)
 Which can be read as: "If x has color y in state s1 and the operation of moving x is applied in
state s1 to produce state s2, then the color of x in S2 is still y."

Dept. of CSE, RNSIT 77


Artificial Intelligence, VII SEM, CSE, Module - II

Chapter 4

USING PREDICATE LOGIC


Here, we explore one particular way of representing facts - the language of logic.

 LOGIC

 Logic is a language for reasoning, a collection of rules used while doing logical reasoning.
Logic is studied as Knowledge Representation languages in artificial intelligence
 Logic is concerned with the truth of statements about the world.
- Generally each statement is either TRUE or FALSE.
- Logic includes: Syntax, Semantics and Inference Procedure.
 Syntax
- Specifies the symbols in the language about how they can be combined to form sentences.
The facts about the world are represented as sentences in logic.
 Semantics
- Specifies how to assign a truth value to a sentence based on its meaning in the world. It
specifies what facts a sentence refers to. A fact is a claim about the world, and it may be
TRUE or FALSE.
 Inference Procedure
- Specifies methods for computing new sentences from the existing sentences.

 REPRESENTING SIMPLE FACTS IN LOGIC

● Propositional Logic (PL)

 We use propositional logic as a way to represent world knowledge in AI systems.


Propositional logic is simple and a decision procedure. It is easy to represent real-world
facts as logical propositions written as well-formed formulas (wff’s) in propositional logic.
Some Simple Facts in Prepositional Logic are as shown below.
- It is raining.
RAINING
- It is sunny.
SUNNY
- It is windy.
WINDY
- If it is raining, then it is not sunny.
RAINING SUNNY
Example 2: Socrates is a man.
SOCRATESMAN
Plato is a man.
PLATOMAN
Dept. of CSE, RNSIT 78
Artificial Intelligence, VII SEM, CSE, Module - II

It would be better to represent these facts as:


MAN (SOCRATES)
MAN (PLATO)
 Now the structure of the representation reflects the structure of the knowledge itself. But to
do that, we need to be able to use predicates applied to arguments.
All men are mortal.
We could represent this as: MORTALMAN
 A proposition is a statement, which in English would be a declarative sentence. Every
proposition is either TRUE or FALSE.
Examples:
(a) The sky is blue
(b) Snow is cold
(c) 12 * 12=144
– Propositions are “sentences”, either true or false but not both.
– A sentence is smallest unit in propositional logic.
– If proposition is true, then truth value is "true".
– If proposition is false, then truth value is "false".

Example:
Sentence Truth value Proposition (Y/N)

"Grass is green" "true" Yes


"2 + 5 = 5" "false" Yes
"Close the door" - No
"Is it hot outside?" - No
"x > 2" where x is variable - No (since x is not defined)
"x = x" - No
(don't know what is "x" and "=";
"3 = 3" or "air is equal to air" or
"Water is equal to water" has no meaning)

 Propositional logic is fundamental to all logic and tells the ways of joining and/or modifying
entire propositions, statements or sentences to form more complicated propositions, statements
or sentences, as well as the logical relationships and properties that are derived from the methods
of combining or altering statements.
 Statement, Variables and Symbols
- These and few more related terms, such as, connective, truth value, contingencies,
tautologies, contradictions, antecedent, consequent, argument are explained below.
 Statement
- A simple statement (sentences), TRUE or FALSE, that does not contain any other
statement as a part, is basic propositions.
- Lower-case letters, p, q, r, are symbols used to represent simple statements.
Dept. of CSE, RNSIT 79
Artificial Intelligence, VII SEM, CSE, Module - II

-
Large, compound or complex statement are constructed from basic propositions by
combining them with connectives.
 Connective or Operator
- The connectives join simple statements into compounds, and joins compounds into
larger compounds.
- Table below indicates, the basic connectives and their symbols: listed in decreasing
order of operation priority; operations with higher priority is solved first.
Example of a formula: ((((a Λ ¬b) V c → d) ↔ ¬ (a V c ))

Connectives and Symbols in decreasing order of operation priority

Connective Symbols Read as

Assertion P "p is true"


Negation ¬p ~ ! NOT "p is false"
Conjunction p 𝖠 q && & AND "both p and q are true"
Disjunction p v q || | OR "either p is true, or q is true, or both”
Implication p→q ⊃ ⇒ "if p is true, then q is true"
if …then “p implies q "
Equivalence ↔≡⇔ "p and q are either both true or both false"
if and only if

Note: The propositions and connectives are the basic elements of propositional logic.

 LIMITATIONS OF PROPOSITIONAL LOGIC

 Propositional logic is declarative. It allows partial/disjunctive/ negated information (unlike


most data structures and databases)
 Propositional logic is compositional: meaning of B1,1  P1,2 is derived from meaning of B1,1 and
of P1,2
 Meaning in propositional logic is context-independent (unlike natural language, where meaning
depends on context)
 Propositional logic has very limited expressive power (unlike natural language)
– Hard to identify individuals. Example: Mary, 3
– Cannot directly talk about properties of individuals or relations between individuals.
Example: “Bill is tall”
– Generalizations, patterns, regularities can’t easily be represented. E.g., all triangles have
3 sides
 Hence, Propositional logic is not powerful enough as a general knowledge representation
language. Impossible to make general statements. Example: “all students sit for exams” or “if
any student sits for an exam, they either pass or fail”.

Dept. of CSE, RNSIT 80


Artificial Intelligence, VII SEM, CSE, Module - II

 The facts like: “peter is a man”, “paul is a man”, “john is a man” can be symbolized by p, q
and r, respectively in PL. We cannot draw any conclusions about similarities between p, q and r.
Further, the sentences like “All men are mortal” cannot be represented in PL. MAN(peter),
MAN(paul) and MAN(john), Similarity between these facts that they are all man can be easily
derived.

Note: Learn the following Basics to understand building logic in PL or in FOPL

Give the BNF notation for sentences (Wffs) in Propositional Logic with examples.
 The proposition symbols S1, S2 etc., are sentences or Well Formed Formula (wff) in
Propositional Logic
– If S is a sentence, S is also a sentence (negation)
– If S1 and S2 are sentences, S1  S2 is also a sentence (conjunction)
– If S1 and S2 are sentences, S1  S2 is also a sentence (disjunction)
– If S1 and S2 are sentences, S1  S2 is also a sentence (implication)
– If S1 and S2 are sentences, S1  S2 is also a sentence (biconditional)

 Rules for evaluating truth with respect to a model m:


S is true iff S is false
S1  S2 is true iff S1 is true and S2 is true
S1  S2 is true iff S1is true or S2 is true
S1  S2 is true iff S1 is false or S2 is true
i.e., is false iff S1 is true and S2 is false
S1  S2 is true iff S1S2 is true and S2S1 is true

– Truth tables for connectives

Dept. of CSE, RNSIT 81


Artificial Intelligence, VII SEM, CSE, Module - II

 Two sentences are logically equivalent iff they are true in same models: α ≡ ß. Some of the
logical equivalences are :

 Tautologies
- A proposition that is always true (for all possible interpretations/assignments) is called a
"tautology".
Example: (P v ¬P) is always true regardless of the truth value of the proposition P.
 Contradictions
- A proposition that is always false (for all possible interpretations/assignments) is called a
"contradiction". Nothing but Unsatisfiable.
Example: (P 𝖠 ¬P) is always false regardless of the truth value of the proposition P.
 Contingencies
- A proposition is called a "contingency”, if that proposition is (for all possible
interpretations/assignments) neither a tautology nor a contradiction.
Example: (P v Q) is a contingency.
 Antecedent, Consequent
- There are two parts of conditional statements. In the conditional statements, p → q, the
1st statement or "if - clause" (here p) is called antecedent, 2nd statement or "then -
clause" (here q) is called consequent.
 Conjunctive Normal Form (CNF).

Dept. of CSE, RNSIT 82


Artificial Intelligence, VII SEM, CSE, Module - II

 Satisfiable: If there is at least one true result for set of inputs in its truth table. Eg.,(P v Q)
 A clause Ci is a closed formula of the form (L1V L2… V Lm), where each Li is a literal with
all the variables occurring in L1, …, Lm being universally quantified.
 Definition: A Horn clause is a clause with at most one positive literal.

 FIRST- ORDER PREDICATE LOGIC (FOPL)

 Now, we have to move towards first- order predicate logic as a way of representing knowledge
because it permits representations of things that cannot reasonably be represented in
prepositional logic. In predicate logic, we can represent real-world facts as statements written as
wff’s.
 First-Order Logic (abbreviated FOL or FOPL) is expressive enough to
– concisely represent individuals
– talk about properties of individuals or relations between individuals
– Generalizations, patterns, regularities
 FOL adds relations, variables, and quantifiers. Examples:
– Every elephant is gray:  x (elephant(x) → gray(x))
– There is a white alligator:  x (alligator(x) 𝖠 white(x))
 FOL models the world in terms of
– Objects, which are things with individual identities
– Properties of objects that distinguish them from other objects
– Relations that hold among sets of objects
– Functions, which are a subset of relations where there is only one value for any given
input
– Examples:
Objects: Students, lectures, companies, cars ...
Relations: Brother-of, bigger-than, outside, part-of, has-color, occurs-after, owns,
visits, precedes, ...
Properties: blue, oval, even, large, ...
Functions: father-of, best-friend, second-half, one-more-than ...
 It has three more logical notions as compared to Propositional Logic.
– Terms, Predicates and Quantifiers
Term
A constant (single individual or concept i.e., 5, john etc.),
A variable that stands for different individuals
n-place function f(t1, …, tn) where t1, …, tn are terms. A function is a mapping
that maps n terms to a term.

Predicate
A relation that maps n terms to a truth value True (T) or False (F).

Dept. of CSE, RNSIT 83


Artificial Intelligence, VII SEM, CSE, Module - II

Quantifiers
Universal and Existential quantifiers i.e.  and  used in conjunction with
variables.
 Now will explore the use of predicate logic as a way of representing knowledge by looking at
specific examples.

Examples:
– “x loves y” is represented as LOVE(x, y) which maps it to true or false when x and y get
instantiated to actual values.
– “john’s father loves john” is represented as LOVE(father(john), john).
Here, father is a function that maps john to his father.
– “x is greater than y” is represented in predicate calculus as GT(x, y).
It is defined as follows:
GT( x, y) = T, if x  y
= F, otherwise
Symbols like GT and LOVE are called predicates
– Translate the sentence "Every man is mortal” into Predicate formula.
Representation of statement in predicate form
“x is a man” as MAN(x)
“x is mortal” as MORTAL(x)
“Every man is mortal” as (x): (MAN(x)  MORTAL(x))

 BNF for FOL: Well formed formula (Wff) in Predicate logic


S: = <Sentence>;
<Sentence>:= <AtomicSentence> | <Sentence> <Connective> <Sentence> |
<Quantifier> <Variable>,... <Sentence> | "NOT" <Sentence> |
"(" <Sentence> ")";
 Thus a sentence is
– an atomic sentence
– ~P(x) , P(x)  Q(y), P(x)  Q(y), P(x) → Q(y), P(x) ↔ Q(y) where P(x) and Q(y) are
sentences
– if P (x) is a sentence and x is a variable, then (x)P(x) and (x)P(x) are sentences
 Constant symbols, which represent individuals in the world
– Mary, 3, Green
 Function symbols, which map individuals to individuals
– father-of(Mary) = John, color-of(Sky) = Blue
 Predicate symbols, which map individuals to truth values
– greater(5,3) , green(Grass) , color(Grass, Green)
 Summary of Components of Predicate Logic:
– Constants: KingJohn, 2, NUS,...
– Predicates: Brother, >,...

Dept. of CSE, RNSIT 84


Artificial Intelligence, VII SEM, CSE, Module - II

− Functions: Sqrt, LeftLegOf,...


− Variables: x, y, a, b,...
− Connectives: , →, , , ↔
− Equality: =
− Quantifiers: , 

 Note on Quantifiers

 Universal quantifiers are often used with “implies” to form “rules”:


(x) student(x) → smart(x) means “All students are smart”
 Existential quantifiers are usually used with “and” to specify a list of properties about an
individual:
(x) student(x)  smart(x) means “There is a student who is smart”
 Switching the order of universal quantifiers does not change the meaning:
(x)(y) P(x, y) ↔ (y)(x) P(x, y)
 Similarly, you can switch the order of existential quantifiers:
(x)(y) P(x, y) ↔ (y)(x) P(x, y)
 Switching the order of universals and existential does change meaning:
Everyone likes someone: (x)(y) likes(x, y)
Someone is liked by everyone: (y) (x) likes(x, y)
 (x) ~P(x) ↔ ~(x) P(x)
 ~(x) P(x) ↔ (x) ~P(x)
 (x) P(x) ↔ ~ (x) ~P(x)
 (x) P(x) ↔ ~(x) ~P(x)

 Translating English Sentences to FOL


1. Every gardener likes the sun.
(x) gardener(x) → likes(x,Sun)
2. All purple mushrooms are poisonous.
(x) (mushroom(x)  purple(x)) → poisonous(x)
3. No purple mushroom is poisonous.
~(x) purple(x)  mushroom(x)  poisonous(x)
(x) (mushroom(x)  purple(x)) → ~poisonous(x)
4. There are exactly two purple mushrooms.
(x)(y) mushroom(x)  purple(x)  mushroom(y)  purple(y)  ~(x=y)  (Az)
(mushroom(z)  purple(z)) → ((x=z) v (y=z))
5. Harry is not tall.
~tall(Harry)
6. X is above Y if X is on directly on top of Y or there is a pile of one or more other objects
directly on top of one another starting with X and ending with Y.
(x)(y) above(x, y) ↔ (on(x, y) v (z) (on(x, z)  above(z, y)))
7. You can fool some of the people all of the time.
(x) (t) can-fool(x, t)
Dept. of CSE, RNSIT 85
Artificial Intelligence, VII SEM, CSE, Module - II

(x) (person(x)  ((t)( time(t) → can-fool(x, t))))


8. You can fool all of the people some of the time.
(x)(t) can-fool(x, t)
(x) (person(x) → ((t) time(t)  can-fool(x, t)))
9. In every city there is a thief who is beaten by every policeman in the city
x[city(x) {y((thief(y)  lives_in (y,x))  z(policeman(z)  beaten_by (z, y)))}]

 Consider the following set of sentences


1. Marcus was a man.
2. Marcus was a Pompeian.
3. All Pompeian were Romans.
4. Caesar was a ruler.
5. All Romans were either loyal to Caesar or hated him.
6. Everyone is loyal to someone.
7. People only try to assassinate rulers they are not loyal to.
8. Marcus tried to assassinate Caesar.

The facts described by these sentences can be represented as a set of wff’s in predicate logic as follows:

1. Marcus was a man.


Man (Marcus)
This representation captures the critical fact of Marcus being a man.
2. Marcus was a Pompeian.
Pompeian (Marcus)
3. All Pompeians were Romans.
✯x: Pompeian (x) → Roman (x)
4. Caesar was a ruler.
Ruler (Caesar)
5. All Romans were either loyal to Caesar or hated him.
✯x: Roman (x) → loyalto(x, Caesar) V hate ( x, Caesar) (OR representation)
or
✯x: Roman(x) → [(loyalto(x, caesar) V hate (x,Caesar)) V ¬(loyato(x, caesar) V hate
(x, Caesar))] (XOR representation)
6. Everyone is loyal to someone
✯X, y: loyalto(x,y)
7. People only try to assassinate rulers they are not loyal to.
✯x, ✯y : Person (x) V ruler (y) V tryassassinate(x,y) → ¬ loyalto(x, y)
8. Marcus tried to assassinate Caesar.
Tryassassinate (Marcus, Caesar)

Now suppose that we want to use these statements to answer the question
Was Marcus loyal to Caesar?

Dept. of CSE, RNSIT 86


Artificial Intelligence, VII SEM, CSE, Module - II

Using 7 and 8, we should be able to prove that Marcus was not loyal to Caesar. Now let’s try to
produce a formal proof, reasoning backward from the desired goal:
loyalto(Marcus, Caesar)
Marcus was a person. We need to add the representation of another fact to our system, namely:
9. All men are people.
✯x: man (x) → person (x)

¬ loyalto (Marcus, Caesar)


𝗍 (7, substitution)

Person (Marcus) V Ruler (Caesar) V Tryassassinate (Marcus, Caesar)


𝗍 (4)
Person (Marcus)
Tryassassinate (Marcus, Caesar)
𝗍 (8)
Person (Marcus)
Now we can satisfy the last goal and produce a proof that Marcus was not loyal to Caesar.

 PEPRESENTING INSTANCE AND ISA RELASHIONSHIP


Below example shows the first five sentences of logic in three different ways.

 The first part of the representation contains we have already discussed. In these representations,
class membership is represented with unary predicates (such as Roman), each of which
corresponds to a class. Asserting that p(x) is true is equivalent to asserting that X is an instance
(or element) of P.
 The second part represents that the use the instance predicate explicitly. The predicate instance
is a binary one, whose first argument is an object and second argument is a class to which the
object belongs. But these representations do not use an explicit isa predicate. Instead, subclass
relationships, such as that between Pompeians and Romans, are described as shown in sentence
3. The implication rule there states that this rule is equivalent to the standard set-theoretic
definition of the subclass-super class relationship.
 The third part contains representations that use both the instance and isa predicates explicitly.
The use of the isa predicate simplifies the representation of sentence 3, but it requires that one
additional axiom (shown here as number 6) be provided. This additional axiom describes how an
instance relation and an isa relation can be combined to derive a new instance relation. This one
additional axiom is general, though, and does not need to be provided separately for additional
isa relations.

Three Ways of Representing Class Membership

1. Man(Marcus)
2. Pompeian(Marcus)
3. ✯x : pompeian(x) → Roman (x)
Dept. of CSE, RNSIT 87
Artificial Intelligence, VII SEM, CSE, Module - II

4. Ruler(Caesar)
5. ✯x : Roman (χ) → loyalto(x, Caesar) V hate(x, Caesar)

1. Instance(Marcus, man)
2. Instance(Marcus, 𝑝𝑜𝑚𝑝𝑒i𝑎𝑛)
3. ✯x : Instance(x, pompeian) → Instance(x, Roman)
4. Instance(Caesar, ruler)
5. ✯x : Instance(x, Roman) → loyalto (x, Caesar) V hate(x, Caesar)

1. Instance(Marcus, man)
2. Instance(Marcus, pompeian)
3. Isa(pompeian, Roman)
4. Instance(Caesar, ruler)
5. ✯ x : Instance(x, Roman) → loyalto (x, Caesar) V hate(x, Caesar)
6. ✯ x, ✯y, ✯z : Instance(x, y) V isa(x, y) → Instance (x, y)

 These examples illustrate two points. The first is fairly specific. It is that, although class and
super class membership are important facts that need to be represented, those memberships need
not be represented with predicates labeled instance and isa.
 The second point is that there are several different ways of representing a given fact within a
particular representational framework, be it logic or anything else.
 There is one additional point that needs to be made here on the subject of the use of isa
hierarchies in logic-based systems. The reason that these hierarchies are so important is not that
they permit the inference of superclass membership. It is that by permitting the inference of
superclass membership, they permit the inference of other properties associated with
membership in that superclass. So, for example, in our sample knowledge base it is important to
be able to conclude that Marcus is a Roman because we have some relevant knowledge about
Romans, namely that they either hate Caesar or are loyal to him.
 Suppose, for example, that, in addition to the facts we already have, we add the following.
pompeian(Paulus)
¬ [loyalto (paulus, Caesar) V hate (paulus, Caesar)]

Suppose we want to make paulus an exception to the general rule about Romans and their
feelings toward Caesar. Unfortunately, we cannot simply add these facts to our existing
knowledge base the way we could just add new nodes into a semantic net. The difficulty is that if
the old assertions are left unchanged, then the addition of the new assertions makes the
knowledge base inconsistent. In order to restore consistency, it is necessary to modify the
original assertion to which an exception is being made. So our original sentence 5 must become:

✯x : Roman (x) V ¬ eq (x, paulus) → loyalto (x, Caesar) V hate (x, Caesar)

Dept. of CSE, RNSIT 88


Artificial Intelligence, VII SEM, CSE, Module - II

In this framework, every exception to a general rule must be stated twice, once in a particular
statement and once in an exception list that forms part of the general rule.

 COMPUTABLE FUNCTIONS AND PREDICATES

 We have explored that all the simple facts were expressed as combinations of individual
predicates, such as: tryassassinate (Marcus, Caesar)
 This is fine if the number of facts is not very large. But suppose we want to express facts, such as
the following greater-than and less-than relationships:

gt(1,0) 1t(0,1)
gt(2,1) 1t(1,2)
gt(3,2) 1t(2,3)
. .
. .
. .
We might want to evaluate the truth of gt(2+3,1)
To do so requires that we first compute the value of the plus function given the arguments 2 and
3, and then send the arguments 5 and 1 to gt.
 Consider the following set of facts, again involving Marcus:
1. Marcus was a man.
Man(Marcus)
2. Marcus was a Pompeian.
Pompeian (Marcus)
3. Marcus was born in 40 A.D.
Born (Marcus, 40)
4. All men are mortal.
✯x: man (x) → mortal(x)
5. All Pompeian died when the volcano erupted in 79 A. D.
Erupted (volcano, 79) 𝖠 ✯x : [Pompeian (x) → died (x, 79)]
6. No mortal lives longer than 150 years.
✯ x, ✯ t1, ✯t2 : mortal (x) 𝖠 born (x, t1) 𝖠 gt(t2-t1,150) → dead (x, t2)
7. It is now 1991.
now =1991
8. Alive means not dead.
✯x, ✯t : [alive (x, t) → ¬ dead (x, t)] 𝖠 [¬ dead (x, t) → alive(x, t)]
9. If someone dies, then he is dead at all later times.
✯ x, ✯ t1, ✯t2 : died (x, t1) 𝖠 gt(t2,t1) → dead (x, t2)

Now suppose we want to answer the question “Is Marcus alive?” There may be two ways of
deducing an answer. Either we can show that Marcus is dead because he was killed by the

Dept. of CSE, RNSIT 89


Artificial Intelligence, VII SEM, CSE, Module - II

volcano or we can show that he must be dead because he would otherwise be more 150 years
old, which we know is not possible.

A Set of Facts about Marcus (above are Rewritten with spilt of 5 into 2 facts)

1. Man(Marcus)
2. Pompeian(Marcus)
3. Born (Marcus, 40)
4. ✯x : man(x) → mortal(x)
5. ✯x : Pompeian(x) → died(x, 79)
6. erupted (yolcano, 79)
7. ✯ x, ✯t1, ✯t2: mortal(x) 𝖠 born(x, t1) 𝖠 gt(t2-t1,150) → dead(x, t2)
8. Now = 1991
9. ✯x, ✯t : [alive(x, t) → ¬ dead(x, t)] 𝖠 [¬ dead(x, t) → alive (x, t)]
10. ✯x, ✯t1, ✯t2: died(x, t1) 𝖠 gt (t2,t1) → dead (x, t2)

Now let’s attempt to answer the question “Is Marcus alive?” by proving:¬ alive (Marcus, now)

Two such proofs are shown below. The term nil at the end of each proof indicates that the list of
conditioned remaining to be proved is empty and so the proof has succeeded. One Way of Proving
that Marcus is dead:
¬ alive (Marcus, now)
𝗍 (9, substitution)
Dead(Marcus, now)
𝗍 (10, substitution)
Died(Marcus, t1) 𝖠 gt(now,t1)
𝗍 (5, substitution)
Pompeian (Marcus) 𝖠 gt(now,79)
𝗍 (2)
gt(now,79)
𝗍 (8, substitute equals)
gt(1991,79)
𝗍 (Compute gt)
Nil

Another Way of Proving that Marcus is dead

¬alive (Marcus,now)
𝗍 (9, substitution)
Dead (Marcus, now)
𝗍 (7, substitution)
Mortal (Marcus) 𝖠 Born (Marcus, t1) 𝖠 gt(now-t1, 150)
Dept. of CSE, RNSIT 90
Artificial Intelligence, VII SEM, CSE, Module - II

𝗍 (4, substitution)
Man (Marcus) 𝖠 Born (Marcus, t1) 𝖠 gt(now-t1, 150)
𝗍 (1)
Born (Marcus, t1) 𝖠 gt(now-t1,150)
𝗍 (3)
gt(now-40,150)
𝗍 (8)
gt(1991-40,150)
𝗍 (Compute minus)
gt(1951,150)
𝗍 (Compute gt)
nil

 From looking at the proofs we have just shown, two things should be clear:
– Even very simple conclusions can require many steps to prove.
– A variety of processes, such as matching, substitution, and application of modus ponens
are involved in the production of a proof. This is true even for the simple statements we
are using. This becomes complex for complicated statements. To reduce complexity,
next we consider Resolution.

 RESOLUTION

 Resolution is a procedure, which gains its efficiency from the fact that it operates on statements
that have been converted to a very convenient standard form, which is described below.
– Resolution produces proofs by refutation. In other words, to prove a statement (i.e., show
that it is valid), resolution attempts to show that the negation of the statement produces a
contradiction with the known statements (i.e., that it is unsatisfiable). This approach
contrasts with the technique that we have been using to generate proofs by chaining
backward from the theorem to be proved to the axioms.

– Resolution Refutation
- Negate the goal
- Convert all pieces of knowledge into clausal form (disjunction of literals)
- See if contradiction indicated by null clause [ ] can be derived through resolution.

 Conversion to Clause Form (Clausal Normal Form)


Algorithm: Convert to Clause Form

1. Eliminate logical implications, → using the fact that A → B is equivalent to ¬A ∨ B


Eliminate all ↔ connectives using the fact that, (P ↔ Q) → ((P → Q) ^ (Q → P))
2. Reduce the scope of each negation to a single term, using the following facts:
¬ (¬P) = P
Dept. of CSE, RNSIT 91
Artificial Intelligence, VII SEM, CSE, Module - II

¬ (A ∨ B) = ¬A � ¬B
¬ (A � B) = ¬A V ¬B
¬✯ x: P(x) = ∃ x: ¬P(x)
¬ ∃x: P(x) = ✯ x: ¬P(x)
3. Standardize variables so that each quantifier binds a unique variable.
4. Move all quantifiers to the left, maintaining their order.
5. Eliminate existential quantifiers, using Skolem constants or Skolem functions (functions
of the preceding universally quantified variables).
Examples:
(x) P(x) as P(c)
c is a Skolem constant (a new constant symbol that is not used in any other sentence)
(x)(y): P(x,y) as (x): P(x, f(x))
Since  is within the scope of a universally quantified variable, use a Skolem function f to
construct a new value that depends on the universally quantified variable. f must be a new
function name not occurring in any other sentence in the KB.
E.g., (x)(y) loves(x,y) ⇒ (x) loves(x, f(x)). In this case, f(x) specifies the person that x
loves
6. Remove universal quantifiers by (1) moving them all to the left end (2) making the scope
of each the entire sentence, and (3) dropping the “prefix” part. Ex: (x)P(x) as P(x)
Drop the prefix: prefix refers to all the quantifiers.
7. Convert the remaining formula into a conjunction of disjuncts.
– Distribute v over ^
a. (P � Q)  R as (P  R) � (Q  R)
b. (P  Q)  R as (P  Q  R)
8. Create a separate clause corresponding to each conjunct.
9. Standardize the variables in the clauses so that each clause contains only variable names that
do not occur in any other clause

Example 1: Conversion to CNF


“Everyone who loves all animals is loved by someone"
x [y Animal(y) →Loves(x, y)] → [y Loves(y, x)]

1. Eliminate biconditionals and implications


x [y Animal(y)  Loves(x, y)] → [y Loves(y, x)]
x [y Animal(y)  Loves(x, y)]  [y Loves(y, x)]
2. Move  inwards: x p ≡ x p,  x p ≡ x p
x [y (Animal(y)  Loves(x, y))]  [y Loves(y, x)]
x [y Animal(y)  Loves(x, y)]  [y Loves(y, x)]
x [y Animal(y)  Loves(x, y)]  [y Loves(y, x)]
3. Standardize variables: each quantifier should use a different one
x [y Animal(y)  Loves(x, y)]  [z Loves(z, x)]
Dept. of CSE, RNSIT 92
Artificial Intelligence, VII SEM, CSE, Module - II

4. All quantifiers are on left only


5. Skolemize: a more general form of existential instantiation. Each existential variable is
replaced by a Skolem function of the enclosing universally quantified variables
x [Animal(F(x))  Loves(x, F(x))]  Loves(G(x), x)
6. Drop universal quantifiers:
[Animal(F(x))  Loves(x, F(x))]  Loves(G(x), x)
7. Distribute  over  :
[Animal(F(x))  Loves(G(x),x)]  [Loves(x,F(x))  Loves(G(x),x)]
8. Create a separate clause corresponding to each conjunct
[Animal(F(x))  Loves(G(x), x)]
[Loves(x, F(x))  Loves(G(x), x)]
9. Variables are standardized in the clauses

Example 2: Conversion to CNF


Suppose we know that, “all Romans who know Marcus either hate Caesar or think that
anyone who hates anyone is crazy”. We could represent that in the following wff:
✯x: [Roman(x) � know(x, Marcus)] →
[hate(x, Caesar) V (✯y, ∃z : hate (y, z) → thinkcrazy(x, y))]

1. ✯x: ¬ [Roman(x) 𝖠 know(x, Marcus)] V


[hate(x, Caesar) V (✯y : ¬(∃z : hate(y, z)) V thinkcrazy(x, y))]
2. ✯x: [¬ Roman(x) V ¬ know(x, Marcus)] V
[hate(x, Caesar) V (✯y: ✯z: ¬ hate(y, z) V thinkcrazy(x, y))]
3. ✯x: ✯y: ✯z: [¬ Roman(x) V ¬ know(x, Marcus)] V
[hate(x, Caesar) V (¬ hale(y, z) V thinkcrazy(x, y))]
4. [¬ Roman(x) V ¬ know(x, Marcus)] V
[hate(x, Caesar) V (¬ hate(y, z) V thinkcrazy(x, y))]
5. ¬ Roman(x) V ¬ know(x, Marcus) V
hate(x, Caesar) V ¬ hate(y, z) V thinkcrazy(x, y)

 The Basis of Resolution


The resolution procedure is a simple iterative process: at each step, two clauses, called the
parent clauses, are compared (resolved), yielding a new clause that has been inferred from
them. The new clause represents ways that the two parent clauses interact with each other.
Suppose that there are two clauses in the system:
C1: Winter V summer
C2: ¬Winter V cold

Now we observe that one of winter and ¬winter will be true at any point. If winter is true,
then cold must be true to guarantee the truth of the second clause. If ¬winter is true, then

Dept. of CSE, RNSIT 93


Artificial Intelligence, VII SEM, CSE, Module - II

summer must be true to guarantee the truth of the first clause. Thus we see that from these two
clauses we can deduce
C3: Summer V cold

This is the deduction that the resolution procedure will make. Resolution operates by taking two
clauses that each contains the same literal, in this example, winter. The literal must occur in
positive form in one clause and in negative form in the other. The resolvent is obtained by
combining all of the literals of the two parent clauses except the ones that cancel.

If the clause that is produced is the empty clause, then a contradiction has been found. For
example, the two clauses will produce the empty clause
C1: Winter
C2: ¬Winter
C3: [ ]

 Resolution in propositional Logic


In propositional logic, the procedure for producing a proof by resolution of proposition p with
respect to a set of axioms F is the following.

Algorithm: Propositional Resolution

1. Convert all the propositions of F to clause form.


2. Negate P and convert the result to clause form. Add it to the set of clauses obtained
in step 1.
3. Repeat until either a contradiction is found or no progress can be made:
(a) Select two clauses. Call these the parent clauses.
(b) Resolve them together. The resulting clause, called the resolvent, will be the disjunction
of all of the literals of both of the parent clauses with the following exception: If there are
any pairs of literals L and ¬ L such that one of the parent clauses contains L and the other
contains ¬ L, then select one such pair and eliminate both L and ¬ L from the resolvent.
(c) If the resolvent is the empty clause, then a contradiction has been found. If it is not,
then add it to the set of clauses available to the procedure.

Look at a simple example: A Few Facts in Propositional Logic

Given Axioms Converted to Clause Form


P P (1)
(P V Q) → R ¬P V ¬ Q V R (2)
(S V T) → Q ¬S V Q (3)
¬T V Q (4)

T T (5)

Dept. of CSE, RNSIT 94


Artificial Intelligence, VII SEM, CSE, Module - II

Then we negate R, producing ¬R, which is already in clause form. Then we begin selecting pairs
of clauses to resolve together. Although any pair of clauses can be resolved, only those pairs that
contain complementary literals will produce a resolvent that is likely to lead to the goal of
producing the empty clause as shown below. We might, for example, generate the sequence of
resolvents as shown below: Take 2 and 6, then 1, then 4, then 5 and will get Nil.

¬R ¬R (6)

Resolution in Propositional Logic

¬PV¬QVR ¬R

¬PV¬Q P
¬T V Q ¬Q

¬T T

 The Unification Algorithm

 In propositional logic, it is easy to determine that two literals cannot both be true at the same
time. Simply look for L and ¬ L in predicate logic, this matching process is more complicated
since the arguments of the predicates must be considered. For example, man(john) and ¬
man(john) is a contradiction, while man(john) and man(Spot) is not. Thus, in order to
determine contradictions, we need a matching procedure that compares two literals and discovers
whether there exists a set of substitutions that makes them identical. There is a straightforward
recursive procedure, called the unification algorithm.
 The basic idea of unification is very simple. To attempt to unify two literals, we first check if
their initial predicate symbols are the same. If so, we can proceed. Otherwise, there is no way
they can be unified, regardless of their arguments. For example, the two literals cannot be
unified.
try assassinate(Marcus, Caesar)
hate(Marcus, Caesar)
 If the predicate symbols match, then we must check the arguments, one pair at a time. If the
first matches, we can continue with the second, and so on.

Dept. of CSE, RNSIT 95


Artificial Intelligence, VII SEM, CSE, Module - II

 A variable can match another variable, any constant, or a predicate expression with the
restriction that the predicate expression must not contain any instances of the variable being
matched. To do this, we must take each substitution that we find and apply it to the remainder
of the literals before we continue trying to unify them.
P (x, x)
P (y, z)
 The two instances of P match fine. Next we compare x and y, and decide that if we substitute y
for x, they could match. We will write that substitution as
y/x
 But now, if we simply continue and match x and z, we produce the substitution z/x, but we
cannot substitute both 𝑦 and z for x, so we have not produced a consistent substitution.
 What we need to do after finding the first substitution y/ x is to make that substitution throughout
the literals, giving
P (y, 𝑦)
P (y, z)
 We can attempt to unify arguments y and z, which succeeds with the substitution z/ 𝑦. The entire
unification process has now succeeded with a substitution that is the composition of the two
substitutions we found. We write the composition as following standard notation for function
composition.
(z / y)( y/ x)
 In general, the substitution (a1/a2, a3/a4, ….) (b1/b2, b3/b4, …..)… means to apply all the
substitutions of the right-most list, then take the result and apply all the ones of the next list, and
so forth, until all substitutions have been applied.
 The object of the unification procedure is to discover at least one substitution that causes two
literals to match. Usually, if there is one such substitution there are many. For example, the
literals
hate (x, 𝑦)
hate (Marcus, z)
could be unified with any of the following substitutions:
(Marcus/x, z/y)
(Marcus/x, y/z)
(Marcus/x, Caesar/ y, Caesar/ z)
(Marcus/ x, polonius/ y, polonius/ z)

We describe a procedure Unify (L1, L2), which returns as its value a list representing the
composition of the substitutions that were performed during the match. The empty list, NIL,
indicates that a match was found without any substitutions. The list consisting of the single value
FAIL indicates that the unification that the unification procedure failed.

Dept. of CSE, RNSIT 96


Artificial Intelligence, VII SEM,CSE, Module - II

Algorithm: Unify (L1, L2)

1. If L1 or L2 are both variables or constants, then:


a. If L1 and L2 are identical, then return NIL.
b. Else if L1 is a variable, then if L1 occurs in L2 then return {FAIL}, else return (L2/L1).
c. Else if L2 is a variable, then if L2 occurs in L1 then return {FAIL}, else return (L1/L2).
d. Else return {FAIL}.
2. If the initial predicate symbols in L1 and L2 are not identical, then return {FAIL}.
3. If LI and L2 have a different number of arguments, then return {FAIL}.
4. Set SUBST to NIL. (At the end of this procedure, SUBST will contain all the substitutions used
to unify L1 and L2.)
5. For i ← 1 to number of arguments in L1:
a. Call Unify with the ith argument of L1 and the ith argument of L2, putting result in S.
b. If S contains FAIL then return {FAIL}.
c. If S is not equal to NIL then:
i. Apply S to the remainder of both L1 and L2.
ii. SUBST: = APPEND(S, SUBST).
6. Return SUBST.

Example:
p = Knows(John, x)
q = Knows(John, Jane)
Unify(p, q) = {x/Jane}

 Resolution in Predicate Logic

 We now have an easy way of determining that two literals are contradictory – they are if one of
them can be unified with the negation of the other. For example, man(x) and ¬man(Spot) are
contradictory, since man(x) and man(Spot) can be unified. This corresponds to the intuition that
man(x) cannot be true for all x if there is known to be some x, say spot, for which man(x) is
false. Thus in order to use resolution for expression in the predicate logic, we use the unification
algorithm to locate pairs of literals that cancel out.
 We also need to use the unifier produced by the unification algorithm to generate the resolvent
clause. For example, suppose we want to resolve two clauses.
1. Man(Marcus)
2. ¬man(x1) V mortal(x1)
 The literal man(Marcus) can be unified with the literal man(x1) with the substitution
Marcus/x1, telling us that for x1=Marcus, ¬man(Marcus) is false. But we cannot simply
cancel out the two man literals as we did in propositional logic and generate the resolvent
mortal(x1). Clause 2 says that for a given x1, either ¬man(x1) or mortal(x1). So for it to be true
for all x1, since for some values of x1, ¬man(x1) might be true, making mortal(x1) irrelevant to
the truth of the complete clause.
Dept. of CSE, RNSIT 97
Artificial Intelligence, VII SEM,CSE, Module - II

We can now state the resolution algorithm for predicate logic as follows, assuming a set of
statements F and statement to be proved P:

Algorithm: Resolution
1. Convert all the statements of F to clause form.
2. Negate P and convert the result to clause form. Add it to the set of clauses obtained in 1.
3. Repeat until either a contradiction is found, no progress can be made, or a
predetermined amount of effort has been expended.
a. Select two clauses. Call these the parent clauses.
b. Resolve them together. The resolvent will be the disjunction of all the literals of parent
clauses with appropriate substitutions performed and with the following exception: If
there is one pair of literals T1 and ¬ T2 such that one of the parent clauses contains T2
and the other contains T1 and if T1 and T2 are unifiable, then neither T1 nor T2 should
appear in the resolvent. We call T1 and T2 Complementary literals. Use the
substitution produced by the unification to create the resolvent. If there is more than one
pair of complementary literals, only one pair should be omitted from the resolvent.
c. If the resolvent is the empty clause, then a contradiction has been found. If it is not,
then add it to the set of clauses available to the procedure.

 There exist STRATEGIES for making the choice that can speed up the process considerably:

– Only resolve pairs of clauses that contain complementary literals, since only such
resolutions produce new clauses that are harder to satisfy than their parents.
– Eliminate certain clauses as soon as they are generated so that they cannot participate in
later resolutions. Two kinds of clauses should be eliminated: tautologies (which can never
be unsatisfied) and clauses that are subsumed by other clauses (i.e., they are easier to satisfy.
For example, P V Q is subsumed by P.)
– Whenever possible, resolve either with one of the clauses that is part of the statement we are
trying to refuse or with a clause generated by a resolution with such a clause. This is called
the set-of-support strategy and corresponds to the intuition that the contradiction we are
looking for must involve the statement we are trying to prove.
– Whenever possible, resolve with clauses that have a single literal. Such resolutions generate
new clauses with fewer literals than the larger of their parent clauses and thus are probably
closer to the goal of a resolvent with zero terms. This method is called the unit-preference
strategy.

Example 1: All statements of Marcus are converted to CNF


Axioms in clause form:
1. Man(Marcus)
2. Pompeian(Marcus)
3. ¬ Pompeian( x1) V Roman(x1)
4. Ruler(Caesar)
Dept. of CSE, RNSIT 98
Artificial Intelligence, VII SEM,CSE, Module - II

5. Roman(x2) V loyalto(x2, Caesar) V hate (x2, Caesar)


6. loyalto(x3, f1(x3))
7. ¬man(x4) V ¬ ruler (y1) V ¬ tryasssassinate (x4, y1) V loyalto (x4, y1)
8. tryasssassinate (Marcus, Caesar )

Prove: hate (Marcus, Caesar)

Below figure shows a resolution proof of the statement

Below example shows an unsuccessful attempt at Resolution because of no contradiction exists.

Dept. of CSE, RNSIT 99


Artificial Intelligence, VII SEM,CSE, Module - II

Example 2: All statements of Marcus are converted to CNF


Axioms in clause form:

Prove: alive (Marcus, now)


Below figure shows use of Resolution with equality and Reduce

 The Need to Try Several Substitutions

 Resolution provides a very good way of finding a refutation proof without actually trying all
the substitutions. But it does not always eliminate the necessity of trying more than one
substitution. For example,
hate (Marcus, Paulus)
hate (Marcus, Julian)

Dept. of CSE, RNSIT 100


Artificial Intelligence, VII SEM, CSE, Module - II

 Now if we want to prove that Marcus hates some ruler, we would be likely to try each
substitution shown in Figure (a) and (b) before finding the contradiction shown in (c).

Prove: x: hate(Marcus, x)  ruler (x)


Negate: x: hate(Marcus, x)  ruler (x)
Clause:  hate (Marcus, x)  ruler(x)

Figure shows Trying Several Substitutions

 Question Answering

 Here, it shows how resolution can be used to answer fill-in-the-blank questions, such as
“when did Marcus die?” or “who tried to assassinate a ruler?” Answering these questions
involves finding a known statement that matches the terms given in the question and then
responding with another piece of that same statement that fills the slot demanded by the
question.
For example, to answer the question “when did Marcus die?” we need a statement of the
form died (Marcus, ??)
With ?? actually filled in by some particular year. So, since we can prove the statement
died(Marcus,79)
We can respond with the answer 79.
 It turns out that the resolution procedure provides an easy way of locating just the statement
we need and finding a proof for it. Let’s continue with the example question.
Dept. of CSE, RNSIT 101
Artificial Intelligence, VII SEM, CSE, Module - II

“When did Marcus die?” in order to be able to answer this question, it must first be true that
Marcus died. Thus it must be the case that
t: died(Marcus, t)
 A reasonable first step then might be try to prove this. To do so using resolution, we attempt
to shown that
t: died(Marcus, t)
produces a contradiction. What does it mean for that statement to produce a contradiction?
Either it conflicts with a statement of the form
t: died(Marcus, t)
Where t is a variable, in which case we can either answer the question by reporting that there
are many times at which Marcus died, or we can simply pick one such time and respond
with it. The other possibility is that we produce a contradiction with one or more specific
statements of the form for specific value of date
died(Marcus, date)
 Figure (a) shows how the resolution process finds the statement for which we looking. The
answer to the question can then be derived from the chain of unifications that lead back to the
starting clause. We can eliminate the necessity for this final step by adding an additional
expression to the one we are going to use to try to find a contradiction.
 Figure (b) shows how this process produces an answer to our question. This will not interfere
with resolution process (underlined). Instead of terminating with nil clause, the resolution
will terminate when all that is left is the dummy expression.
x: event(x,79)
Figure shows Answer Extraction Using Resolution

Dept. of CSE, RNSIT 102


Artificial Intelligence, VII SEM, CSE, Module - II

 We can, however, answer the question if we change our representation. Instead of saying
erupted (volcano, 79)
we can say
event(erupted(volcano), 79)
Then the simple proof shown in Figure below enables us to answer the question.

 NATURAL DEDUCTION

 We introduced resolution as an easily implementable proof procedure that relies for its simplicity
on a uniform representation of the statements it uses. Unfortunately, uniformity has its price
everything looks the same. Since everything looks the same, there is no easy way to select those
statements that are the most likely to be useful in solving a particular problem. In converting
everything to clause form, we often lose valuable heuristic information that is contained in the
original representation of the facts. For example, suppose “we believe that all judges who are
not crooked are well- educated”, which can be represented as

x: judge(x)  crooked(x) → educated(x)

 In this form, the statement suggests a way of deducing that someone is educated. But when the
same statement is converted to clause form,

judge(x)  crooked(x)  educated(x)

 It appears also to be a way of deducing that someone is not a judge by showing that he is not
crooked and not educated. Of course, in a logical sense, it is. But it is almost certainly not the
way, or even a very good way, to go about showing that someone is not a judge. The heuristic
information contained in the original statement has been lost in the transformation.
 Natural deduction is not a precise term. Rather it describes a mixture of techniques, used in
combination to solve problems that are not tractable by any one method alone. One common
technique is to arrange knowledge, not by predicates, as we have been doing, but rather by the
objects involved in the predicates.

Dept. of CSE, RNSIT 103


Artificial Intelligence, VII SEM, CSE, Module - II

Additional problems including exercise and others (practice well)

I. Represent the following sentences in FOL using consistent vocabulary

1. Some students took French in spring 2001


∃x: student(x)  took (x, French)

2. Every student who takes French passes it.


✯x: Student  took (x, French) → pass (x, French)

3. Only one student took Greek is spring 2001.


Student (A)  took (A, Greek)

4. The best score in Greek is always higher than the best score is French.
✯ x, ✯y: BS(x, Greek)  BS (y, French) → Higher (x, y)

5. Every person who buys a policy is smart.


✯x: Person(x)  buy (x, policy) → smart(x)

6. No person buys an expensive policy


✯x: Person(x) →  buy(x, expensive-policy)

7. Politicians can fool some of the people all the time, and they can fool all of the people some of
the time, but they can’t fool all of the people all of the time.
x: Politician(x) → ∃y People (y) V (✯t: time (t) → fool (x, y, t))
∃t time (t) V (✯y: people(y) → tool (x, y, t))
~ [(✯ y, ✯t: people(y) V time (t) → fool(x, y, t)]

8. All germens speaks the same language


x1,x2,l1,l2: germen (x1)  speak (x1,l1)  germen (x2)  speak(x2, l2) 
~ equal(x1, x2) → same (l1, l2)

9. No person likes a professor unless the professor is smart.


x,y: [person(x)  professor(y)] →[likes(x, y) → smart(y)]

10. There is a Barber who shaves all men in town who do not shave themselves.
x: barber(x)  (y: town-man(y)  ~ shaves(y, y) → shaves(x, y))

11. There is a woman who likes all men who are not vegetarians.
x: woman (x)  (y: man(y)  ~ vegetarian(y) → likes (x, y))

Dept. of CSE, RNSIT 104


Artificial Intelligence, VII SEM, CSE, Module - II

12. Every person who dislikes all vegetarians is smart.


x: person(x)  y [vegetarian(y) → ~ likes(x, y)] →smart(x)

II. Translate the following into clause form (CNF).

x,y: (z (p(x, z)  p(y, z)) → n: Q(x, y, n)

1. x,y ~ z (p(x, z)  p(y, z)  n: Q(x, y, n)


2. x,y,z ~ (p(x, z)  p(y, z))  n Q (x, y, n)
3. x y (z ~ (p(x, z)  ~ p(y, z))  n Q(x, y, n)
4. x y (z ~ (p(x, z)  ~ p(y, z))  Q(x, y, a)
5. ~ p(x, z)  ~ p(y, z)  Q(x, y, a)

III. Consider the following sentences and translate them into wffs in first order predicate logic. Also
convert all these wffs in FOP logic into clauses and answer the question. “What kind of food John
likes?”
1. John likes all kinds of food.
x: food (x) → likes(John, x)
2. Bananas are food
x Banana (x) → food (x) OR food (Banana)
3. Rice is food
food (RICE)
4. Anything anyone eats and is not killed by is food.
x,y: eats(y, x)  alive(y) → food(x)
5. Vikki eats apple and is still alive.
eats (Vikki, Apple)  alive (vikki)
6. Varun eats everything vikki eats.
x: eats (vikki, x) → eats(Varun, x)

Converting them into clauses.

1. ~food(x)  likes (John, x) C1

2. ~Banana(x)  food (x) OR food (Banana) C2

C3
3. food (RICE)

C4
4. ~ eats(y, x)  ~ alive(y)  food(x)

C5
5. eats(vikki, apple)
Alive (vikki) C6

Dept. of CSE, RNSIT 105


Artificial Intelligence, VII SEM, CSE, Module - II

C7
6. ~ eats(vikki, x)  eats(Varun, x)

Resolution Principle applied on above clauses to answer the question “what kind of food that
John eats?”

John likes Apple. Hence the proof

 Proof by forward chaining / Reasoning:

From (4) eats(Vikki, Apple)  alive(Vikki)


and (5) eats(y, x)  alive(y) → food(x)

with substitution = (x/Apple, y/vikki) food(Apple)

From food (Apple)


and (1) food(x) → likes(John, x)

with substitution = (x/Apple) likes (John, Apple)

Hence the proof: John likes Apple.

Dept. of CSE, RNSIT 106


Artificial Intelligence, VII SEM, CSE, Module - II

 Proof by Backward Chaining / Reasoning:

IV. Sam, Clyde and other Oscar are Elephants. We know the following facts about them.

1. Sam is pink
2. Clyde is gray and likes Oscar
3. Oscar is either pink or gray (but not both) and likes Sam.

Use resolution reputation to prove that a gray elephant likes a pink elephant.
Prove that: x, y: gray(x)  pink(y)  likes(x, y)

Solution:
wffs is predicate logic:

1. Pink(Sam)
2. Gray(Clyde)  likes(Clyde, Oscar)
3. (pink (Oscar)  Gray(Oscar))  likes(Oscar, Sam)

Converting the above wffs into Clauses:

1. Pink(Sam)
2. Gray(Clyde)
3. Likes(Clyde, Oscar)
4. Pink(Oscar)  Gray(Oscar)
5. Likes(Oscar, Sam)
Dept. of CSE, RNSIT 107
Artificial Intelligence, VII SEM, CSE, Module - II

Goal:
6. Gray (A)
Pink (B)
Likes (A, B) (from to be proved)

~ Gray (A)  ~ Pink (B)  ~ likes (A, B)

Proof: From 3 and 6


~ Gray (Clyde)  ~ Pink (Oscar) - (7)
From 7 and 2
~ Pink (Oscar) - (8)
From 5 and 6
~ Gray (Oscar)  ~ Pink (Sam) - (9)
From 9 and 1
~ Gray (Oscar) - (10)
From 10 and 4
Pink (Oscar) - (11)
From 11 and 8
[ ]
Contradiction Hence gray elephant likes pink elephant

V. Consider the following facts


1. Steve likes only easy courses.
2. Science courses are hard.
3. All courses in the Basket weaving department are easy.
4. BKW301 is a Basket weaving courses.

Use resolution to answer the question: “What course would Steve like?”
Solution:
Convert the facts into wffs in predicate logic
1. x: easy- course (x) → likes (Steve, x)
2. x: science-course(x) → hard- course(x)
3. x: course-dept (x, Basket weaving) → easy- course(x)
4. course-dept (BKW301, Basket weaving)

Translate the above into Clauses

1. ~ easy-course (x)  likes(Steve, x) C1

Dept. of CSE, RNSIT 108


Artificial Intelligence, VII SEM, CSE, Module - II

2. ~ science-course (x)  hard course (x) C2

3. ~ course-dept (x, BW)  easy-course (x) C3

4. course-dept (BKW301,BW) C4

Using resolution to prove that “Steve likes BKW301”

Hence the Proof: Steve likes BKW301.

VI. Consider the following facts


a. The members of the Elm Steve Bridge club are Joe, sally, Bill and Ellen.
b. Joe is married to Sally.
c. Bill is Ellen’s Brother.
d. The spouse of every married person in the club is also in the club.
e. The last meeting of the club was at Joe’s house.

Represent the above facts in FOPL. Using resolution, prove that “Ellen is not married” OR
“Bill is not married”

Solution:

Translate the facts into wffs in FOPL

a. Member (Joe), Member(Sally), Member(Bill), Member(Ellen)


b. Married(Joe, Sally)
c. Brother (Bill, Ellen)
d. x, y: member (x)  married (x, y) → member(y)
e. x,y,t1,t2: members(x)  house(y)  owns(x, y)  meeting-held(y, t1)  gt(t2, t1)
→ owns (Joe, y)

Dept. of CSE, RNSIT 109


Artificial Intelligence, VII SEM, CSE, Module - II

Additional Premises to be assumed:

f. x,y,z: married (x, y) → ~ married(x, z)


g. x,y: Brother (x, y) → ~ married(x, y)
h. x,y: ~ married(x, y) → ~ member(y)  ~ marry(x)
i. x,y: ~ married(x, y) → ~ married(y, x)
j. x,y: married (x, y) → married(y, x)

Convert the above premises a to j into clauses

C1: member (Joe)

C2: member (Sally)


a
C3: member (Bill)

C4: member (Ellen)

C5: married (Joe, Sally) b

C6: Brother (Bill, Ellen) c

C7: ~ member(x)  ~ married(x, y)  member(y) d

C8: ~ married(x, y)  ~ married(x, z) f

C9: ~ Brother (x, y)  ~ married(x, y) g

C10: married(x, y)  ~ member (y) h

C11: married(x, y)  ~ married (x)

C12: married(x, y)  ~ married(y, x) i

C13: ~ married(x, y)  married(y, x) j

Note: e is not important.

Using resolution principle for giving Proof: “Ellen is not married”. OR Bill is not married.

Dept. of CSE, RNSIT 110


Artificial Intelligence, VII SEM, CSE, Module - II

Bill is not married. Hence the proof .

Simillarly,

Ellen is not married. Hence the proof.

VII. Translate the Following


1. Everyone is loyal to someone
2. Eatables are food
3. No employee earns more than the president
4. Some employees are sick today
5. People only try to assassinate someone they are not loyal to
6. All Romans were either loyal to Caesar or hated him.

Dept. of CSE, RNSIT 111


Artificial Intelligence, VII SEM,CSE, Module - II

Solution:
1. x, y: loyal (x, y)
2. x: eatables (x) → food(x)
3. x, y: employee(x)  president (y) → ~ greater (income(x), income(y))
4. x: employee(x)  sick(x)
5. x, y: person (x)  ruler someone(y)  try-assassinate (x, y) → ~ loyal(y, x)
6. x: Roman(x) → (loyal(x, Caesar)  hated (x, Caesar))

VIII. Represent the Following in FOPL

1. Everyone loves himself or herself


x: loves (x, x)
2. Everyone loves Everyone
x, y: loves (x, y)
3. Everyone loves someone
x, y: loves(x, y)
4. There is someone who loves every one
x, y: loves (x, y)
5. There is someone whom everyone loves
x, y: loves ( y, x)
6. Someone loves someone
x, y: loves (x, y)
7. Someone loves himself
x: loves (x, x)

IX. Consider the following facts in FOPL

1. Every bird sleeps in some tree.


2. Every Loon is a bird, and every loon is aquatic.
3. Every tree, in which any aquatic bird sleeps in, is beside some lake.
4. Anything that sleeps in anything, that is beside any lake eat fish.
Show the conclusion “every loon eat fish” using resolution principle.

Solution:

1. x, y: bird(x)  tree (y)  sleeps (x, y)


2. x: loon(x) →(bird(x)  aquatic (x))
3. x,y: tree(y)  aquatic (x)  bird(x) → beside(y, lake)
4. x,y: sleep(x, y)  beside(y, lake) → eat(x, fish)

Convert the above into Clauses


Dept. of CSE, RNSIT 112
Artificial Intelligence, VII SEM, CSE, Module - II

1. bird(x)  tree (f(x))  sleeps (x, f(x))


2. (~ loon(x)  bird(x))  (~ loon(x)  aquatic (x))
3. ~ tree(y)  ~aquatic (x)  ~ bird(x)  beside(y, lake)
4. ~ sleep(x, y)  ~ beside(y, lake)  eat(x, fish)

1. bird(x) – c1
2. tree (f(x)) – c2
3. sleeps (x, f(x)) – c3
4. ~ loon(x)  bird(x) – c4
5. ~ loon(x)  aquatic (x) – c5
6. ~ tree(y)  ~aquatic (x)  ~ bird(x)  beside(y, lake) – c6
7. ~ sleep(x, y)  ~ beside(y, lake)  eat(x, fish) – c7

To be proved: every loon eats fish


x: loon(x) →eat(x, fish)
~ loon(x)  eat(x, fish) (in CNF)

Every loon eats the fish - Hence the proof

Dept. of CSE, RNSIT 113


Artificial Intelligence, VII SEM, CSE, Module - II

X. Represent the following in FOPL

1. Lipton is a Tea
2. Latha is a child who drinks Tea
3. Rumpa dislikes children who drink Tea

Solution:

1. Tea (Lipton)
2. Child(Latha)  drinks (Latha, Tea)
3. x: child (x)  drinks (x, Tea) → dislikes(Rumpa, x)

From there, using modus ponen’s rule, we can prove that: “ Rumpa dislikes Latha”.

XI. Suppose that we are attempting to resolve the following clauses


C1
Loves (father (a), a)

~loves (y, x)  loves(x, y) C2

What will be the result of the unification algorithm when applied to C1 and first
term of C2 ?

Solution:
Let L1 = (loves, father (a), a)
L2 = (~ loves, y, x)
Call unify (L1, L2)
Result:
Subst = {father (a) / y, a / x} Unifier
Using this, if we resolve the clauses C1 & C2

Loves (father (a), a) ~loves(y, x)  loves(x, y)

Father (a)/y, a/x

Loves (a, father (a))

Another Example: hate(x, y)


Hate (Marens, z)
Could be unified with any of the following substitution:
(Marens/x, z/y)
(Marens/x, y/z)
(Marens/x, Caesar /y, Caesar /z)
(Marens/x, John/y, John/z)
Dept. of CSE, RNSIT 114
Artificial Intelligence, VII SEM, CSE, Module - II

XII. Did Curiosity kill the cat?


Given: Jack owns a dog. Every dog owner is an animal lover. No animal lover kills an
animal. Either Jack or Curiosity killed the cat, who is named Tuna. Did Curiosity
kill the cat?
Solution: The axioms can be represented as follows:
1. (x) Dog(x) ^ Owns(Jack, x)
2. (x) ((y) Dog(y) ^ Owns(x, y)) → AnimalLover(x)
3. (x) AnimalLover(x) → (y) Animal(y) → ~Kills(x,y)
4. Kills(Jack,Tuna)  Kills(Curiosity,Tuna)
5. Cat(Tuna)
6. (x) Cat(x) → Animal(x)
Proof:
1. Dog(spike)
2. Owns(Jack, spike)
3. ~Dog(y) v ~Owns(x, y) v AnimalLover(x)
4. ~AnimalLover(x1) v ~Animal(y1) v ~Kills(x1, y1)
5. Kills(Jack, Tuna) v Kills(Curiosity, Tuna)
6. Cat(Tuna)
7. ~Cat(x2) v Animal(x2)
8. ~Kills(Curiosity, Tuna) negated goal
9. Kills(Jack, Tuna) 5, 8
10. ~AnimalLover(Jack) V ~Animal(Tuna) 9, 4 x1/Jack, y1/Tuna
11. ~Dog(y) v ~Owns(Jack, y) V ~Animal(Tuna) 10, 3 x/Jack
12. ~Owns(Jack, spike) v ~Animal(Tuna) 11, 1
13. ~Animal(Tuna) 12, 2
14. ~Cat(Tuna) 12, 7 x2/Tuna
15. False 14, 6

XIII. Love Example


Given: There is a girl who is loved by every boy.
 X (girl(X)   Y (boy(Y) → loves(Y, X)))
Therefore prove that every boy loves some girl.
Negating this we obtain.
¬ Y (boy(Y) →  X (girl(X)  loves(Y, X)))

1.  X (girl(X)   Y(boy(Y) → loves(Y,X)))


- Eliminate →
 X (girl(X)   Y(¬boy(Y)  loves(Y,X)))
- Eliminate 
girl(c)   Y(¬boy(Y)  loves(Y,c))
- Eliminate 
Dept. of CSE, RNSIT 115
Artificial Intelligence, VII SEM, CSE, Module - II

girl(c)  (¬boy(Y)  loves(Y,c))


- Put into clausal form
{{girl(c)}, {¬boy(Y), loves(Y,c)}}

2. ¬ Y(boy(Y) → X (girl(X)  loves(Y,X)))


- Eliminate →
¬ Y (¬boy(Y)   X (girl(X)  loves(Y, X)))
- Move ¬ in as far as possible.
 Y (boy(Y)   X (¬girl(X)  ¬loves(Y, X)))
- Eliminate 
boy(b)   X (¬girl(X)  ¬loves(b, X)))
- Eliminate 
boy(b)  (¬girl(X)  ¬loves(b, X))
- Put into clausal form
{{boy(b)}, {¬girl(X), ¬loves(b, X)}}

Proof:

Dept. of CSE, RNSIT 116


Artificial Intelligence, VII SEM, CSE, Module - II

Chapter 6
REPRESENTING KNOWLEDGE USING RULES

Here, we discuss the use of rules to encode Knowledge. This is a particularly important issue since
rule-based reasoning systems have played a very important role in the evolution of AI from a purely
laboratory science into a commercially significant one.

 PROCEDURAL VERSUS DECLARATIVE KNOWLEDGE

 We viewed logical assertion as declarative representations of knowledge. In declarative


representation, the Knowledge is specified, but how to use that Knowledge 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. For example, a set of logical assertions can be combined with a
resolution theorem prover to give a complete program for solving problems. There is different
way, though, in which logical assertions can be viewed, namely as a program, rather than as data
to a program. In this view, the implication statements define the legitimate reasoning paths and
the atomic assertions provide the starting points (or, if we reason backward, the ending points)
of those paths. These reasoning paths define the possible execution paths of the program in much
the same way that traditional control constructs, such as if-then-else.
 In other words, we could view logical assertions as procedural representation of Knowledge.
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 the procedural
representation, we need to augment it with an interpreter that follows the instructions given in
the Knowledge. The real difference between the declarative and the procedural views of
Knowledge lies in where control information resides.
 For example, consider the Knowledge base:

Now, consider to extract answer to question from this knowledge base and bind that to y.

This knowledge base justifies any of the following answers.

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 the assertions are examined during
the search for a response.

Dept. of CSE, RNSIT 117


Artificial Intelligence, VII SEM, CSE, Module - II

 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:

Viewed declaratively, this is the same Knowledge base as above. All the same answers are
supported by the system and no one of them is explicitly selected. But viewed procedurally, and
using the control model we used to get y = Cleopatra as our answer.
 But this is a different Knowledge base since now the answer to our question is Marcus. This
happens because the first statement that can achieve the person goal is the inference rule
x: man(x) → person(x). This rule sets up a subgoal to find a man. Again the statements are
examined from the beginning, and now Marcus is found to satisfy the subgoal and thus also the
goal. So Marcus is reported as the answer.
 It is important to keep in mind that although we have said that a procedural representation
encodes control information in the Knowledge base, it does so only to the extent that the
interpreter for the Knowledge base recognizes that control information.
 There has been a great deal of controversy in AI over whether declarative or procedural
Knowledge representation frameworks are better. There is no clear-cut answer to the question.

 LOGIC PROGRAMMING

 Logic programming is a 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 PROLOG. A PROLOG program is described as a series of logical assertions, each of
which is a Horn clause. A Horn clause is clause that has at most one positive literal. Thus p,
PQ, and P→Q are all Horn clauses.
 Programs written in pure PROLOG are composed only of Horn clauses. Any logical expression
can be converted to clause form. If we do that for this example, the resulting clauses is PQ,
which is a well- formed Horn clause. The fact that PROLOG programs are composed only of
Horn clauses because of a simple and efficient interpreter can be written and the logic of Horn
clause systems is decidable.
 The control structure that is imposed on a PROLOG program by the PROLOG interpreter is the
same one used to find the answers Cleopatra and Marcus. The input to a program is a goal to be
proved. Backward reasoning is applied to try to prove the goal, given the assertions in the
program. The program is read top to bottom, left to right and depth-first search is performed
with backtracking.
 Figure below shows an example of a simple Knowledge base represented in standard logical
notation and then in PROLOG. Both of these representations contain two types of statements,
facts, which contain only constants and rules, which do contain variables. Facts represent
statements about specific objects. Rules represent statements about classes of objects.
Dept. of CSE, RNSIT 118
Artificial Intelligence, VII SEM, CSE, Module - II

Representation in logic

Representation in Prolog

 Notice that there are several superficial, syntactic differences between the logic and the
PROLOG representations, including:
1. In logic, variables are explicitly quantified. In PROLOG, quantification is provided implicitly
by the way the variables are interpreted. The distinction between variables and constants is
made in PROLOG by having all variables begin with upper case letters and all constants
begin with lower case letters or numbers.
2. In logic, there are explicit symbols for AND() and OR (). In PROLOG, there is an explicit
symbol for AND ( , ) but there is none for OR. Instead, disjunction must be represented as a
list of alternative statements, any one of which may provide the basis for a conclusion.
3. In logic, implications of the “p implies q” are written as p→q. In PROLOG, the same
implication is written “backward,” as q : - p. This form is natural in PROLOG because
the interpreter always works backwards from a goal, and this form causes every rule to begin
with the component that must therefore be matched first. This first component is called the
head of the rule.
 The first two of the above differences arise naturally from the fact that PROLOG programs are
actually sets of Horn clauses that have been transformed as follows:
1. If the Horn clause contains no negative literals (i.e., it contains a single literal which is
positive), then leave it as it is.
2. 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 (if there is one)
as the consequent.
 This procedure causes a clause, which originally consisted of a disjunction of literals to be
transformed into a single implication whose antecedent is a conjunction of literals. Further, recall
that in a clause, all variables are implicitly universally quantified. But, when we apply this
transformation, any variables that occurred in negative literals and so now occur in the antecedent
become existentially quantified, while the variables in the consequent (the head) are still
universally quantified. For example, the PROLOG clause P(x) : - Q(x, y) is equivalent to the
logical expression x: y: Q(x, y) → P(x)

Dept. of CSE, RNSIT 119


Artificial Intelligence, VII SEM, CSE, Module - II

 A key difference between logic and the PROLOG representation is that the PROLOG interpreter
has a fixed control strategy, and so the assertions in the PROLOG program define a particular
search path to an answer to any question. In contrast, the logical assertions define only the set
of answers that they justify and they themselves say nothing about how to choose among those
answers if there is more than one.
 The basic PROLOG control strategy outlined above is simple. Begin with a problem statement,
which is viewed as a goal to be proved. Look for assertions that can prove the goal. Consider
facts, which prove the goal directly, and also consider any rule whose head matches the goal.
To decide whether a fact or a rule can be applied to the current problem, invoke a standard
unification procedure. Reason backward from that goal until a path is found that terminates with
assertions in the program. Consider paths using a depth-first search strategy with
backtracking. At each choice point, consider options in the order in which they appear,
propagating variable (X). We state this goal to PROLOG as
?- apartmentpet (X).
Think of binding as they are determined during unification. We can illustrate this strategy with
a simple example. Suppose the problem we are given is to find a value of X that satisfy the
predicate apartmentpet as the input to the program. The PROLOG interpreter begins looking for
a fact with the predicate apartmentpet or a rule with that predicate as its head. Usually
PROLOG programs are written with the facts containing a given predicate coming before the
rules for that predicate so that the facts can be used immediately if they are appropriate and rules
will only be used when the desired fact is not immediately available.
 Using the rules about dogs and poodles and using the fact poodle (fluffy). This results in the
variable X being bound to fluffy. Now the second clause small(X) of the initial rule must be
checked. Since X is now bound to fluffy, the more specific goal, small (fluffy), must be proved.
This too can be done by reasoning backward to the assertion poodle (fluffy). The program then
halts with the result apartmentpet(fluffy).
 Logical negation () cannot be represented explicitly in pure PROLOG. So, for example, it is not
possible to encode directly the logical assertion x: dog(x) → cat(x). Instead, negation is
represented implicitly by the lack of an assertion. This leads to the problem- solving strategy
called negation as failure. If the PROLOG program of figure above were given the goal it would
return FALSE because it is unable to prove that Fluffy is cat. ?- cat (fluffy).
 Negation by failure requires that we make what is called the closed world assumption, which
states that all relevant, true assertions are contained in our knowledge base are derivable from
assertions that are so contained. Any assertion that is not present can therefore be assumed to be
false.
 There is much to say on the topic of PROLOG –style versus LISP- style programming. A great
advantage of logic programming is that the programmer need only specify rules and facts since a
search engine is built directly into the language. The disadvantage is that the search control is
fixed. Although it is possible to write PROLOG code that uses search strategies other than depth-
first with backtracking, it is difficult to do so.

Dept. of CSE, RNSIT 120


Artificial Intelligence, VII SEM, CSE, Module - II

 More generally, the fact that PROLOG programs must be composed of a restricted set of logical
operators can be viewed as a limitation of the expressiveness of the language. But the other side
of the coin is that it is possible to build PROLOG compilers that produce very efficient code.

 FORWARD VERSUS BACKWARD REASONING

 The objective of a search procedure is to discover a path through a problem space from an initial
configuration to a goal state. PROLOG only searches from a goal state. There are actually two
directions in which such search could proceed.
– Forward, from the start states
– Backward, from the goal states
 The production system model of the search process provides an easy way of viewing forward and
backward reasoning as symmetric process. Consider the problem of solving a particular instance
of the 8-puzzle. The rules to be used for solving the puzzle can be written as shown in Figure
below.

Example: Start state Goal State

 Reasoning forward from the initial states begins building a tree of move sequence that might be
solutions by starting with the initial configurations(s) at 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
sides to create the new configurations. Generate the next level by taking each node generated at the
previous level and applying to it all of the rules whose left sides match it. Continue until a
configuration that matches the goal state is generated.

Dept. of CSE, RNSIT 121


Artificial Intelligence, VII SEM, CSE, Module - II

 Reasoning backward from the goal states begins building a tree of move sequences that might
be solutions by starting with the goal configurations(s) at the root of the tree. Generate the next
level of the tree by finding all the rules whose right sides match the root node. These are all rules
that, if only we could apply them, would generate the state we want. Use the left sides of the rules
to generate the nodes at this second level of the tree. Generate the next level of the tree by taking
each node at the previous level and finding all the rules whose right sides match it. Then use the
corresponding left sides to generate the new nodes. Continue until a node that matches the initial
state is generated. This method of reasoning backward from the desired final state is often called
goal-directed reasoning.
 Notice that the same rules can be used both to reason forward from the initial state and to reason
backward from the goal state. To reason forward, the left sides (the preconditions) are matched
against the current state and the right sides (the results) are used to generate new nodes until the
goal is reached. To reason backward, the right sides are matched against the current node and the
left sides are used to generate new nodes representing new goal states to be achieved. This
continues until one of these goal states is matched by an initial state.
 In the case of the 8-puzzle, it does not make much difference whether we reason forward or
backward, about the same number of paths will be explored in either case. But this is not always
true. Depending on the topology of the problem space, it may be significantly more efficient to
search in one direction rather than the other.
 Four factors influence, the question of whether it is better to reason forward or backward.
– 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.
– In which direction is the branching factor greater? We would like to proceed in the
direction with the lower branching factor.
– Will the program be asked to justify its reasoning process to a user? If so, it is important
to proceed in the direction that corresponds more closely with the way the user will think.
– What kind of event is going to trigger a problem-solving episode? If it is the arrival of a
new fact, forward reasoning makes sense. If it is a query to which a response is desired,
backward reasoning is more natural.
 A few examples make these issues clearer. It seems easier to drive from unfamiliar place to home
than from home to an unfamiliar place. Consider again the problem of proving theorems in some
particularly domain of mathematics. Our goal states the particular theorem to be proved. This
suggests that it would be much better to reason backward when trying to prove theorems.
 The factor that determines the direction in which search should proceed is the need to generate
coherent justifications of the reasoning process as it proceeds. This is often crucial for the
acceptance of programs for the performance of very important tasks. For example, doctors are
unwilling to accept the advice of a diagnostic program that cannot explain its reasoning to the
doctors’ satisfaction. This issue was of concern to the designers of MYCIN, a program that
diagnoses infectious diseases. It reasons backward from its goal of determining the cause of a
patient’s illness. To do that, it uses rules that tell it such things as “if the organism has the
following set of characteristics as determined by the lab results, then it is likely that it is
organism x.” by reasoning backward using such rules, the program can answer questions like
Dept. of CSE, RNSIT 122
Artificial Intelligence, VII SEM, CSE, Module - II

“why should I perform that test you just asked for?” With such answers as “Because it would
help to determine whether organism x is present.”
 We can also search both forward from the start state and backward from the goal
simultaneously until two paths meet somewhere in between. This strategy is called bidirectional
search. It seems appealing if the number of nodes at each step grows exponentially with the
number of steps that have been taken. Figure below shows why bidirectional search may be
ineffective. The two searches may pass each other, resulting in more work than it would have
taken for one of them, on its own, to have finished.

 Although in principle the same set of rules can be used for 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


PROLOG is an example for Backward ‒ Chaining rule systems, of which, are good for goal-
directed problem- solving. For example, a query system would probably use backward chaining to
reason about and answer user questions. In PROLOG, rules are restricted to Horn Clauses. This
allows for rapid indexing because all of the rules for deducing a given fact share the same rule head.
Rules are matched with the unification procedure. Unification tries to find a set of bindings for
variables to equate a (sub) goal with the head of some rule. Rules in a PROLOG program are
matched in the order in which they appear. Other backward‒chaining systems allow for more
complex rules. Example is MYCIN

 Forward‒Chaining Rule Systems


Instead of being directed by goals, we want to be directed by incoming data. For example, suppose
you sense burning heat near your hand. You are likely to jerk your hand away. While this could be
construed as goal‒directed behavior, it is modeled more naturally by the recognize‒act cycle
characteristic of forward‒chaining rule systems. In forward‒chaining 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 typically more complex for forward‒chaining
systems than backward ones. Most forward‒chaining systems (e.g., OPS5) implement highly
efficient matchers and supply several mechanisms for preferring one rule over another.

Dept. of CSE, RNSIT 123


Artificial Intelligence, VII SEM, CSE, Module - II

 Combining Forward and Backward Reasoning


Sometimes certain aspects of a problem are best handled via forward chaining and other aspects
by backward chaining. Consider a forward chaining medical diagnosis program. It might accept
twenty or so facts about a patient’s condition, then forward chain on those facts to try to deduce the
nature and/or cause of the disease. Now suppose that at some point, the left side of a rule was nearly
satisfied-say, nine out of ten of its preconditions were met. It might be efficient to apply backward
reasoning to satisfy the tenth precondition in a directed manner, rather than wait for forward
chaining to supply the fact by accident. Or perhaps the tenth condition requires further medical
tests. In that case, backward chaining can be used to query the user. Whether it is possible to use the
same rules for both forward and backward reasoning also depends on the form of the rules
themselves. If both left sides and right sides contain pure assertions, then forward chaining can
match assertions on the left side of a rule and add to the state description the assertions on the right
side.

 MATCHING

The process of using search to solve problems as the application of appropriate rules to
individual problem states to generate new states, then to which the rules can then be applied, and
so forth, until a solution is found. The clever search involves choosing from among the rules that
can be applied at a particular point, the ones that are most likely to lead to a solution. But how to
extract from the entire collection of rules those that can be applied at a given point?. To do so
requires some kind of matching between the current state and the preconditions of the rules. How
should this be done? The answer to this question can be critical to the success of a rule-based
system. We discuss a few proposals below.

 Indexing
One way to select applicable rules is to do a simple search through all the rules, comparing each
one’s preconditions to the current state and extracting all the ones that match. But there are two
problems with this simple solution:
– In order to solve very interesting problems, it will be necessary to use a large number of
rules. Scanning through all of them at every step of the search would be inefficient.
– It is not always immediately obvious whether a rule’s preconditions are satisfied by a
particular state.
 Sometimes 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. For example, consider the legal-move generation rule for chess shown in figure
below to be able to access the appropriate rules immediately, all we need to do is assign and
index to each board position. This can be done simply by treating the board description as a
large number. Any reasonable hashing function can then be used to treat that number as an
index into the rules. It is often better to write rules in a more general form, such as that shown in
figure below.

Dept. of CSE, RNSIT 124


Artificial Intelligence, VII SEM, CSE, Module - II

Rules 


When this is done, such simple indexing is not possible. In fact, there is often a trade-off between
the ease of writing rules and the simplicity of matching process. All of this does not mean that
indexing cannot be helpful even when the preconditions of rules are started as fairly high-level
predicates.

 Matching with Variables


One efficient many-many match algorithm is RETE, which gains efficiency from three major
sources:
 The temporal nature of data: Rules usually do not alter the state description completely.
Instead, a rule will typically add one or two elements, or perhaps delete one or two, but most
of the state description remains the same. If a rule did not match in the previous cycle, it will
most likely fail to apply in the current cycle. RETE maintains a network of rule conditions, and
it uses changes in the state description to determine which new rules might apply and which rules
might no longer apply. Full matching is only pursued for candidates that could be affected by
incoming or outgoing data.

 Structural similarity in rules: Different rules may share a large number of pre-conditions. For
example, consider rules for identifying wild animals. One rule concludes Jaguar(x) if
mammal(x), feline (x), carnivorous (x), and has-spots(x). Another rule concludes tiger(x) and

Dept. of CSE, RNSIT 125


Artificial Intelligence, VII SEM, CSE, Module - II

is identical to the first rule except that it replaces has-spots with has-stripes. If we match two
rules independently, we will repeat a lot of work unnecessarily. RETE stores the rules so that
they share structures in memory: sets of conditions that appear in several rules are matched once
per cycle.

 Persistence of variable binding consistency: While all the individual preconditions of a rule
might be met, there may be variable binding conflicts that prevent the rule from firing. For
example, suppose we know the facts son(Mary, Joe) and son(Bill, Bob). The individual
preconditions of the rule can be matched but not in a manner that satisfies the constraint imposed
by the variable y. Son(x, y)  son(y, z) → grandparent (x, z)

 Complex and Approximate Matching


 An even more complex matching process is required if rules should be applied if their
preconditions approximately match the current situation. This is the case in situations involving
physical descriptions of the world. For example, a speech-understanding program must contain
rules that map from a description of a physical wave form to phones (instances of English
phonemes, such as p or d). There is so much variability in physical signal, as result of
background noise, differences in the way individuals speak, and so forth, that one can hope to
find only an approximate match between the rule that describes an ideal sound and the input that
describes an unideal world. Approximate matching is particularly difficult to deal with because
as increasing the size of the main search process. For example, in ELIZA, an early AI program
that simulated the behavior of a Rogerian Therapist. A fragment of a dialogue between ELIZA
and a user is shown in figure below. ELIZA’s knowledge about both English and psychology
was coded in a set of simple rules.

Dept. of CSE, RNSIT 126


Artificial Intelligence, VII SEM, CSE, Module - II

Figure below shows some ELIZA-like rules.

 ELIZA operated by matching the left sides of the rules against the user’s last sentence and using
the appropriate right side to generate a response. For example, if the user typed “My brother is
mean to me”, ELIZA might respond, “Who else in your family is mean to you?” or “tell me
more about your family”. The rules were indexed by key words so only a few had actually to
be matched against a particular sentence.

 Conflict Resolution
 The result of the matching process is a list of rules whose antecedents have matched the
current state description along with whatever variable bindings were generated by the matching
process. It is the job of the search method to decide on the order in which rules will be applied.
But sometimes it is useful to incorporate some of that decision making into the matching process.
This phase of the matching process is then called conflict resolution.
There are three basic approaches to the problem of conflict resolution in a production system:
Assign a preference based on the rule that matched.
Assign a preference based on the objects that matched.
Assign a preference based on the action that the matched rule would perform.

Preferences Based on Rules


There are two common ways of assigning a preference based on the rules themselves. The
first, and simplest, is to consider the rules to have been specified in a particular order, such
as the physical order in which they are presented to the system. Then priority is given to the
rules in the order in which they appear. This is the scheme used in PROLOG. The other
common rule-directed preference scheme is to give priority to special case rules over rules
that are more general. In the case of the water jug problem rule 11 and 12 were special cases

Dept. of CSE, RNSIT 127


Artificial Intelligence, VII SEM, CSE, Module - II

of rules 9 and 5, respectively. The purpose of such specific rules is to allow for the kind of
knowledge that expert problem solvers use when they solve problems directly, without
search.

Preferences Based on Objects


Another way in which the matching process can ease the burden on the search mechanism is
to order the matches it finds based on the importance of the objects that are matched. There
are a variety of ways this can happen. Consider again ELIZA, which matched patterns
against a user’s sentence in order to find a rule to generate a reply. The patterns looked for
specific combinations of important keywords. Often an input sentence contained several of
the keywords that ELIZA knew. If that happened, then ELIZA made use of the fact that some
keywords had been marked as being more significant than others. The pattern matcher
returns the match involving the highest priority keyword. For example, ELIZA knew the
word “I” as a keyword. Matching the input sentence “I Know everybody laughed at me”
by the keyword “I” would have enabled it to respond, “You say you know everybody
laughed at you”. But ELIZA also knew the word “everybody” as a keyword. Because
“everybody” occurs more rarely than “I”, ELIZA knows it to be more semantically
significant and thus to be the clue to which it should respond. So it will produce a response
such as “who in particular are you thinking of?” this was true for ELIZA and would also
be true.

Preferences Based on States


Suppose that there are several rules waiting to fire. One way of selecting among them is to
fire all of them temporarily and to examine the results of each. Then, using a heuristic
function, that can evaluate each of the resulting states, compares the merits of the results, and
it select the preferred one. Throw away or may be keep for later if necessary the remaining
ones.

 CONTROL KNOWLEDGE

 In large knowledge bases that contain thousands of rules, the intractability of search is an
overriding concern. When there are many possible paths of reasoning, it is critical that fruitless
once not be pursued. Knowledge about which paths are most likely to lead quickly to a goal state
is often called search control knowledge. It can take many forms:

1. Knowledge about which states are more preferable to others.


2. Knowledge about which rule to apply in a given situation.
3. Knowledge about the order in which to pursue subgoals.
4. Knowledge about useful sequences of rules to apply.

 The first type of Knowledge could be represented with heuristic evaluation functions. There are
many ways of representing the other types of control Knowledge. For example, rules can be
Dept. of CSE, RNSIT 128
Artificial Intelligence, VII SEM, CSE, Module - II

labeled and partitioned. A medical diagnoses system might have one set rules for reasoning
about bacteriological disease and another set for immunological disease.
 Another method is to assign to cost and probability– of – success measures to rules. The
problem-solver can then use probabilistic decision analysis to choose a cost-effective
alternative at each point in the search.
 Now it should be clear that how to represent Knowledge about Knowledge. For this reason,
search control Knowledge is sometimes called meta-knowledge. The syntax for one type of
control rule is shown in figure below.

Syntax for control rule

 A number of AI systems represent their control Knowledge with rules. We look briefly at two
such systems, SOAR and PRODIGY. In SOAR:
1. Long-term memory is stored as a set of productions/rules.
2. Short-term memory (working memory) is a buffer that is affected by perceptions and
serves as a storage area for facts deduced by rules in long-term memory. Working memory
is analogous to the state descriptions in problem solving.
3. All problem-solving activity takes place as state space traversal. There are several classes
of problem-solving activities, including reasoning about which states to explore, which
rules to apply in a given situation, and what effects those rules will have.
4. All intermediate and final results of problem solving are remembered for future
differences.

 The third future is of most interest to us here. When SOAR is given a start state and a goal
state, it sets up an initial problem space. In order to take the first step in that space, it must
choose a rule from the set of applicable ones. Instead of employing a fixed conflict resolution
strategy, SOAR considers that choice of rules to be important problem in its own and it actually
sets up another, auxiliary problem space.

Dept. of CSE, RNSIT 129


Artificial Intelligence, VII SEM, CSE, Module - II

 PRODIGY is a general-purpose problem-solving system that incorporates several different


learning mechanisms. A good deal of the learning in PRODIGY is directed at automatically
constructing a set of control rules to improve search in a particular domain. PRODIGY can
acquire control rules in a number of ways:
– Through hand coding by programmers.
– Through a static analysis of the domain’s operators.
– Through looking at traces of its own problem-solving behavior.
 PRODIGY learns control rules from its experience, but unlike SOAR it also learns from its
failures. If PRODIGY pursues on unfruitful path, it will try to come up with an explanation of
why that path failed. It will then use that explanation to build control knowledge that will help
it avoid fruitless search paths in the future.

Dept. of CSE, RNSIT 130


Artificial Intelligence, VII SEM,CSE, Module - II

RNS Institute of Technology, Bengaluru – 98


Department of Information Science and Engineering
7th Semester
Question Bank

1. Define a) Knowledge Base b) Logic


2. What are the four properties that every knowledge representation scheme/method should
possess? Explain the following four approaches for knowledge representation with an
example for each
a) Simple relational knowledge b) Inheritable knowledge
c) Inferential knowledge and d) Procedural knowledge
3. What are the issues in knowledge representation?
4. Explain the frame problem.
5. Give the BNF notation for sentences (Wffs) in Propositional Logic with examples.
6. Define the following with examples in respect of sentences/wffs in Propositional logic
a. Logical Equivalence b. Validity or Tautology
c. Satisfiability or Contingency d. Contradiction
Decide whether each of the following sentences is valid, unsatisfiable or neither
i. (Smoke → Fire) → (Smoke → Fire)
ii. (Smoke  Heat) → Fire) ( (Smoke → Fire) V (Heat → Fire))
iii. (Big  Dumb) V Dumb
7. List and Explain the reasoning patterns or Inference rules in propositional logic with examples
8. Describe the steps in converting a sentence in propositional logic into Conjunctive Normal
Form(CNF) with the example: P  ( Q V R)
9. What do you mean by a Clause and Horn Clause? Write the Resolution algorithm for
propositional logic
10. Discuss the forward and backward chaining/reasoning algorithms in propositional logic
11. List the drawbacks of propositional logic.
12. What are the components of First-order Logic? Explain each with an example
13. Represent the following sentences in First-order Logic using consistent vocabulary
a. Some students took French in Spring 2001
b. Every student who takes French passes it
c. Only one student took Greek in Spring 2001
14. Give algorithm for Resolution in propositional and predicate logic
15. Give algorithm for converting a sentence in First-order logic into Clausal Form with an
example.
16. Represent the following sentences in First-order logic. Convert them into Clauses and prove that
“ Did Curiosity Kill the Cat ? “ using resolution
a. Everyone who loves animals is loved by some one
b. Anyone who kills animal an animal is loved by no one
c. Jack loves all animals
d. Either Jack or Curiosity killed the cat who is named Tuna
17. Discuss the Resolution Strategies in FOPL that helps in finding the proofs efficiently.
18. Translate the following statements into WFFs using predicate logic.
a) Everyone is loyal to someone.

Dept. of CSE, RNSIT 14


Artificial Intelligence, VII SEM,CSE, Module - II
b) People only try to assassinate someone they are not loyal to.
c) All Romans were either loyal to Caesar or hated him.
d) Eatables are food.
19. Look at the following sentences
a. Marcus was a Man b. Marcus was a Pompeian c. Marcus was born in 040 AD
d. All men are mortal e. All Pompeian’s died in 079 AD
f. No mortal lives for more than 150 years g. Now it is 2003 AD
Convert them into predicate logic. Is it possible to prove that "Marcus is not alive now"? If not,
what additional data is to be assumed? Assume them and prove that "Marcus is not alive now".
20. Consider the following sentences:
i. John likes all kinds of food. ii. Bananas are food.
iii. Rice is food. iv. Anything any one eats and is not killed by is food.
v. Vikki eats apple and is still alive. vi. Varun eats everything Vikki eats.
a) Translate these sentences into predict logic formula (Part-1)
b) Convert the formulae (Part- 1) into clause form. Prove that “John likes apple” using
resolution
21. Sam, Clyde and Oscar are elephants. Given the following statements
I. Sam is pink II. Clyde is gray and likes Oscar
III. Oscar is either pink or gray (But not both) and likes Sam.
Represent the above as Wffs in FOPL. Prove that a gray elephant likes a pink elephant.
22. Consider the following axioms:
 Every bird sleeps in some tree.
 Every loon is a bird, and every loon is aquatic.
 Every tree in which any aquatic bird sleeps is beside some lake.
 Anything that sleeps in anything that is beside any lake eats fish.
Show the conclusion “Every loon eat fish” using resolution principle.
23. Convert the following formula (WFF) to clause form [explain all the steps]

x: [Roman (x) Ʌ know (x, Marcus) ]


[hate (x, Caesar ) V (y,  Z: hate (y, Z) think crazy (y, x))]
24. Translate the following sentence in to CNF: “There exists a dog which doesn’t produce milk”.
25. Represent the following facts as predicates and convert them to clause form
a. Any student who is intelligent or hardworking will pass the exam with good marks
b. Anyone who is passed with good marks get a job
26. Explain with examples the procedure versus declarative knowledge?
27. What is logic programming? Explain with an appropriate example.
28. What is forward and back ward reasoning? Explain with examples.
29. What is bidirectional search? How it is not suitable in some situations.
30. What is matching? Explain matching with Indexing and variables.
31. Explain complex and approximate matching?
32. What is the meaning of conflict resolution? Explain.
33. What do you mean by control knowledge? Explain important concepts of it with examples.

Dept. of CSE, RNSIT 15

You might also like