Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Knowledge representation in AI, Lecture notes of Artificial Intelligence

Different techniques for Knowledge representations in AI

Typology: Lecture notes

2017/2018

Uploaded on 11/02/2018

Shantha.L.Jayakumar
Shantha.L.Jayakumar 🇮🇳

5

(1)

2 documents

1 / 26

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
UNIT – II
Knowledge Representation: Approaches and issues in knowledge representation-
Propositional Logic –Predicate logic-Forward and backward reasoning - Unification-
Resolution- Weak slot-filler structure – Strong slot-filler structure- Knowledge- Based Agent
Knowledge Representation
Knowledge representation (KR) is the study of how knowledge about the world can be
represented and what kinds of reasoning can be done with that knowledge. Knowledge
Representation is the method used to encode knowledge in Intelligent Systems.
Since knowledge is used to achieve intelligent behaviour, the fundamental goal of knowledge
representation is to represent knowledge in a manner as to facilitate inferencing (i.e. drawing
conclusions) from knowledge. A successful representation of some knowledge must, then, be
in a form that is understandable by humans, and must cause the system using the knowledge
to behave as if it knows it.
Issues in knowledge representation from an AI perspective:
1. How do people represent knowledge?
2. What is the nature of knowledge and how do we represent it?
3. Should a representation scheme deal with a particular domain or should it be general
purpose?
4. How expressive is a representation scheme or formal language?
5. Should the scheme be declarative or procedural?
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Partial preview of the text

Download Knowledge representation in AI and more Lecture notes Artificial Intelligence in PDF only on Docsity!

UNIT – II

Knowledge Representation: Approaches and issues in knowledge representation- Propositional Logic –Predicate logic-Forward and backward reasoning - Unification- Resolution- Weak slot-filler structure – Strong slot-filler structure- Knowledge- Based Agent

Knowledge Representation Knowledge representation (KR) is the study of how knowledge about the world can be represented and what kinds of reasoning can be done with that knowledge. Knowledge Representation is the method used to encode knowledge in Intelligent Systems.

Since knowledge is used to achieve intelligent behaviour, the fundamental goal of knowledge representation is to represent knowledge in a manner as to facilitate inferencing (i.e. drawing conclusions) from knowledge. A successful representation of some knowledge must, then, be in a form that is understandable by humans, and must cause the system using the knowledge to behave as if it knows it.

Issues in knowledge representation from an AI perspective:

  1. How do people represent knowledge?
  2. What is the nature of knowledge and how do we represent it?
  3. Should a representation scheme deal with a particular domain or should it be general purpose?
  4. How expressive is a representation scheme or formal language?
  5. Should the scheme be declarative or procedural?

Fig: Two entities in knowledge representation

For example: English or natural language is an obvious way of representing and handling facts. Logic enables us to consider the following fact: spot is a dog as dog(spot) We could then infer that all dogs have tails with: ꓯx: dog(x)–> hasatail(x).

We can then deduce: hasatail(Spot) Using an appropriate backward mapping function the English sentence Spot has a tail can be generated.

Representation and Mapping F 0D 8 Problem solving requires large amount of knowledge and some mechanism for

manipulating that knowledge. F 0D 8 The Knowledge and the Representation are distinct entities, play a central but

distinguishable roles in intelligent system. F 0B 7 Knowledge is a description of the world; it determines a system's competence by what it

knows. F 0B 7 Representation is the way knowledge is encoded; it defines the system's performance in

doing something. F 0B 7 Facts Truths about the real world and what we represent. This can be regarded as the

knowledge level F 0D 8 In simple words, we :

  • need to know about things we want to represent , and
  • Need some means by which things we can manipulate.

Thus, knowledge representation can be considered at two levels : F 0D 8 Knowledge level at which facts are described, and F 0D 8 symbol level at which the representations of the objects, defined in terms of symbols, can

be manipulated in the programs. Note: A good representation enables fast and accurate access to knowledge and understanding of the content. Mapping between Facts and Representation F 0D 8 Knowledge is a collection of “ facts” from some domain.

F 0B 7provides a framework to compare two objects based on equivalent attributes. F 0B 7any instance in which two different objects are compared is a relational type of knowledge. F 0D 8 Inheritable Knowledge F 0B 7is obtained from associated objects. F 0B 7 it prescribes a structure in which new objects are created which may inherit all or a subset

of attributes from existing objects. F 0D 8 Inferential Knowledge F 0B 7is inferred from objects through relations among objects. F 0B 7 e.g., a word alone is a simple syntax, but with the help of other words in phrase the reader

may infer more from a word; this inference within linguistic is called semantics. F 0D 8 Declarative Knowledge F 0B 7 a statement in which knowledge is specified, but the use to which that knowledge is to be

