Download as pdf or txt
Download as pdf or txt
You are on page 1of 48

3

Unit

KNOWLEDGE REPRESENTATION

First Order Predicate Logic – Prolog Programming – Unification – Forward Chaining-


Backward Chaining – Resolution – Knowledge Representation – Ontological Engineering-
Categories and Objects – Events – Mental Events and Mental Objects – Reasoning Systems for
Categories – Reasoning with Default Information

What is a Logic?
• Logic basically deals with the study of principles of reasoning. It is mainly concerned
about truth of the statements of the world.
• They are formal system in which formulas or sentences have true or false values.
• Logic involves syntax, semantics and inference procedure.
◦ Syntax: Specifies the symbols in the language about how they can be combined to
form sentences.
◦ Semantics: Specifies how to assign a truth value to a sentence based on its
meaning in the world.
◦ Inference procedure: Specifies methods for computing new sentences from the
existing sentences.
• Mapping of relationships:
◦ Let x and y are two sentences whose relationship is to be determined.
◦ One thing follows from another KB = α
◦ KB entails sentence α if and only if α is true in all worlds where KB is true.
◦ E.g. x+y=4 entails 4=x+y
◦ Entailment is a relationship between sentences that is based on semantics.
• Logics are of different types: Propositional logic, Predicate logic, Temporal logic
Modal logic and Description logic, etc.
• Among the above types predicate and propositional logic are fundamental.
3.2 Artificial Intelligence
◦ Propositional Logic – The study of statements and their connectivity.
◦ Predicate Logic – The study of individuals and their properties.

Propositional Logic Syntax:


• A proposition is a sentence, written in a language, that has a truth value (i.e., it is true
or false) in a world.
• A proposition is built from atomic propositions using logical connectives.
• A proposition is either
◦ an atomic proposition or
◦ a compound proposition of the form
• An atomic proposition, or just an atom, is a symbol that starts with a lower-case letter.
◦ Intuitively, an atom is something that is true or false.
◦ For example, ai_is_fun, lit_l1, live_outside, and sunny can all be atoms.
• A compound proposition of the form
◦ p (read "not p")--the negation of p
p∧q (read "p and q")--the conjunction of p and q
p∨q (read "p or q")--the disjunction of p and q
p→q (read "p implies q")--the implication of q from p
p←q (read "p if q")--the implication of p from q
p ↔q (read "p if and only if q" or "p is equivalent to q")

Where p and q are propositions.

3.1 PROPOSITIONAL LOGIC SEMANTIC


• Semantics specifies how to put symbols of the language into correspondence with the
world.
• Semantics can be used to understand sentences of the language.
Knowledge Representation 3.3
• The semantics of propositional calculus is defined below.
• An interpretation consists of a function π that maps atoms to {true, false}.
• If π(a)=true, we say atom a is true in the interpretation, or that the interpretation
assigns true to a. If π(a)=false, we say a is false in the interpretation
• The truth value of a compound proposition is built using the truth table
of Figure given below.

p Q ¬p p ∧q p∨q p ←q p →q p ↔q

true True false true true true true true

true false false false true true false false

false true true false true false true False

false false true false false true true True


Example:
AI is fun be represented by B. If Ai is fun to learn, students will be happy or they interact
in the class alot. Thus students are happy is represented by P and students interact is represented
by Q. This can be mapped in propositional logic as follows: B (PVQ) based on such
implications and assumptions rules are formed which aids in designing the KB for any problem.
Once carefully analyzed and understood the relationships can be inferred properly.

An inference rule is a rule of the form (α1, α2, . . . , αn) /β, where α1, α2, . . . , αn are
sentences called conditions and β is a sentence called conclusion. Whenever we have a set of
sentences that match the conditions of an inference rule then we can conclude the sentence in the
conclusion.

Inference Rules for Propositional Logic


3.4 Artificial Intelligence

Some concepts related to propositional logic:


1) Tautology/Validity: If a sentence is true if it is true in all models. The proposition is
always true.
2) Contradiction: The proposition is always false.
3) Satisfiability: A sentence or a proposition is satisfiable if it is true for some model. If
A is true in model m then m satisfies A. m is a model of A. Satisfiability has to be
determined by some factors that is taken care by refutation.
4) Contingency: Its neither tautology nor Contradiction.
Reasoning patterns in propositional logic depends on applying the basic rules in order to
derive chains of conclusions to get the target, those basic rules are called Patterns of Inference.
Two commonly used rules are Modes Ponens and and-Elimination.

3.1.1 Knowledge Representtion Using Predicate Logic


Predicate Logic:
A predicate is a statement that contains variables and they may be true or false depending
on the value of the variables.
To know how predicate is different from propositional logic, let us see the example:
• Every CSE student must study AI
• Sam is a CSE student
This looks logical but can’t be represented as a propositional logic, since there is a lack of
logical operators to apply here.

Universal Quantifier: is a Quantifier meaning “given any” or “for all” the symbol used to
represent this quantifier is

Existential Quantification: Is a quantifier meaning “there exists”, “there is atleast one” or


“for some”.
Knowledge Representation 3.5

Syntax and Semantics


Predicate logic is a formal language (like a programming language) with rules for

Syntax (i.e. how to write expressions)


• Syntax are well-formed formulas
• Logical symbols: and, or, not, all, at least one, brackets, variables, equality (=), true,
false
• Predicate and function symbols (for example, Cat(x) for “x is a Cat”)
• Term: variables and functions (for example, Cat(x))
• Formula: any combination of terms and logical symbols (for example, “Cat(x) and
Sleeps(x)”)
• Sentence: formulas without free variables (for example, “All x: Cat(x) and Sleeps(x)”)
Semantics (i.e. how to formalise the meaning of expressions)
• The meaning of a term or formula is a set of elements.
• The meaning of a sentence is a truth value.
• The function that maps a formula into a set of elements is called an interpretation. An
interpretation maps an intensional description (formula/sentence) into an extensional
description (set or truth value).
Validity of Predicates:
A sentence is ...
• Satisfiable if it is true under at least one interpretation.
• Valid if it is true under all interpretations.
• Invalid if it is false under some interpretation.
• Contradictory if it is false under all interpretations.
Example: “All x: Cat(x) and Sleeps(x)” If this is interpreted on an island which only has
one cat that always sleeps, this is satisfiable. Since not all cats in all interpretations always
sleep, the sentence is not valid.

Examples of Predicate Logic:


