0% found this document useful (0 votes)
79 views48 pages

Unit 3

1. The document discusses different methods of knowledge representation including propositional logic, first-order predicate logic, programming languages, and natural languages. 2. It notes that while propositional logic and programming languages are limited in their expressiveness, first-order predicate logic and natural languages allow for more complex and flexible knowledge representation through tools like predicates, variables, and context. 3. The key challenge is developing representations that have adequate representation, inference, efficiency of inference and acquisition to model real-world domains.

Uploaded by

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

Unit 3

1. The document discusses different methods of knowledge representation including propositional logic, first-order predicate logic, programming languages, and natural languages. 2. It notes that while propositional logic and programming languages are limited in their expressiveness, first-order predicate logic and natural languages allow for more complex and flexible knowledge representation through tools like predicates, variables, and context. 3. The key challenge is developing representations that have adequate representation, inference, efficiency of inference and acquisition to model real-world domains.

Uploaded by

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

R.M.

D ENGINEERING COLLEGE
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
VI Semester (EVEN 2022-23)
CS8691ARTIFICIAL INTELLIGENCE

UNIT IIIKNOWLEDGE 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

1. KNOWLEDGE REPRESENTATIONS AND MAPPINGS


In order to solve the complex problems encountered in artificial intelligence, one 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. But we are
dealing with two different kinds of entities:
• Facts: truths in some relevant world. These are the things we want to represent.
•Representations of facts in some chosen formalism. These are the things we will actually be able to
manipulate.

One way to think of structuring these entities is as two levels:


• The knowledge level at which facts 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.
The model is shown in Fig 2.7. Rather than thinking of one level on top of another, we will focus on
facts, on representations, and on the two-way mappings that must exist between them.

We will call these links representation mappings.


 The forward representation mapping maps from facts to representations.
 The backward representation mapping goes the other way from representations to facts.

Fig 2.7: Mappings between Facts and Representation


Approaches to knowledge representation
A good system for the representation of knowledge in a particular domain should possess the
following four properties:
1. Representational adequacy - the ability to represent all the kinds of knowledge that are

1
needed in that domain

2
2. 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.
3. Inferential efficiency – the ability to incorporate into the knowledge structure additional
information that can be used to focus the attention of the inference mechanisms in the most
promising directions.
4. Acquisitional efficiency – the ability to acquire new information easily. The simplest case
involves direct insertion, by a person, of new knowledge into the database. Ideally, the
program itself would be able to control knowledge acquisition

Simple Relational Knowledge


The simple way to represent declarative facts is as a set of relations of the same sort used in database
systems. Figure 2.10 shows an example of such a relational system

Figure 2.10 Simple relational knowldege and a sample fact in Prolog


The relational knowledge of Fig. 2.10 corresponds to a set of attributes and associated values that
together describe the objects of the knowledge base

1. The relational knowledge corresponds to a set of attributes and associated values that together
describe the objects of the knowledge base.
2. This representation is simple
3. It provides very weak inferential capabilities
4. But knowledge represented in this form may serve as the input to more powerful inference
engines.
5. It is not possible even to answer the simple question. "Who is the heaviest player?'
6. But if a procedure for finding the heaviest player is provided, then these facts will enable the
procedure to compute an answer.

If, instead, we are provided with a set of rules for deciding which hitter to put up against a given
pitcher (based on right- and left-handedness. say), then this same relation can provide at least some of
the information required by those rules.