put is not given. F 0B 7 e.g. laws, people's name; these are facts which can stand alone, not dependent on other

knowledge; F 0D 8 Procedural Knowledge F 0B 7 a representation in which the control information, to use the knowledge, is embedded in

the knowledge itself. F 0B 7 e.g. computer programs, directions, and recipes; these indicate specific use or

implementation; Relational Knowledge This knowledge associates elements of one domain with another domain. F 02 D Relational knowledge is made up of objects consisting of attributes and their

corresponding associated values. F 02 D The results of this knowledge type is a mapping of elements among different domains.

The table below shows a simple way to store facts. F 02 D The facts about a set of objects are put systematically in columns. F 02 D This representation provides little opportunity for inference.

F 0F C Given the facts it is not possible to answer simple question such as :

" Who is the heaviest player? ". but if a procedure for finding heaviest player is provided, then these facts will enable that procedure to compute an answer.

F 0F C We can ask things like who "bats – left" and "throws – right".

Inheritable Knowledge F 0D 8 Here the knowledge elements inherit attributes from their parents. F 0D 8 The knowledge is embodied in the design hierarchies found in the functional, physical and

process domains. Within the hierarchy, elements inherit attributes from their parents, but in many cases not all attributes of the parent elements be prescribed to the child elements. F 0D 8 The inheritance is a powerful form of inference, but not adequate. The basic KR needs to

be augmented with inference mechanism. F 0D 8 The KR in hierarchical structure, shown below, is called “semantic network” or a

collection of “frames” or “slot-and-filler structure". The structure shows property inheritance and way for insertion of additional knowledge. F 0D 8 Property inheritance: The objects or elements of specific classes inherit attributes and

values from more general classes. The classes are organized in a generalized hierarchy.

F 0F C The directed arrows represent attributes ( isa, instance, team ) originates at objectbeing

described and terminates at object or its value. F 0F C The box nodes represents objects and values of the attributes. F 0D 8 Viewing a node as a frame

Example : Baseball-player isa : Adult-Male Bats : EQUAL handed Height : 6. Batting-average : 0. F 0D 8Algorithm : Property Inheritance

Retrieve a value V for an attribute A of an instance object O Steps to follow:

  1. Find object O in the knowledge base.
  2. If there is a value for the attribute A then report that value.
  3. Else, if there is a value for the attribute instance; If not, then fail.
  4. Else, move to the node corresponding to that value and look for a value for the attribute A ; If one is found, report it.
  5. Else, do until there is no value for the “ isa ” attribute or until an answer is found :

Here, the knowledge is a mapping process between domains that specify “what to do when” and the representation is of “how to make it” rather than “what it is”. The procedural knowledge F 0F C may have inferential efficiency, but no inferential adequacy and acquisition efficiency. F 0F C are represented as small programs that know how to do specific things, how to proceed.

Example : A parser in a natural language has the knowledge that a noun phrase may contain articles, adjectives and nouns. It thus accordingly call routines that know how to process articles, adjectives and nouns. Issues in Knowledge Representation F 0D 8 The fundamental goal of Knowledge Representationis to facilitate inference (conclusions)

from knowledge. F 0D 8 The issues that arise while using KR techniques are many. Some of these are explained

below. F 0F C Important Attributes:

Any attribute of objects so basic that they occur in almost every problem domain? F 0F C Relationship among attributes:

Any important relationship that exists among object attributes? F 0F C Choosing Granularity :

At what level of detail should the knowledge be represented? F 0F CSet of objects :

How sets of objects be represented? F 0F C Finding Right structure :

Given a large amount of knowledge stored, how can relevant parts be accessed? F 0D 8 Important Attributes F 0F C There are attributes that are of general significance. F 0F C There are two attributes "instance" and "isa", that are of general importance. These

attributes are important because they support property inheritance. F 0D 8 Relationship among Attributes

  • The attributes to describe objects are themselves entities they represent.
  • The relationship between the attributes of an object, independent of specific knowledge they encode, may hold properties like: - To describe these facts, the only way is to attach assertion to the sets representing people, sheep, and English.
  • The reason to represent sets of objects is :
  • If a property is true for all or most elements of a set, then it is more efficient to associate it once with the set rather than to associate it explicitly with every elements of the set.
  • This is done in different ways :
    • in logical representation through the use of universal quantifier, and
    • in hierarchical structure where node represent sets, the inheritance propagate set level assertion down to individual.
  • Example: assert large (elephant); Remember to make clear distinction between,
  • whether we are asserting some property of the set itself, means, the set of elephants is large, or
  • asserting some property that holds for individual elements of the set , means, any thing that is an elephant is large.
  • There are three ways in which sets may be represented :
    • Name, as in the example. Inheritable KR, the node - Baseball- Player and the predicates as Ball and Batter in logical representation.
    • Extensional definition is to list the numbers, and
    • (^) In tensional definition is to provide a rule, that returns true or false depending on whether the object is in the set or not. F 0D 8 Finding Right Structure
  • Access to right structure for describing a particular situation.
  • It requires, selecting an initial structure and then revising the choice. While doing so, it is necessary to solve following problems :
  • how to perform an initial selection of the most appropriate structure.
  • how to fill in appropriate details from the current situations.
  • how to find a better structure if the one chosen initially turns out not to be appropriate.
  • what to do if none of the available structures is appropriate.
  • when to create and remember a new structure.
  • There is no good, general purpose method for solving all these problems. Some knowledge representation techniques solve some of them.

