0 ratings0% found this document useful (0 votes) 28 views46 pagesUnit 3
Knowledge Representation–First Order Predicate Logic – Prolog Programming–Unification– Forward Chaining – Backward – Chaining – Resolution – Knowledge Representation – Onto logical Engineering–Categories and Objects–Events–Mental Events and Mental Objects– Reasoning Systems for Categories–Reasoning with Default Information.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
UNIT 3
KNOWLEDGE REPRESENTATION
First Order Predicate Logie — 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.
First order Logic
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.
* It is also either includes or forms the foundation of many other representation
languages.
* Its also called as First-Order Predicate calculus.
© Itis abbreviated as FOL or FOPC
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.
syntax of natural language contains elements such as,
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)
‘ations in which the
‘Some of these relations are functions is only one “Value” for a
given “input”, Whereas propositional logic assumes the world contains facts, first-order logic
ssumes the world contains Objects: people, houses, numbers, colors,
(like natural language) a
baseball games, wars,
Relations: red, round, prime, brother of, bigger than, part of, comes between,
Functions: father of, best friend, one more than, plus,
683.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
{ Richard the Lionheart, King John>, ¢ King John, Richard the Lionheart> }
Figure 3.1 First-Order Logic in BNF Form
The crown is on King John’s head, so the “on head” relation contains just one tuple, _
the crown, King John_, The “brother” and “on head” relations are binary relations — 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
hhas one left leg, so the model has @ unary “left leg” function that includes the following
mappings:
Richard the Lionheart> — Richard's left leg
«King John> — John’s left leg
69‘The five objects are,
Richard the Lionheart
His younger brother
The evil King John
The left legs of Richard and John
Actown
* 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 crown is on King John’s head, so the “on head” relation contains just one tuple,
(the crown, King John),
© Therelation can be binary relation relating pairs of objects (Ex:- “Brother”) or unary
relation representing a common object (Ex:- “Person” representing both Richard
and John)
Certain kinds of relationships are best considered as functions that relates an object to
exactly one object,
For Example:- each person has one left leg, so the model has @ unary “left leg” function
> Richard’s left leg
that includes the following mappings (Richard the Lionheart)
(King John) —> John’s left leg
Symbols and Interpretations:
‘The basic syntactic elements of first-order logic are the symbols that stand for objects,
relations and functions
Kinds of Symbols
The symbols come in three kinds namely,
Constant Symbols standing for Objects (Ex:- Richard)
Predicate Symbols standing for Relations (Ex:- King)
Function Symbols stands for funetions (Ex:-Left Leg)
70© Symbols will begin with uppercase letters,
© The choice of names is entirely up to the user
0 Each predicate and function symbol comes with an arity
© Arity fixes the number of arguments.
‘The semantics must relate sentences to models in order to determine truth,
To do this, an interpretation is needed specifying exactly which objets, relations and
functions are referred to by the constant, predicate and function symbols.
One possible interpretation called as the intended interpretation- is as follows;
Richard refers to
ard 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 Jobn),(King John, Richard the
Lionheart)}
(On Head refers to the “on head” relation that holds between the crown and King John;
Person, King and Crown refer to the set of objects that are persons, kings and crowns,
Leff leg refers to the “left leg” function, that is, the mapping given in {(Richard the
Lion heart, King John), (King John, Richard the Lionheart)}
A complete description from the formal grammar is as follows
Sentence + AtomicSentence
| (Sentence Connective Sentence )
| Quantifier Variabie,... Sentence
| Sentence
AlomicSentence + Praticate(Term,...)| Term= Term
Term —+ Panetion(Term,...)
| Constant
| Variable
Connective +
Ale le
Ouansifier > 713
Constant + A| Xi] John|
Variable ~ af x| sf.
Predicate —+ Before | HasColor | Raining |
Function —+ Mother | Leftleg |
nTerm 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 distinet symbol to name every
‘object. For example, in English we might use the expression “King John’s left leg” rather than
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 fitl, . . ., tm). 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
that Richard the Lionheart’s father is married to King John’s mother.
Complex Sentences
We can use logical connectives to construct more complex
syntax and semantics as in propositional calculus
“Brother (LeftLeg (Richard), John)
Brother (Richard, John) A Brother (John, Richard)
King(Richard ) v King John)
—King(Richard) > King(John).
Quantifiers
Quantifiers are used to express properties of entire collections of objects, instead of
enumerating the objects by name. First-order logic contains two standard quantifiers, called
universal and existential
Universal quantification (¥)
“All kings are persons,” is written in first-order logic as
Vx King(x) => Person(x)
“For all x, if x is a king,
V is usually pronounced “For all. ..” Thus, the sentene
then x is @ person.” The symbol x is called a variable. A term with no variables is called a
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:
x — Richard the
jonheart,
x — King John, x — Richard’s left leg,
x — John’s left leg,
x= the crown.
n¢ universally quantified sentence V 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:
Richard the Lionheart is a king => Richard the Lionheart is a person.
King John is a king = King John is a person.
Richard’s left leg is a king => Richard’s left leg is a person,
John’s left leg is a king = John’s left leg is a person.
‘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
2 Crown(s) AOnHead(s, John)
3x is pronounced “There exists an x such that ...” or “For some x...” More precisely,
3x 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:
Richard the Lionheart is a crown A Richard the Lionheart is on John’s head;
King John is a crown A King John is on John’s head;
Richard’s left leg is a crown A Richard’s left leg is on John’s head;
John’s left leg is a crown A.John’s left leg is on John’s head;
The crown is a crown A the crown is on John’s head.
The fifth assertion is true in the model, so the original existentially quantified sentence
rue in the model. Just as = appears to be the natural connective to use with V, A is the natural
connective to use with 3
Using A as the main connective with V led to an overly strong statement in the example
in the previous section; using = with 3 usually leads to a very weak statement, indeed. Consider
the following sentence:
3x Crown(x) >OnHead(x, John)
Applying the semantics, we see that the sentence says that at least one of the following,
assertions is true:
Richard the Lionheart is a crown = Richard the Lionheart is on John’s head;
on John’s head;
Richard’s left leg is a crown = Richard’s left leg is on John’s head;
King John is a crown = King Johi
RBand 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 the quantifiers are of the same type. For example, “Brothers are siblings”
‘can be written as
vey Brother (x, y) = Sibling(x, »)
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
Vi» Sibling(x, y) €2 Sibling(y, x). In other cases we will have mixtures
loves somebody” means that for every person, there is someone that person loves:
Vey Loves(, y).
‘On the other hand, to say “There is someone who is loved by everyone,” we write
yx Loves(, y).
‘The order of quantification is therefore very important. It becomes clearer if we insert
parentheses.
¥ (Fy Loves(x, y)) says that everyone has a particular property, namely, the property
that they love someone. On the other hand,
3y (Wx Loves(s, y)) says that someone in the world has a particular property, namely
the property of being loved by everybody.
Connections between Vand 7
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
Va Likes(x, Parsnips ) is equivalent to
VaeLikes(x, Parsnips ) is equivalent to 74 x Likes(x, Parsnips). We can go one
step further: “Everyone likes ice cream” means that there is no one who does not like
Vx Likes(x, IceCream) is equivalent to 4 x TLikes(x, IeeCream).
14Equality
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
2s, y Brother (x,Richard ) A Brother (j,Richard ) AXx=y).
Compare different knowledge representation languages
Language
(Ontological Commaitisent
(Wat exists in the world)
Epistemological Commitment
(What an agent believes about facts)
Propositionallogic
Fistorderlogic
Temporal logic
Probabiliny theory
Fuzzy logic
cts objects. relations
ste objects relations, times
facts
facts with degnee of truth ¢ [0,1
trucfalse/omknown
trucfalsefumkmown
trueifalse/unimovin
degree of belief ¢ [0,1]
snow terval value
Figure 3.2 Formal languages and their ontological and epistemological commitments
‘What are the syntactic elements of First Order Logic?
The basic syntactic elements of first-order logie are the symbols that stand for objects,
relations, and functions. The symbols, come in three kinds:
a) constant symbols, which stand for objects;
b) predicate symbols, which stand for relations;
©) and function symbols, which stand for functions
‘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
BsQuantifiers
Quantifiers are used to express properties of entire collections of objects, instead of
enumerating the objects by name if a logic that allows object is found.
thas two type,
The following are the types of standard quantifiers,
Universal
Existential
Universal quantification
Explain Universal Quantifiers with an example.
Rules such as "All kings are persons," is written in first-order logic as
Ox King(x) => Person(x)
where(] is pronounced as
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)
that P is true for every object x.
‘The sentence (Ix P, where P is a logical expr
‘© Universal Quantification make statement about every object,
© “All Kings are persons”, is written in first-order logic as
Vs king (x) = Person (x)
‘© Vis usually pronounced “For all... Thus the sentences says . “For all x, if xis @
king, then x is a person!
‘© The symbol x is called a variable.
A variable is a term all by itself, and as such can also serve as the argument of a
function-for example, LeftLeg(s).
‘© A term with no variables is called a ground term.
Based on our model, we can extend the interpretation in five ways,
Richard the Lionheart
King John
-- Richard’s Left lez
John’s Left leg
— the crown,
16‘The universally quantified sentence is equivalent to asserting the following five sentences
Richard the Lionheart
King John is a King ~---- King John is a Person
Richards left leg is King
John’s left leg is a King ~
Richard the Lionheart is a person
Richards left leg is a person
John’s left leg is a person
The crown is a Person
The crown is a King
Existential quantification
Universal quantification makes statements about every object.
It is possible to make a statement about some object in the universe without naming
iby using an existential quantifier.
Example
“King John has a crown on his head”
x Crown(x) * OnHead(x,John)
Ux is pronounced “There exists an x such that..” or “ For some x
Existential Quantification (3):
© An existential quantifier is used make a statement about some object in the
‘universe without naming i
= To say, for example
(8) A OnFfead (x, John)
‘¢ 3eis pronounced "There exists an x such that.” or “For some x
‘© Consider the following sentence,
it King Jon has a crown ow his bead, write 3x crown
3, crown (x) > OnHead (s,Fohn)
‘© Applying the semantics says that at Least one ofthe following assestion is tue
Richard the Lionheart is a esown A Richard the Liouheast is on John's head
King John is Crown ‘A King John is on Jol’ head
Richard's let leg isacrown A Riclinrd’s left leg is on John’s head
Joln’s let leg isa crown A John’s left leg ison John’s head
The crown is acrown /\ The crown is on John's head
‘© Now an implication is une if both premise and conclusion are true, ot if its
premise is false.
Nested Quantifiers
More complex sentences are expressed using multiple quantifiers
‘The following are the some
‘The s
of multiple quanti
implest case where the quantifiers are of the same type
1For Example:- “Brothers are Siblings” can be written as
VeWy, Brother (x,y) > sibling (
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 as
Vx sibling (x,y) © sibling (y.2)
3.2. THE WUMPUS WORLD
‘The wumpus world is a cave consisting of rooms connected by passageways. Lurking
somewhere in the cave is the terrible wumpus, a beast that eats anyone who enters its room.
‘The wumpus can be shot by an agent, but the agent has only one arrow. Some rooms contain
bottomless pits that will trap anyone who wanders into these rooms (except for the wumpus,
which is too big to fall in). The only mitigating feature of this bleak environment is the
possibility of finding a heap of gold. Although the wumpus world is rather tame by modem
computer game standards, it illustrates some important points about intelligence. A sample
‘wumpus world is shown in Figure
hy
fp
Stench
’
an
> we
1 us
a
1 2 3 4
Figure 3.3 wumpus world
BTo specify the agent's task, we specify its percepts, actions, and goals. In the wumpus
world, these are as follows:
+ Im the square containing the wumpus and in the directly (not diagonally)
adjacent squares the agent will perceive a stench.
+ Inthe squares directly adjacent to a pit, the agent will perceive a breeze.
+ Inthe 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 tur 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
Percept ({Stench, Breeze, Glitter, None, None], 5).
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
Turn(Right ), Turn(Left), Forward, Shoot, Grab, Climb.
To determine which is best, the agent program executes the query
ASKVARS(J a BestAction(a, 5)),
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:
Wis,gumyc Percept ([s,Breeze,g,m,chyt) = Breeze(),
Wi s,bmye Percept ([s,b,Glitter,m,chy) = Glitter (9)
9These rules exhibit a trivial form of the reasoning process called perception. Simple
“reflex” behavior can also be implemented by quantified implication sentences,
For example, we have V1 Glitter (t) =»BestAction(Grab, 0)
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:
Ws, t At(Agent, s, 1) A Breeze(t) > Breezy(s).
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
(orsmelly) 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:
¥s Breezy(s) ¢25r Adjacent (r, s) A Pit(r).
33 SUBS’
‘TION
Let us begin with universal quantifiers
We King(s) A Greedy(s) = Evils)
Then it seems quite permissible to infer any of the following sentences
King(John) A Greedy(John) = Evil(John)
King(Richard ) A Greedy(Richard) = Evil(Richard)
King(Father (John)) A Greedy(Father (John)) = Evil(Father (John)).
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 SUBST(0,a) denote the result of applying the substitution 0 to the sentence a, Then
the rule is written
vv a SUBST ({v/g}, a) for any variable v and ground term g.
For example, the three sentences given earlier are obtained with the substitutions
{x/John}, {x/Richard }, and {x/Father (John)}.
In the rule for Existential Instantiation, the variable is replaced by a single new constant
symbol. The formal statement is as follows: for any sentence a, variable v, and constant symbol
that does not appear elsewhere in the knowledge base,
ya SUBST ({v/k}, a) For example, from the sentence
80x Crown(x) AOnHead(x, John) we can infer the sentence
Crown(Cl) AOnHead(Cl, John)
EXAMPLE
Suppose our knowledge base contains just the sentences
Vi King(x) A Greedy(x) > Evil(s)
King(John)
Greedy(John) Brother (Richard, John)
Then we apply UI to the first sentence using all possible ground-term substitutions from
the vocabulary of the knowledge base—in this case,
{x/John} and {x/Richard }. We obtain
King(John) A Greedy(John) = Evil(John)
King(Richard ) A Greedy(Richard) = Evil(Richard),
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 frst-
order inference algorithms. The UNIFY algorithm takes two sentences and returns a unifier for
them if one exists: UNIF¥(p, q)=0 where SUBST(0, p)= SUBST(O, q).
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}
UNIFY(Knows(John, x), Knows(y, Bill) = {x/Bill, y/John}
UNIFY(Knows(John, x), Knows(y, Mother (y))) = {y/John, x/Mother (John)}
UNIFY(Knows(John, x), Knows(x, Elizabeth)) = fail.
The last unification fails because x cannot take on the values John and Elizabeth at the
same time, Now, remember that Knows(x, Elizabeth) means “Everyone knows Elizabeth,” so
‘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
81standardizing 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(s, Elizabeth) to x17 (a new variable name) without changing its meaning,
Now the unification will work
UNIFY(Knows(John, x), Knows(x17, Elizabeth) = {x/Elizabeth, x17/John} UNIFY
should return a substitution that makes the two arguments look the same. But there could be
more than one such unifier.
For example,
UNIFY(Knows(John, x), Knows(y, 2)) could return
{9/John, x/z} or {y/John, x/John, /John}.
‘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 fo“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.
The process is simple: recursively explore the two expressions simultaneously “side by
side,” building up a 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; ifit does, the
match fails because no consistent unifier can be constructed.
function UNIFY(z,y.6) returns a substitution to make x and y identical
Inputs: 2 varuble, constant, list, of compound expression
¥. a vanable, constant, list or compound expression
6 the substitution butt up 30 far (optional, defaults to empty)
failure then return failure
then return
cle if VARIABLE7(2) then return UNIFY-VAR(2, ¥, 9)
else if VARIABLE7(y) them return UNIEY-VAR(y. 2.9)
‘se if COMPOUND?(2) and COMPOUND?(y) then
‘return UNIFY(2-ARCS, y.ARGS, UNIFY(2.0P, y.OP,8))
clue if LiST?(z) and L1ST%) then
return UNIFY (x REST, y REST, UNIFY(2.PIRST, y FIRST, ))
se return failure
function UNIFY-VAR(var, 2,0) returns a substination
Wt (oar/val) turn UNIFY eal, 2,9)
se it (2/val} UNIFY(ear, eal)
se if OCCUR-CHECK (var, 2) then return failure
se return a (var/2) 10 6
Figure 3.4 Recursively explore
82In artificial intelligence, forward and backward chaining is one of the important topics,
bbut 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
Hom 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.
Hom 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.
Example: (p V~q V k). It has only one positive literal k.
It is equivalent to p Aq — k.
A, Forward Chaining
Forward chaining is also known as a forward deduction or forward reasoning method
when using an inference engine. Forward chaining is a form of reasoning which start with
atomic sentences in the knowledge base and applies inference rules (Modus Ponens) in the
forward direction to extract more data until a goal is reached.
‘The Forward-chaining algorithm starts from known facts, triggers all rules whose
fied, and add their conclusion to the known facts. This process repeats until
premises are sat
the problem is solved.
Properties of Forward-Chaining
© Itis a down-up approach, as it moves from bottom to top.
© It is a process of making a conclusion based on known facts or data, by starting
from the initial state and reaches the goal state.
83Forward-chaining approach is also called as data-driven as we reach to the goal
using available data,
© 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 isa 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."
Prove that "Robert is criminal."
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,
Facts Conversion into FOL
© It isa crime for an American to sell weapons to hostile nations. (Let's say p, q, and r
are variables)
American (p) A weapon(q) A sells (p,q, 1) A hostile(r) Criminal(p) —...(1)
© Country A has some missiles. 3p Owns(A, p) A Missile(p). It can be written in two
definite clauses by using Existential Instantiation, introducing new Constant T1
Owns(A, TI) (2)
Missile(T1) 8)
© Allof the missiles were sold to country A by Robert.
¥p Missiles(p) A Owns (A, p) —» Sells (Robert, p, A) 4)
© Missiles are weapons.
Missile(p) — Weapons (p) (3)
© Enemy of America is known as hostile
Enemy(p, America) —Hostile(p) 6)
© Country A is an enemy of America.
Enemy (A, America) @
© Robert is American
American(Robert). (8)
84Forward 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, TI), and
Missile(T1). All these facts will be represented as below.
Enemy (A, America]
Figure 3.
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-(2) and (3) are already added.
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),
Weapons(T1) Sells (Robert, 11, A) Hostile(A)
Missile (T1) | | Owns (4,71)
|American (Robert)
Enemy (A, America)
Figure 3.6
Step-3
‘At step-3, as we can check Rule-(1) is satisfied with the substitution {p/Robert, q/T1,
1A}, so we can add Criminal (Robert) which infers all the available facts. And hence we
reached our goal statement.
85Criminal (Robert)
Weapons(Ti) | [sells Robert,T1, A) Hostile(A)
JAmerican Robert)|] Missile (T1) | } Owns (AT1) | | Enemy (A, America)
Figure 3.7
Hence it is proved that Robert is Criminal using forward chaining approach,
B. Backward Chaining
Backward-chaining is also known as a backward deduction or backward reasoning method
‘when using an inference engine. A backward chaining algorithm is a form of reasoning, which
starts with the goal and works backward, chaining through rules to find known facts that
support the goal.
Properties of backward chaining
© Itis known as a top-down approach.
© Backward-chaining is based on modus ponens inference rule.
© In backward chaining, the goal is broken into sub-goal or sub-goals to prove the facts
true,
© Its called a goal-driven approach, as a list of goals decides which rules are selected
and used.
© Backward -chaining algorithm is used in game theory, automated theorem proving
tools, inference engines, proof assistants, and various AI applications.
© The backward-chaining method mostly used a depth-first search strategy for proof.
Example
In backward-chaining, we will use the same above example, and will rewrite all the rules.
© American (p) A weapon(q) A sells (p, q, 2) A hostile(r) — Criminal(p) a)
Owns(A, TI) (2)
86© Missile(T1)
© 2p Missiles(p) A Owns (A, p) + Sells (Robert, p, A) 4)
© Missile(p) + Weapons (p) (3)
© Enemy(p, America) —+Hostile(p) Oy
© Enemy (A, America) 0)
© American (Robert) (8)
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
Criminal (Robert)
satisfies the rules. So
‘ond step, we will infer other facts form goal fact whi
as we can see in Rule-I, 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.
Here we can see American (Robert) is a fact, so itis proved here.
Criminal (Rober)
{ Robert/p}
|rmercan oben] | Weapon (a) | |Seile(Reberta.n) | | Hostle(n
t}
Figure 3.8
87Step-3
{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 TI at q,
Criminal (Reber
{ Robert/p)
Jamescan Reber] | weapon ia) | {setts Robert T1.9 | | Hosier
t}
Missie (a)
tam}
Figure 3.9
Step-4
At step-4, we can infer facts Missile(T1) and Owns(A, T1) form Sells(Robert, TL, r)
which satisfies the Rule- 4, with the substitution of A in place ofr. So these two statements are
proved here.
Criminal Robert)
{ Robert/p)
|smoican Rater] | Weapon a) | {seis Rober.t1,9] | Hosble()
t}
Missile @) issie 71) | | Owns(AT1)
t¥ <¥
tam)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.
aaa
Oo ox“
fon} + {} to
Figure 31
‘Suppose you have a production system with the FOUR rules: RI: 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
facts: A, B, C, D. PROVE A&B TRUE THEN D IS TRUE. Explain what is meant by “forward
chaining”, and show explicitly how it can be used in this case to determine new facts.
3.8 RESOLUTION IN FOL
Resolution
Resolution is @ theorem proving technique that proceeds by building refutation proofs,
i.e,, proofs by contradictions. It was invented by a Mathematician John Alan Robinson in the
year 1965.
Resolution is used, if there are various statements are given, and we need to prove @
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,
Conjunetive Normal Form: A sentence represented as a conjunction of clauses is said
to be conjunctive normal form or CNF
89Steps for Resolution
Conversion of facts into first-order logic.
Convert FOL statements into CNF
Negate the statement which needs to prove (proof by contradiction)
Draw resolution graph (unification).
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.
Apple and vegetable are food
¢. Anything anyone eats and not killed is food.
4. Anil eats peanuts and still alive
¢. Harry cats everything that Anil eats, Prove by resolution that:
£ John likes peanuts.
Step-1: Conversion of Facts into FOL
In the first step we will convert all the given statements into its first order logic,
a. Wx: food|x) > likes(John, x)
o
food{Apple) A food|vegetables)
c. Ya Wy: eats(x, y) Askilled(x) > food(y)
d._ eats (Anil, Peanuts) A alive(Anil).
fe. Vic: eats(Anil, x) 3 eatsiHarry, x)
f. Ye:—killad(x) 3 alivalx) added predicates
g. Ye: alive(x) >— killed)
hy likes(lohn, Peanuts)
© Eliminate all implication (—) and rewrite
Vx food(x) V likes(John, x)
food(Apple) A food{vegetables)
Vx Wy — [eats(x, y) A ~ killed(x)] V food(y)
cats (Anil, Peanuts) A alive(Anil)
Wx ~ eats(Anil, x) V eats(Harry, x)
vx> [> killed(x) ] V alivetx)
Vx ~ alive(x) V > killed(x)
likes(Fohn, Peanuts)
90‘Move negation (-)inwards and rewrite
Vx food(x) V likes(John, x)
food(Apple) A food{vegetables)
Wx Wy —eats(x, y) V killed(x) V food(y)
cats (Anil, Peanuts) A alive(Anil)
Wx — eats(Anil, x) V eats(Harry, x)
Wx “killed(x) ] V alive(x)
Vx_~ alive(x) V~ killed(x)
likes(John, Peanuts)
Rename variables or standardize variables
Wx food(x) V likes(John, x)
food(Apple) A food{vegetables)
vy Wz.~ eats(y, 2) V killed(y) V food(z)
cats (Anil, Peanuts) A alive(Anil)
‘Ww eats(Anil, w) V eats(Harry, w)
Vg ~killed(g) ] V alive(g)
Vk ~ alive(k) V > killed(e)
likes(John, Peanuts)
Eliminate existential instantiation quantifier by elimination. In this step, we will
climinate existential quantifier 3, and this process is known as Skolemization. But in
this example problem since there is no existential quantifier so all the statements will
remain same in this step.
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.
— food(x) V likes(John, x)
food(Apple)
food(vegetables)
4, eats(y, 2) V killed(y) V food(z)
5. eats (Anil, Peanuts)
6. alive(Anil)
7, ~eats(Anil, w) V eats(Harry, w)
8
9
1
Killed(g) V alive(g)
~alive(k) V~killed(k)
(0 likes(John, Peanuts)
Distribute conjunction A over disjunction ~.This step will not make any
this problem.
aStep-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)
Step-4: Draw Resolution geaph
© Now in this step, we will solve the problem by resolution tree using substitution, For
the above problem, it will be given as follows:
—likes(lohn, Peanuts)
2
\ =
— food(Peanuts)
\
\-
catty, Peanuts) Vea
\
=
= foods) Vlkes(iohn, x)
{Peanuts/x)
_psatsly.2)Vkilled(y)V Food!)
{Peanuts/s}
cats (Anil, Peanuts}
‘Ani
oe
sedan
\ ee
\
—alvetAni)
t
salive(k) v— killed(k}
fang
alive(Ani
a
aa
} Hence proved.
igure 3.12
‘planation of Resolution graph
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)
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).
In the third step of the resolution graph, ~ cats(y, Peanuts) and eats (Anil, Peanuts) get
resolved by substitution {Anil’y}, and we are left with Killed(Anil),
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).
2© Inthe last step of the resolution graph ~ alive(Anil) and alive(Anil) get resolved,
Difference between Predicate Logic and Propositional Logic
Table 3.1
Predicate logic
Propositional logic
Predicate logic is a generalization of
propositional logic that allows us to
express and infer arguments in infinite
models,
‘A preposition is a declarative statement
that’s either TRUE or FALSE (but not
both).
Predicate logic (also called predicate
calculus and first-order logic) is an
extension of propositional logic to
formulas involving terms and
predicates. The full predicate logic is
undecidable
Propositional logic is an axiomatization
of Boolean logic. Propositional logic is
decidable, for example by the method of
truth table,
Predicate logic have variables
Propositional logic has variables.
Parameters are all constant
A predicate is a logical statement that
depends on one or more variables (not
necessarily Boolean variables)
Propositional logic deals solely with
propositions and logical connectives.
Predicate
properties,
involved.
logic there objects,
functions (relations) are
Proposition logic is represented in terms
of Boolean variables and logical
connectives.
In predicate logic, we symbolize subject
and predicate separately. Logicians
often use lowercase letters to symbolize
subjects (or objects) and upper case
letter to symbolize predicates.
In propositional logic, we use letters to
symbolize entire propositions.
Propositions are statements of the form
xx is y” where x is a subject and y is a
predicate.
Predicate logic uses quantifies such as
universal quantifier (“V"), the
existential quantifier (“3”)
Prepositional logic has not qualifiers
Example
Everything is a green as “Wx Green(x)”
or
“Something is blue as “3 x Blue(x)”
Example
s “Gr
Everything isa
or
“Something is blue as “B(x”
green
KNOWLEDGE REPRESENTATION ONTOLOGICAL ENGINEERING
Concepts such as Events,
Time, Physical Objects, and Beliefs— that occur in many
different domains, Representing these abstract concepts is sometimes called ontological
engineering.
9%GenerakjedEvens
ha
lObjecss Inverval Places PhysicalO)
an
Moeents Sie
\
x NS
Animals Agents Selif Liquid Gas
VY
Hamas
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.
The general framework of concepts is called an upper ontology because of the
convention of drawing graphs with the general concepts at the top and the more spet
concepts below them, as in Figure
Categories and Objects
The organization of objects into eategories is a vital part of knowledge representation
Although interaction with the world takes place at the level of individual objects, much
reasoning takes place at the level of categories.
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
first-order logic: predicates and objects. That is, we can use the predicate Basketball (b), or we
can reilyl the category as an object, Basketballs,
We could then say Member(b, Basketballs ), which we will abbreviate as bE
Basketballs, to say that b is a member of the category of basketballs. We say
Subset(Basketballs, Balls), abbreviated as Basketballs C Balls, to say that Basketballs is a
subcategory of Balls. Categories serve to organize and simplify the knowledge base through.
inheritance. If we say that all instances of the category Food are edible, and if we assert that
Fruit is a subclass of Food and Apples is a subclass of Fruit, then we can infer that every apple
is edible. We say that the individual apples inherit the property of edibility, in this ease from
their membership in the Food category. First-order logic makes it easy to state facts about
categories, either by relating objects to categories or by quantifying over th
are some types of facts, with examples of each:
members. Here
+ An object is a member of a category.
94BBY € Basketballs
+ A category is a subclass of another category. Basketballs & Balls
+ All members of a category have some properties.
(x€ Basketballs) = Spherical (x)
+ Members of a category can be recognized by some properties.
Orange(x) A Round (x) A Diameter(x)-9.5 A x¢ Balls = x€ Basketballs,
+ category as a whole has some properties,
Dogs € Domesticated Species
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:
x€ Bachelors ¢ Unmarried(x) Ax€ Adults x€ Males
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:
PartOf (Bucharest, Romania)
PartOf (Romania, EasternEurope)
PartOftEastern Europe, Europe)
PartOf (Europe, Earth)
The PartOf relation is transitive and reflexive; that is,
PartOf (sx; y) APartOf (y, 2) =»PartOf (x, 2)
PartOf (x, x)
Therefore, we can conclude PartOf (Bucharest, Earth).
For example, if the apples are Applel, Apple2, and Apple3, then
BunchOf {Applet Apple2,Apple3})
denotes the composite object with the three apples as parts (not elements). We can
define BunchOf in terms of the PartOf relation. Obviously, each element of sis part
of
BunchOf (s): Vs 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:
Wy [Ve x€s =PartOf (x, y)] PartOf (BunchOf (s), y)
95Measurements
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
‘entimeters(3.81)
Conversion between units is done by equating multiples of one unit to another:
Centimeters(2.54 d)=Inches(d)
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 (Baskethall12)=Inches(9.5)
ListPrice (Basketball12)=8(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 zeto duration:
Partition({Moments,ExtendedIntervals}, Intervals )
i€Momentse2Duration(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) —Duration(i)=(Time(End() — - ~—_—‘Time(Begin(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(ij) € End(i)=Beging)
Before(ij) 9 End() < Begin)
After (j,i) © Before(i, j)
During(i,j) € Begin() < Begin(i) [V y Loves(y,x)]
Y x Animals(x) =>Loves(Jack, x)
Kills Jack, Tuna) V Kills (Curiosity, Tuna)
Cat (Tuna)
¥ x Cat(x) => Animal (x)
G._—Kills(Curiosity, Tuna)
=moop
102Now we apply the conversion procedure to convert each sentence to CNF:
Al, Animal(()) v Loves (G(x).x)
A2, —-Loves(x,F(x)) v Loves (G(x),x)
B, — —Loves(y,x) v— Animal(z) V-Kills(x,
C, sAnimal(x) v Loves(Jack, x)
D. _Kills(Jack, Tuna) v Kills (Curiosity, Tuna)
Cat (Tuna)
F. =Cat(x) v Animal (x)
1G, Kills (Curiosity, Tuna)
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 sueceed after the variables have been standardized apart
The proof answers the question “Did Curiosity kill the cat?” but often we want to pose
‘more general questions, such as “Who killed the cat?” Resolution can do this, but it takes a
little more work to obtain the answer. The goal is 3w 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
1. All people who are graduating are happy.
103