Consider the following set of sentences with the facts/descriptions as a set of well- formed
formulas in predicate logic as follows:
3.6 Artificial Intelligence
(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.
∀x: Pompeian(x) → Roman(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 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.


∀x: 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. Some people will
argue, however, that this English sentence is really stating an exclusive-or.

To express that, we would have to write:


∀x : Roman(x) → [( loyalto(x, Caesar) V hate(x, Caesar)) ∧ ¬ (Ioyalto(x, Caesar) ∧
hate(x, Caesar))]

(6) Everyone is loyal to someone.


∀x : → y: Ioyal to(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
Knowledge Representation 3.7
everyone? Or does it say that there exists someone to whom everyone is loyal (which would be
written as ∃ y : ∀ x : 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.
∀ x : ∀ y : person(x) ∧ ruler(y) ∧ tryassassinate(x,y) → ¬ Ioyalto(x,y)

This sentence, too, is ambiguous. Does it mean that the only rulers that people try to
assassinate are those to whom they are not loyal (the interpretation used here), or does it mean
that the only thing people try to do is to assassinate rulers to whom they are not loyal?

In representing this sentence the way we did, we have chosen to write ''try to assassinate"
as a single predicate. This gives a fairly simple representation with which we can reason about
trying to assassinate. But using this representation, the connections between trying to assassinate
and trying to do other things and between trying to assassinate and actually assassinating could
not be made easily. If such connections were necessary, we would need to choose a different
representation.

(8) Marcus tried to assassinate Caesar.


tryassassinate (Marcus, Caesar)
If we want to use these statements to answer the question:
“Was Marcus loyal to Caesar?” Using 7 and 8, prove that Marcus was not loyal to Caesar.
To produce a Formal proof, reasoning backward from the desired goal:
 loyal to (Marcxus, Caesar)

To prove the goal:


Use the rules of inference to transform it into another goal that can be transformed and so
on, until there are no unsatisfied goals remaining.

This process require the search of an AND-OR graph when there is an alternative way of
satisfying individual goals. We show only a single path for simpler way.

The Below fig shows an attempt to produce a proof of the goal by reducing the set of
necessary but as yet anattained goals to the empty set. If attempt fails, there is no way to satisfy
the goal person with the available statements.

Problem Marcus was a man, need to add the representation of another fact to our system,
namely:
 loyalto(Marcus, Caesar)
 (7, substitution)
person (Marcus) 
ruler(Caesar)
tryassassinated (Marcus, Caesar)
3.8 Artificial Intelligence
 (4)
person (Marcus)
tryassassinate (Marcus, Caesar)
 (8)
person (Marcus)
Fig shows An attempt to prove  loyal to [Marcus, Caesar]
(9) All men are people.
∀ : man(x) → person(x)

Now we can satisfy the last goal and produce a proof that Marcus was not loyal to Caesar.

From this simple example, we see that three important issues must be addressed in the
process of converting English sentences into logical statements and then using those
statements to deduce new ones:

The three issues are:


• Many English sentences are ambiguous (for example, 5, 6, and 7 above). Choosing the
correct interpretation may be difficult.
• 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 practical representation for a particular set of sentences
depends on the use to which the knowledge contained in the sentences will be put.
• 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) or ¬ loyalto(Marcus, Caesar)

Strategies-
i) Reasoning backward from a proposed truth to the axioms and instead try to reason forward
and see which answer it gets to.
The problem with this approach is the Branching factor going forward from the axioms is
great that it would not get to either answer in any time.
Knowledge Representation 3.9
ii) Use some heuristic rules for deciding which answer is more likely and try to prove that
one first. If it fails to find a proof after some reasonable amount of some reasonable
amount of effort, it try other answer. Any proof procedure we use not halt if given a non
theorem.
iii) Try to prove both answers simultaneously and stop when one effort is successful. No
information to answer the question with certainity, the program never halt.
iv) Try both to prove one answer and disprove it, and to use information gained in one
process to guide the other.
Representing Instance and ISA Relationships:
1) man(Marcus)
2) Pompeian(Marcus)
3) x: Pompeian(x)  Roman(x)
4) ruler (Caesar)
5) x: Roman (x)  loyalto(x, Caesar)  hate(x, Caesar)

1) instance(Marcus,man)
2) instance (Marcus, Pompeian)
3) x: instance(x, Pompeian)  instance(x, Roman)
4) instance (Caesar,ruler)
5) x: instance (x, Roman)  loyalto(x, Caesar)  hate(x, Caesar)

1) instance(Marcus,man)
2) instance (Marcus, Pompeian)
3) isa: (Pompeian, Roman)
4) instance (Caesar,ruler)
5) x: instance (x, Roman)  loyalto(x, Caesar)  hate(x, Caesar)
6) x: y: z :instance (x, y)  isa (y, z)  instance (x, z)
Fig- shows Three ways of Representing Class Membership
The first five sentences of the last section represented in logic in three different ways.
(i) The first part of the figure contains the representations, in these representations,
class membership is represented with unary predicates, each corresponds to a
class. Asserting that p(x) is true is equivalent to asserting that x is an instance of p.
(ii) The second part of the figure contains representations that use the instance
predicate explicitly. The predicate instance is a binary one, whose first argument is
an object and whose second argument is a class to which the object belongs.
Representations use subclass relationships, such as that between pompeians and
3.10 Artificial Intelligence
Romans, are described in sentences 3. The implication rule states object is an
instance of the subclass Pompeian then it is an instance of the superclass Roman.
This rule is equivalent to the standard set-theoretic definition of the subclass-
superclass relationship.
(iii) The third part contains representations use both the instance and isa predicates
explicitly. Use of isa simplifies the representation of sentence 3, but requires one
additional axiom. It describes how an instance relation and an isa relation
combined to derive a new instance relation. This additional axiom is general and
not needed to be provided separately for additional isa relations.

The examples illustrate two points:


(i) The first is specific class and superclass memberships are facts to be represented,
those memberships need not to be represented with predicates labeled instance and isa.
In a logical framework, unary predicates corresponding to the classes are often used.
(ii) The second point is general. There are different ways of representing a given fact
within a particular representational framework, be it logic.
◦ Particular knowledge base consistency of representation is critical.
◦ Particular inference rule is designed to work on one particular form of
representation, all the knowledge to which that rule is intended to apply be in the
form that the rule demands.
◦ Many errors in the reasoning preformed by knowledge-based programs are the
result of inconsistent representation decisions.
(iii) The Additional point is the use of isa hierarchies in logic-based system.
The reason that these hierarchies are so important is not that they permit the inference of
superclass membership.

It is that by permitting the inference of superclass membership, they permit the inference
of other properties associated with membership in that superclass.

Computable Functions And Predicates:


Simple facts were expressed as combinations of individual predicates. If Number of facts
is not large or if the facts are unstructured then there is little alternative. If we want to express
simple facts, like greater than and less than relations:

gt(1, 0) lt(0,1)
gt(2, 1) lt(1, 2)
gt(3, 2) lt(2, 3)
Knowledge Representation 3.11
There are infinite representation of each of these fact. But if we consider the finite number
of them that can be represented, using a single machine word per number, extremely inefficient to
store explicitly large a set of statements. Instead, we compute each one as we need it.

Thus, it becomes useful to augment our representation by these computable predicates. We


invoke a procedure which specify in addition to our regular rules that will evaluate it and return
true or false.

It is useful to have computable functions as well as computable predicates. We evaluate


the truth of

gt (2 + 3, 1)

We compute the value of the plus function given the arguments 2 and 3 and then send the
arguments 5 and 1 to gt.

Introduction To Predicate Calculus


Example:
We know that all Romans who know Marcus either hate Caesar or think that anyone who
hates anyone is crazy.

Represented in the well-formed formula(wff):


x : [Roman (x)  know (x, Marcus)]
[hate (x, Caesar) V (y: EZ : hate (y,z)  think crazy (x,y))]

• To use this formula in a proof requires a complex matching process.


• Matched one piece of it, such as think crazy (x, y), it is necessary to do the right thing
with the rest of the formula including the pieces in which the matched part is
embedded and which is not.
• If the formula is simple, process would be easier.

The formula would be easier to work if