Knowledge Representation using predicate logic 2.4 Representing Simple Facts in Logic

  1. All Pompeians were Romans.
  2. Caesar was a ruler.
  3. All Romans were either loyal to Caesar or hated him.
  4. Everyone is loyal to someone.
  5. People only try to assassinate rulers they are not loyal to.
  6. Marcus tried to assassinate Caesar. The facts described by these sentences can be represented as a set of wff's in predicate logic as follows:
  7. Marcus was a man. man(Marcus) Although this representation fails to represent the notion of past tense (which is clear in the English sentence), it captures the critical fact of Marcus being a man. Whether this omission is acceptable or not depends on the use to which we intend to put the knowledge.
  8. Marcus was a Pompeian. Pompeian(Marcus) 3.All Pompeians were Romans.

4.Caesar was a ruler. ruler(Caesar) Since many people share the same name, the fact that proper names are often not references to unique individuals, overlooked here. Occasionally deciding which of several people of the same name is being referred to in a particular statement may require a somewhat more amount of knowledge and logic. But that fails to capture the relationship between any individual being a man and that individual being a mortal. To do that, we really need variables and quantification unless we are willing to write separate statements about the mortality of every known man. Let's now explore the use of predicate logic as a way of representing knowledge by looking at a specific example. Consider the following set of sentences:

  1. Marcus was a man.

  2. Marcus was a Pompeian.

  3. All Pompeians were Romans.

  4. Caesar was a ruler.

  5. All Romans were either loyal to Caesar or hated him.

  6. Everyone is loyal to someone.

  1. People only try to assassinate rulers they are not loyal to.
  2. Marcus tried to assassinate Caesar. The facts described by these sentences can be represented as a set of wff's in predicate logic as follows:
  3. Marcus was a man. man(Marcus) Although this representation fails to represent the notion of past tense (which is clear in the English sentence), it captures the critical fact of Marcus being a man. Whether this omission is acceptable or not depends on the use to which we intend to put the knowledge.
  4. Marcus was a Pompeian. Pompeian(Marcus) 3.All Pompeians were Romans.

4.Caesar was a ruler. ruler(Caesar) Since many people share the same name, the fact that proper names are often not references to unique individuals, overlooked here. Occasionally deciding which of several people of the same name is being referred to in a particular statement may require a somewhat more amount of knowledge and logic.

  1. People only try to assassinate rulers they are not loyal to.

8.Like the previous one this sentence too is ambiguous which may lead to more than one conclusion. The usage of “try to assassinate” as a single predicate gives us a fairly simple representation with which we can reason about trying to assassinate. But there might be connections as try to assassinate and not actually assassinate could not be made easily.

  1. Marcus tried to assassinate Caesar. tryassasinate (Marcus,Caesar) now, say suppose we wish to answer the following question: Was Marcus loyal to Caesar? What we do is start reasoning backward from the desired goal which is represented in predicate logic as:

F 0D 8 Some of the computational predicates like Less than, Greater than used in knowledge

representation. F 0D 8 It generally return true or false for the inputs. Examples: Computable predicates gt(1,0) or lt(0,1) gt(5,4) or gt(4,5) Computable functions: gt(2+4, 5) Consider the following set of facts, again involving Marcus:

  1. marcus was a man man(Marcus)
  2. Marcus was a pompeian Pompeian(Marcus)
  3. Marcus was born in 40 A.D born(marcus, 40)
  4. All men are mortal ∀x: men(x)→ mortal(x)
  5. All Pompeians died when the volcano erupted in 79 A.D erupted(volcano,79) & x :pompeian(x)→died(x, 79)
  6. No mortal lives longer than150 years ∀x: ∀t1: ∀t2: mortal(x) & born(x,t1) & gt(t2-t1,150)→ dead(x,t1)
  7. It is Now 1991 Now=
  8. Alive means not dead ∀x: ∀t: [ alive(x,t) →~dead(x,t)] & [~dead(x,t)→alive(x,t)]
  9. If someone dies then he is dead at all later times ∀x: ∀t1: ∀t2: died(x,t1) & gt(t2,t1)→ dead(x1,t2) This representation says that one is dead in all years after the one in which one died. It ignores the question of whether one is dead in the year in which one died.
  10. man(Marcus)
  11. Pompeian(Marcus)
  12. born(marcus, 40)
  13. ∀x: men(x)→ mortal(x)
  14. ∀:pompeian(x)→died(x, 79)
  15. erupted(volcano,79)
  1. ∀ x: ∀t1: ∀t2: mortal(x) & born(x,t1) & gt(t2-t1,150)→ dead(x,t1)
  2. Now=
  3. ∀x: ∀ t: [ alive(x,t) →~dead(x,t)] &[~dead(x,t)→alive(x,t)]
  4. ∀ x: ∀t1: ∀t2: died(x,t1) & gt(t2,t1)→ dead(x1,t2)