2 PROPOSITIONAL LOGIC
Propositional logic is appealing because it is simple to deal with and a decision procedure for it
exists.
We can easily represent real-world facts as logical propositions written as well formulas (wff's) in
propositional logic.
Using these propositions, we could, conclude from the fact that it is mining the fact that it is not
3
sunny. But very quickly we run up against the limitations of propositional logic.

Suppose we want to represent the obvious fact stated by the classical sentence

It is raining.
RAINING
It is sunny.
SUNNY
It is windy.
WINDY
It is raining, then it is not sunny.
RAINING SUNNY
Fig. 2.16 Some Simple Facts in Prepositional Logic

Socrates is a man.
We could write:
SOCRATESMAN
But if we also wanted to represent
Plato is a man.
we would have to write something such as:
PLATOAMAN
which would be a totally separate assertion, and we would not be able to draw any conclusions about
similarities between Socrates and Plato. It would be much 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. We are in even more difficulty if we try to
represent the equally classic sentence

All men are mortal. We could represent this as: MORTALMAN

But that fails to capture the relationship between any individual being a man and that individual
being a mortal.
To do that, we really need variables and quantification unless we are willing to write separate
statements about the mortality of every known man.
But a major motivation for choosing to use logic
1. A good way of reasoning with that knowledge is available.
2. Determining the validity of a proposition in propositional logic is straightforward.
3. It provides a way of deducing new statements from old ones. But, it does not possess a
decision procedure. There do exist procedures that will find a proof of a proposed theorem
if indeed it is a theorem. But these procedures are not guaranteed to halt if the proposed
statement is not a theorem. First-order predicate logic is not decidable, it is
semidecidable.
A simple such procedure is to use the rules of inference to generate theorem's from the axioms in
4
some orderly fashion, testing each to see if it is the one for which a proof is sought.
 Propositional logic is a declarative language because its semantics is based on a truth relation
between sentences and possible worlds.
 It is also has sufficient expressive power to deal with partial information, using disjunction and
negation.
 Propositional logic has a third property that is desirable in representation languages, namely
compositionality. In a compositional language, the meaning of a sentence is a function of the
meaning of its parts.
For example, ―S1,4 ^S1,2‖ is related to the meaning of ―S1,4‖ and ―S1,2‖.

BNF Grammar Propositional Logic

Drawback in propositional logic


Propositional logic lacks the expressive power to describe an environment with many objects
concisely. For example, we were forced to write a separate rule about breezes and pits for each
square, such as

B1,1 <=> (P1,2 V P2,1)


Programming languages
 Programming languages such as C++ or Java or Lisp are by far the largest class of formal
languages in common use.
 Data structures within programs can represent facts; for example, a program could use a 4 X 4
arrays to represent the contents of the wumpus world.
Drawback in data structures:
1. Programming languages lack is any general mechanism for deriving facts from other facts
2. Programs can store a single value for each variable. It is difficult to represent, for example
―There is a pit in square[2,2] or [3,1]‖ or ―If the Wumpus is in [1,1] then he is not in [2, 2]‖.

Natural languages
The natural languages are very expressive
In natural languages, it is easy to say ―squares Adjacent to pits are breezy‖, even for a grid of Infinite
size.
Natural languages like English or German:
• are far more expressive than propositional logic
• serve as medium for communication
• depend heavily on the context
5
• can be ambiguous

When a speaker points and says ―Look!‖ the listener comes to know that, say, Superman has finally
appeared over the rooftops. Yet we would not want to say that the sentence ―Look!‖ encoded
that fact.

Rather, the meaning of the sentence depends both on the sentence itself and on the context in
which the sentence was spoken. Clearly, one could not store a sentence such as ―Look!‖ in
a knowledge base and expect to recover its meaning without also storing a representation of the
context
– which raises the question of how the context itself can be represented.
The syntax of natural language, the most obvious elements are
1. Nouns and noun phrases that refer to objects, and
2. Verbs and verb phrase that refer to relations among objects.
3. Some of these relations are functions— relations in which there is only one "value"
for a given "input."

It is easy to start listing examples of objects, properties, relations, and functions:


• Objects: people, houses, numbers, theories, Ronald McDonald, colors, baseball games, wars,
centuries
• Relations: brother of, bigger than, inside, part of, has color, occurred after, owns...
• Properties: red, round, bogus, prime, multistoried...
 Functions: father of, best friend, third inning of, one more
than ... Some examples follow:
• "One plus two equals three"
Objects: one, two, three, one plus two;
Relation: equals;
Function: plus. (One plus two is a name for the object that is obtained by applying the function plus
to the objects one and two. Three is another name for this object.)
• "Squares neighboring the wumpus are smelly."
Objects: wumpus, square;
Property: smelly;
Relation: neighboring.
 "Evil King John ruled England in 1200."
Objects: John, England, 1200;
Relation: ruled;
Properties: evil,
king.

INFERENCE RULES FOR PROPOSITIONAL LOGIC:


 The propositional logic has seven inference rules.
 Inference means conclusion reached by reasoning from data or premises; speculation.
 A procedure which combines known facts to produce ("infer") new facts.
 Logical inference is used to create new sentences that logically follow from a given set of
predicate calculus sentences (KB).
6
 An inference rule is sound if every sentence X produced by an inference rule operating on a
KB logically follows from the KB. (That is, the inference rule does not create any contradictions)
 An inference rule is complete if it is able to produce every expression that logically follows from
(is entailed by) the KB. (Note the analogy to complete search algorithms.)
 Here are some examples of sound rules of inference
A rule is sound if its conclusion is true whenever the premise is true

Rule Premise Conclusion


Modus Ponens A, A  B B
And Introduction A, B AB
And Elimination AB AB
Or Introduction A, B A
Double Negation A A
Unit Resolution A  B, B A
Resolution A  B, B  C AC

4. PREDICATE LOGIC
First-order logic (PREDICATE LOGIC), is sufficiently expressive to represent a good deal of our
commonsense knowledge. It also either subsumes or forms the foundation of many other
representation languages.
• First-order logic (FOL) is built around objects and relations
• Has greater expressive power than propositional logic
• It can also express facts about some or all objects in the universe.
• First-Order Logic assumes that the world contains:
– Objects (E.g. people, houses, numbers, theories, colors, football games, wars, centuries,
…)
– Relations (E.g. red, round, prime, bogus, multistoried, brother of, bigger than, inside, part
of, has color, occurred after, owns, comes between, …)
– Functions (E.g. father of, best friend, third quarter of, one more than, beginning of,..)
• Epistemological commitments define the possible states of knowledge that a logic allows with
respect to each fact

The primary difference between first-order logic and propositional logic lies in the Ontological
commitments made by each language- that is, what it assumes about the nature of reality.
Ontological commitments
• Propositional logic assumes that there are facts that either hold or do not in the world. Each
fact can be in one of two states: true or false.
• First-order logic assumes more: namely, that the world consists of objects with certain
7
relations between them that do or do not hold.
• Temporal logic assumes that the world is ordered by a set of time points or intervals, and
includes built-in mechanisms for reasoning about time.
Epistemological commitments have to do with the possible states of knowledge an agent can have
using various types of logic.
• Propositional logic & First-order logic have three possible states of belief regarding any
sentence.
• Probability theory, can have any degree of belief, ranging from 0 (total disbelief) to 1 (total
belief).
o For example, a probabilistic wumpus-world agent might believe that the wumpus is in
[1,3] with probability 0.75.
• Fuzzy logic can have degrees of belief in a sentence, and also allow degrees of truth: a fact
need not be true or false in the world, but can be true to a certain degree.

For example, "Vienna is a large city" might be true only to degree 0.6. The ontological and
epistemological commitments of various logics are summarized

Syntax and Semantics of First-Order Logic


Bakus Naur Form (BNF) for FOL

First-order logic is also called (first-order) predicate logic and predicate calculus
Models for first-order logic
• The models of a logical language are the formal structures that constitute the possible worlds
under consideration.
• Models for propositional logic are just sets of truth values for the proposition symbols.
• The domain of a model in FOL is the set of objects or domain elements that it contains
• It must be nonempty, every possible world must contain at least one object
• It doesn’t matter what these objects are
• In the following examples, we use named objects, i.e., we refer to objects using their names

8
Relations:
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.
1. The ―brother‖ relation in this model is the set {<Richard the Lionheart, King John>,
<King John, Richard the Lionheart>}
2. The ―on head‖ relation in this model is the set {<the crown, King John>}
3. The ―person‖ property (unary relation) is the set {<Richard the Lionheart>, <King John>}

Properties:
1. The model also contains unary relations, or properties: the “person” property is true of
both Richard and John;
2. he “king” property is the only of John; and
3. the “crown” property is true only of the crown.

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 has one left leg, so the model has a unary
“left leg” function that includes the following mappings:
(Richard the Lionheart) → Richard’s left leg
(King John) → John’s left leg

Components of FOL
i. Symbols
The basic syntactic elements of first-order logic are the symbols that stand for objects, relations, and
functions.
The symbols, therefore, come in three kinds:
Constant symbols which stands for objects; ex, Marcus, Caesar
Predicate symbols which stands for relations ex, Person, Man, loyalto
Function symbols which stands for functions ex Left_leg
ii. Interpretations
The semantic must relate sentences to models in order to determine truth. For this to happen, we need
an interpretation that specifies exactly which objects, relations and functions are referred to by the
constant, predicate and function symbols.

One possible interpretation for our example – which we will call the intended interpretation – is as
follows:
 Richard refers to Richard the Lionheart and John refers to the evil King John
 Brother refers to the brotherhood relation, that is , the set of tuples of objects
 LeftLeg refers to the ―left leg‖ function

Not all the objects need have name – for example, the intended interpretation does no name the
crown or the legs.

It is also possible for an object to have several names; there is an interpretation under which both
Richard and John refer to the crown.
9
In propositional logic, it is perfectly possible to have a model in which cloudy and sunny are both
true; it is the job of the knowledge base to rule out models that are inconsistent with our knowledge.

iii. Terms
A term is a logical expression that refers to an object. Constant symbols are therefore terms.
Sometimes, it is more convenient to use an expression to refer to an 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
LeftLegOf (John).
Complex term is formed by a function symbol followed by a parenthesized list of terms as
arguments to the function symbol.

Thus LeftLegOf function symbol might refer to the following functional relation:
{ (King John, King John's left leg), (Richard the Lionheart, Richard's left leg)}

and if King John refers to King John, then LeftLegOf (King John) refers to King John's left leg.

iv. Atomic sentences


An atomic sentence is formed from a predicate symbol followed by a parenthesized list of terms.

For example, Brother(Richard, John) states, under the interpretation given before, that Richard the
Lionheart is the brother of King John. Atomic sentences can have arguments that are complex terms:
Married(FatherOf (Richard),MotherOf (John)) states that Richard the Lionheart's father is married to
King John's mother (again, under a suitable interpretation).

An atomic sentence is true if the relation referred to by the predicate symbol holds between the
objects referred to by the arguments relation holds just in case the tuple of objects is in the relation!
The truth of a sentence therefore depends on both the interpretation and the world.

v. Complex sentences
Logical connectives are used to construct more complex sentences, just as in propositional calculus.
The semantics of sentences formed using logical connectives is identical to that in the propositional
case.

For example:
• Brother(Richard, John) Λ Brother(John, Richard) is true just when John is the brother of Richard
and Richard is the brother of John.
• Older(John, 30) V Younger(John, 30) is true just when John is older than 30 or John is younger
than 30.
• Older(John, 30) => ¬Younger(John, 30) states that if John is older than 30, then he is not younger
than 30
• ¬Brother(Robin, John) is true just when Robin is not the brother of John.

10
vi. Quantifiers
Quantifiers let us 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: x
Existential quantification: x

a. Universal quantification (V)


―All kings are persons‖ is written in first-order logic as
 x King(x) => Person(x)
Thus, the sentence says, ―For all x, if x is a king, then x is a person‖. The symbol x is called
a
variable.

The variable is a term all by itself, and as such can also serve as the argument of a function – for
example, LeftLeg(x).
A term with no variables is called a ground term.

Intuitively, the sentence Vx P, where P is any logical expression, says that P is true for every object
x. More precisely, Vx P is true in a given model under a given interpretation if P is true in all possible
extended interpretations constructed from the given interpretation, where each extended
interpretation specifies a domain element to which x refers.

The universally quantified sentence  x King(x) => Person(x) is true under the original
interpretation if the sentence King(x) => Person(x) is true in each of the five extended
interpretations.

b. 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  y person(x)person(y)father(y,x)
 is pronounced "There exists ...‖ In general,  x P is true if P is true for at least one object x.

More precisely,  x P is true in a given model under a given interpretation if P is true in at least one
extended interpretation that assigns x to a domain element.

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

11
 x  y Brother(x,y) => Sibling(x,y)
Consecutive quantifiers of the same type can be written as on 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)
In other cases we will have mixtures. "Everybody loves somebody" means that for every person,
there is someone that person loves:
 x  y Loves(x,y)
On the other hand, to say "There is someone who is loved by everyone" we write
 y  x Loves(x,y)
The order of quantification is therefore very important. It becomes clearer if we put in parentheses.
 x (  y Loves(x,y)) says that everyone has a particular property, namely, the property that