• It were flatter, i.e., there was less embedding of components.
• The quantifiers were separated from the rest of the formula so that they did not need to
be considered.
Conjunctive normal form [Davis and Putnam, 1960] has both of these properties, for
example, the formula given above for the feelings of romans who know Marcus would be
represented in conjunctive normal form as
 Roman(x)   know(x, Marcus) 
hate(x,Caesar)   hate (y, z)  thinkcrayz(x, z)

◦ Alg to convert any wff into conjunctive normal form, we lose no generality if we
employ a proof procedure that operates only on wff”s in this form.
3.12 Artificial Intelligence
◦ We need to reduce a set of wff’’s to a set of clauses, where a clause is defined to
be a wff in conjunctive normal form but with no instances of the connector A.
◦ Converting each wff into conjunctive normal form and then breaking apart each
such expression into clauses , one for each conjunct
◦ All conjuncts considered to be conjoined together as the proof procedure operates.

Algorithms: Convert to clause form


1) Eliminate →, using the fact that a → b is equivalent to ¬ a V b. Performing this
transformation on the wff given above yields
∀x: ¬ [Roman(x) ∧ know(x, Marcus)] V
[hate(x, Caesar) V (∀y : ¬(∃z : hate(y, z)) V thinkcrazy(x, y))]
2) Reduce the scope of each ¬ to a single term, using the fact that ¬ (¬ p) = p,
deMorgan's laws [which say that ¬ (a ∧ b) = ¬ a V ¬ b and ¬ (a V b) = ¬ a ∧ ¬ b ],
and the standard correspondences between quantifiers [¬ ∀ x: P(x) = ∃ x: ¬ P(x) and ¬
∃ x: P(x) = ∀ x: ¬P(x)]. Performing this transformation on the wff from step 1 yields
∀x: [¬ Roman(x) V ¬ know(x, Marcus)] V
[hate(x, Caesar) V (∀y: ∀z: ¬ hate(y, z) V thinkcrazy(x, y))]
3) Standardize variables so that each quantifier binds a unique variable. Since variables
are just dummy names, this process cannot affect the truth value of the wff. For
example, the formula
∀x: P(x) V ∀x: Q(x)
would be converted to
∀x: P(x) V ∀y: Q(y)
This step is in preparation for the next.
4) Move all quantifiers to the left of the formula without changing their relative order.
This is possible since there is no conflict among variable names. Performing this
operation on the formula of step 2, we get
∀x: ∀y: Az: [¬ Roman(x) V ¬ know(x, Marcus)] V
[hate(x, Caesar) V (¬ hate(y, z) V thinkcrazy(x, y))]
At this point, the formula is in what is known as prenex normal form. It consists of a
prefix of quantifiers followed by a matrix, which is quantifier-free.
5) Eliminate existential quantifiers. A formula that contains an existentially quantified
variable asserts that there is a value that can be substituted for the variable that makes
the formula true. We can eliminate the quantifier by substituting for the variable a
reference to a function that produces the desired value. Since we do not necessarily
know how to produce the value, we must create a new function name for every such
replacement. We make no assertions about these functions except that they must exist.
So, for example, the formula
∃y : President(y)
Knowledge Representation 3.13
can be transformed into the formula
President(S1)
where S1 is a function with no arguments that somehow produces a value that satisfies
President. If existential quantifiers occur within the scope of universal quantifiers, then
the value that satisfies the predicate may depend on the values of the universally
quantified variables. For example, in the formula
∀x: ∃y: father-of(y, x)
the value of y that satisfies father-of depends on the particular value of x. Thus we
must generate functions with the same number of arguments as the number of
universal quantifiers in whose scope the expression occurs. So this example would be
transformed into
∀x: father-of(S2(x), x)
These generated functions are called Skolem functions. Sometimes ones with no
arguments are called Skolem constants.
6) Drop the prefix. At this point, all remaining variables are universally quantified, so the
prefix can just be dropped and any proof procedure we use can simply assume that any
variable it sees is universally quantified. Now the formula produced in step 4 appears
as
[¬ Roman(x) V ¬ know(x, Marcus)] V
[hate(x, Caesar) V (¬ hate(y, z) V thinkcrazy(x, y))]
7) Convert the matrix into a conjunction of disjuncts. In the case or our example, since
there are no and’s, it is only necessary to exploit the associative property of or
[ i.e., (a ∧ b) V c = (a V c) ∧ (b ∧ c)] and simply remove the parentheses, giving
¬ Roman(x) V ¬ know(x, Marcus) V
hate(x, Caesar) V ¬ hate(y, z) V thinkcrazy(x, y)
However, it is also frequently necessary to exploit the distributive property
[i.e. , (a ∧ b) V c = (a V c) ∧ (b V c)]. For example, the formula
(winter ∧ wearingboots) V (summer ∧ wearingsandals)
becomes, after one application of the rule
[winter V (summer ∧ wearingsandals)]
∧ [wearingboots V (summer ∧ wearingsandals)]
and then, after a second application, required since there are still conjuncts joined by
OR's,
(winter V summer) ∧
(winter V wearingsandals) ∧
(wearingboots V summer) ∧
(wearingboots V wearingsandals)
3.14 Artificial Intelligence
8) Create a separate clause corresponding to each conjunct. In order for a wff to be true,
all the clauses that are generated from it must be true. If we are going to be working
with several wff’s, all the clauses generated by each of them can now be combined to
represent the same set of facts as were represented by the original wff's.
9) Standardize apart the variables in the set of clauses generated in step 8. By this we
mean rename the variables so that no two clauses make reference to the same variable.
In making this transformation, we rely on the fact that
(∀x: P(x) ∧ Q(x)) = ∀x: P(x) ∧ ∀x: Q(x)
Thus since each clause is a separate conjunct and since all the variables are universally
quantified, there need be no relationship between the variables of two clauses, even if
they were generated from the same wff.
Performing this final step of standardization is important because during the resolution
procedure it is sometimes necessary to instantiate a universally quantified variable
(i.e., substitute for it a particular value). But, in general, we want to keep clauses in
their most general form as long as possible. So when a variable is instantiated, we
want to know the minimum number of substitutions that must be made to preserve the
truth value of the system.
After applying this entire procedure to a set of well-formed formulas, we will have a
set of clauses, each of which is a disjunction of literals. These clauses can now be
exploited by the resolution procedure to generate proofs.

3.2 LOGIC PROGRAMMING


• Logic programming systems which is popular is PROLOG
• PROLOG Program – Series of logical assertions, each of which is a Horn Clause.
• A Horn Clause is a clause that has at most one positive literal
• Thus, P, P. VP and Pq are all Horn Clause.
x: pet(x)  small(x)  apartmentpet(x)
x: cat(x)  dog(x)  pet(x)
x: poodle(x)  dog(x)  small(x)
Poodle(fluffy)
A representation in logic
Apartmentpet(x) :- pet(x), small(x) .
pet(x) :- cat(x) .
pet(x) :- dog(x) .
dog(x) :- poodle(x) .
small(x) :- poodle(x) .
poodle(fluffy) .
A representation in PROLOG
Knowledge Representation 3.15
Fig – shows A Declarative and a procedural Representation
• The last of these does not look like a clause and it appears to have two positive literals.
• Logical expression converted to clause form.

Example:
The Resulting clause is  p V q, which is Horn Clause.