Two things should be clear from the proofs we have just shown: F 0B 7 Even very simple conclusions can require many steps to prove. F 0B 7A 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. Disadvantage: F 0D 8 Many steps required to prove simple conclusions F 0D 8 Variety of processes such as matching and substitution used to prove simple conclusions

2.5 Resolution F 0D 8 Resolution is a proof procedure by refutation. F 0D 8 To prove a statement using resolution it attempt to show that the negation of that statement.

Algorithm: 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))]
  1. 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))]
  2. Convert the matrix into a conjunction of disjuncts. In the case or our example, since there are no and 2 01 Fs, 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. 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 2 01 Fs,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.
  4. 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 wff's, 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.

2.5.1 Resolution in Propositional Logic In propositional logic, the procedure for producing a proof by resolution of proposition P with respect to a set of axioms F is the following.

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

Suppose we are given the axioms shown in the first column of Table 1 and we want to prove R. First we convert the axioms to clause which is already in clause form. Then we begin selecting pairs of clauses to resolve together. Although any pair of clauses can be resolved, only those pairs that contain complementary literals will produce a resolvent that is likely to lead to the goal of sequence of resolvents shown in figure 1.

We begin by resolving with the clause 2 C7 7R since that is one of the clauses that must be involved in the contradiction we are trying to find.

ii) A variable can match another variable, any constant or a function or predicate expression, subject to the condition that the function or [predicate expression must not contain any instance of the variable being matched (otherwise it will lead to infinite recursion). iii) The substitution must be consistent. Substituting y for x now and then z for x later is inconsistent. (a substitution y for x written as y/x) The Unification algorithm is listed below as a procedure UNIFY (L1, L2). It returns a list representing the composition of the substitutions that were performed during the match. An empty list NIL indicates that a match was found without any substitutions. If the list contains a single value F, it indicates that the unification procedure failed. The empty list, NIL, indicates that a match was found without any substitutions. The list consisting of the single value FAIL indicates that the unification procedure failed.

Algorithm: Unify(L1, L2) I. If L1 or L2 are either 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}.

  1. If the initial predicate symbols in L1 and L2 are not identical, then return {FAIL}.

  2. If LI and L2 have a different number of arguments, then return {FAIL}.

  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 arguments in L1 : (a) Call Unify with the ith 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).

  5. Return SUBST. 2.5.4 Resolution in Predicate Logic ALGORITHM: RESOLUTION IN PREDICATE LOGIC

  6. Convert all the statements of F to clause form

  7. Negate P and convert the result to clause form. Add it to the set of clauses obtained in step

  8. Repeat until either a contradiction is found or 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 resulting clause, called the resolvent, will be the disjunction of all of the literals of both the 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 T1 and the other contains T2 and if T1 and T2 are unifiable, then neither T nor T2 should appear in the resolvent. We call T1 and T2 complementary literals. Use the substitution produced by the unification to create the resolvent. If there is one pair of complementary literals, only one such pair should 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. If the choice of clauses to resolve together at each step is made in certain systematic ways, then the resolution procedure will find a contradiction if one exists. However, it may take a very long time. There exist strategies for making the choice that can speed up the process considerably as given below.

  9. persecute(x, y) F 0E 0hate(y, x)

  10. hate(x,y) F 0E 0persecute(y, x) Converting to clause form, we get

  11. F 0D 8persecute(x5,y2) F 0D Ahate(y2,x5)

  12. F 0D 8hate(x6,y3) F 0D Apersecute(y3,x6)

2.5.5 Procedural v/s Declarative Knowledge F 0D 8 A Declarative representation is one in which knowledge is specified but the use to which

that knowledge is to be put in, is not given. F 0D 8A Procedural representation is one in which the control information that is necessary to use

the knowledge is considered to be embedded in the knowledge itself. F 0D 8 To use a procedural representation, we need to augment it with an interpreter that follows

the instructions given in the knowledge.