Unit III - KNOWLEDGE REPRESENTATION SCHEMES and LOGICgood.pdf
1. Unit III - KNOWLEDGE REPRESENTATION
SCHEMES and LOGIC
Approaches to knowledge representation, Propositional logic,
predicate logic, Resolution in proportional logic
Nature cares nothing for logic, our human logic: she has her own, which we do not recognize and
acknowledge until we are crushed under its wheel.
-Ivan Turgenev
(1818-1883), Russian novelist and playwright
2. Knowledge Representation
Earlier it was believed that the best approach to solutions was through the
development of General Purpose Problem Solver, that is, systems powerful to
prove a theorem in geometry, perform a complex robotic task, or to develop a
plan to complete a sequence of operations.
But it was deduced that the systems became effective only when the solution
methods incorporated domain specific rules and facts, i.e. after gaining specific
knowledge.
It eventually led to knowledge based systems.
3. Knowledge Representation
Importance of Knowledge
Knowledge can be defined as the body of facts and principles
accumulated by human-kind or the act, fact or state of knowing.
In actuality it is more than this, it also includes having a familiarity with
language, concepts, procedures, rules, ideas, abstractions , places,
customs, facts associations along with ability to use these notions
effectively in modeling different aspects of the world.
How is knowledge stored in biological organisms and computers?
Human brain weighs 3.3 pounds - estimated number of neurons 1012 -
potential storage – 1014
In computers, knowledge is also stored as symbolic structures, in the
form of collections of magnetic spots and voltage states.
4. Knowledge Representation
Let’s take the following examples
A is tall.
A Likes B.
C has learned to use recursion to manipulate linked lists in several
programming languages.
1st one represents a fact, an attribute possessed by a person.
2nd expresses a complex binary relation between two persons.
3rd is most complex, expressing relations between a person and more
abstract programming concepts.
5. Knowledge Representation
Knowledge can be of following types
Declarative (statements)
Procedural (facts)
Heuristics (rule of thumb / experience)
We should not confuse Knowledge with data.
– Physician example
Belief v/s Hypothesis
Belief is any meaningful and coherent expression that can be
represented.
Hypothesis is a justified belief that is not known to be true.
Epistemology – study of nature of knowledge.
Metaknowldge – knowledge about knowledge.
6. Knowledge Representation
Knowledge alone cannot serve the purpose, we need to include
understanding, learning, thinking, remembering & reasoning.
Knowledge based systems get their power from expert knowledge that has
been coded into facts, rules, heuristics and procedures.
Knowledge is stored in a knowledge base separate from the control and
inferencing components , this makes it possible to add new knowledge or
refine existing knowledge without recompiling the control and inferencing
programs.
This simplifies the construction and maintenance of knowledge-based
systems.
7. Mappings between Facts and Representation
Facts: Truths in some relevant world. These are the things we want to represent
Representation of fact in some chosen formalism. These are the things we will actually
be able to manipulate
8. Knowledge Representation
Some mathematical ways of representing the sentences
Spot is a dog. dog(spot)
All dogs have tails. x : dog(x) hastail(x)
Then using the deduction method of logic, we may generate they new
representation object : hastail(spot)
So we can , using backward mapping function : Spot has a tail.
10. Knowledge Representation
Approaches to Knowledge representation
A good system for the representation of knowledge in a particular domain
should possess the following properties :
Representational Adequacy – the ability to represent all of the kinds
of knowledge that are needed in that domain
Inferential Adequacy – The ability to manipulate the representational
structures in such a way as to derive new structures corresponding to new
knowledge inferred from old.
Inferential Efficiency – The ability to incorporate into the knowledge
structure additional information that can be used to focus the attention of
the inference mechanisms in the most promising direction.
Acquisitional Efficiency - Acquiring new information easily.
11. Knowledge Representation
Simple Relational Knowledge
Player Height Weight Runs
Dhoni 6-0 150 3000
Sachin 5-4 140 15000
Zaheer 6-2 160 1000
This even does not tell us that who is the heaviest player?
A procedure should be defined to figure out the result.
12. Knowledge Representation
Inheritable Knowledge
It is possible to enhance the basic representation with inference
mechanism that operate on the structure of the representation.
The most useful form of inference is Property Inheritance, in which
elements of specific classes inherit attributes and values from ore general
classes in which they are included.
In order to do this, objects must be organized into classes, classes must
be arranged into generalization hierarchy.
14. 85
Algorithm : Property Inheritance
To retrieve a value V for attribute A of an instance object O:
1. Find O in the knowledge base.
2. If there is a value there for the attribute A, report that value.
3. Otherwise, see if there is a value for the attribute instance. If
not, then fail.
4. Otherwise, move to the node corresponding to that value and
look for a value for the attribute A. If one is found, report it.
5. Otherwise, do until there is no value for the is a attribute or until
an answer is found:
(a)Get the value of the is a attribute and move to that node.
(b) See if there is a value for the attribute A. If there is,
report it.
16. Knowledge Representation
Inferential Knowledge
Sometimes all the power of traditional logic is necessary to describe he
inferences that are needed.We can represent inferential knowledge about a domain
using first order predicate-logic.
But all this knowledge is useless unless there is also an inference procedure
that can exploit it. The required inference procedure now is one that implements
the standard logical rules of inference.
There are many procedures, some of which reason forward from given facts to
conclusions, some reason backward from desired conclusions to given facts. One
most common procedure is RESOLUTION, which uses contradiction strategy.
18. Knowledge Representation
Procedural Knowledge
The previous forms deal with Static, Declarative facts. This knowledge
specifies what to do and when.
This 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.
Eg : If – then else etc.
19. Representing Simple facts in logic
• The logical formalism is appealing because it immediately
suggests a powerful way of deriving new knowledge from
old - mathematical deduction.
• 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-formed formulas (wff's) in propositional logic
20. Socrates is a man.
SOCRATESMAN
Plato is a man.
PLATOMAN
Better representations :
MAN(SOCRATES)
MAN(PLATO)
All men are mortal.
MORTALMAN
Better representation :
Limitations of Propositional Logic
21. A Predicate Logic Example
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.
23. Points to consider in predicate
logic representation
• Statement 1: 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.
• Statement 4: 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.
• Statement 5: 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.
• Statement 6:A major problem that arises when trying to convert English
sentences into logical statements is the scope of quantifiers. Does this sentence
say 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 : x :
loyalto(x,y))? Often only one of the two interpretations seems likely, so people
tend to favor it.
24. Points to consider in predicate
logic representation
• Statement 7: 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.
26. Another Predicate Logic Example
1. Marcus was a man.
2. Marcus was a Pompeian.
3. Marcus was born in 40 A.D.
4. All men are mortal.
5. All Pompeians died when the volcano erupted in 79 A.D.
6. No mortal lives longer than 150 years.
7. It is now 1991.
8. Alive means not dead.
9. If someone dies, then he is dead at all later times.
27. A Set of Facts about Marcus
This example shows how the ideas of computable functions and predicates
can be useful. Here gt is a computational function.
29. Another Way of Proving That Marcus Is Dead
• Even very simple conclusions can require
many steps to prove.
• A variety of processes, such as matching,
substitution, and application of modus ponens
are involved in the production of a proof. This
is true even for the simple statements we are
using. It would be worse if we had
implications with more than a single term on
the right or with complicated expressions
involving ands and ors on the left.
30. Resolution: Conversion to Clause Form
Problem :
Solution :
Flatten
Separate out Quantifiers
Conjunctive Normal Form :
Clause Form :
Conjunctive Normal Form
No instances of
32. Examples of Conversion to Clause Form
Example :
1 Eliminate
2 Reduce scope of
3 Standardize Variables.
33. Examples of Conversion to Clause Form
4 Move quantifiers.
5 Eliminate existential quantifiers.
will be converted to
while
will be converted to
6 Drop the prefix.
7 Convert to a conjunction of disjuncts.
35. The Basis of Resolution
Given :
The resolution procedure is a simple iterative
process: at each step, two clauses, called the
parent clauses, are compared (resolved),
yielding a new clause that has been inferred
from them. The new clause represents ways
that the two parent clauses interact with each
other
precisely one of winter and ¬ winter will be true at any point. If
winter is true, then cold must be true to guarantee the truth of
the second clause. If ¬ winter is true, then summer must be true
to guarantee the truth of the first clause. Thus we see that from
these two clauses we can deduce
36. Algorithm : Propositional Resolution
1. Convert all the propositions of F to clause form.
2. Negate P and convert the result to clause form. Add it to the
set of clauses obtained in step 1.
3. Repeat until either a contradiction is found or no progress
can be made:
(a) Select two clauses. Call these the parent clauses.
(b) Resolve them together. The resulting clause, called the resolvent,
will be the disjunction of all of the literals of both of the parent
clauses with the following exception: If there are any pairs of
literals L and ¬L such that one of the parent clauses contains L
and the other contains ¬L, then select one such pair and
eliminate both L and ¬L from the resolvent.
(c) If the resolvent is the empty clause, then a contradiction has been
found. If it is not, then add it to the set of clauses available to the
procedure.
37. A Few Facts in Propositional Logic
Let's look at a simple example. Suppose we are given the axioms shown in
the following figure and we want to prove R. First convert the axioms to
clause form, as shown in the second column of the figure.
Then we negate R, producing ¬ R, which is already in clause form.
41. Algorithm : Unify (L1, L2)
1. If L1 or L2 are both variables or constants, then:
(a) If L1 and L2 are identical, then return NIL.
(b) Else if L1 is a variable, then if L1 occurs in L2 then return {FAIL}, else
return (L2/L1).
(c) Else if L2 is a variable then if L2 occurs in L1 then return {FAIL}, else
return (L1/L2).
(d) Else return {FAIL}.
2. If the initial predicate symbols in L1 and L2 are not identical, then return {FAIL).
3. If LI and L2 have a different number of arguments, then return {FAIL}.
4. Set SUBST to NIL.
5. For i ← 1 to number of arguments in L1:
(a) Call Unify with the /th argument of L1 and the ith argument of L2, putting
result in S.
(b) If S contains FAIL then return {FAIL}.
(c) If S is not equal to NIL then:
(i) Apply S to the remainder of both L1 and L2.
(ii) SUBST : = APPEND(S, SUBST).
6. Return SUBST.
42. Why Do the Occur Check?: Reason
for step 1.b and 1.c in Unify Algo
Example :
If we accepted g(x) as a substitution for x, then we would have to
substitute it for x in the remainder of the expressions. But this
leads to infinite recursion since it will never be possible to
eliminate x.
43. Resolution in Predicate Logic
Example :
Yield the substitution :
Marcus/x1
So it does not yield the resolvent :
mortal/x1
It does yield :
mortal(Marcus)
44. Algorithm : Resolution
1. Convert all the statements of F to clause form.
2. Negate P and convert the result to clause form. Add it to
the set of clauses obtained in 1.
3. Repeat until either a contradiction is found, no progress
can be made, or a predetermined amount of effort has
been expended.
(a) Select two clauses. Call these the parent clauses.
(b) Resolve them together. The resolvent will be the disjunction of
all the literals of both parent clauses with appropriate
substitutions performed and with the following exception: If there
is one pair of literals T1 and ¬T2 such that one of the parent
clauses contains T2 and the other contains T1 and if T1 and T2
are unifiable, then neither T1 nor T2 should appear in the
resolvent. If there is more than one pair of complimentary
literals, only one pair shold be omitted from the resolvent.
(c) If the resolvent is the empty clause, then a contradiction has
been found. If it is not, then add it to the set of clauses available
to the procedure.
53. Resolution Example
John likes all kind of food.
Apples are food.
Chicken is food.
Anything anyone eats and isn’t killed by is
food.
Bill eats peanuts and is still alive.
Sue eats everything Bill eats.
54. Resolution Example
The members of the Elm St. Bridge Club are Joe,
Sally, Bill and Ellen.
Joe is married to Sally.
Bill is Ellen’s brother.
The spouse of every married person in the club is
also in the club.
The last meeting of the club was at Joe’s house.
55. Resolution Example
Steve only likes easy courses.
Science courses are hard.
All the courses in the basket weaving department
are easy.
BK301 is a basket weaving course.
60. Example –Resolution Refutation in
predicates
Consider the following axioms:
• All hounds howl at night.
• Anyone who has any cats will not have any mice.
• Light sleepers do not have anything which howls at
night.
• John has either a cat or a hound.
• (Conclusion) If John is a light sleeper, then John does
not have any mice.
• Basic predicates are: HOUND(x), HOWL(x), HAVE(x,y),
CAT(x), MOUSE(x), LS(x)