As we will see, Horn Clauses looks like the form we started with them the clause form we
just produced.
• Examples of PROLOG Horn clauses:
(i) PROLOG programs are composed only of Horn clauses and not of arbitrary
logical expressions has two important sequences.
a) First is that because of the uniform representation a simple and efficient
interpreter can be written
b) Second consequence is more important.
The logic of Horn clause systems is decidable
(ii) The control structure imposed on a PROLOG program by the PROLOG
interpreter is the one we used at the beginning to find the answer Cleopatra and
Marcus
(iii) The input to be program is a goal to be proved.
(iv) Backward reasoning is applied to prove the goal given the assertions in the
program.
(v) The program is read top to bottom, left to right and search is performed depth-
first with backtracking
• the above fig- shows an example of a knowledge base represented in std logical
notation and then in PROLOG.
Both Representations has 2 types of statements:
(i) Facts – contain only constants and Represent statements about specific objects.
(ii) Rules – Contain variables and Represent statements about classes of objects.

Difference between logic and PROLOG Representations, includes:


1) In logic, variables are explicitly quantified. In PROLOG, quantification is provided
implicitly by the way variables are interpreted (see below). The distinction between
variables and constants is made in PROLOG by having all variables being with upper
case letters and all constants begin with lower case letters or numbers.
2) In logic, there are explicit symbol for and () and or (). In PROLOG, there is an
explicit symbol for and (,), but there is none for or. Instead, disjunction must be
3.16 Artificial Intelligence
represented as a list of alternative statements, any one of which may provide the basis
for a conclusion.
3) In logic, implications of the form “p implies q” are written as pq. in PROLOG, the
same implication is written “backward,” as q :- p. This form is natural in PROLOG
because the interpreter always works backward from a goal, and this form causes
every rule to begin with the component that must therefore be matched first. This first
component is called the head of the rule.
The first two of these differences are naturally from the fact that PROLOG programs are
actually sets of horn clauses that have been transformed as follows:
1) If the horn clause contains no negative literals (i.e., it contains a single literal which is
positive), then leave it as it is.
2) Otherwise, rewrite the horn clause as an implication, combining all of the negative
literal into antecedent of the implication and leaving the single positive literal (if there
is one) as the consequent.

Procedural Representation:
(i) It causes a clause consisting of a disjunction of literals to be transformed into a single
implication whose antecedent is a conjunction of literals.
(ii) In a clause, all variables are implicitly universally quantified.
(iii) Applying this transformation, any variables that occurred in negative literals and now
occur in the antecedent become existentially quantified, while the variables in the
consequent are still universally quantified.
Example: The PROLOG clause
P(x) : -Q(x,y)
Equivalent to the logical expression
x : y : Q (x,y)  p(x)

Logic Representation PROLOG Representation


Logical assertions define only the set of PROLOG interpreter has a fixed control
answers that they justify : they say nothing strategy so the assertions define a particular
about how to choose among those answers if search path to an answer to any question.
there are more than one.

PROLOG Control Strategy:


• It is simple
• Begin with a problem statement, which is viewed as a goal to be proved.
• Assertions prove the goal.
• Facts which prove the goal directly, and rule whose head matches the goal.
• To decide whether a fact or a rule can be applied to the current problem, invoke a
standard unification procedure.
Knowledge Representation 3.17
• Reason backward from the goal until a path is found that terminates with assertions in
the program.
• Consider paths using a depth-first search strategy and using backtracking, consider
options in the order in which they appear in the program.
• If a goal has more than one conjunctive part, prove the parts in the order in which they
appear, propagating variable bindings as they are determined during unification.
Example:
Problem- Find a value of x that satisfies the predicate apartment pet (x). We state this goal
to PROLOG as

Input: ? – apartment pet (x).

• The PROLOG interpreter begins looking for a fact with the predicate apartment or a
rule with that predicate as its head.
• PROLOG Programs are written with the facts containing a given predicate coming
before the rules for that predicate.
• Facts can be used immediately if they are appropriate and the rules used when the
desired fact is not available.
• There are no facts with this predicate, so the one rule must be used.
• Rule succeed if both of the clauses on its right-hand side can be satisfied the next thing
the interpreter try to prove each of them.
• There are no facts with the predicate pet but there are rules with it on the right-hand
side.
• There are 2 rules they will be tried in the order in which they occur:
(i) First will fail because there are no assertions about the predicate cat in the
program.
(ii) Second will eventually lead to success, using the rule about dogs and poodles and
using the fact poodle (fluffy)
• It results in the variable x being bound to fluffy
• Second clause small (x) of the initial rule must be checked.
• X is bound to fluffy, the more specific goal, small (fluffy), must be proved.
• This can be done by reasoning backward to the assertion poodle(Fluffy)
• The program then halts with the result apartmentpet (fluffy).
• Logical negation () can’t be represented explicitly in a pure PROLOG

Example:
It’s not possible to encode direct by the logical assertion

x : dog(x)  cat (x)


3.18 Artificial Intelligence
Instead, negation is represented implicitly by the lack of an assertion. It leads to the
problem-solving strategy called negation as failure.

If the PROLOG program of above fig given the goal

? – cat (Fluffy)

Would return false because it’s unable to prove that fluffy is a cat.
• This program returns the same answer when given the goal even though the program
knows nothing about Mittens and knows nothing that prevent Mittens from being a
cat.
• Negation by failure requires that we make what is called the closed world assumption,
which states that all relevant, true assertings are contained our K B.
• Any Assertion not present are assumed to be false.
• These assumptions are justified, cause serious problems when KB are incomplete

Advantage of Logic programming: (LP)


Programmer need only specify rules and facts since a search engine is built directly in to
the language.

Disadvantage of LP
• Search control is fixed
Disadvantage of PROLOG:
• PROLOG code can be written that uses search strategies other than depth. First with
backtracking but its difficult to do.
• It is difficult to apply domain knowledge to constrain a search.
Advantage of PROLOG:
• PROLOG allow for rudimentary control of search through a non-logical operator
called cut.
• A cut can be inserted into a rule to specify a point that may not be backtracked over.
PROLOG programs composed of a restricted set of logical operators viewed as a
limitation of the expressiveness of the language.

3.3 UNIFICATION
In propositional logic it is easy to determine that two literals can not both be true at the
same time. Simply look for L and ~L . In predicate logic, this matching process is more
complicated, since bindings of variables must be considered.

For example man (john) and man(john) is a contradiction while man (john) and
man(Himalayas) is not. Thus in order to determine contradictions we need a matching procedure
that compares two literals and discovers whether there exist a set of substitutions that makes them
Knowledge Representation 3.19
identical . There is a recursive procedure that does this matching . It is called Unification
algorithm.

In Unification algorithm each literal is represented as a list, where first element is the
name of a predicate and the remaining elements are arguments. The argument may be a single
element (atom) or may be another list. For example we can have literals as

The Unification algorithm is listed below as a procedure UNIFY (L1, L2). It returns a list
representing the composition of the substitutions that were performed during the match. An empty
list NIL indicates that a match was found without any substitutions. If the list contains a single
value F, it indicates that the unification procedure failed.

UNIFY (L1, L2)


