UNIT-2 Logical Reasoning
UNIT-2 Logical Reasoning
LOGICAL REASONING
KNOWLEDGE REPRESENTATION
First Order Predicate Logic Prolog Programming Unification Forward Chaining-
Backward Chaining Resolution Knowledge Representation Ontological Engineering-
Categories and Objects Events Mental Events and Mental Objects Reasoning Systems for
Categories Reasoning with Default Information.
Propositional logic is a declarative language because its semantics is based on a truth relation
between sentences and possible worlds. It also has sufficient expressive power to deal with
partial information, using disjunction and negation.
First-Order Logic is a logic which is sufficiently expressive to represent a good deal of our
common sense knowledge.
FOL adopts the foundation of propositional logic with all its advantages to build a more
expressive logic on that foundation, borrowing representational ideas from natural language
while avoiding its drawbacks.
1. Nouns and noun phrases that refer to objects (Squares, pits, rumpuses)
2. Verbs and verb phrases that refer to among objects ( is breezy, is adjacent to)
68
3.1 SPECIFY THE SYNTAX OF FIRST-ORDER LOGIC IN BNF FORM
The domain of a model is DOMAIN the set of objects or domain elements it contains.
The domain is required to be nonempty every possible world must contain at least one object.
Figure 8.2 shows a model with five objects: Richard the Lionheart, King of England from 1189
to 1199; his younger brother, the evil King John, who ruled from 1199 to 1215; the left legs of
Richard and John; and a crown. The objects in the model may be related in various ways. In
the figure, Richard and John are brothers. Formally speaking, a relation TUPLE is just the set
of tuples of objects that are related. (A tuple is a collection of objects arranged in a fixed order
and is written with angle brackets surrounding the objects.) Thus, the brotherhood relation in
this model is the set
The crown is on
that is,
they relate pairs of objects. Certain kinds of relationships are best considered as functions, in
that a given object must be related to exactly one object in this way. For example, each person
mappings:
69
The five objects are,
The objects in the model may be related in various ways, In the figure Richard and John
are brothers.
Formally speaking, a relation is just the set of tuples of objects that are related.
A tuple is a collection of Objects arranged in a fixed order and is written with angle
brackets surrounding the objects.
Thus, the brotherhood relation in this model is the set {(Richard the Lionheart, King
John),(King John, Richard the Lionheart)}
The c
(the crown, King John).
Certain kinds of relationships are best considered as functions that relates an object to
exactly one object.
The basic syntactic elements of first-order logic are the symbols that stand for objects,
relations and functions
Kinds of Symbols
70
o Symbols will begin with uppercase letters
o The choice of names is entirely up to the user
o Each predicate and function symbol comes with an arity
o Arity fixes the number of arguments.
Richard refers to Richard the Lion heart and John refers to the evil King John.
Brother refers to the brotherhood relation, that is the set of tuples of objects given in
equation {(Richard the Lionheart, King John),(King John, Richard the
Lionheart)}
On Head
Person, King and Crown refer to the set of objects that are persons, kings and crowns.
71
Term A term is a logical expression that refers TERM to an object. Constant symbols
are therefore terms, but it is not always convenient to have a distinct symbol to name every
giving a name to his leg. This is what function symbols are for: instead of using a constant
symbol, we use Left Leg (John). The formal semantics of terms is straightforward. Consider a
term f(t1, . . . , tn). The function symbol f refers to some function in the model. Atomic
sentences Atomic sentence (or atom for short) is formed from a predicate symbol optionally
followed by a parenthesized list of terms, such as Brother (Richard, John). Atomic sentences
can have complex terms as arguments. Thus, Married (Father (Richard),Mother (John)) states
Complex Sentences
We can use logical connectives to construct more complex sentences, with the same
syntax and semantics as in propositional calculus
Quantifiers
Universal quantification ( )
-order logic as
x King(x) Person(x)
ground term.
Consider the model shown in Figure 8.2 and the intended interpretation that goes with
it. We can extend the interpretation in five ways:
72
The universally quantified sentence x King(x) Person(x) is true in the original
model if the sentence King(x) Person(x) is true under each of the five extended
interpretations. That is, the universally quantified sentence is equivalent to asserting the
following five sentences:
son.
The crown is a king the crown is a person.
Existential quantification ( )
Universal quantification makes statements about every object. Similarly, we can make
a statement about some object in the universe without naming it, by using an existential
quantifier. To say, for example, that King John has a crown on his head, we write
x P is true in a given model if P is true in at least one extended interpretation that assigns x to
a domain element. That is, at least one of the following is true:
The fifth assertion is true in the model, so the original existentially quantified sentence
is true in the model. Just as appears to be the natural connective to use with , is the natural
connective to use with .
Using as the main connective with led to an overly strong statement in the example
in the previous section; using with usually leads to a very weak statement, indeed. Consider
the following sentence:
Applying the semantics, we see that the sentence says that at least one of the following
assertions is true:
73
and so on. Now an implication is true if both premise and conclusion are true, or if its premise
is false. So if Richard the Lionheart is not a crown, then the first assertion is true and the
existential is satisfied. So, an existentially quantified implication sentence is true whenever any
object fails to satisfy the premise
Nested quantifiers
We will often want to express more complex sentences using multiple quantifiers. The
simplest case is where th
can be written as
Consecutive quantifiers of the same type can be written as one quantifier with several
variables. For example, to say that siblinghood is a symmetric relationship, we can write
x, y Sibling(x, y) Sibling(y, x)
x y Loves(x, y).
y x Loves(x, y).
x ( y Loves(x, y)) says that everyone has a particular property, namely, the property
that they love someone. On the other hand,
y ( x Loves(x, y)) says that someone in the world has a particular property, namely
the property of being loved by everybody.
The two quantifiers are actually intimately connected with each other, through negation.
Asserting that everyone dislikes parsnips is the same as asserting there does not exist someone
who likes them, and vice versa:
ice cream:
74
Equality
We can use the equality symbol to signify that two terms refer to the same object. For
example,
Father (John)=Henry
says that the object referred to by Father (John) and the object referred to by Henry are the
same.
The equality symbol can be used to state facts about a given function, as we just did for
the Father symbol. It can also be used with negation to insist that two terms are not the same
object. To say that Richard has at least two brothers, we would write
Figure 3.2 Formal languages and their ontological and epistemological commitments
The basic syntactic elements of first-order logic are the symbols that stand for objects,
relations, and functions. The symbols, come in three kinds:
We adopt the convention that these symbols will begin with uppercase letters. Example:
Constant symbols :
Richard and John;
predicate symbols :
Brother, On Head, Person, King, and Crown; function symbol : LeftLeg.
75
Quantifiers
Universal quantification
where
Thus, the sentence says, "For all x, if x is a king, then is a person." The symbol x is called a
variable(lower case letters)
The sentence x P, where P is a logical expression says that P is true for every object x.
76
The universally quantified sentence is equivalent to asserting the following five sentences
Existential quantification
It is possible to make a statement about some object in the universe without naming
it,by using an existential quantifier.
Example
x Crown(x) ^ OnHead(x,John)
Nested Quantifiers
77
For Example:-
Consecutive quantifiers of the same type can be written as one quantifier with
78
To specify the agent's task, we specify its percepts, actions, and goals. In the wumpus
world, these are as follows:
In the square containing the wumpus and in the directly (not diagonally)
adjacent squares the agent will perceive a stench.
In the squares directly adjacent to a pit, the agent will perceive a breeze.
In the square where the gold is, the agent will perceive a glitter.
When an agent walks into a wall, it will perceive a bump.
When the wumpus is killed, it gives out a woeful scream that can be perceived
anywhere in the cave.
The percepts will be given to the agent in the form of a list of five symbols; for
example, if there is a stench, a breeze, and a glitter but no bump and no scream,
the agent will receive the percept [Stench, Breeze, Glitter, None, None]. The
agent cannot perceive its own location.
Just as in the vacuum world, there are actions to go forward, turn right by 90°,
and turn left by 90°. In addition, the action Grab can be used to pick up an object
that is in the same square as the agent. The action Shoot can be used to fire an
arrow in a straight line in the direction the agent is facing. The arrow continues
until it either hits and kills the wumpus or hits the wall. The agent only has one
arrow, so only the first Shoot action has any effect.
The wumpus agent receives a percept vector with five elements. The corresponding
first order sentence stored in the knowledge base must include both the percept and the time at
which it occurred; otherwise, the agent will get confused about when it saw what. We use
integers for time steps. A typical percept sentence would be
Here, Percept is a binary predicate, and Stench and so on are constants placed in a list.
The actions in the wumpus world can be represented by logical terms:
which returns a binding list such as {a/Grab}. The agent program can then return Grab
as the action to take. The raw percept data implies certain facts about the current state.
For example:
79
These rules exhibit a trivial form of the reasoning process called perception. Simple
Given the percept and rules from the preceding paragraphs, this would yield the desired
conclusion
BestAction(Grab, 5) that is, Grab is the right thing to do. For example, if the agent is
at a square and perceives a breeze, then that square is breezy:
It is useful to know that a square is breezy because we know that the pits cannot move
about. Notice that Breezy has no time argument. Having discovered which places are breezy
(or smelly) and, very important, not breezy (or not smelly), the agent can deduce where the pits
are (and where the wumpus is). first-order logic just needs one axiom:
3.3 SUBSTITUTION
The rule of Universal Instantiation (UI for short) says that we can infer any sentence
obtained by substituting a ground term (a term without variables) for the variable.
Let
the rule is written
In the rule for Existential Instantiation, the variable is replaced by a single new constant
80
x Crown(x) OnHead(x, John) we can infer the sentence
Crown(C1) OnHead(C1, John)
EXAMPLE
Then we apply UI to the first sentence using all possible ground-term substitutions from
the vocabulary of the knowledge base in this case,
and we discard the universally quantified sentence. Now, the knowledge base is essentially
propositional if we view the ground atomic sentences
King(John),
Greedy(John), and so on as proposition symbols.
3.4 UNIFICATION
Lifted inference rules require finding substitutions that make different logical
expressions look identical. This process is called unification and is a key component of all first-
order inference algorithms. The UNIFY algorithm takes two sentences and returns a unifier for
them if one exists: where .
Suppose we have a query AskVars(Knows(John, x)): whom does John know? Answers
can be found by finding all sentences in the knowledge base that unify with Knows(John, x).
Here are the results of unification with four different sentences that might be in the
knowledge base: UNIFY(Knows(John, x), Knows(John, Jane)) = {x/Jane}
The last unification fails because x cannot take on the values John and Elizabeth at the
same time. Now, remember that Knows(x, Elizabeth)
we should be able to infer that John knows Elizabeth. The problem arises only because the two
sentences happen to use the same variable name, x. The problem can be avoided by
81
standardizing apart one of the two sentences being unified, which means renaming its variables
to avoid name clashes. For example, we can rename x in
Knows(x, Elizabeth) to x17 (a new variable name) without changing its meaning.
For example,
The first unifier gives Knows(John, z) as the result of unification, whereas the second
gives Knows(John, John). The second result could be obtained from the first by an additional
substitution {z/John}; we say that the first unifier is more general than the second, because it
places fewer restrictions on the values of the variables. An algorithm for computing most
general unifiers is shown in Figure.
unifier along the way, but failing if two corresponding points in the
structures do not match. There is one expensive step: when matching a variable against a
complex term, one must check whether the variable itself occurs inside the term; if it does, the
match fails because no consistent unifier can be constructed.
82
In artificial intelligence, forward and backward chaining is one of the important topics,
but before understanding forward and backward chaining lets first understand that from where
these two terms came.
Inference engine
The inference engine is the component of the intelligent system in artificial intelligence,
which applies logical rules to the knowledge base to infer new information from known facts.
The first inference engine was part of the expert system. Inference engine commonly proceeds
in two modes, which are:
a. Forward chaining
b. Backward chaining
Horn clause and definite clause are the forms of sentences, which enables knowledge
base to use a more restricted and efficient inference algorithm. Logical inference algorithms
use forward and backward chaining approaches, which require KB in the form of the first-order
definite clause.nt
Definite clause: A clause which is a disjunction of literals with exactly one positive
literal is known as a definite clause or strict horn clause.
Horn clause: A clause which is a disjunction of literals with at most one positive
literal is known as horn clause. Hence all the definite clauses are horn clauses.
A. Forward Chaining
The Forward-chaining algorithm starts from known facts, triggers all rules whose
premises are satisfied, and add their conclusion to the known facts. This process repeats until
the problem is solved.
Properties of Forward-Chaining
83
o Forward-chaining approach is also called as data-driven as we reach to the goal
using available data.
o Forward -chaining approach is commonly used in the expert system, such as CLIPS,
business, and production rule systems.
Consider the following famous example which we will use in both approaches:
Example
"As per the law, it is a crime for an American to sell weapons to hostile nations. Country
A, an enemy of America, has some missiles, and all the missiles were sold to it by Robert, who
is an American citizen."
To solve the above problem, first, we will convert all the above facts into first-order
definite clauses, and then we will use a forward-chaining algorithm to reach the goal.
o It is a crime for an American to sell weapons to hostile nations. (Let's say p, q, and r
are variables)
American (p) weapon(q) sells (p, q, r) (1)
o Robert is American
American(Robert). (8)
84
Forward chaining proof
Step-1
In the first step we will start with the known facts and will choose the sentences which
do not have implications, such as: American (Robert), Enemy(A, America), Owns(A, T1), and
Missile(T1). All these facts will be represented as below.
Figure 3.5
Step-2
At the second step, we will see those facts which infer from available facts and with
satisfied premises.
Rule-(1) does not satisfy premises, so it will not be added in the first iteration.
Rule-(4) satisfy with the substitution {p/T1}, so Sells (Robert, T1, A) is added, which infers
from the conjunction of Rule (2) and (3).
Rule-(6) is satisfied with the substitution(p/A), so Hostile(A) is added and which infers from
Rule-(7).
Figure 3.6
Step-3
At step-3, as we can check Rule-(1) is satisfied with the substitution {p/Robert, q/T1,
r/A}, so we can add Criminal (Robert) which infers all the available facts. And hence we
reached our goal statement.
85
Figure 3.7
B. Backward Chaining
Example
In backward-chaining, we will use the same above example, and will rewrite all the rules.
86
o Missile(T1)
o ?p Missiles(p) (4)
o (5)
o (6)
Backward-Chaining proof
In Backward chaining, we will start with our goal predicate, which is Criminal (Robert),
and then infer further rules.
Step-1
At the first step, we will take the goal fact. And from the goal fact, we will infer other
facts, and at last, we will prove those facts true. So our goal fact is "Robert is Criminal," so
following is the predicate of it.
Step-2
At the second step, we will infer other facts form goal fact which satisfies the rules. So
as we can see in Rule-1, the goal predicate Criminal (Robert) is present with substitution
{Robert/P}. So we will add all the conjunctive facts below the first level and will replace p
with Robert.
Figure 3.8
87
Step-3
t At step-3, we will extract further fact Missile(q) which infer from Weapon(q), as it
satisfies Rule-(5). Weapon (q) is also true with the substitution of a constant T1 at q.
Figure 3.9
Step-4
At step-4, we can infer facts Missile(T1) and Owns(A, T1) form Sells(Robert, T1, r)
which satisfies the Rule- 4, with the substitution of A in place of r. So these two statements are
proved here.
Figure 3.10
88
Step-5
At step-5, we can infer the fact Enemy(A, America) from Hostile(A) which satisfies
Rule- 6. And hence all the statements are proved true using backward chaining.
Figure 3.11
Suppose you have a production system with the FOUR rules: R1: IF A AND C then F
R2: IF A AND E, THEN G R3: IF B, THEN E R4: R3: IF G, THEN D and you have four initial
Resolution
Resolution is used, if there are various statements are given, and we need to prove a
conclusion of those statements. Unification is a key concept in proofs by resolutions.
Resolution is a single inference rule which can efficiently operate on the conjunctive normal
form or clausal form.
Clause: Disjunction of literals (an atomic sentence) is called a clause. It is also known
as a unit clause.
89
Steps for Resolution
To better understand all the above steps, we will take an example in which we will
apply resolution.
Example
a. John likes all kind of food.
b. Apple and vegetable are food
c. Anything anyone eats and not killed is food.
d. Anil eats peanuts and still alive
e. Harry eats everything that Anil eats. Prove by resolution that:
f. John likes peanuts.
In the first step we will convert all the given statements into its first order logic.
o
1. x ¬ food(x) V likes(John, x)
2.
3. x killed(x)] V food(y)
4.
5. x ¬ eats(Anil, x) V eats(Harry, x)
6. x¬ [¬ killed(x) ] V alive(x)
7. x ¬ alive(x) V ¬ killed(x)
8. likes(John, Peanuts).
90
o Move negation (¬)inwards and rewrite
1. x ¬ food(x) V likes(John, x)
2.
3. x y ¬ eats(x, y) V killed(x) V food(y)
4.
5. x ¬ eats(Anil, x) V eats(Harry, x)
6. x ¬killed(x) ] V alive(x)
7. x ¬ alive(x) V ¬ killed(x)
8. likes(John, Peanuts).
o Drop Universal quantifiers. In this step we will drop all universal quantifier since all
the statements are not implicitly quantified so we don't need it.
1. ¬ food(x) V likes(John, x)
2. food(Apple)
3. food(vegetables)
4. ¬ eats(y, z) V killed(y) V food(z)
5. eats (Anil, Peanuts)
6. alive(Anil)
7. ¬ eats(Anil, w) V eats(Harry, w)
8. killed(g) V alive(g)
9. ¬ alive(k) V ¬ killed(k)
10. likes(John, Peanuts).
o Distribute conjunction over disjunction ¬.This step will not make any change in
this problem.
91
Step-3: Negate the statement to be proved
In this statement, we will apply negation to the conclusion statements, which will be
written as ¬likes(John, Peanuts)
o Now in this step, we will solve the problem by resolution tree using substitution. For
the above problem, it will be given as follows:
Figure 3.12
o In the first step of resolution graph, ¬likes(John, Peanuts), and likes(John, x) get
resolved (canceled) by substitution of {Peanuts/x}, and we are left with ¬
food(Peanuts)
o In the second step of the resolution graph, ¬ food (Peanuts), and food(z) get resolved
(canceled) by substitution of { Peanuts/z}, and we are left with ¬ eats(y, Peanuts) V
killed(y).
o In the third step of the resolution graph, ¬ eats(y, Peanuts) and eats (Anil, Peanuts) get
resolved by substitution {Anil/y}, and we are left with Killed(Anil).
o In the fourth step of the resolution graph, Killed(Anil) and ¬ killed(k) get resolve by
substitution {Anil/k}, and we are left with ¬ alive(Anil).
92
o In the last step of the resolution graph ¬ alive(Anil) and alive(Anil) get resolved.
Table 3.1
8. Example Example
or or
Concepts such as Events, Time, Physical Objects, and Beliefs that occur in many
different domains. Representing these abstract concepts is sometimes called ontological
engineering.
93
Figure 3.13 The upper ontology of the world, showing the topics to be
covered later in the chapter. Each link indicates that the lower concept is a
specialization of the upper one. Specializations are not necessarily disjoint;
a human is both an animal and an agent, for example.
For example, a shopper would normally have the goal of buying a basketball, rather
than a particular basketball such as BB9 There are two choices for representing categories in
first-order logic: predicates and objects. That is, we can use the predicate Basketball (b), or we
can reify1 the category as an object, Basketballs.
94
BB9 Basketballs
A category is a subclass of another category. Basketballs Balls
All members of a category have some properties.
Notice that because Dogs is a category and is a member of Domesticated Species, the
latter must be a category of categories. Categories can also be defined by providing necessary
and sufficient conditions for membership. For example, a bachelor is an unmarried adult male:
Physical Composition
We use the general PartOf relation to say that one thing is part of another. Objects can
be grouped into part of hierarchies, reminiscent of the Subset hierarchy:
BunchOf (s): x x s PartOf (x, BunchOf (s)) Furthermore, BunchOf (s) is the
smallest object satisfying this condition. In other words, BunchOf (s) must be part of
any object that has all the elements of s as parts:
95
Measurements
In both scientific and commonsense theories of the world, objects have height, mass,
cost, and so on. The values that we assign for these properties are called measures.
Length(L1)=Inches(1.5)=Centimeters(3.81)
Similar axioms can be written for pounds and kilograms, seconds and days, and dollars
and cents. Measures can be used to describe objects as follows:
Diameter (Basketball12)=Inches(9.5)
ListPrice(Basketball12)=$(19)
d Days Duration(d)=Hours(24)
Time Intervals
Event calculus opens us up to the possibility of talking about time, and time intervals.
We will consider two kinds of time intervals: moments and extended intervals. The distinction
is that only moments have zero duration:
Partition({Moments,ExtendedIntervals}, Intervals )
i Moments Duration(i)=Seconds(0)
The functions Begin and End pick out the earliest and latest moments in an interval,
and the function Time delivers the point on the time scale for a moment.
The function Duration gives the difference between the end time and the start time.
Interval (i)
Time(Begin(AD1900))=Seconds(0)
Time(Begin(AD2001))=Seconds(3187324800)
Time(End(AD2001))=Seconds(3218860800)
Duration(AD2001)=Seconds(31536000)
Two intervals Meet if the end time of the first equals the start time of the second. The
complete set of interval relations, as proposed by Allen (1983), is shown graphically in Figure
12.2 and logically below:
Meet(i,j) End(i)=Begin(j)
Before(i,j) End(i) < Begin(j)
After (j,i) Before(i, j)
During(i,j) Begin(j) < Begin(i) < End(i) < End(j)
96
Overlap(i,j) Begin(i) < Begin(j) < End(i) < End(j)
Begins(i,j) Begin(i) = Begin(j)
Finishes(i,j) End(i) = End(j)
Equals(i,j) Begin(i) = Begin(j) End(i) = End(j)
3.7 EVENTS
Event calculus reifies fluents and events. The fluent At(Shankar, Berkeley) is an
object that refers to the fact of Shankar being in Berkeley, but does not by itself say anything
about whether it is true. To assert that a fluent is actually true at some point in time we use the
predicate T, as in T(At(Shankar, Berkeley), t). Events are described as instances of event
categories. The event E1 of Shankar flying from San Francisco to Washington, D.C. is
described as E1 Flyings Flyer (E1, Shankar ) Origin(E1, SF) Destination (E1,DC)
we can define an alternative three-argument version of the category of flying events and say
E1 Flyings(Shankar, SF,DC) We then use Happens(E1, i) to say that the event E1 took
place over the time interval i, and we say the same thing in functional form with Extent(E1)=i.
We represent time intervals by a (start, end) pair of times; that is, i = (t1, t2) is the time interval
that starts at t1 and ends at t2. The complete set of predicates for one version of the event
calculus is T(f, t) Fluent f is true at time t Happens(e, i) Event e happens over the time interval
i Initiates(e, f, t) Event e causes fluent f to start to hold at time t Terminates(e, f, t) Event e
causes fluent f to cease to hold at time t Clipped(f, i) Fluent f ceases to be true at some point
during time interval i Restored (f, i) Fluent f becomes true sometime during time interval i We
assume a distinguished event, Start, that describes the initial state by saying which fluents are
initiated or terminated at the start time. We define T by saying that a fluent holds at a point in
time if the fluent was initiated by an event at some time in the past and was not made false
(clipped) by an intervening event. A fluent does not hold if it was terminated by an event and
not made true (restored) by another event. Formally, the axioms are:
Happens(e, (t1, t2)) Initiates(e, f, t1) Clipped(f, (t1, t)) t1 < t T(f,
t)Happens(e, (t1, t2)) Terminates(e, f, t1) Restored (f, (t1, t)) t1 < t T(f, t)
97
where Clipped and Restored are defined by Clipped(f, (t1, t2)) e, t, t3 Happens(e,
(t, t3)) Terminates(e, f, t) Restored (f, (t1, t2)) e, t, t3 Happens(e, (t,
t3)) Initiates(e, f, t)
The model does not have to be detailed. We do not have to be able to predict how many
milliseconds it will take for a particular agent to make a deduction. We will be happy just to be
able to conclude that mother knows whether or not she is sitting.
We begin with the propositional attitudes that an agent can have toward mental objects:
attitudes such as Believes, Knows, Wants, Intends, and Informs. The difficulty is that these
For example, suppose we try to assert that Lois knows that Superman can fly: Knows
(Lois, CanFly(Superman)) One minor issue with this is that we normally think of
CanFly(Superman) as a sentence, but here it appears as a term. That issue can be patched up
just be reifying CanFly(Superman); making it a fluent. A more serious problem isthat, if it is
true that Superman is Clark Kent, then we must conclude that Lois knows that Clark can fly:
(Superman = Clark) Knows(Lois, CanFly(Superman)) |= Knows(Lois, CanFly (Clark))
Modal logic is designed to address this problem. Regular logic is concerned with a single
operator for knowledge. It takes two arguments, an agent (written as the subscript) and a
sentence. The syntax of modal logic is the same as first-order logic, except that sentences can
also be formed with modal operators. In first-order logic a model contains a set of objects and
an interpretation that maps each name to the appropriate object, relation, or function. In modal
is Clark Kent, she does know that Clark knows: KLois [KClark Identity(Superman, Clark )
98
KClark Identity(Superman, Clark )] Figure 3.15 shows some possible worlds for this
domain, with accessibility relations for Lois and Superman
Figure 3.15
In the TOP-LEFT diagram, it is common knowledge that Superman knows his own
identity, and neither he nor Lois has seen the weather report. So in w0 the worlds w0 and w2
are accessible to Superman; maybe rain is predicted, maybe not. For Lois all four worlds are
But she does know that Superman knows whether he is Clark, because in every world that is
accessible to Lois, either Superman knows I, or he knows I. Lois does not know which is the
case, but either way she knows Superman knows. In the TOP-RIGHT diagram it is common
knowledge that Lois has seen the weather report. So in w4 she knows rain is predicted and in
w6 she knows rain is not predicted. Superman does not know the report, but he knows that Lois
knows, because in every world that is accessible to him, either she knows R or she knows
R. In the BOTTOM diagram we represent the scenario where it is common knowledge that
Superman knows his identity, and Lois might or might not have seen the weather report. We
represent this by combining the two top scenarios, and adding arrows to show that Superman
arrows for her. In w0 Superman still knows I but not R, and now he does not know whether
Lois knows R. From what Superman knows, he might be in w0 or w2, in which case Lois does
not know whether R is true, or he could be in w4, in which case she knows R, or w6, in which
case she knows R.
99
This section describes systems specially designed for organizing and reasoning with
categories. There are two closely related families of systems: semantic networks provide
graphical aids for visualizing a knowledge base and efficient algorithms for inferring properties
of an object on the basis of its category membership; and description logics provide a formal
language for constructing and combining category definitions and efficient algorithms for
deciding subset and superset relationships between categories.
There are many variants of semantic networks, but all are capable of representing
individual objects, categories of objects, and relations among objects. A typical graphical
notation displays object or category names in ovals or boxes, and connects them with labeled
links. For example, Figure 12.5 has a Member Of link between Mary and Female Persons,
corresponding to the logical assertion Mary FemalePersons ; similarly, the SisterOf link
between Mary and John corresponds to the assertion SisterOf (Mary, John). We can connect
categories using SubsetOf links, and so on. We know that persons have female persons as
mothers, so can we draw a HasMother link from Persons to FemalePersons? The answer is no,
because HasMother is a relation between a person and his or her mother, and categories do not
have mothers. For this reason, we have used a special notation the double-boxed link in
Figure 12.5. This link asserts that x x Persons [ y HasMother (x, y) y FemalePersons
] We might also want to assert that persons have two legs that is, x x Persons Legs(x,
2) The semantic network notation makes it convenient to perform inheritance reasoning. For
example, by virtue of being a person, Mary inherits the property of having two legs. Thus, to
find out how many legs Mary has, the inheritance algorithm followsthe MemberOf link from
Mary to the category she belongs to, and then follows SubsetOf links up the hierarchy until it
finds a category for which there is a boxed Legs link in this case, the Persons category.
Inheritance becomes complicated when an object can belong to more than one category
or when a category can be a subset of more than one other category; this is called multiple
inheritance. The drawback of semantic network notation, compared to first-order logic: the fact
100
that links between bubbles represent only binary relations. For example, the sentence
Fly(Shankar, NewYork, NewDelhi, Yesterday) cannot be asserted directly in a semantic
network. Nonetheless, we can obtain the effect of n-ary assertions by reifying the proposition
itself as an event belonging to an appropriate event category. Figure 12.6 shows the semantic
network structure for this particular event. Notice that the restriction to binary relations forces
the creation of a rich ontology of reified concepts. One of the most important aspects of
semantic networks is their ability to represent.
One of the most important aspects of semantic networks is their ability to represent
default values for categories. Examining Figure 3.6 carefully, one notices that John has one
leg, despite the fact that he is a person and all persons have two legs. In a strictly logical KB,
this would be a contradiction, but in a semantic network, the assertion that all persons have two
legs has only default status; that is, a person is assumed to have two legs unless this is
contradicted by more specific information
We also include the negated goal Criminal (West). The resolution proof is shown in
Figure 3.18.
101
Figure 3.18 A resolution proof that West is a criminal. At each step,
the literals that unify are in bold.
Notice
clauses from the knowledge base until the empty clause is generated. This is characteristic of
resolution on Horn clause knowledge bases. In fact, the clauses along the main spine
correspond exactly to the consecutive values of the goals variable in the backward-chaining
algorithm of Figure. This is because we always choose to resolve with a clause whose positive
exactly what
happens in backward chaining. Thus, backward chaining is just a special case of resolution
with a particular control strategy to decide which resolution to perform next.
EXAMPLE 2
Our second example makes use of Skolemization and involves clauses that are not
definite clauses. This results in a somewhat more complex proof structure. In English, the
problem is a follows:
102
Now we apply the conversion procedure to convert each sentence to CNF:
The resolution proof that Curiosity kills the cat is given in Figure. In English, the proof
could be paraphrased as follows:
Suppose Curiosity did not kill Tuna. We know that either Jack or Curiosity did; thus
Jack must have. Now, Tuna is a cat and cats are animals, so Tuna is an animal. Because anyone
who kills an animal is loved by no one, we know that no one loves Jack. On the other hand,
Jack loves all animals, so someone loves him; so we have a contradiction. Therefore Curiosity
killed the cat.
Figure 3.19 A resolution proof that Curiosity killed that Cat. Notice then use
of factoring in the derivation of the clause Loves(G(Jack), Jack). Notice also
in the upper right, the unification of Loves(x,F(x)) and Loves(Jack,x) can
only succeed after the variables have been standardized apart
The
little more work to obtain the answer. The goal is w Kills (w, Tuna), which, when negated
become Kills (w, Tuna) in CNF, Repeating the proof in Figure with the new negated goal,
we obtain a similar proof tree, but with the substitution {w/Curiosity} in one of the steps. So,
in this case, finding out who killed the cat is just a matter of keeping track of the bindings for
the query variables in the proof.
EXAMPLE 3
103
2. All happy people smile.
3. Someone is graduating.
4. Conclusion: Is someone smiling?
Solution
(v) Eliminate
1. x graduating(x) vhappy(x)
2. x happy(y) vsmile(y)
104
3. graduating(name1)
4. w smile(w)
(vi) Eliminate
1. graduating(x) vhappy(x)
2. happy(y) vsmile(y)
3. graduating(name1)
4. smile(w)
EXAMPLE 4
Explain the unification algorithm used for reasoning under predicate logic with an
example. Consider the following facts
a. Team India
b. Team Australia
c. Final match between India and Australia
d. India scored 350 runs, Australia scored 350 runs, India lost 5 wickets, Australia
lost 7 wickets.
f. If the scores are same the team which lost minimum wickets wins the match.
105
Solution
(v) Eliminate
(a) team(India)
(b) team(Australia)
(c) team(India) v team(Australia) v final_match (India,Australia)
(d) score(India,350) ^ score(Australia,350) ^ wicket(India,5) ^ wicket(Australia,7)
(e) team(x) v wins(x) vscore(x, max_runs))
(f) score(x,equal(y)) v wicket(x,min_wicket) v-final_match(x,y)) vwin(x)
(vi) Eliminate
106
(vii) Convert to conjunct of disjuncts form.
EXAMPLE 5
Problem 3
107
Solution
(i)
1. company(ABC) ^employee(500,ABC)
2. x (company(ABC) ^employee(x,ABC) ^ earns(x,5000)) v pays(x,tax)
3. manager(John,ABC)
4. x manager(x, ABC) v earns(x,10000)
(v) Eliminate
1. company(ABC) ^employee(500,ABC)
2. company(ABC) v employee(x,ABC) v earns(x,5000) v pays(x,tax)
3. manager(John,ABC)
4. manager(x, ABC) v earns(x,10000)
(vi) Eliminate
108
(viii) Make each conjunct a separate clause.
1. (a) company(ABC)
(b) employee(500,ABC)
2. company(ABC) v employee(x,ABC) v earns(x,5000) v pays(x,tax)
3. manager(John,ABC)
4. manager(x, ABC) v earns(x,10000)
Problem 4
If a perfect square is divisible by a prime p then it is also divisible by square of p.
Every perfect square is divisible by some prime.
36 is a perfect square.
1.
109
2. x y perfect)sq(x) ^prime(y) ^divides(x,y)
3. perfect_sq(36)
Problem 5
Example
Trace the operation of the unification algorithm on each of the following pairs of literals:
In propositional logic it is easy to determine that two literals can not both be true at the
same time. Simply look for L and ~L. In predicate logic, this matching process is more
complicated, since bindings of variables must be considered.
For example man (john) and man(john) is a contradiction while man (john) and
man(Himalayas) is not. Thus in order to determine contradictions we need a matching
procedure that compares two literals and discovers whether there exist a set of substitutions
that makes them identical. There is a recursive procedure that does this matching. It is called
Unification algorithm.
110
In Unification algorithm each literal is represented as a list, where first element is the
name of a predicate and the remaining elements are arguments. The argument may be a single
element (atom) or may be another list. For example we can have literals as
To unify two literals, first check if their first elements re same. If so proceed. Otherwise
they can not be unified. For example the literals
Can not be Unfied. The unification algorithm recursively matches pairs of elements,
one pair at a time. The matching rules are :
ii) A variable can match another variable, any constant or a function or predicate
expression, subject to the condition that the function or [predicate expression
must not contain any instance of the variable being matched (otherwise it will
lead to infinite recursion).
iii) The substitution must be consistent. Substituting y for x now and then z for x
later is inconsistent (a substitution y for x written as y/x).
The Unification algorithm is listed below as a procedure UNIFY (L1, L2). It returns a
list representing the composition of the substitutions that were performed during the match. An
empty list NIL indicates that a match was found without any substitutions. If the list contains
a single value F, it indicates that the unification procedure failed.
111
4. For I = 1 to number of elements in L1 do
Consider a knowledge base containing just two sentences: P(a) and P(b). Does this
knowledge base entail x P(x)? Explain your answer in terms of models.
The knowledge base does not entail x P(x). To show this, we must give a model
where P(a) and P(b) but x P(x) is false. Consider any model with three domain elements,
where a and b refer to the first two elements and the relation referred to by P holds only for
those two elements.
What is ontological commitment (what exists in the world) of first order logic?
Ontological commitment means what assumptions language makes about the nature if
x, y [Brother (x, y)
Siblings (x, y)]
Following are the comparative differences versus first order logic and propositional
logic.
112
propositional logic, but it also has variables for individual objects, quantifier,
symbols for functions and symbols for relations.
Illustrate the use of first order logic to represent knowledge. The best way to find usage
of First order logic is through examples. The examples can be taken from some simple domains.
In knowledge representation, a domain is just some part of the world about which we wish to
express some knowledge. Assertions and queries in first-order logic Sentences are added to a
knowledge base using TELL, exactly as in propositional logic. Such sentences are called
assertions. For example, we can assert that John is a king and that kings are persons: Where
KB is knowledge base. TELL(KB, x King(x) => Person(x)). We can ask questions of the
knowledge base using AS K. For example, returns true. Questions asked using ASK are called
queries or goals ASK(KB, Person(John)) Will return true. (ASK KBto find whether Jon is a
king) ASK (KB, x person(x)) The kinship domain The first example we consider is the domain
of family relationships, or kinship. This domain includes facts such as "Elizabeth is the mother
of Charles" and "Charles is the father of William7' and rules such as "One's grandmother is the
mother of one's parent." Clearly, the objects in our domain are people. We will have two unary
predicates, Male and Female. Kinship relations-parenthood, brotherhood, marriage, and so on-
will be represented by binary predicates: Parent, Sibling, Brother, Sister, Child, Daughter, Son,
Spouse, Husband, Grandparent, Grandchild, Cousin, Aunt, and Uncle. We will use functions
for Mother and Father.
113