somebody loves them.
On the other hand  x (  y Loves(x,y) says that there is some objectin the world that has a particular
property, namely the property of being loved by everybody.

Connections between V and 


The two quantifiers are actually intimately connected with each other, through negation. When one
says that everyone dislikes parsnips, one is also saying that there does not exist someone who likes
them; and vice versa:
 x ¬Likes(x, Parsnips) is equivalent to ¬  x Likes(x, Parsnips)
We can go one step further. "Everyone likes ice cream" means that there is no one who does not like
ice cream:
 x Likes(x, IceCream) is equivalent to ¬  x ¬Likes(x, IceCream)
Because V is really a conjunction over the universe of objects and Ǝ is a disjunction, it should not be
surprising that they obey De Morgan's rules.

The De Morgan rules for quantified and unqualified sentences are as follows:
 x ¬P = ¬  x P ¬P ^ ¬ Q = ¬(P VQ)
¬  x P =  x ¬P ¬(PΛ Q) = ¬P V ¬Q
 x P = ¬  x¬P P Λ Q = ¬(¬PV¬Q)
 x P = ¬  x ¬P PVQ = ¬(¬P Λ ¬Q)

Thus, we do not really need both V and  , just as we do not really need both Λ and V. For the
purposes of AI, the content, and hence the readability, of the sentences are important. Therefore, we
will keep both of the quantifiers.

A new statement is true by proving that it follows from the statements that are already known.
Thus the idea of a proof, as developed in mathematics as a rigorous way of demonstrating the truth of
an already believed proposition, can be extended to include deduction as a way of deriving answers
to questions and solutions to problems.

So we move to first-order predicate logic as a way of representing knowledge because it permits


representations of things that cannot reasonably be represented in prepositional logic.

12
Well-formed Formulas (wffs)
Defined recursively
• Literals are wffs

• wffs surrounded by quantifiers are wffs


In predicate logic, we can represent real-world facts as statements written as wff's.
But a major motivation for choosing to use logic
1. A good way of reasoning with that knowledge is available.
2. Determining the validity of a proposition in propositional logic is straightforward.
3. It provides a way of deducing new statements from old ones. But, it does not possess a
decision procedure. There do exist procedures that will find a proof of a proposed theorem
if indeed it is a theorem. But these procedures are not guaranteed to halt if the proposed
statement is not a theorem. First-order predicate logic is not decidable, it is
semidecidable.
4. A simple such procedure is to use the rules of inference to generate theorem's from the
axioms in some orderly fashion, testing each to see if it is the one for which a proof is
sought.

Let's now explore the use of predicate logic as a way of representing knowledge by looking at a
specific example. 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. It fails to capture some of the
information in the English sentence, namely the notion of past tense. Whether this omission is
acceptable or not depends on the use to which we intend to put the knowledge. For this simple
example, it will be all right.
2. Marcus was a Pompeian.
Pompeian(Marcus)
3. All Pompeians were Romans.
Vs : Pompeian(x) → Romon(x)
4. Caesar was a ruler.
Ruler(Caesar)
Here we ignore the fact that proper names are often not references to unique individuals, since many
13
people share the same name. Sometimes deciding which of several people of the same name is being
referred to in a particular statement may require a fair amount of knowledge and reasoning.
5. All Romans were either loyal to Caesar or hated him.
Vx: Roman(x) →[ (loyalto(x, Caesar) V hate(x,Caesar)
In English. the word "or" sometimes means the logical inclusive-or and sometimes means the logical
exclusive-or (XOR). Here we have used the inclusive interpretation. To express that, we would have
to write:
Vx Roman(x) → [(loyalto(x, Caesar) V hate(x, Caesar)) ˄ ┐(loyalto(x, Caesar) ˄ hate(x,
Caesar))]
6. Everyone is loyal to
someone. Vx : y :
→loyalto(x,y)

A major problem that arises when trying to convert English sentences into logical statements is the
scope of quantifiers. Does this sentence say, as we have assumed in writing the logical formula
above, that for each person there exists someone to whom he or she is loyal, possibly a different
someone for everyone? Or does it say that there exists someone to whom everyone is loyal (which
would be written as Ǝy :Vx : loyalto(x, y))? Often only one of the two interpretations seems likely, so
people tend to favor it.

7. People only try to assassinate rulers they are not loyal to.
Vx : Vy person(x) ˄ ruler(y) ˄ tryassassinate(x, y) → ┐ loyalto(x, y)
8. Marcus tried to assassinate Caesar.
tryassassinate (Marcus, Caesar)

From this brief attempt to convert English sentences into logical statements, it should be clear how
difficult the task is. For a good description of many issues involved in this process. Now suppose that
we want to use these statements to answer the question

Was Marcus loyal to Caesar?


It seems that using 7 and 8, we should be able to prove that Marcus was not loyal to caesar (again
ignoring the distinction between past and present tense).

Now let's try to produce a formal proof, reasoning backward from the desired goal:
┐loyalto(Marcus, Caesar)

In order to prove the goal, we need to use the rules of inference to transform it into another goal (or
possibly a set of goals) that can in turn be transformed, and so on, until there are no unsatisfied
goals remaining.

This process may require the search of an AND-OR graph when there are alternative ways of
satisfying individual goals. Here, for simplicity, we show only a single path. Figure 5.2 shows an
attempt to produce a proof of the goal by reducing the set of necessary but as yet unattained

14
goals to the empty set. The attempt fails, however, since there is no way to satisfy the goal person
(Marcus) with the statements we have available.

The problem is that, although we know that Marcus was a man, we do not have any way to conclude
from that that Marcus was a person. We need to add the representation of another fact to our system,
namely:

8. All men are people.


Vx : man(x)→ person(x)

Now we can satisfy the last goal and produce a proof that Marcus was not loyal to Caesar. Three
important issues must be addressed in the process of convening English sentences into logical
statements and then using those statements to deduce new ones:
1. Many English sentences are ambiguous (for example. 5, 6, and 7 above). Choosing
the correct interpretation may be difficult.
2. There is often a choice of how to represent the knowledge (as discussed in connection
with 1 , and 7 above). Simple representations are desirable. but they may preclude
certain kinds of reasoning. The expedient representation for a particular set of
sentences depends on the use to which the knowledge contained in the sentences will
be put.
3. Even in very simple situations. a set of sentences is unlikely to contain all the
information necessary to reason about the topic at hand. In order to be able to use a
set of statements effectively, it is usually necessary to have access to another set of
statements that represent facts that people consider too obvious to mention.

An additional problem arises in situations where we do not know in advance which statements to
deduce. In the example just presented, the object was to answer the question "Was Marcus loyal to
Caesar?' How would a program decide whether it should try to prove
loyalto(Marcus. Caesar)
┐loyalto(Marcus. Caesar)

Reasoning backward from a proposed truth to the axioms can be done and instead try to reason
forward and see which answer it gets to.
The problem with this forward approach is that,
1. The branching factor going forward from the axioms is so great that it would probably not get
to either answer in any reasonable amount of time.
15
2. It could use some sort of heuristic rules for deciding which answer is more likely and then try
to prove that one first. If it fails to find a proof after some reasonable amount of effort, it can
try the other answer. This notion of limited effort is important, since any proof procedure we
use may not halt if given a nontheorem.
3. Try to prove both answers simultaneously and stop when one effort is successful. Even here,
however, if there is not enough information available to answer the question with
certainty,the program may never halt. Yet a fourth strategy is to try both to prove one answer and
to disprove it, and to use information gained in one of the processes to guide the other.

REPRESENTING INSTANCE AND ISA RELATIONSHIPS


The specific attributes instance and isa are play in a particularly useful form of reasoning, property
inheritance. Figure 5.3 shows the first five sentences of the last section represented in logic in three
different ways.
The first part of the figure contains the representations 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 of the figure contains representations that use the instance predicate explicitly
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.

Pompeian(Paulus)
┐[loyalto(Paulus, Caesar) V hate(Paulets.Caesar)]

For convenience, we now return to our original notation using unary predicates to denote class
16
relations.

In other words, 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

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

V x : Roman(x) ˄┐eq(x, Paulus) →loyalto(x, Caesar) V hate(x, Caesar)

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. This makes the use of
general rules in this framework less convenient and less efficient when there arc exceptions than is
the use of general rules in a semantic net. A further problem arises when information is incomplete
and it is not possible to prove that no exceptions apply in a particular instance.

USING FIRST-ORDER LOGIC (KNOWLEDGE REPRESENTATION IN FOL)


In knowledge representation, a domain is a section 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 those kings are persons:
TELL(KB, King(John))
TELL(KB,  x King(x) => Person(x))
We can ask questions of the knowledge base using ASK. For example
ASK(KB, King(John))

Return true. Questions asked using ASK are called queries or goals. Generally speaking, any query
that is logically entailed by the knowledge base should be answered affirmatively. For example,
given the two assertions in the preceding paragraph, the query
ASK(KB, Person(John))
Should also return true. We can also ask quantified queries, such as
ASK(KB,  x Person(x))
The answer to this query could be true, but this is neither helpful nor amusing. A query with
existential variables is asking ―Is there an x such that …‖ and we solve it by providing such an x.

The standard form for an answer of this sort is a substitution or binding list, which is a set of variable/
term pair.

In this particular case, given just the two assertions, the answer would be {x/John}. If there is more
than one possible answer, a list of substitutions can be returned.
Axioms, definitions, and theorems
Axioms are facts and rules that attempt to capture all of the (important) facts and concepts about a
domain; axioms can be used to prove theorems

18
• Each of these sentences is an axiom, as they provide basic factual information
• They are definitions since they have the form:
o x,y P(x,y) …
• Some logical sentences are theorems
o x,y Sibling(x,y)  Sibling(y,x)
• Theorems provide no new information, as they are entailed by the axioms
• But they reduce the computational cost of deriving new sentences

From a purely logical point of view,


• A knowledge base contains only axioms and no theorems, because the theorems do not increase
the set of conclusions that follow from the knowledge base.
• Theorems are essential to reduce the computational cost of deriving new sentences.

Without them, a reasoning system has to start from first principles every time, rather like a physicist
having to rederive the rules of calculus for every new problem.

Not all axioms are definitions. Some provide more general information about certain predicates
without constituting a definition. Indeed, some predicates have no complete definition because we do
not know enough to characterize them fully.

For example, there is no obvious way to complete the sentence:


 x Person(x) <=> ...
Fortunately, first-order logic allows us to make use of the Person predicate without completely
defining it. Instead we can write partial specifications of properties that every person has and
properties that make something a person:
 x Person(x) => ...
 x ... => Person(x)
Axioms can also be ―just plain facts‖, such as Male(Jim) and Spouse(Jim,Laura). Such facts form the
descriptions of specific problem instances, enabling specific questions to be answered. The answers
to these questions will then be theorems that follow from the axioms.

An axiom of the form  x,y P(x,y) = ... is often called a definition of P, because it serves to define
exactly for what objects P does and does not hold. It is possible to have several definitions for the
same predicate;

Numbers, sets and lists


We want to be able to represent individual sets, including the empty set. We need a way to build up
sets by adding an element to a set or taking the union or intersection of two sets. We will want to
know if an element is a member of a set, and to be able to distinguish sets from objects that are not
sets.

19
We will use the normal vocabulary of set theory: EmptySet is a constant written as {}. There is only
unary predicate, Set, which is true of sets. The binary predicates are x ϵ s and s1 s2. The binary
functions are s1 s2, s1 s2 , and {x/ s}

The following eight axioms provide this:


1. The only sets are the empty set and those made by adjoining something to a set:
s set(s) <=> (s=EmptySet) v (x,r Set(r) ^ s=Adjoin(s,r))

2. The empty set has no elements adjoined to it:


~ x,s Adjoin(x,s)=EmptySet

3. Adjoining an element already in the set has no effect:


x,s Member(x,s) <=> s=Adjoin(x,s)

4. The only members of a set are the elements that were adjoined into it:
x,s Member(x,s) <=> y,r (s=Adjoin(y,r) ^ (x=y  Member(x,r)))

5. A set is a subset of another iff all of the 1st set’s members are members of the 2nd:
s,r Subset(s,r) <=> (x Member(x,s) => Member(x,r))

6. Two sets are equal iff each is a subset of the other:


s,r (s=r) <=> (subset(s,r) ^ subset(r,s))

7. Intersection
x,s1,s2 member(X,intersection(S1,S2)) <=> member(X,s1) ^ member(X,s2)

8. Union
x,s1,s2 member(X,union(s1,s2)) <=> member(X,s1)  member(X,s2)

lists
The domain of lists is very similar to the domain of sets. The difference is that lists are ordered, and
the same element can appear more than once in a list.

We can use the vocabulary of Lisp for lists:


Nil is the constant list with no elements;
Cons, Append, First, and Rest are functions; and
Find is the predicate that does for lists what Member does for sets.
List? is a predicate that is true only of lists.

As with sets, it is common to use syntactic sugar in logical sentences involving lists. The empty list is
[].
The term Cons(x,y), where y is a nonempty list, is written [x | y ].
The term Cons(x,Nil) is written as [x].
20
A list with several elements, such as [A,B,C], corresponds to the nested term
Cons(A,Cons(B,Cons(C,Nil)))

These rules exhibit a trivial form of the reasoning process called perception.

5. PROGLOG Programming:-
 A system in which KB can be constructed and used.
 A relation between logic and algorithm is summed up in Robert Kowalsh equation
Algorithm = Logic + Control
 Logic programming languages, usually use backward chaining and input/output of
programming languages.
 A logic programming language makes it possible to write algorithms by augmenting
logic sentences with information to control the inference process.
 For Example:- PROLOG
 A prolog program is described as a series of logical assertions each of
which is a Horn Clause.
 A Horn Clause is a Clause that has atmost one positive literal,
Example: - P, ¬PQ
 Implementation: - All inferences are done by backward chaining, with
depth first search. The order of search through the conjuncts of an antecedent
is left to right and the clauses in the KB are applied first-to- last order.
 Example for FOL to PROLOG conversion:-
o FOL
 x Pet(x)  Small(x)  Apartment(x)
 x Cat(x) v Dog(x)  Pet(x)
 x Product(x)  Dog(x)  Small(x)
 Poodle(fluffy)
o Equivalent PROLOG representation
 Apartment(x) :- Pet(x), Small(x)
 Pet(x) :- Cat(x)
Pet(x) :- Dog(x)
 Dog(x) :- Poodle(x)
Small(x) :- Poodle(x)
 Poodle(fluffy)
o In the PROLOG representation the consequent or the left hand side is called as
head and the antecedent or the right hand side is called as body.
 Execution of a PROLOG program:-
o The execution of a prolog program can happen in two modes,
1. Interpreters
2. Compilers
o Interpretation:
 A method which uses BACK-CHAIN algorithm with the program as
the KB.
 To maximize the speed of execution, we will consider two different
types of constraints executed in sequence, They are
1. Choice Point: - Generating sub goals one by one to
perform interpretation.

21
2. Trail: - Keeping track of all the variables that have been
bound in a stack is called as trail.
o Compilation:-
 Procedure implementation is done to run the program (i.e.) calling the
inference rules whenever it is required for execution

6. 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 process of finding all legal substitutions that make logical expressions look identical and
 Unification is a "pattern matching" procedure that takes two atomic sentences, called literals, as
input, and returns "failure" if they do not match and a substitution list, Theta, if they do match.
The Unify algorithm takes two sentences and returns a unifier for them if one exists:

UNIFY (p, q) = q where SUBST (θ, p) = SUBST (θ, q).

Let us look at some examples of how Unify should behave. Suppose we have a query Knows (John,
x): whom does John know? Some answers to this query 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}
UNlFY (Knows (John,x), Knows (y, Mother(y))) = {y/John, x/Mother(John)}
UNlFY (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 standardizing apart one of the two sentences being unified, which means
renaming its variables to avoid name clashes.

This so-called occur check makes the complexity of the entire algorithm quadratic in the size of the
expressions being unified. Some systems, including all logic programming systems, simply omit the
occur check and sometimes make unsound inferences as a result; other systems use more complex
algorithms with linear-time complexity.

22
The Unification algorithm

7. FORWARD CHAINING
Using a deduction to reach a conclusion from a set of antecedents is called forward chaining. In other
words,the system starts from a set of facts, and a set of rules, and tries to find the way of using these
rules and facts to deduce a conclusion or come up with a suitable cause of action. This is known as
data driven reasoning.
Steps for forward-chaining algorithm
The first forward chaining algorithm,
1. Starting from the known facts
2. Triggers all the rules whose premises are satisfied
3. Add their conclusions to the known facts.
4. The process repeats until the query is answered (assuming that just one answer is required) or
no new facts are added.
Note:
(a) The initial facts appear in the bottom level
(b) Facts inferred on the first iteration is in the middle level
(c) The facts inferered on the 2nd iteration is at the top level

23
Forward Chaining algorithm
EXAMPLE
We will prove that West is a criminal. First, we will represent these facts as first-order definite
clauses. "... it is a crime for an American to sell weapons to hostile nations":
American(x) A Weapon(y) A Sells(x,y,z) A Hostile(z)  Criminal(x) . (3.3)
"Nono ... has some missiles." The sentence x Owns(Nono, x) Λ Missile(x) is transformed into two
definite clauses by Existential Elimination, introducing a new constant M1
Owns (Nono, M1) (3.4)
Missile (M1) (3.5)
"All of its missiles were sold to it by Colonel West":
Missile(x) A Owns (Nono, x) => Sells (West, x, Nono) . (3.6)
We will also need to know that missiles are weapons:
Missile(x) => Weapon(x) (3.7)
and we must know that an enemy of America counts as "hostile":
Enemy (x, America) => Hostile(x). (3.8)
"West, who is American ...":
American ( West) . (3.9)

"The country Nono, an enemy of America ...":


Enemy (Nono, America) . (3.10)
Figure: The proof tree generated by forward chaining on the crime example
Step 1:

American(West) Missile(M1) Owns(Nono, M1) Enemy(Nono, America)

Step 2:
24
Step 3:

Forward chaining applies a set of rules and facts to deduce whatever conclusions can be derived.
FC Algorithm has three possible types of complexity
 Pattern Matching: - ―inner loop‖ of the algorithm involves finding all possible
unifiers such that the premise of a rule unifies with a suitable set of facts in the KB.
 Matching rules against known facts:- The algorithm re-checks every rule on every iteration to
see whether its premises are satisfied, even if very few additions are made to the KB on
each iteration
 Irrelevant facts to the goal are generated

8. BACKWARD CHAINING

In backward chaining, we start from a conclusion, which is the hypothesis we wish to prove
and we aim to show how that conclusion can be reached from the rules and facts in the data
base.The conclusion we are aiming to prove is called a goal and the reasoning in this way is
known as goal-driven.
Note:
(a) To prove Criminal (West), we have to prove four conjuncts below it.
(b) Some of which are in knowledge base, and others require further backward chaining.

25
Proof tree constructed by backward chaining to prove that West is a criminal.
Step 1:

Criminal (West)

Step2:

Step 3

Step 4:

Step 5:

26
Step 6:

Step 7:

The tree should be read depth first, left to right.


 To prove Criminal (West), we have to prove the four conjuncts below it. Some of these are in
the knowledge base, and others require further backward chaining.
 Bindings for each successful unification are shown next to the corresponding subgoal. Note
that once one subgoal in a conjunction succeeds, its substitution is applied to subsequent
subgoals.
 Thus, by the time FOL-BC-ASK gets to the last conjunct, originally Hostile(z), z is already
bound to Nono.

27
 The algorithm uses composition of substitutions. COMPOSE (θ1, θ2) is the substitution
whose effect is identical to the effect of applying each substitution in turn. That is,

SUBST (COMPOSE (θ1, θ2),p) = SUBST (θ2,SUBST (θ1,p)) .


In the algorithm, the current variable bindings, which are stored in θ, are composed with the bindings
resulting from unifying the goal with the clause head, giving a new set of current bindings for the
recursive call.

9. RESOLUTION
 Resolution yields a complete inference algorithm when coupled with any complete search
algorithm.
 Resolution makes use of the inference rules.
 Resolution performs deductive inference.
 Resolution uses proof by contradiction.
 One can perform Resolution from a Knowledge Base. A Knowledge Base is a collection of facts
or one can even call it a database with all facts.

In 1930, the German mathematician Kurt Godel proved the first completeness theorem for first-
order logic, showing that any entailed sentence has a finite proof.
In 1931, Godel proved an even more famous incompleteness theorem. The theorem states that a
logical system that includes the principle of induction—without which very little of discrete
mathematics can be constructed—is necessarily incomplete. Hence, there are sentences that are
entailed, but have no finite proof within the system.

Steps for Resolution

1. Convert all facts to clause form (product of sums)


2. Negate the goal (theorem to be proven)
3. Convert the negated goal to clause form, and add to the set of facts
4. Until NIL is found, repeat
• Select two clauses
• Compute their resolvent
• Add it to the set of facts

Conjunctive normal form for first-order logic


First-order resolution requires that sentences be in conjunctive normal form (CNF)—that is, a
conjunction of clauses, where each clause is a disjunction of literals. Literals can contain
variables, which are assumed to be universally quantified. For example, the sentence

x American (x) Λ Weapon (y) Λ Sells (x, y, z) Λ Hostile (z) =>Criminal (x)
becomes, in CNF,
¬American (x) V ¬Weapon (y) V ¬Sells (x, y, z) V ¬Hostile (z) V Criminal (x) .

28
A clause can also be represented as an implication with a conjunction of atoms on the left and a
disjunction of atoms on the right. This form, sometimes called Kowalski form when written with a
right-to-left implication symbol, is often much easier to read.
Every sentence of first-order logic can be converted into an inferentially equivalent CNF sentence. In
particular, the CNF sentence will be unsatisfiable just when the original sentence is unsatisfiable, so
we have a basis for doing proofs by contradiction on the CNF sentences.

CNF CONVERSION
The steps are as follows:

Step 1: Eliminate implications:


x [¬y ¬Animal(y) V Loves(x,y)] V [y Loves(y,x)] .
Step 2: Move ¬ inwards:
In addition to the usual rules for negated connectives, we need rules for negated quantifiers. Thus, we
have
¬x p becomes x ¬p
¬x p becomes x ¬p.
Our sentence goes through the following transformations:
x [y ¬ (¬Animal(y)V Loves(x,y))]V [y Loves(y,x)} .
x [y ¬¬Animal(y) Λ ¬Loves(x,y)] V [y Loves(y,x)] .
x [y Animal(y) Λ ¬Loves(x,y)] \/ [y Loves(y,x)] .

Notice how a universal quantifier ( y) in the premise of the implication has become an existential
quantifier. The sentence now reads "Either there is some animal that x doesn't love, or (if this is not
the case) someone loves x." Clearly, the meaning of the original sentence has been preserved.

Step 3: Standardize variables:


For sentences like (x P(x)) V (x Q(x)) which use the same variable name twice, change the name
of one of the variables. This avoids confusion later when we drop the quantifiers. Thus, we have

x [y Animal(y) Λ ¬Loves(x,y)]\/ [z Loves(z,x)] .

Step 4: Skolemize:
Skolemization is the process of removing existential quantifiers by elimination. In the simple
case, it is just like the Existential Instantiation rule. Translate x P(x) into P(A), where A is a new
constant. If we apply this rule to our sample sentence, however, we obtain
x [Animal(A) Λ ¬Loves(x, A)] V Loves(B, x)

Which has the wrong meaning entirely: it says that everyone either fails to love a particular animal A
or is loved by some particular entity B. In fact, our original sentence allows each person to fail to
love a different animal or to be loved by a different person. Thus, we want the Skolem entities to
depend on x:
x [Animal(F(x)) Λ ¬Loves(x, F(x))] V Loves(G(x), x) .
29
Here F and G are Skolem functions. The general rule is that the arguments of Skolem function are
all the universally quantified variables in whose scope the existential quantifier appears. As with
Existential Instantiation, the Skolemized sentence is satisfiable exactly when the original sentence is
satisfiable.

Step 5: Drop universal quantifiers:


At this point, all remaining variables must be universally quantified. Moreover, the sentence is
equivalent to one in which all the universal quantifiers have been moved to the left. We can therefore
drop the universal quantifiers:
[Animal (F(x)) Λ ¬Loves(x, F(x))] V Loves(G(x),x) .

Step 6: Distribute V over Λ:


[Animal(F(x)) V Loves(G(x),x)]Λ [¬Loves(x, F(x)) V Loves(G(x),x)] .

This step may also require flattening out nested conjunctions and disjunctions.The sentence is now in
CNF and consists of two clauses. It is quite unreadable. (It may help to explain that the Skolem
function F(x) refers to the animal potentially unloved by x, whereas G(x) refers to someone who
might love x.) Fortunately, humans seldom need look at CNF sentences—the translation process is
easily automated.

The rule we have just given is the binary resolution rule, because it resolves exactly two literals. The
binary resolution rule by itself does not yield a complete inference procedure. The full resolution rule
resolves subsets of literals in each clause that are unifiable.

An alternative approach is to extend factoring—the removal of redundant literals—to the first-order


case.

Propositional factoring reduces two literals to one if they are identical; first-order factoring reduces
two literals to one if they are unifiable.

The unifier must be applied to the entire clause. The combination of binary resolution and factoring is
complete.

Example proofs
Consider the following problem:
We will prove that West is a criminal. First, we will represent these facts as first-order definite clauses.

 It is a crime for an American to sell weapons to hostile nations:


x y z American(x)  Weapon(y)  Nation(z)  Hostile(z)  Sells(x, y, z 
Criminal(x)
 Nono … has some missiles,
x Owns(Nono,x)  Missile(x)
 all of its missiles were sold to it by Colonel West

30
x Missiles(x)  Owns(Nono,x)  Sells(West,x,Nono)
 We will also need to know that missiles are weapons
x Missile(x)  Weapon(x)
 An enemy of America counts as "hostile―
x Enemy(x,America)  Hostile(x)
 West, who is American …
American(West)
 Nono, is a nation
Nation (Nono)
 Nono, an enemy of America
Enemy (Nono, America)
 America is nation
Nation (America)

This knowledge base contains no function symbols and is therefore an instance of the class of Datalog
knowledge bases—that is, sets of first-order definite clauses with no function symbols. The absence of
function symbols makes inference much easier.
Resolution proves that KB |= a by proving KB Λ ¬α unsatisfiable, i.e., by deriving the empty clause.

¬American(x) V ¬Weapon(y) V ¬Sells(x, y, z) V ¬Hostile (z) V Criminal(x)


¬Missile(x) V ¬Owns (Nono, x) V Sells (West, x, Nono)
¬Enemy(x, America) V Hostile(x)
¬Missile(x) V Weapon(X)

American (West)
Missile (M1)
Owns (Nono, M1)
Enemy (Nono,America)

Figure : A resolution proof that West is a criminal.

31
We also include the negated goal ¬Criminal (West).
Notice the structure: single "spine" beginning with the goal clause, resolving against 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

11. KNOWLEDGE REPRESENTATION


Internal Representation
central for „reasoning―: internal representation and symbol manipulation.
• Representation in general: An idealized world description (not necesserily symbolic)
• Internal symbolic representation: requires a common symbol language, in which an agent
can express and manipulate propositions about the world.
• good choicefor symbolic representations are languages of logic, however, some preparations
have to be made...

Symbolic representations must be unique regarding several aspects:


• referential • semantic • functional
 Make References Explicit
Natural language often is ambiguous:
The chair was placed on the table. It was broken.
Is represented as
The chair (r1) was placed on the table (r2).It (r1) was broken.
(Now it becomes obvious what was broken.)
 Refrential Uniqueness
o Symbolic representations must explicitly define relations for
entity references!
o i.e., all ambiguity with respect to entities must be eliminated in the
internal representation:
o all individuals get a unique name
o this means only one individual per name
Hence: instead of multiple "Daves": dave-1, dave-2
etc. Such unique names are denoted as instances or
tokens.

 Functional Uniqueness
Jack caught a ball. [catch-object]
Jack caught a cold. [catch-illness]
Different symbols imply different semantics
(even if their linguistic roots might be the same):
For example, who caught a cold must sneeze

o Internal representations must uniquely express the functional roles!


32
Petra catches the ball. The ball Petra
catches. The ball is caught by Petra.
Who is the catcher? Who or what is the caught object?

From Linguistic Sentence to Representation

Predicates, Logic Sentences, Assertions

 A logic sentence defines a fact about one or multiple entities, in this case a catch
relation between one Jack and a specific ball.
 Assertions are logic sentences which we take as given
facts (as elements of an actual internal representation)

Linguistic Sentence and Representation


In general, a linguistic sentence is represented by multiple logic sentences:

Jack caught a blue block.


(catch-object jack-1 block-1)
(inst block-1 block)
(color block-1 blue)

 Processes operating on internal representations are used to deduct derive new facts
from known facts: Inference
 Commonly used inference concept and term: Deduction
 Such processes can be modeled in higher order logic. (Normally we use first order logic.)

33
Slot-Assertion-Notation
A slot is an attribute value pair in its simplest form

 It enables attribute values to be retrieved quickly


o assertions are indexed by the entities
o binary predicates are indexed by first argument. E.g. team(Mike-Hall , Cardiff).
 Properties of relations are easy to describe .
 It allows ease of consideration as it embraces aspects of object oriented programming.
 A slot is an attribute value pair in its simplest form.
 A filler is a value that a slot can take -- could be a numeric, string (or any data type) value or a
pointer to another slot

Reason: To express functional relations

Slot-and-Filler-Notation (–>Frames)
Different slot-assertions are combined to provide a structured expression
A frame is a collection of attributes or slots and associated values that describe some real world
entity. Frames on their own are not particularly helpful but frame systems are a powerful way of
encoding information to support reasoning.
1Frames as Sets and Instances
Set theory provides a good basis for understanding frame systems. Each frame represents:
 a class (set), or
 an instance (an element of a class).

34
12. ONTOLOGICAL ENGINEERING
Representing these abstract concepts is called ontological engineering.
• How to create more general and flexible representations.
• Concepts like actions, time, physical object and beliefs
• Operates on a bigger scale than K.E.
• Define general framework of concepts
• Upper ontology
• Limitations of logic representation
• Red, green and yellow tomatoes: exceptions and uncertainty

The upper ontology of the world

For example, we will define what it means to be a physical object and the detail of different types of
objects—robots, televisions, books, or whatever—can be filled in later.
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 specific concepts below
them

For example, although "tomatoes are red" is a useful rule, some tomatoes are green, yellow, or
orange. Similar exceptions can be found to almost all the general statements in this chapter.

35
The ability to handle exceptions and uncertainty is extremely important, but is orthogonal to the task
of understanding the general ontology.

For example, time is omitted completely. Signals are fixed, and do not propagate. The structure of the
circuit remains constant. If we wanted to make this more general, consider signals at particular times,
and include the wire lengths and propagation delays. This would allow us to simulate the timing
properties of the circuit, and indeed such simulations are often carried out by circuit designers.

We could also introduce more interesting classes of gates, for example by describing the technology
(TTL, MOS, CMOS, and so on) as well as the input/output specification. If we wanted to discuss
reliability or diagnosis, we would include the possibility that the structure of the circuit or the
properties of the gates might change spontaneously. To account for stray capacitances, we would
need to move from a purely topological representation of connectivity to a more realistic description
of geometric properties.

Difference with special-purpose ontologies


• A general-purpose ontology should be applicable in more or less any special-purpose
domain.
• Add domain-specific axioms
A more general ontology, better suited for the real world, would allow for simultaneous changes
extended over time. We also used a Pit predicate to say which squares have pits. We could have
allowed for different kinds of pits by having several individuals belonging to the class of pits, each
having different properties.

For any special-purpose ontology, it is possible to make changes like these to move toward greater
generality. There are two major characteristics of general- purpose ontologies that distinguish them
from collections of special-purpose ontologies:

• A general-purpose ontology should be applicable in more or less any special-purpose domain. This
means that, as far as possible, no representational issue can be finessed or brushed under the carpet.

• In any sufficiently demanding domain, different areas of knowledge must be unified, because
reasoning and problem solving could involve several areas simultaneously.

• What do we need to express?


Categories, Measures, Composite objects, Time, Space, Change, Events, Processes, Physical
Objects, Substances, Mental Objects, Beliefs

13. CATEGORIES AND OBJECTS


• KR requires the organisation of objects into categories
• Interaction at the level of the object
• Reasoning at the level of categories

The organization of objects into categories 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 might have the goal of buying a basketball, rather than a particular basketball
such as BB9. Categories also serve to make predictions about objects once they are classified.

36
One infers the presence of certain objects from perceptual input, infers category membership from
the perceived properties of the objects, and then uses category information to make predictions about
the objects.

For example, from its green, mottled skin, large size, and avoid shape, one can infer that an object
is a watermelon; from this, one infers that it would be useful for fruit salad.

• Categories play a role in predictions about objects


• Based on perceived properties
• Categories can be represented in two ways by FOL
• Predicates: apple(x)
• Reification of categories into objects: apples

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 know that every apple is edible.
• Category = set of its members

Category organization
• Relation = inheritance:
• All instance of food are edible, fruit is a subclass of food and apples is a subclass of fruit
then an apple is edible.
• Defines a taxonomy

We say that the individual apples inherit the property of edibility, in this case from their membership
in the Food category.

Subclass relations organize categories into a taxonomy, or taxonomic hierarchy. Taxonomies have
been used explicitly for centuries in technical fields.

For example, systematic biology aims to provide a taxonomy of all living and extinct species; tax
authorities and other government departments have developed extensive taxonomies of occupations
and commercial products. Taxonomies are also an important aspect of general commonsense
knowledge.

37
First-order logic makes it easy to state facts about categories, either by relating objects to categories
or by quantifying over their members:

FOL and categories


• An object is a member of a category
• MemberOf(BB12,Basketballs)
• A category is a subclass of another category
• SubsetOf(Basketballs,Balls)
• All members of a category have some properties
• ∀ x (MemberOf(x,Basketballs) ⇒ Round(x))
• All members of a category can be recognized by some properties
• ∀ x (Orange(x) 𝖠 Round(x) 𝖠 Diameter(x)=9.5in 𝖠 MemberOf(x,Balls)
⇒ MemberOf(x,BasketBalls))
• A category as a whole has some properties
• MemberOf(Dogs,DomesticatedSpecies)
Relations between categories
• Two or more categories are disjoint if they have no members in common:
• Disjoint(s)⇔(∀ c1,c2 c1 ∈ s 𝖠 c2 ∈ s 𝖠 c1 ≠ c2 ⇒ Intersection(c1,c2) ={})
• Example: Disjoint({animals, vegetables})

• A set of categories s constitutes an exhaustive decomposition of a category c if all members


of the set c are covered by categories in s:
• E.D.(s,c) ⇔ (∀ i i ∈ c ⇒ ∃ c2 c2 ∈ s 𝖠 i ∈ c2)
• Example:
ExhaustiveDecomposition( {Americans, Canadian, Mexicans}, NorthAmericans)

Relations between categories

• A partition is a disjoint exhaustive decomposition:


• Partition(s,c) ⇔ Disjoint(s) 𝖠 E.D.(s,c)
• Example: Partition({Males,Females},Persons).
• Is ({Americans,Canadian, Mexicans},NorthAmericans)
a partition?
• No! There might be dual citizenships.
• Categories can be defined by providing necessary and sufficient conditions for membership
• ∀ x Bachelor(x) ⇔ Male(x) 𝖠 Adult(x) 𝖠 Unmarried(x)

Natural kinds
• Many categories have no clear-cut definitions
(e.g., chair, bush, book).
• Tomatoes: sometimes green, red, yellow, black. Mostly round.
• One solution: subclass using category Typical(Tomatoes).
• Typical(c) ⊆ c

38
• ∀ x, x ∈ Typical(Tomatoes) ⇒ Red(x) 𝖠 Spherical(x).
• We can write down useful facts about categories without providing exact definitions.

• Wittgenstein (1953) gives an exhaustive summary about the problems involved when exact
definitions for natural kinds are required in his book ―Philosophische Untersuchungen‖.
• What about ―bachelor‖? Quine (1953) challenged the utility of the notion of strict definition. We
might question a statement such as ―the Pope is a bachelor‖.

Physical composition
The idea that one object can be part of another is a familiar one. One's nose is part of one's head, Romania is
part of Europe. We use the general part of relation to say that one thing is part of another. Objects can be
grouped into PartOf hierarchies, reminiscent of the Subset hierarchy:
• One object may be part of another:
• PartOf(Bucharest,Romania)
• PartOf(Romania,EasternEurope)
• PartOf(EasternEurope,Europe)
• The PartOf predicate is transitive (and reflexive), so we can infer
that PartOf(Bucharest,Europe)
• More generally:
• ∀ x PartOf(x,x)
• ∀ x,y,z PartOf(x,y) 𝖠 PartOf(y,z) ⇒ PartOf(x,z)
• Often characterized by structural relations among parts.
• E.g. Biped(a) ⇒

14. Measurements
In both scientific and common sense theories of the world, objects have height, mass, cost, and so on. The
values that we assign for these properties are called measures

• Objects have height, mass, cost, ....


Values that we assign to these are measures
• Combine Unit functions with a number:
Length(L1) = Inches(1.5) =
Centimeters(3.81).
• Conversion between units:
∀ i Centimeters(2.54 x i)=Inches(i).
• Some measures have no scale: Beauty, Difficulty, etc.
• Most important aspect of
measures: they are orderable.
• Don't care about the actual numbers.
39
(An apple can have deliciousness .9 or .1.)
There are some properties that are intrinsic: they belong to the very substance of the object, rather than to
the object as a whole.
extrinsic properties are the opposite: properties such as weight, length, shape, function, and so on are
not retained under subdivision.

A class of objects that includes in its definition only intrinsic properties is then a substance, or mass
noun; a class that includes any extrinsic properties in its definition is a count noun.

The category Stuff is the most general substance category, specifying no intrinsic properties.
The category Thing is the most general discrete object category, specifying no extrinsic properties.

All physical objects belong to both categories, so the categories are coextensive—they refer to the
same entities.
Actions, events and situations
Reasoning about outcome of actions is central to KB-agent.
• How can we keep track of location in FOL?
• Remember the multiple copies in PL.
• Representing time by situations (states resulting from the execution of actions).
• Situation calculus

• Situation calculus:
• Actions are logical terms
• Situations are logical terms consiting of
• The initial situation I

40
• All situations resulting from the action on I (=Result(a,s))
• Fluents are functions and predicates that vary from one situation to the next.
• E.g. ¬Holding(G1, S0)
• Eternal predicates are also allowed
• E.g. Gold(G1)

 Results of action sequences are determined by the individual actions.


• Projection task: an SC agent should be able to deduce the outcome of a sequence of actions.
• Planning task: find a sequence that achieves a desirable effect

Describing change
Each action is described by two axioms:
1. Possibility axiom that says when it is possible to execute the action, and
2. Effect axiom that says effect axiom what happens when a possible action is executed.
We will use Poss(a, s) to mean that it is possible to execute action a in situation s.
• Simples Situation calculus requires two axioms to describe change:
• Possibility axiom: when is it possible to do the action
At(Agent,x,s) 𝖠 Adjacent(x,y) ⇒ Poss(Go(x,y),s)
• Effect axiom: describe changes due to action
Poss(Go(x,y),s) ⇒ At(Agent,y,Result(Go(x,y),s))

Frame problem
• What stays the same?
• Frame problem: how to represent all things that stay the same?
• Frame axiom: describe non- changes due to actions
At(o,x,s) 𝖠 (o ≠ Agent) 𝖠 ¬Holding(o,s) ⇒ At(o,x,Result(Go(y,z),s))

Representational frame problem


• If there are F fluents and A actions then we need AF frame axioms to describe other objects
are stationary unless they are held.
• We write down the effect of each actions

41
• Solution; describe how each fluent changes over time
• Successor-state axiom:
Pos(a,s) ⇒ (At(Agent,y,Result(a,s)) ⇔ (a = Go(x,y)) ∨
(At(Agent,y,s) 𝖠 a ≠ Go(y,z))
• Note that next state is completely specified by current state.
• Each action effect is mentioned only once
To solve the inferential frame problem, we have two possibilities.
1. First, we could discard situation calculus and invent a new formalism for writing axioms. This
has been done with formalisms such as the fluent calculus.
2. Second, we could alter the inference mechanism to handle frame axioms more efficiently.
We need to say that an implicit effect of an agent moving from x to y is that any gold it is carrying
will move too (as will any ants on the gold, any bacteria on the ants, etc.). Dealing with implicit
effects is called the ramification problem.

Other problems
• How to deal with secondary (implicit) effects?
• If the agent is carrying the gold and the agent moves then the gold moves too.
• Ramification problem
• How to decide EFFICIENTLY whether fluents hold in the future?
• Inferential frame problem.
• Extensions:
• Event calculus (when actions have a duration)
• Process categories

15. MENTAL EVENTS AND OBJECTS


• So far, KB agents can have beliefs and deduce new beliefs
• What about knowledge about beliefs? What about knowledge about the inference proces?
• Requires a model of the mental objects in someone’s head and the processes that
manipulate these objects.
• Relationships between agents and mental objects: believes, knows, wants, …
• Believes(Lois,Flies(Superman)) with Flies(Superman) being a function … a candidate
for a mental object (reification).
• Agent can now reason about the beliefs of agents
The agents we have constructed so far have beliefs and can deduce new beliefs. Yet none of them has
any knowledge about beliefs or about deduction. For single-agent domains, knowledge about one's
own knowledge and reasoning processes is useful for controlling inference.

For example, if one knows that one does not know anything about Romanian geography, then one
need not expend enormous computational effort trying to calculate the shortest path from Arad to
Bucharest. One can also reason about one's own knowledge in order to construct plans that will
change it—for example by buying a map of Romania. In multiagent domains, it becomes important
for an agent to reason about the mental states of the other agents.

42
For example, a Romanian police officer might well know the best way to get to Bucharest, so the
agent might ask for help.

In essence, what we need is a model of the mental objects that are in someone's head (or something's
knowledge base) and of the mental processes that manipulate those mental objects. The model should
be faithful, but it does not have to be detailed.

We will be happy to conclude that the Romanian police officer will tell us how to get to Bucharest if
he or she knows the way and believes we are lost.

A formal theory of beliefs

We begin with the relationships between agents and "mental objects"—relationships such as
Believes, Knows, and Wants.

Relations of this kind are called propositional attitudes, because they describe an attitude that an
agent can take toward a proposition. Suppose that Lois believes something—that is, Believes(Lois,x).
What kind of thing is xl Clearly, x cannot be a logical sentence.

If Flies (Superman) is a logical sentence, we can't say Believes(Lois, Flies [Superman)), because only
terms (not sentences) can be arguments of predicates. But if Flies is a function, then Flies [Superman)
is a candidate for being a mental object, and Believes can be a relation between an agent and a
propositional fluent. Turning a proposition into an object is called reification.

This appears to give us what we want: the ability for an agent to reason about the beliefs of agents.
Unfortunately, there is a problem with that approach: If Clark and Superman are one and the same
(i.e., Clark = Superman) then Clark's flying and Superman's flying are one and the same event
category, i.e., Flies(Clark) = Flies (Superman). Hence, we must conclude that if Lois believes that
Superman can fly, she also believes that Clark can fly, even if she doesn't believe that Clark is
Superman. That is,

(Superman = Clark) ╞ (Believes(Lois, Flies (Superman)) <=>


Believes [Lois, Flies (Clark))) .

There is a sense in which this is right: Lois does believe of a certain person, who happens to be called
Clark sometimes, that that person can fly. But there is another sense in which it is wrong: if you
asked Lois "Can Clark fly?" she would certainly say no. Reified objects and events work fine for the
first sense of Believes, but for the second sense we need to reify descriptions of those objects and
events, so that Clark and Superman can be different descriptions (even though they refer to the same
object).

Technically, the property of being able to substitute a term freely for an equal term is called
referential transparency. In first-order logic, every relation is referentially transparent. We would like
to define Believes (and the other prepositional attitudes) as relations whose second argument is
referentially opaque—that is, one cannot substitute an equal term for the second argument without
changing the meaning.

There are two ways to achieve this.

1. The first is to use a different form of logic called modal logic, in which prepositional attitudes
such as Believes and Knows become modal operators that are referentially opaque.

43
2. The second approach, which we will pursue, is to achieve effective opacity within a
referentially transparent language using a syntactic theory of mental objects. This means that
mental objects are represented by strings. The result is a crude model of an agent's
knowledge base as consisting of strings that represent sentences believed by the agent. A
string is just a complex term denoting a list of symbols, so the event Flies(Clark) can be
represented by the list of characters [F, l, i, e, s, (, C, l, a, r, k,)], which we will abbreviate as a
quoted string, ―Flies(Clark)". The syntactic theory includes a unique string axiom
stating that strings are identical if and only if they consist of identical characters. In this way,
even if Clark = Superman, we still have "Clark" ≠ "Superman".

We start by defining Den as the function that maps a string to the object that it denotes and Name as a
function that maps an object to a string that is the name of a constant that denotes the object.

For example, the denotation of both "Clark" and "Superman" is the object referred to by the constant
symbol ManOfSteel, and the name of that object within the knowledge base could be either
"Superman", "Clark", or some other constant, such as "In":

Den("Clark") = ManOfSteel Λ Den("Superman") = ManOfSteel .


Name{ManOfSteel) = "X11" .

The next step is to define inference rules for logical agents. For example, we might want to say that a
logical agent can do Modus Ponens: if it believes p and believes p => q, then it will also believe q.
The first attempt at writing this axiom is

LogicalAgent(a) Λ Believes(a,p) Λ Believes(a,"p=> q") => Believes(a,q) .

But this is not right because the string "p => q" contains the letters 'p' and 'q' but has nothing to do
with the strings that are the values of the variables p and q. The correct formulation is

LogicalAgent(a) Λ Believes(a,p) Λ Believes(a, Concat(p,"=>", q)) => Believes(a,q) .

Where Concat is a function on strings that concatenates their elements. We will abbreviate
Concat(p,"=>",q) as "p=>q". That is, an occurrence of x within a string is unquoted, meaning that we
are to substitute in the value of the variable x.

Lisp programmers will recognize this as the comma/backquote operator, and Perl programmers will
recognize it as $-variable interpolation.

Once we add in the other inference rules besides Modus Ponens, we will be able to answer questions
of the form "given that a logical agent knows these premises, can it draw that conclusion?" Besides
the normal inference rules, we need some rules that are specific to belief.

For example, the following rule says that if a logical agent believes something, then it
believes that it believes it.

LogicalAgent(a) Λ Believes(a,p) => Believes(a,"Believes(Name(a), p)") .

Now, according to our axioms, an agent can deduce any consequence of its beliefs infallibly. This is
called logical omniscience. A variety of attempts have been made to define limited rational agents,
which can make a limited number of deductions in a limited time.

44
None is completely satisfactory, but these formulations do allow a highly restricted range of
predictions about limited agents.

THE INTERNET SHOPPING WORLD


• A Knowledge Engineering example
• An agent that helps a buyer to find product offers on the internet.
• IN = product description (precise or ¬precise)
• OUT = list of webpages that offer the product for sale.
• Environment = WWW
• Percepts = web pages (character strings)
• Extracting useful information required

• Find relevant product offers


RelevantOffer(page,url,query) ⇔ Relevant(page, url, query) 𝖠 Offer(page)
• Write axioms to define Offer(x)
• Find relevant pages: Relevant(x,y,z) ?
• Start from an initial set of stores.
• What is a relevant category?
• What are relevant connected pages?
• Require rich category vocabulary.
• Synonymy and ambiguity
• How to retrieve pages: GetPage(url)?
• Procedural attachment
• Compare offers (information extraction)

16. REASONING SYSTEMS FOR CATEGORIES


• How to organize and reason with categories?
• Semantic networks
• Visualize knowledg-e

• Efficient algorithms for category membership inference


• Description logics
• Formal language for constructing and combining category definitions
• Efficient algorithms to decide subset and superset relationships between categories

REPRESENTATION OF A SCE

45
(inst block-2 block)
(color block-2 red)
(supported-by block-2 block-1) (

inst block-1 block)


(color block-1 yellow)
(supported-by block-1 table-1)
as set of logic expressions
• as Semantic Net

16. SEMANTIC NETWORKS


A Semantic Net : is a formal graphic language representing facts about entities in some world about
which we wish to reason. The meaning of a concept comes from the ways in which it is connected to
other concepts. In semantic net, information is represented as a set of nodes connected to each other
by set of labeled arcs, which represent relationships among the nodes.
• Logic vs. semantic networks
• Many variations
• All represent individual objects, categories of objects and relationships among objects.
• Allows for inheritance reasoning
• Female persons inherit all properties from person.
• Cfr. OO programming.
• Inference of inverse links
• SisterOf vs. HasSister

Alternative Notations
Semantic Nets (a.k.a. „associative nets) and FOL sentences represent same information in
different formats:

Nodes correspond to terms marked out directed edges correspond to predicates

46
They are alternative notations for the same content, not in principle different
representations!

Missing existential quantifier Functions (extensions exist) Semantic nets additionally provide
pointers (and sometimes back pointers) which allow easy and high-
performance information access (e.g., to instances): INDEXING

ISA-Hierarchy and Inheritance


• Key concept in the tradition of semantic nets
• Instances inherit properties which we attribute to sets of individuals (classes).
• This can be propagates along the complete isa hierarchy
• Inheritance of properties
Reason: Knowledge representation economy
• Search along isa- and inst-links to access information not
“instance of“ directly associated (using inheritance)
„Instanz von”

• inst: member of
• isa: subset of

Example of an ISA-Hierarchy

Drawbacks
• Links can only assert binary relations
• Can be resolved by reification of the proposition as an event
• Representation of default values
• Enforced by the inheritance mechanism.

47
Representation of a Scene
(inst block-2 block) (color block-2 red)
(supported-by block-2 block-1) (inst block-1 block)
(color block-1 yellow) (supported-by block-1 table

48

You might also like