1) if L1 or L2 is an atom part of same thing do
(a) if L1 or L2 are identical then return NIL
(b) else if L1 is a variable then do
(i) if L1 occurs in L2 then return F else return (L2/L1)
else if L2 is a variable then do
(i) if L2 occurs in L1 then return F else return (L1/L2)
else return F.
2) If length (L!) is not equal to length (L2) then return F.
3) Set SUBST to NIL
(at the end of this procedure , SUBST will contain all the substitutions used to
unify L1 and L2).
4) For I = 1 to number of elements in L1 do
i) call UNIFY with the i th element of L1 and I’th element of L2, putting the result in
S
ii) if S = F then return F
iii) if S is not equal to NIL then do
(A) apply S to the remainder of both L1 and L2
(B) SUBST := APPEND (S, SUBST) return SUBST.
3.20 Artificial Intelligence
3.4 FORWARD CHAINING
Forward chaining or data-driven inference works by repeatedly: starting from the
current state, matching the premises of the rules (the IF parts), and performing the corresponding
actions (the THEN parts) that usually update the knowledge base or working memory. The
process continues until no more rules can be applied, or some cycle limit is met, e.g.

This seems simple enough, but in this case we only had a few initial facts, and a few rules.
Generally, things will not be so straight forward. The Forward chaining inference stated above has
no rules.

Disadvantages of Forward Chaining


• Many rules may be applicable at each stage – so how should we choose which one to
apply next at each stage?
• The whole process is not directed towards a goal, so how do we know when to stop
applying the rules?

3.5 BACKWARD CHAINING


Backward chaining or goal-driven inference works towards a final state by looking at the
working memory to see if the sub-goal states already exist there. If not, the actions (the THEN
parts) of the rules that will establish the sub-goals are identified, and new sub-goals are set up for
achieving the premises of those rules (the IF parts). The previous example now becomes:
Knowledge Representation 3.21

The first part of the chain works back from the goal until only the initial facts are required,
at which point we know how to traverse the chain to achieve the goal state

Advantage of Backward Chaining


The search is goal directed, so we only apply the rules that are necessary to achieve the
goal.

Disadvantage of Backward Chaining


A goal has to be known. Fortunately, most AI systems we are interested in can be
formulated in a goal based fashion.

3.6 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.

Resolution Algorithm:
Resolution basically works by using the principle of proof by contradiction. To find the
conclusion we should negate the conclusion. Then the resolution rule is applied to the resulting
clauses. Each clause that contains complementary literals is resolved to produce a two new clause,
which can be added to the set of facts (if it is not already present).This process continues until one
of the two things happen:
• There are no new clauses that can be added
• An application of the resolution rule derives the empty clause
3.22 Artificial Intelligence
An empty clause shows that the negation of the conclusion is a complete contradiction,
hence the negation of the conclusion is invalid or false or the assertion is completely valid or true.

Steps for Resolution Refutation


1) Convert all the propositions of KB to clause form (S).
2) Negate a and convert it to clause form. Add it to S.
3) Repeat until either a contradiction is found or no progress can be made:
Resolution in Prepositional Logic
We start by converting this first sentence into conjunctive normal fom. We don’t actually
have to do anything. It’s already in the right form. Now, “P implies R” turns into “not P or
R”. Similarly, “Q implies R” turns into “not Q or R .

We start by converting this first sentence into conjunctive normal fom. We don’t actually
have to do anything. It’s already in the right form. Now, “P implies R” turns into “not P or
R”. Similarly, “Q implies R” turns into “not Q or R .
Knowledge Representation 3.23

Now we want to add one more thing to our list of given statements. What's it going to be?
Not R. Right?We're gong to assert the negation of the thing we're trying to prove. We'd like to
prove that R follows from these things. But what we're going to do instead is say not R, and now
we're trying to prove false. And if we manage to prove false, then we will have a proof that R is
entailed by the assumptions.

And now, we look for opportunities to apply the resolution rule. You can do it in any order
you like (though some orders of application will result in much shorter proofs than others). We
can apply resolution to lines 1 and 2, and get “Q or R” by resolving away P. And we can take lines
2 and 4, resolve away R, and get “not P.” Similarly, we can take lines 3 and 4, resolve away R,
and get “not Q”. By resolving away Q in lines 5 and 7, we get R. And finally, resolving away R in
lines 4 and 8, we get the empty clause, which is false. We’ll often draw this little black box to
indicate that we’ve reached the desired contradiction.

Resolution in Predicate Logic


Consider the example,

“All Romans who know Marcus either hate Caesar or think that anyone who hates
anyone is crazy”

Step 1: Convert the given statements in Predicate/Propositional Logic


3.24 Artificial Intelligence
Knowledge Representation 3.25

Example:

General Conflict Resolution Strategies


The five most common General Conflict Resolution Strategies are:
1) Delete instantiations of rules that have already fired.
2) Order instantiations by the generation age of all the elements. Prefer the youngest.
3.26 Artificial Intelligence
3) Compare the generation age of the elements in working memory which match the first
condition of the rules. Prefer the youngest.
4) Prefer the most specific rules (i.e. those with the most pre-conditions).
5) Random choice.

The rationale behind these strategies is fairly obvious:


1) Prevents obvious endless loops of the same rules being applied with the same facts.
2) New elements are more likely to describe the current situation.
3) As for strategy 2, but may be more efficient.
4) This catches any exceptions/special cases before applying more general rules.
5) Very easy to compute.

Specific Conflict Resolution


Example Consider the following set of rules:
R1: IF: engine does not turn AND battery is not flat THEN: ask user to test starter motor
R2: IF: there is no spark THEN: ask user to check the points
R3: IF: engine turns AND engine does not start THEN: ask user to check the spark
R4: IF: engine does not turn THEN: ask user to check the battery
R5: IF: battery is flat THEN: ask user to charge battery AND EXIT

If the initial facts are “engine does not turn” and “battery is not flat”, the conflict set is:

{ 〈 R1, engine does not turn, battery is not flat 〉, 〈 R4, engine does not turn 〉 }
The easiest way to proceed in problem specific cases is to simply add extra conditions to
the rules to avoid the conflicts.
These extra conditions can be related to the inference strategies, e.g. to what is currently
being searched for, or to what rule applications tend to be most useful.
Modify R1in the previous example to give:
R1: IF: haven’t already tested starter motor
AND engine does not turn
AND battery is not flat
THEN: ask user to test starter motor

Disadvantages
1) Mixture of heuristics and factual knowledge are produced.
2) Large knowledge bases will not be easily maintainable.
Knowledge Representation 3.27
3.7 KNOWLEDGE REPRESENTATION
What is Knowledge?
The fact or condition of knowing something with familiarity gained through experience or
association". Knowledge consists of facts, concepts rules and so forth.

What is Knowledge Represenation?


Knowledge representation (KR) is the study of
• How knowledge and facts about the world can be represented
• What kinds of reasoning can be done with that knowledge.
Knowledge representation Language:
Two aspects of this representation are:
• Syntax and Semantics
• Example: Let a, b > are the components of the artithmetic language. The Syntax says
that ‘a > b’ is a valid statement but >>ab is not valid according to syntax. The
semantic ‘a>b’ is false if ‘a’ is less than ‘b’ and true otherwise.
Important KR questions one has to consider:
• Representational adequacy – Ability to represent knowledge of different kind
• Representational quality – Ability to create new structures from existing structures
• Computational cost of related inferences
• Representation of default, commonsense, or uncertain information.

Aspects of Good Represenations


• Complete – Representations must contain all necessary things
• Computable – Implementable procedures must be included
• Objects and relations - must be explicitly represented
• Supress irrelevant details
• Constraints – must be specified precisely and explicitly
• Transparency is a must
• Concise and fast implementation required.

