









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This is the Notes About Artificial. Where Multiple Documents.
Typology: Study Guides, Projects, Research
1 / 16
This page cannot be seen from the preview
Don't miss anything!










Matthew Huntbach, Dept of Computer Science, Queen Mary and Westfield College, London, UK E1 4NS. Email: [email protected]. Notes may be used with the permission of the author.
Semantic networks are an alternative to predicate logic as a form of knowledge representation. The idea is that we can store our knowledge in the form of a graph, with nodes representing objects in the world, and arcs representing relationships between those objects. For example, the following:
Tom
Cat
Cream
Mat
Mammal
Bird
is_a
is_a is_a
caught
like
sat_on is_a
John
is_owned_by
Fur has
Animal
is_coloured
Ginger
is intended to represent the data:
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.
It is argued that this form of representation is closer to the way humans structure knowledge by building mental links between things than the predicate logic we considered earlier. Note in particular how all the information about a particular object is concentrated on the node representing that object, rather than scattered around several clauses in logic.
There is, however, some confusion here which stems from the imprecise nature of semantic nets. A particular problem is that we haven’t distinguished between nodes representing classes of things, and nodes representing individual objects. So, for example, the node labelled Cat represents both the single (nameless) cat who sat on the mat, and the whole class of cats to which Tom belongs,
which are mammals and which like cream. The is_a link has two different meanings – it can mean that one object is an individual item from a class, for example Tom is a member of the class of cats, or that one class is a subset of another, for example, the class of cats is a subset of the class of mammals. This confusion does not occur in logic, where the use of quantifiers, names and predicates makes it clear what we mean so:
Tom is a cat is represented by Cat(Tom)
The cat sat on the mat is represented by ∃x∃y(Cat(x)∧Mat(y)∧SatOn(x,y))
A cat is a mammal is represented by ∀x(Cat(X)→Mammal(x))
We can clean up the representation by distinguishing between nodes representing individual or instances, and nodes representing classes. The is_a link will only be used to show an individual belonging to a class. The link representing one class being a subset of another will be labelled a_kind_of, or ako for short. The names instance and subclass are often used in the place of is_a and ako, but we will use these terms with a slightly different meaning in the section on Frames below.
Note also the modification which causes the link labelled is_owned_by to be reversed in direction. This is in order to avoid links representing passive relationships. In general a passive sentence can be replaced by an active one, so “Tom is owned by John” becomes “John owns Tom”. In general the rule which converts passive to active in English converts sentences of the form “X is Yed by Z” to “Z Ys X”. This is just an example (though often used for illustration) of the much more general principle of looking beyond the immediate surface structure of a sentence to find its d e e p structure.
The revised semantic net is:
Tom
is_a
caught
like
John
Mat
Cats
Mats Mammals
Animals
Birds Bird
Cat
ako ako
is_a
sat_on is_a
is_a
ako
owns
Cream
Fur
have
is_coloured
Ginger
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 process similar to t h e Skolemisation we considered previously as a way of dealing with existential quantifiers. For example, “Tom caught a bird” would be represented in logic by ∃x(bird(x)∧caught(Tom,x)), which would be Skolemised by replacing the x with a Skolem constant; the same thing was done above where bird1 was the name given to the individual bird that Tom caught.
There are still plenty of issues to be resolved if we really want to represent what is meant by t h e English phrases, or to be really clear about what the semantic net means, but we are getting towards a notation that can be used practically (one example of a thing we have skated over is how to deal
An alternative form of representation considers the semantic network directly as a graph. We have already seen ways of representing graphs in Prolog. We could represent each edge in the semantic net graph by a fact whose predicate name is the label on the edge. The nodes in this graph, whether they represent individuals or classes are represented by arguments to the facts representing edges. This gives the following representation for our initial graph:
is_a(mat1,mats). is_a(cat1,cats). is_a(tom,cats). is_a(bird1,birds). caught(tom,bird1). ako(cats,mammals). ako(mammals,animals). ako(birds,animals). like(cats,cream). owns(john,tom). sat_on(cat1,mat1). is_coloured(tom,ginger). have(mammals,fur).
Alternatively, the graph could be built using the cells or pointers of an imperative language. There are also special purpose knowledge representation languages which provide a notation which translates directly to this sort of graph.
This process of turning a predicate into an object in a knowledge representation system is known as reification. So, for example, the constant symbol cats represents the set of all cats, which we can treat as just another object.
We have shown how binary relationships may be represented by arcs in graphs, but what about relationships with more than two arguments? For example, what about representing the sentence “John gave the book to Mary”? In predicate logic, we could have a 3-ary predicate gave, whose first argument is the giver, second argument the object given and third argument the person to whom it was given, thus gave(John,Book1,Mary). The way this can be resolved is to consider the act of giving a separate object (remember how in the first set of notes we saw how the pronoun “it” could in some contexts be taken to refer to a previously mentioned action itself rather than to an object involved in the action), thus it is further reification. We can than say that any particular act of giving has three participants: the donor, the recipient, and the gift, so the semantic net representing the sentence is:
John (^) Book Mary
Give
Books
Givings
is_a
is_a recipient
gift donor
In fact the three different roles correspond to what is known in natural language grammar as subjective (the object doing the action, in this case John), objective (the object to which the action is
being done, in this case the book) and dative (the recipient of the action, in this case Mary). These different roles of objects in a sentence are known as cases.
The fact that various natural languages make this case distinction can be used to support using it in artificial knowledge representation. The “case for case” is associated with the linguist Charles Fillmore whose work has been influential among AI workers in knowledge representation. The idea is that all sentences can be analysed as an action plus a number of objects filling the roles in t h e action, with there being a fixed set of roles (though not every role will always be filled). Other roles suggested as fundamental include the locative indicating where the action is done, and t h e instrumental , indicating the means by which an action is done.
In some natural languages the different roles which a word may fill are indicated by the ending or inflexion of the word. A well-known example of such an inflexional language is Latin (but some modern languages, such as Russian are equally as inflexional), where, for example “Dog bites man” is “Canis hominem mordet” while “Man bites dog” is “Homo canem mordet”. The word for “dog” is “canis” if it is the object of the sentence, but “canem” if it is the subject, while for “man” it is “homo” if he is the object of the sentence and “hominem” if he is the subject. If something were being given to a dog, the word used would be “cane”, if a dog were being used for something the word used would be “cani”. In English the objective and subjective roles are indicated by word order, with the object coming before the verb and the object coming after. In Latin, it is the case endings, not the word order that indicates a role, so “Hominem canis mordet” is just another way of saying “Dog bites man”. You could perhaps compare it the programming languages where the relationship of arguments to formal parameter names in procedure calls may be indicated by their position, but in some cases (e.g. Modula-3) a facility is available for named arguments.
In English the dative is occasionally indicated by word order (for example in “John gave Mary t h e book”), but more often by prefixing the word indicating the dative item with the preposition “to”, as in “John gave the book to Mary”. Other cases are always indicated by prepositions, for example the locative with “at” (e.g. “John gave the book to Mary at school”) and the instrumental with “by” or “with” (“John sent the book to Mary by post”, “Mary hit John with the book”). Most inflexional languages have a limited range of cases, and use prepositions to extend the range. In fact the argument for case as innate is damaged by the fact that different languages have different case structures, and it is by no means certain which cases are fundamental and which are just variants of others. For example, in sentences involving the concept of movement linguists distinguish t h e ablative case (the source of the movement, in English indicated by the preposition “from”) and t h e a l l a t i v e case (the destination of the movement), but should the latter be considered just another form of the dative role?
Using the concept of a semantic network in which nodes represent individual actions, with arcs representing objects having roles in these actions, it is possible to build up complex graphs representing complete scenarios. For example, the story:
“John gave Mary a book. The book was not the one Mary likes, so she punched John. That made her feel sorry for him, so she then kissed him”
is represented by the graph on the next page. The class nodes are omitted as the graph is complex enough without them. The arcs are labelled with sub and obj, for the subject and object of t h e action, ind.obj and instr for the case where there is an indirect object (i.e. dative in t h e terminology used previously) and an instrument. There are also arcs representing time relationships
Note that in the graph some English words are translated to an equivalent, thus “punch” is represented as “hit with fist” (we might also, for example, have represented “kiss” by “touch with lips”, though this perhaps illustrates why this sort of attempt to find an underlying representation can miss some of the subtleties of human language!). Similarly, if we are trying to represent underlying meanings, we have not only to convert passive forms to active forms as suggested previously, but also to note forms where one verb is equivalent to another, except with the roles in a different order. For example, the sentence “X buys Y from Z” is essentially equivalent to “Z sells Y to X”, so we could therefore convert all sentences involving selling to the equivalent involving buying and make them instances of the buying class. Work on trying to find underlying primitives to aid network representation of the meaning of natural language semantics is associated with the AI researcher Roger Schank.
In this case, however, the answer will not be an individual but simply a name assigned to an node representing a feeling_sorry_for action. A more correct report would need to give the complete sentence represented by the node to which the reason link points.
Similarly, a “when” question is a search for a time link. Time links may point to nodes actually storing times and dates. However, as in our example, it is more likely to be a time which is relative to another, so again the answer given must involve looking beyond just the node pointed to by t h e time link. For example, with our above graph the question “When did Mary feel sorry for John” would be answered by finding that the time link from the node sorry1 links to time time3. It can then be noted that time3 is the subject of one after node, and the object of another, so the answer could be given as both “After Mary hit John” and “Before Mary kissed John”. If two different action nodes pointed to the same time node, the time of the action of one could be given as when the other happened, so for example with the graph below:
Seeing Hearing
Tom
Jill
See1 Time1 Heard
Peter
Sue
is_a is_a
Time Time Subject
Object
Subject
Object
the question “When did Tom see Jill?” could be answered “When Peter heard Sue”. Note that a simplification we are making here is that all actions occur instantly at a fixed time point. A more realistic treatment of time would deal with time intervals which have a start and finish time.
Consideration of the use of cases suggests how we can tighten up on the semantic net notation to give something which is more consistent, known as the frame notation. In the place of an arbitary number of arcs leading from a node there are a fixed number of slots representing attributes of an object. Every object is a member or instance of a class, which it may be thought of as linking to with an is_a link as we saw before. The class indicates the number of slots that an object has, and the name of each slot. In the case of a giving object, for instance, the class of giving objects will indicate t h a t it has at least three slots: the donor, the recipient and the gift. There may be further slots indicated as necessary in the class, such as ones to give the time and location of the action. The time slot may be considered a formalisation of the tense of the verb in a sentence.
The idea of inheritance is used, with some slots being filled at class level, and some at instance level. Where a slot is filled at class level the idea is that this represents attributes which are common to all members of that class. Where it is filled at instance level, it indicates that the value of that attribute varies among members of that class. Slots may be filled with values or with pointers to other objects. This is best illustrated by an example.
In our example we have a general class of birds, and all birds have attributes flying, feathered and colour. The attributes flying and feathered are boolean values and are fixed to true at this level, which means that for all birds the attribute flying is true and t h e attribute feathered is true. The attribute colour, though defined at this level is not filled, which means that though all birds have a colour, their colour varies. Two subclasses of birds, pet_canaries and ravens are defined. Both have the colour slot filled in, pet_canaries with yellow, ravens with black. The class pet_canaries has an additional slot, owner, meaning that all pet canaries have an owner, though it is not filled at this level since it is obviously not t h e case that all pet canaries have the same owner. We can therefore say that any instance of the class pet_canary has attributes colour yellow, feathered true, flying true, and owner, the last of these varying among instances. Any instance of class raven has colour black, feathered true, flying true, but no attribute owner. The two instances of pet_canary shown, Tweety and
Cheepy have owners John and Mary who are separate instances of the class person, for simplicity no attributes have been given for class person. The instance of pet_canary Cheepy has an attribute which is restricted to itself, vet (since not all pet canaries have their own vet), which is a link to another person instance, but in this case we have subclass of person, vet. The frame diagram for this is:
Pet Canaries
Colour Owner
Yellow Ravens Colour Black
Flying Feathered Colour
Birds
T T
Tweety Owner
Owner John^ Cheepy
Mary
Edgar
Person
is_a
is_a
is_a
owner
is_a owner
is_a
Vet (^) Sally
Vet
Vet
is_a
a_kind_of a_kind_of
a_kind_of
We can define a general set of rules for making inferences on this sort of frame system. We can say that an object is an instance of a class if it is a member of that class, or if it is a member of a class which is a subclass of that class. A class is a subclass of another class if it is a kind of that class, or if it is a kind of some other class which is a subclass of that class. An object has a particular attribute if it has that attribute itself, or if it is an instance of a class that has that attribute. In Prolog:
aninstance(Obj,Class) :– is_a(Obj,Class).
aninstance(Obj,Class) :– is_a(Obj,Class1), subclass(Class1,Class).
subclass(Class1,Class2) :– a_kind_of(Class1,Class2).
subclass(Class1,Class2) :– a_kind_of(Class1,Class3), subclass(Class3,Class2).
We can then say that an object has a property with a particular value if the object itself has an attribute slot with that value, or it is an instance of a class which has an attribute slot with t h a t value, in Prolog:
value(Obj,Property,Value) :– attribute(Obj,Property,Value).
value(Obj,Property,Value):– aninstance(Obj,Class), attribute(Class,Property,Value).
The diagram above is represented by the Prolog facts:
the use of a variable conventionally called Self. We then need to add the reference to Self to our rules for determining the value of some property:
value(Obj,Property,Value) :– attribute(Obj,Obj,Property,Value).
value(Obj,Property,Value):–
aninstance(Obj,Class), attribute(Obj,Class,Property,Value).
The first argument to attribute here is the reference to Self. Our previous attributes do not depend on the value of Self, so we can just add it as an anonymous variable:
attribute(_,birds,flying,true).
attribute(_,pet_canaries,colour,yellow).
and so on for the other attributes. For our example, we must have the attribute fees attached to vets (it will vary from vet to vet so it will be filled in at instance level), so we will also add to our example:
attribute(_,sally,fees,20).
Now, to add our demon, which we will name eval_maintenance, we add:
attribute(Self,pet_canaries,maintenance,Costs) :– eval_maintenance(Self,Costs).
eval_maintenance(Self,Costs) :– value(Self,vet,SelfsVet), !, value(SelfsVet,fees,VetFees), Costs is VetFees+5.
eval_maintenance(Self,5).
The use of the cut here is because the only way we can find out if a pet canary doesn’t have a vet is to see if fails, but we don’t want backtracking for a pet canary that does have a vet to give an alternative value for maintenance costs.
The introduction of demons brings our knowledge representation method close to that of object- oriented programming. Several object-oriented programming language have been developed which give mechanisms directly for expressing classes with attached procedures and inheritance. The most successful examples are C++ and Smalltalk. Development of the idea of demons into full procedures which may change the values stored with an object moves away from the declarative ideas of knowledge representation, so we shall not develop it further here, but those taking t h e course in Object-Oriented Programming will be able to build the connection.
One of the problems we mentioned with predicate logic is that it does not provide us with a way of saying that some particular conclusion may be drawn unless we can show otherwise. We had to add the idea of negation as failure to deal with this, and even then if we want to draw a conclusion we have to show that all the conditions that would cause that conclusion to fail are false.
For example, we know that in general birds can fly. So we can write in Prolog:
flies(X) :– bird(X).
But suppose we want to deal with special cases of birds that cannot fly. We know that kiwis and penguins cannot fly, for instance. We also know that any bird with a broken wing cannot fly. So strictly we would have to say:
flies(X) :– bird(X), +kiwi(X), +penguin(X), +broken_wing(X).
We can summarise this as:
flies(X) :– bird(X), +ab(X).
where ab(X) means “X is an abnormal bird”. We could list the factors that make X an abnormal bird in respect to flying:
ab(X) :– kiwi(X).
ab(X) :– penguin(X).
ab(X) :– broken_wing(X).
but there might always be circumstances we had not thought of (other species of birds that don’t fly, birds whose wings are not broken but whose feet are trapped, etc.). As we mentioned in a previous set of notes forms of default logic exist which enable us to say that some conclusion holds on the assumption that there are no facts known to indicate why they should not. So we might say that bird(x) is true with assumption set {¬ab(x)}. This is non-monotonic reasoning, since t h e addition of a fact which makes some assumption false will make a conclusion false. For example, i f we have ostrich(ossie) and bird(X):–ostrich(X) we can assume flies(ossie), but if we add ab(X):–ostrich(X), this reasoning fails. In practice there will have to be a separate form of ab for every rule.
Another way of putting this is to say that the default is for any bird x, flies(x) is true.
Default reasoning is easily added to the frame system of representation. The idea used is that an attribute at class level is inherited only if it is not cancelled out or overridden by the same attribute slot occurring in a subclass of that class or in an individual instance with a different value. For example, we could add the class of kiwis as a subclass of birds in our diagram above, and indicate that kiwis cannot fly. The additional attributes to create a class of kiwis with one instance kevin are:
a_kind_of(kiwis,birds).
attribute(kiwis,flying,false).
attribute(kiwis,colour,brown).
is_a(kevin,kiwis).
We have to add a colour attribute for kiwis as this was a slot in its superclass, birds. For simplicity we have gone back to the representation which does not allow for the possibility of demons.
The following arcs are added to our diagram:
Flying Feathered Colour
Birds
T T
Kiwis
Kevin
Flying Colour Brown
F
is_a
ako
Now it will be seen that for X=tweety, cheepy or edgar,
| ?- value(X,flying,V). will give the response
V = true? but
| ?- value(kevin,flying,V). will give the response
V = false? One problem is that if we typed ; in response to this we would get:
V = true?
Pet Canaries
Birds Flying T
Dogs Pets^
Cute Owner
T Sound Bark
Pet Dogs
Rottweilers Cute F Fido Tweety
John
Bill
Person Spike
Owner
Colour Yellow Canaries Sound Cheep
ako
ako ako
ako
ako ako
is_a owner
is_a
is_a
owner
ako
We have also added that John is the default owner of any pet, so any pet whose owner we don’t know we assume is John’s.
The Prolog facts representing this set up are:
attribute(birds,flying,true). attribute(dogs,sound,bark). attribute(pets,cute,true). attribute(pets,owner,john). attribute(canaries,colour,yellow). attribute(canaries,sound,cheep). attribute(rottweilers,cute,false). attribute(fido,owner,bill). a_kind_of(canaries,birds). a_kind_of(pet_canaries,canaries). a_kind_of(pet_canaries,pets). a_kind_of(pet_dogs,dogs). a_kind_of(pet_dogs,pets). a_kind_of(rottweilers,pet_dogs). is_a(tweety,pet_canaries). is_a(spike,rottweilers). is_a(fido,pet_dogs). is_a(john,person). is_a(bill,person).
If these are loaded into Prolog, together with the inference rules, it will be seen that multiple inheritance works. We have:
| ?- value(fido,sound,S).
S = bark?
showing that fido inherits the sound bark from dogs,
| ?- value(fido,cute,V).
V = true?
showing that fido inherits the cute is true from pets,
| ?- value(spike,cute,V).
V = false?
showing that the cute is true property of pet_dogs is overridden in the rottweiler spike.
Note that overrides may themselves be overridden. For example, in a classification of animals, molluscs typically have the property that they have shells. Cephalopods (octopuses and squids) are a subclass of mollusc which typically do not have shells, so the property has_shell=true is overridden. Nautiluses, however are a subclass of cephalopods which typically do have shells, so the property is again overridden. This can easily be represented, in Prolog facts:
attribute(molluscs,has_shell,true).
attribute(cephalopods,has_shell,false).
attribute(nautiluses,has_shell,true).
a_kind_of(cephalopods,molluscs).
a_kind_of(nautiluses,cephalopods).
A more tricky situation happens when with multiple inheritance an instance or a subclass inherits one property from one superclass and a contradictory property from another. This is often referred to as the “Nixon diamond” property, as it is frequently illustrated by the case of Richard Nixon being both a Quaker (a group whose members typically hold pacifist views) and a Republican (a group whose members typically do not hold pacifist views). As a similar example building from our previous examples, let us consider the case of pet spiders. As before we assume that pets are typically cute, but we will also assume that spiders are not typically cute. So are pet spiders typically cute or not?
Spiders Cute F Pets Cute T
Pet Spiders
Webster
ako ako
is_a
In our Prolog representation, the answer will depend on the ordering of the clauses. If we have t h e ordering
ako(pet_spiders,spiders).
ako(pet_spiders,pets).
then using the rules defined above, we would get:
| ?- value(webster,cute,V).
V = false?
whereas if the order were
ako(pet_spiders,pets).
ako(pet_spiders,spiders).
we would get:
In our previous example, A was John, B was Mary, α was giving the wrong book, β was punching, and γ was kissing. In another instance of the same script, A could be the factory managers, B the factory workers, α could be cutting tea-break time, β could be going on strike, and γ could be agreeing to accept a bonus payment.
Agent A Agent B Action α Action β Action γ
"Settling a disagreement"
Agent A Agent B Action α Action β Action γ
Story 2
John
Mary
Giving wrong book
Punching
Kissing
Managers
Agent A Agent B Action α Action β Action γ
Workers
Cut tea breaks
Go on strike
Accept bonus pay
a_kind_of
a_kind_of
Story 1
The idea is that information on general points will be stored at the class level, which will enable us to answer questions on a variety of stories by relating them to a common theme.
A good coverage of the issues in this section is contained in:
H.Reichgelt Knowledge Representation: An AI Perspective Ablex Publishing Corporation 1991.
A collection of reprints of original papers on the subject is:
R.J.Brachman and H.J.Levesque Readings in Knowledge Representation Morgan Kaufmann 1985.
The subject in the context of object-oriented programming in:
G.Masini et al Object Oriented Programming Languages Academic Press 1991.
Further reading following from the section “The Case for Case” may be found in books on natural language processing, particularly those books with a good coverage of the semantic issues (many books on natural language processing are more concerned with the syntax i.e. saying whether a given sentence is grammatically correct or not, rather than the semantics i.e. determining t h e meaning of the sentence). Two books with a good coverage of semantics are:
M.D.Harris Natural Language Processing Prentice-Hall 1985.
J.Allen Natural Language Understanding Benjamin/Cummings 1987.