Components of Good Representation


For analysis purposes it is useful to be able to break any knowledge representation down
into their four fundamental components:
• Lexical Part – Determines symbols or words used
• Strutural or syntactic part – constraints on how the words or symbols used
3.28 Artificial Intelligence
• Semantic Part – association of real world meaning with representation.
• Procedural Part – Access procedures that generates and compute things with the
representation.
Knowledge can be represented in different forms, as mental images in one’s thoughts, as
spoken or written words in some language, as graphical or other pictures, and as character strings
or collections of magnetic spots stored in a computer.

Mental images

Written text

Character strings

Binary number

Magnetic spots

Figure: Different levels of knowledge Representation


Any choice of representation depend on the type of problem to be solved and the inference
methods available.

Example:
If we wish to write a program to play a simple card game using the deck of 52 cards.

Need some ways to represent the cards dealt to each player and a way to express the rules.

Represent cards in different ways:


(i) To record the suit (club, diamonds, hearts, spades) and face values (ace, 0, 2, 3, …, 10.
Jack, queen, king) as a symbolic pair. So, the queens of hearts be represented as
(queens, hearts). We assign abbreviated codes (c 6 for the 6 of clubs), numeric values
ignore suit (1,2,3,……13).
a) If the game is bridge , suit and value is important.
b) If the game is black jack, only face values are important and program will result if
only numeric values are used.

Several representation schemes:


(i) First order predicate logic is important and it has a well – developed theory, has
reasonable expressive power and uses valid forms of inferring.
Knowledge Representation 3.29
Limitation:
In commonsense reasoning.
A typical statement in this logic express the family relationship of fatherhood a
FATHER.(joh, jim) where the predicate father is to express the fact that john is the
father of jim.
(ii) Frames are flexible structures that permit the grouping of closely related knowledge.
Example:
An object such as a ball and its properties and its relationship to other objects are
grouped together in to a single structure for easy access.
(iii) Networks allow easy access to groups of related items. They associate objects with
their attributes, and linkages show their relationship to other objects.
(iv) FUZZY logic is a generalization of predicate logic, developed to permit varying
degrees of some property such as tall. In classical two – valued logic, TALL ( john) is
either true or false, but in fuzzy logic this statement may be partially true.
(v) Modal logic is an extension of classical logic. It’s developed to represent
commonsense reasoning by permitting conditions.
(vi) Object oriented representations package an object together with its attributes and
function hiding these facts. Operations are performed by sending message between the
objects.
(vii) Uncertainty, knowledge may be vague, contradictory, or incomplete. We are in
position to reason and make decisions.
Humans do well with fuzzy or incomplete knowledge.

Knowledge representation - Knowledge is the body of facts and principles. Knowledge


can be language, concepts, procedures, rules, ideas, abstractions, places, customs, and so on. The
Study of knowledge is called Epistemology.

Types of knowledge
The types of knowledge include procedural knowledge, declarative knowledge and
heuristic knowledge.

Procedural knowledge
Procedural knowledge is compiled or processed form of information. Procedural
knowledge is related to the performance of some task. For example, sequence of steps to solve a
problem is procedural knowledge.

Declarative knowledge
Declarative knowledge is passive knowledge in the form of statements of facts about the
world. For example, mark statement of a student is declarative knowledge.

Heuristic knowledge
3.30 Artificial Intelligence
Heuristics knowledge are rules of thumb or tricks. Heuristic knowledge is used to make
judgments and also to simplify solution of problems. It is acquired through experience. An expert
uses his knowledge that he has gathered due to his experience and learning.

Properties/Approaches of Knowledge Representation System


The following properties should be possessed by a knowledge representation system.
Representational Adequacy
• the ability to represent the required knowledge;
Inferential Adequacy
• the ability to manipulate the knowledge represented to produce new knowledge
corresponding to that inferred from the original;
Inferential Efficiency
• the ability to direct the inferential mechanisms into the most productive directions by
storing appropriate guides;
Acquisitional Efficiency
• the ability to acquire new knowledge using automatic methods wherever possible
rather than reliance on human intervention.

3.7.1 Representations and Mappings


To solve problems, we need both a large amount of knowledge and some mechanisms. For
manipulating that knowledge to create solutions to new problems. There are two different kinds of
entities:
(i) Facts: Truth in some relevant world. These are the things we want to represent.
(ii) Representation of facts in some chosen formalism.These are the thing we will actually
be able to manipulate.

Structuring entities is as two levels:


(i) The knowledge level, at which facts are described
(ii) The knowledge level, at which representations of objects at the knowledge level are
defined in terms of symbols that can be manipulated by programs.

The Below Fig shows the context of agents and their goals and behaviors

Fig- Mappings between facts and Representations


Knowledge Representation 3.31
• Focus on Facts, on representations, and the two-way mappings that must exist between
them. These links are called as representation mappings
• The forward representation mapping maps from facts to representations.
• The backward representation mapping goes the other way, from representation to
facts.

Representation of facts deserves special mention:


(i) Natural Language
(ii) Sentences

Representation of those facts in order to facitlitate getting information into and out of the
system. The above fig shows how these three kinds of objects relate to each other

Example:
English Sentence:
Spot is a dog.
The fact represented by that English sentence can also be represented in logic as:
dog(Spot)
Suppose that we also have a logical representation of the fact that all dogs have tails:
x: dog(x)  hastail(x)
Then, using the deductive mechanism of logic, we may generate the new representation
object:
hastail(Spot)
Using an appropriate back ward mapping function, we could then generate the English
sentence:
Spot has a tail.
Or we make use of this representation of a new fact to cause us to take some appropriate
action or to derive representations of additional facts.

Mapping functions are not one – to – one in fact, they are often not even functions but
many – to- many relations.

Example:
Two sentences:
“All dogs have Tails” and
“Every dog has a Tail”.

Represent the same fact, that every dog has at least one tail.
(i) The former represent either the fact that every dog has atleast one tail or the fact
that each dog has several tails.
3.32 Artificial Intelligence
(ii) The letter represent either the fact that every dog has at least one tail or the fact
that there is a tail that every dog has.
◦ The starred links of above fig are key components of the design of any knowledge-
based program
◦ The internal representations of the facts should result in new structures that can be
interpreted as internal representations of facts.
◦ Internal representations of a facts correspond to the answer to the problem
described by the starting set of facts.
◦ Good representation makes the operation of a reasoning program trivial.
◦ A well-known example of this occurs in context of the multilated checker board
problem, which can be stated as follows:
Desired real
Intial reasoning Final facts
facts

Forward Backward
* representation representation *
mapping mapping

Internal Internal
representations of representations of
initial acts Operation of initial acts
program

Fig- Representation of Facts


• The Dotted line across the top represents the abstract reasoning process that a program
is intended to model
• The solid line across the bottom represents the concrete reasoning process that a
particular program performs.
• Backward representation mapping is applied, the appropriate final facts are actually
generated.
• If the mapping is not good then no good programs can solve the problem and not able
to produce answers that correspond to real answers to the problem.
• The above fig shows the relationship between an abstract data type and a concrete
implementation of that type.
Example:
In data type design it is expected that the mapping that we are calling the backward
representation mapping is a function and that it is onto.

Main idea of programmers is to find concrete implementations of abstract concepts.

3.7.2 Knowledge Representation Schemes:


Knowledge Representation 3.33
(i) Simple Relational knowledge:
The simplest way to represent declarative facts is as a set of relations of the same sort used
in database systems.

Below fig shows an example of such a relational system.

Player Height Weight Bats-Throws


Hank Aaron 6-0 180 Right-Right
Willie Mays 5-10 170 Right-Right
Babe Ruth 6-2 215 Left-Left
Ted Williams 6-3 205 Left-Right
player_info(‘hank aaron’, ‘6-0’, 180, right-right)

Fig-2.2.2 Simple Relational knowledge and a Sample fact in prolog

Reason:
Representation provides very weak inferential capabilities but knowledge represented in
this form may serve as the input to more powerful inference engines.

Example:
Given just the facts of above fig, its not possible even to answer the simple question, “who
is the heaviest player?”
• Procedure for finding the heaviest player is provided, then these facts will enable the
procedure to compute an answer.
• We are provided with a set of rules for deciding which hitter to put up against a given
pitcher then this same relation can provide at least some of the information required by
those rules.
• Database systems are designed to provide support for relational database.

(ii) Inheritable knowledge:


• The set of attributes and associated values that together describe the objects of the
knowledge base.
• To be more effective, structure of representation designed to correspond to the
inference mechanism that are desired.
Property inheritance in which elements of specific classes inherit attributes and values
from more general classes in which they are included.

To support property inheritance, objects are organized into classes and classes must be
arranged in a generalization hierarchy.

The Below fig shows some additional baseball knowledge inserted into a structure that is
so arranged.
3.34 Artificial Intelligence

to

Fig- Inheritable knowledge


(i) Lines represent attributes
(ii) Boxed nodes represent objects and values of attributes of objects.
(iii) These values can be viewed as objects with attributes and values and so on.
(iv) The arrows on the lines point from an object to its value along the corresponding
attribute line.
(v) The structure shown in the above fig is a slot – and – filter structure.
(vi) It is also called as semantic Network or a collection of frames.
(vii) Each individual frame represents the collection of attributes and values associated with
a node.
The below fig shows the node for Baseball player displayed as a frame.

Baseball-player
isa: Adult-Male
bats: (EQUAL handed)
height: 6-1
batting-average .252

Fig- Viewing a Node as a frame.


There is more flexibility in solving representational problems. The frame system implies
more structure on the attributes and the inference mechanism that are available to apply to them
than does the term semantic network.

The two exceptions to baseball example are the attribute


(i) is a – used to show class inclusion.
(ii) Is a – used to show class membership
Knowledge Representation 3.35
These 2 attributes provide the basis for property inheritance as an inference technique.

Using this technique, the knowledge base support retrival both of facts that have been
stored and of facts can be derived from those that are stored.

(iii) Inferential knowledge:


x: Ball(x)  Fly(x)  Fair (x)  Infield – Catchable (x) 
Occupied-Base(First)  Occupied-Base(Second)  (Outs < 2) 
[Line-Drive(x)  Attempted-Bt,(x)]
 Infield-Fly(x)
x, y: Batter(x)  batted(x, y)  Infield-Fly(y)  Out(x)
Fig- 2.2.2 (c) Inferential knowledge
The above fig shows two examples of the use of first-order predicate logic to represent
additional knowledge about baseball.

Inference procedure implements the standard logical rules of inference.


• Some procedures reason forward from given facts to conclusions.
• Some procedures reason backward from desired conclusions to given facts.
• One of the most commonly used of these procedures is Resolution, which exploits a
proof by contradiction strategy.

(iv) Procedural knowledge:


• Procedural or operational knowledge specifies what to do when.
• Procedural knowledge can be represented in programs in many ways
• The most common way is simply as code for doing something.
• The machine uses the knowledge when it executes the code to perform a task.
• Procedural knowledge gets low scores with respect to the properties of inferential
adequacy and acquisitional efficiency.

3.7.3 Issues in Knowledge Representation


There are various issues related to information mapping and use of structure while dealing
with knowledge representation. Some of them are:
1) Which information is to be mapped?
2) How can it be mapped?
3) What would be the memory constraints?
4) Is there a better way to help represent them?
3.36 Artificial Intelligence
Knowledge Based Agent:
Knowledge Base (KB): is a set of sentences represented in a knowledge representation
language; stores assertions about the world.

Inference Rule: When one asks questions to the KB, the answer follows from what has
been telled to the KB previously.

A generic Knowledge Based Agent

An Agent must be able to:


Represent states and actions
Incorporate new percepts
Update internal representation of the world
Deduce hidden properties of the world
Deduce appropriate actions

Levels:
Agents can be described at different levels

Knowledge Level – What they know, regardless of the actual implementation


(Declarative description)

Implementation Level – Data structures in KB and algorithms that manipulate them,


e.g., propositional logic and resolution.

EXAMPLE – WUMPUS WORLD


Knowledge Representation 3.37

Wumpus world is a traditional example to learn about intelligent agents. Wumpus world is
basically a cave where each room is interconnected with others. Wumpus is a monster that eats
anyone who enters the room. An agent is the one who can shoot the wumpus with an arrow.
There are few pits in the rooms inside the cave. The payoff in the game is the gold that an agent
may acquire with or without killing the wumpus. The PEAS of the WUMPUS World is as
follows:

[1,1] KB initially contains the rules of the environment. First percept is [none,
none,none,none,none], move to safe cell e.g. 2,1
3.38 Artificial Intelligence
[2,1] Breeze which indicates that there is a pit in [2,2] or [3,1], return to [1,1] to try next
safe cell

[1,2] Stench in cell which means that wumpus is in [1,3] or [2,2] but not in [1,1]

YET … not in [2,2] or stench would have been detected in [2,1] THUS … wumpus is in
[1,3] THUS [2,2] is safe because of lack of breeze in [1,2] THUS pit in [3,1] move to next safe
cell [2,2]

[2,2] Move to [2,3]

[2,3] Detect glitter, smell, breeze Pick up gold THUS pit in [3,3] or [2,4]

Concluding the fact that wumpus is in [1, 3] is difficult without previous experience.
Hence it is reasoning that leads the agent to take correct actions and this is dependent on the
correctness of the facts. Thus making it clear that logical reasoning is the essence to have correct
conclusions.

3.7.4 Structured representation of knowledge:


Representing knowledge using logical formalism, like predicate logic, has several
advantages. They can be combined with powerful inference mechanisms like resolution, which
makes reasoning with facts easy. But using logical formalism complex structures of the world,
objects and their relationships, events, sequences of events etc. can not be described easily.
Knowledge Representation 3.39
A good system for the representation of structured knowledge in a particular domain
should posses the following four properties:
(i) Representational Adequacy:- The ability to represent all kinds of knowledge that are
needed in that domain.
(ii) Inferential Adequacy :- The ability to manipulate the represented structure and infer
new structures.
(iii) Inferential Efficiency:- The ability to incorporate additional information into the
knowledge structure that will aid the inference mechanisms.
(iv) Acquisitional Efficiency :- The ability to acquire new information easily, either by
direct insertion or by program control.
The techniques that have been developed in AI systems to accomplish these objectives fall
under two categories:
1) Declarative Methods:- In these knowledge is represented as static collection of facts
which are manipulated by general procedures. Here the facts need to be stored only
one and they can be used in any number of ways. Facts can be easily added to
declarative systems without changing the general procedures.
2) Procedural Method:- In these knowledge is represented as procedures. Default
reasoning and probabilistic reasoning are examples of procedural methods. In these,
heuristic knowledge of “How to do things efficiently “can be easily represented.
In practice most of the knowledge representation employ a combination of both. Most
of the knowledge representation structures have been developed to handle programs
that handle natural language input. One of the reasons that knowledge structures are so
important is that they provide a way to represent information about commonly
occurring patterns of things . such descriptions are some times called schema. One
definition of schema is
“Schema refers to an active organization of the past reactions, or of past experience,
which must always be supposed to be operating in any well adapted organic
response”.
By using schemas, people as well as programs can exploit the fact that the real world
is not random. There are several types of schemas that have proved useful in AI
programs. They include
(i) Frames: – Used to describe a collection of attributes that a given object possesses
(eg: description of a chair).
(ii) Scripts: – Used to describe common sequence of events
(eg:- a restaurant scene).
(iii) Stereotypes :– Used to described characteristics of people.
(iv)Rule models: – Used to describe common features shared among a set of rules in a
production system.

Frames and scripts are used very extensively in a variety of AI programs. Before selecting
any specific knowledge representation structure, the following issues have to be considered.
3.40 Artificial Intelligence
(i) The basis properties of objects , if any, which are common to every problem domain
must be identified and handled appropriately.
(ii) The entire knowledge should be represented as a good set of primitives.
(iii) Mechanisms must be devised to access relevant parts in a large knowledge base.

Semantic Network
A semantic net (or semantic network) is a knowledge representation technique used for
propositional information. So it is also called a propositional net. Semantic nets convey meaning.
They are two dimensional representations of knowledge. Mathematically a semantic net can be
defined as a labelled directed graph.

Semantic nets consist of nodes, links (edges) and link labels. In the semantic network
diagram, nodes appear as circles or ellipses or rectangles to represent objects such as physical
objects, concepts or situations. Links appear as arrows to express the relationships between
objects, and link labels specify particular relations. Relationships provide the basic structure for
organizing knowledge. The objects and relations involved need not be so concrete. As nodes are
associated with other nodes semantic nets are also referred to as associative nets.

Consider the example,

• Tom is a cat.
• Tom caught a bird.
• Tom is owned by John.
• Tom is ginger in colour.
• Cats like cream.
• The cat sat on the mat.
• A cat is a mammal.
• A bird is an animal.
• All mammals are animals.
• Mammals have fur
Knowledge Representation 3.41

Note that where we had an unnamed member of some class, we have had to introduce a
node with an invented name to represent a particular member of the class. This is a proces ssimilar
to the Skolemisation we considered previously as a way of dealing with existential quantifiers.

3.8 ONTOLOGICAL ENGINEERING


What is in an ontology?
An ontology is a formal explicit description of concepts in a domain of discourse
(classes (sometimes called concepts)), properties of each concept describing various features and
attributes of the concept (slots (sometimes called roles or properties)), and restrictions on slots
(facets (sometimes called role restrictions)).

An ontology together with a set of individual instances of classes constitutes a knowledge


base. In reality, there is a fine line where the ontology ends and the knowledge base begins.

Classes are the focus of most ontologies. Classes describe concepts in the domain. For
example, a class of wines represents all wines. Specific wines are instances of this class. The
Bordeaux wine in the glass in front of you while you read this document is an instance of the
class of Bordeaux wines.

In practical terms, developing an ontology includes:


• defining classes in the ontology,
• arranging the classes in a taxonomic (subclass–superclass) hierarchy,
• defining slots and describing allowed values for these slots,
• filling in the values for slots for instances.
3.42 Artificial Intelligence
A knowledge base can be created by defining individual instances of these classes filling
in specific slot value information and additional slot restrictions.

3.9 CATEGORIES AND OBJECTS


• KR requires the organisation of objects into categories
◦ Interaction at the level of the object
◦ Reasoning at the level of categories
• 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
• Category = set of its members

Figure shows some classes, instances, and relations


among them in the wine domai
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))
Knowledge Representation 3.43
• 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).
• 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)

Physical Composition
• One object may be part of another:
◦ PartOf(Bucharest,Romania)
◦ PartOf(Romania,EasternEurope)
◦ PartOf(EasternEurope,Europe)
• The PartOf predicate is transitive (and irreflexive), so we can infer that
PartOf(Bucharest,Europe)
• More generally: 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.
3.44 Artificial Intelligence

◦ E.g. Biped(a) ⇒

3.10 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 consisting of
• The initial situation I
• All situations resulting from the action on I (=Result(a,s))
• Fluent 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
• Simples Situation calculus requires two axioms to describe change:
Knowledge Representation 3.45
• 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))

3.11 MENTAL EVENTS AND OBJECTS


• KB agents can have beliefs and deduce new beliefs
• 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.
Example: 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).
3.46 Artificial Intelligence
3.12 REASONING SYSTEMS FOR CATEGORIES
Reasoning is the set of processes that enables us to go beyond the information provided.
Reasoning is the thought process that follows rules of logic.

Components of Reasoning:
• An unambiguous representation language
• Sound inference rules
• Well defined search strategies
Categories:
• Monotonic Reasoning – if a set of axioms are enlarged cannot retract any existing
axioms or assertions.
• Non – monotonic Reasoning – a logic is non-monotonic if some conclusions can be
invalidaded by adding new knowledge. It is useful in representing defaults.
• Deductive Reasoning – It allows to draw conclusions that must hold given a set of
premises (facts). The logic used here is deductive logic./specialization
• Inductive Reasoning – opposite of deductive reasoning, makes generalization based
on the results available for instances.
◦ Category – based induction
◦ Mental models
• Abductive Reasoning – It is similar to inverse process of applying a rule. (when q is
true, p is true)
◦ Even though they are not valid as per rules of logic, these reasoning serves good in
case where there is no information available. A measure of certainity is used to
decide whether to accept it or not.
• Default Reasoning – Common type of non-monotonic reasoning, based on what is
most likely to be true. These are used to make inferences in cases where the
information at hand is incomplete (absence of information). Conclusions drawn from
these type of rules are called defaults.

How to organize and reason with categories?


• Semantic networks
• Visualize knowledge- base
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.
Knowledge Representation 3.47

Semantic Networks
Logic vs. semantic networks
• Many variations are available
• 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 ¾ they are
alternative notations for the same content, not in principle different representations!

What differs?
Missing existential quantifier Functions (extensions exist) Semantic nets additionally
provide pointers (and sometimes back pointers) which allow easy and highperformance
information access (e.g., to instances): INDEXING [ similar: frames ]

ISA-Hierarchy and Inheritance isa: “is a” “ist ein” inst: “instance of“ „Instanz von”
• 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
3.48 Artificial Intelligence
• Inheritance of properties
• Reason: Knowledge representation economy
• Search along isa- and inst-links to access information not directly associated (using
inheritance)
• inst: ∈ member of
• isa: ⊆ subset of

Semantic networks

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

Description Logics
• Are designed to describe defintions and properties about categories
◦ A formalization of semantic networks
• Principal inference task is
◦ Subsumption: checking if one category is the subset of another by comparing their
definitions
◦ Classification: checking whether an object belongs to a category.
◦ Consistency: whether the category membership criteria are logically satisfiable

3.13 REASONING WITH DEFAULT INFORMATION

You might also like