KNOWLEDGE REPRESENTATION 22C:145 ARTIFICIAL INTELLIGENCE THE UNIVERSITY OF IOWA THE IMPORTANCE OF KNOWLEDGE REPRESENTATION Contrary to the beliefs of early workers in AI, experience has shown that Intelligent Systems cannot achieve anything useful unless they contain a large amount of real-world - probably domain-specific - knowledge. Humans almost always tackle difficult realworld problems by using their resources of knowledge - "experience", "training" etc. KNOWLEDGE REP. FORMALISMS Production rules Formal logic, and languages based on it (e.g. PROLOG) Structured objects: Semantic nets (or networks) Frames, and object-orientated programming, which was derived from frames Other similar objects, such as Scripts KNOWLEDGE REPRESENTATION USING STRUCTURED OBJECTS Structured objects are: knowledge representation formalisms whose components are essentially similar to the nodes and arcs found in graphs. in contrast to production rules and formal logic. an attempt to incorporate certain desirable features of human memory organisation into knowledge representations. TAXONOMIC KNOWLEDGE The entities with which we reason can be grouped into categories. Categories may be divided into sub-categories. The hierarchical structure of these categories is called taxonomy. Taxonomic knowledge can be represented by first-order logic, or more conveniently by semantic nets. SEMANTIC NETS Devised by Quillian in 1968, as a model of human memory. The technique offered the possibility that computers might be made to use words in something like the way humans did, following the failure of early machine-translators. Organisation of semantic nets. c o v e re d _ b y a n im a l s k in tr a v e ls _ b y fly in g is a is a tr a v e ls _ b y b ir d fe a th e r s fis h c o v e re d _ b y is a o s tr ic h s w im m in g is a p e n g u in is a is a c a n a ry r o b in tr a v e ls _ b y c o lo u r c o lo u r w a lk in g y e llo w tr a v e ls _ b y re d in s ta n c e _ o f O pus in s ta n c e _ o f T w e e ty c o lo u r w h ite SEMANTIC NETS knowledge is represented as a collection of concepts, represented by nodes (shown as boxes in the diagram), connected together by relationships, represented by arcs (shown as arrows in the diagram). SEMANTIC NETS certain arcs - particularly isa arcs - allow inheritance of properties. This permits the system to "know" that a Ford Escort has four wheels because it is a type of car, and cars have four wheels. SEMANTIC NETS inheritance provides cognitive economy, but there is a storage-space / processing-time trade-off. This means that, if you adopt this technique, you will use less storage space than if you don't, but your system will take longer to find the answers to questions. SEMANTIC NETS a semantic net should make a distinction between types and tokens. This is why the diagram above uses “instance_of” arcs as well as “isa” arcs. Individual instances of objects have a token node. Categories of objects have a type node. There is always at least one type node above a token node. The information needed to define an item is (normally) found attached to the type nodes above it. SEMANTIC NETS So far, this is just a diagram - not a knowledge base. But it can be converted into a knowledge base. SEMANTIC NETS TO PROLOG is_a(sammy,goldfish). is_a(goldfish,freshwater_fish). … has(fish,fins). has(fish,scales). … Etc. Each arrow on the semantic net becomes a Prolog clause. 13 c o v e re d _ b y a n im a l s k in tr a v e ls _ b y fly in g is a is a tr a v e ls _ b y b ir d fe a th e r s fis h c o v e re d _ b y is a o s tr ic h s w im m in g is a p e n g u in is a is a c a n a ry r o b in tr a v e ls _ b y c o lo u r c o lo u r w a lk in g y e llo w tr a v e ls _ b y re d in s ta n c e _ o f O pus in s ta n c e _ o f T w e e ty c o lo u r w h ite A SEMANTIC NET PROGRAM WRITTEN IN PROLOG % defining operators. :- op(500, xfx, isa). :- op(500,xfx, instance_of). :- op(500,xfx, covered_by). :- op(500,xfx, travels_by). :- op(500,xfx, colour). :- op(500,xfx, travels). :- op(500,fx, is). :- op(600,xfx, a). :- op(600,xfx, an). :- op(700, xf, ?). :- op(500,fx, what). :- op(600, xfx, is). A SEMANTIC NET PROGRAM WRITTEN IN PROLOG :- op(650, xfx, what). :- op(650, xfx, how). ostrich isa bird. penguin isa bird. canary isa bird. robin isa bird. bird isa animal. fish isa animal. opus instance_of penguin. tweety instance_of canary. canary colour yellow. A SEMANTIC NET PROGRAM WRITTEN IN PROLOG robin colour red. tweety colour white. penguin travels_by walking. ostrich travels_by walking. bird travels_by flying. fish travels_by swimming. bird covered_by feathers. animal covered_by skin. A SEMANTIC NET PROGRAM WRITTEN IN PROLOG inherit(A isa C):A isa C. inherit(A isa C):A instance_of inherit(D isa inherit(A isa C):A isa D, inherit(D isa is X a Y :- inherit(X is X an Y:- inherit(X D, C). C). isa Y). isa Y). A SEMANTIC NET PROGRAM WRITTEN IN PROLOG inherit(A colour C):A colour C. inherit(A colour C):(A instance_of D ; A isa D), inherit(D colour C). what_colour A :inherit(A colour C), nl, write(A), write(' is '), write(C). A SEMANTIC NET PROGRAM WRITTEN IN PROLOG inherit(A covered_by C):A covered_by C. inherit(A covered_by C):(A instance_of D ; A isa D), inherit(D covered_by C). A covers:inherit(A covered_by C), nl, write(A), write(' is covered by '), write(C). SEMANTIC NETS This is a program, written in Prolog, which contains all the knowledge represented in the diagram above, together with a mechanism for finding information by inheritance, and a rudimentary natural language interface. SEMANTIC NETS It can answer questions like is tweety an animal ? (it answers “yes”) what colour is tweety ? (it answers “white”) opus is covered_by what ? (it answers “feathers”) and so on. SEMANTIC NETS It could have been written in C++ or Java (although it would have been much harder), or any other present-day high-level language. SEMANTIC NETS Problems with semantic nets logical inadequacy - vagueness about what types and tokens really mean. heuristic inadequacy – finding a specific piece of information could be chronically inefficient. trying to establish negation is likely to lead to a combinatorial explosion. "spreading activation" search is very inefficient, because it is not knowledge-guided. SEMANTIC NETS Attempted improvements building search heuristics into the network. more sophisticated logical structure, involving partitioning. these improvements meant that the formalism’s original simplicity was lost. SEMANTIC NETS Developments of the semantic nets idea: psychological research into whether human memory really was organised in this way. used in the knowledge bases in certain expert systems. special-purpose languages have been written to express knowledge in semantic nets. FRAMES The frame system mimics the human style of knowledge organisation by creating a structure consisting of slots that are filled with specific instances of data. For example we could organise the information about a wooden table as follows: In some cases a slot may hold a default value which will be assumed unless an alternative value is specified. In the Table frame, the default value for the number of legs is 4, but this could be changed (for example a larger table might have 6 legs) 27 FRAME STRUCTURE The values stored in slots are often pointers to other frames Frames allow facts to be retrieved directly Frames may be linked to form a hierarchy that allows properties to be inherited 28 SEMANTIC NET VS FRAMES Terminology: Subclass and has-part are called slots. Animal and head are the slot values. As Nellie is an instance of elephant, she inherits the properties of elephants, so we can also say that Nellie is large and grey. Elephants, in turn, are a subclass of mammals, so we can say that Nellie has a head, and is an animal, by a process of multiple inheritance. We could represent the same knowledge in the form of frames, as above: (note: these 3 frames represent only parts of the semantic net) 29 MONOTONIC LOGIC Standard logic is monotonic: once you prove something is true, it is true forever Monotonic Logic is not a good fit to reality If the wallet is in the purse, and the purse in is the car, we can conclude that the wallet is in the car But what if we take the purse out of the car? 30 MONOTONIC LOGIC Given a collection of facts D that entail some sentence s (s is a logical conclusion of D): For any collection of facts D’ such that DD’ , D’ also entails s. In other words: s is also a logical conclusion of any superset of D. 31 NONMONOTONIC LOGIC In a nonmonotonic system: the addition of new facts can reduce the set of logical conclusions. S is a conclusion of D, but is not necessarily a conclusion of D+new fact. Humans use nonmonotonic reasoning constantly! 32 WHAT IS “NON-MONOTONIC LOGIC” ? To understand what nonmonotonic logic means simple consider a popular example: "all birds fly", "Tweety is a bird", "Does Tweet fly?". The obvious answer is yes, however what if later you learned that Tweety had a broken wing, then the answer becomes no, then what if you learned that tweet was an airplane pilot, or had a jet pack, the answer can change again. The important point is that as new information is added the answers change. 33 NONMONOTONIC LOGIC Facts and rules can be changed at any time such facts and rules are said to be dynamic Prolog uses nonmonotonic logic assert(...) adds a fact or rule retract(...) removes a fact or rule assert and retract are said to be extralogical predicates. Negation as failure is also non-monotonic. 34 INTELLIGENT REASONING One of the characteristics associated with intelligent systems is adaptability - the ability to deal with a changing environment. Adaptation requires that a system be capable of adding and retracting beliefs as new information is available. This requires non-monotonic reasoning. 35 UNCERTAINTY Another characteristic of intelligent systems is the ability to reason under conditions of uncertainty. Another way of saying this: the ability to reason with an incomplete set of facts. 36 CAN WE IMPLEMENT INHERITANCE USING PREDICATE LOGIC? Pat is a Bat. Bats are Mammals. Bats can fly. Bats have 2 legs. Mammals cannot fly. Mammals have 4 legs. How many legs does Pat have? 37 INHERITANCE Reasoning about inheritance of properties from one class to another: Bird(x) Flies(x) Clearly this is not a good rule, since we know there are exceptions. Bird(x) Normal(x) Flies(x) This provides for exceptions, although we must define the conditions that imply Normal(x). 38 NORMAL(X) Assuming we know that: Ostrich(x) Bird(x) ~Flies(x) we can derive: Ostrich(x) ~Normal(x) So an ostrich is not a normal bird. But what about all the the other things that are birds? 39 ASSUMPTIONS AND DEFAULTS If there is no reason to believe otherwise, assume that Normal(x) is TRUE. The default is that everything is normal. Now we only need to supply additional information for exceptions. 40 HOW TO SPECIFY DEFAULTS A number of formal systems have been developed to handle defaults. Nonmonotonic logics formalize unsound but reasonable patterns of reasoning with uncertain, incomplete and inconsistent information Default Logic: New rule of inference Abduction: New interpretation of implication. 41 AND MORE LOGICS TO THINK ABOUT! Modal logic is useful for modeling reasoning about knowledge, actions, time (next, eventually, forever, never) or obligations. Epistemic logics apply the techniques of modal logic to reasoning about knowledge. Both individual and group knowledge is studied. The study of epistemic logic is relevant to communication protocols and cooperation. Deontic logic formalizes normative modalities. Deontic logic can be applied to representation of normative (e.g. legal) knowledge. 42 DEFAULT REASONING WITH NONMONOTONIC LOGIC Predicate logic with an extension: a modal operator M which means is “consistent with everything we know”. Example: x,y: Related(x,y) M GetAlong(x,y) WillDefend (x,y) 43 DEFAULT LOGIC New rule of inference: A:B C If A is true and it is consistent to assume B, then C is true. Same idea, but now used as a rule of inference. The new rule extends the knowledge base to a set of plausible extensions, any new statement that is true in all extensions is added. 44 INHERITANCE WITH DEFAULT LOGIC Support for inheritance using Default Logic: Mammal(x) : Legs(x,4) Legs(x,4) In the absence of contradictory information, we can assume anything that is a mammal has 4 legs (also need a rule stating that nothing can have 2 different numbers of legs!) The following statements are consistent in Default Logic: Pat is a Bat. Bats are Mammals. Bats can fly. Bats have 2 legs. Mammals cannot fly. Mammals have 4 legs. 45 ABDUCTION Deduction: Given A(x) B(x) and A(x), we assume that B(x) is true. Similar to forward reasoning [Cf.] reasoning from the general to the particular (or from cause to effect) Abduction: Given A(x) B(x) and B(x), we assume that A(x) is true. Similar to backward reasoning 46 INHERITANCE DIAGRAMS we can also express default reasoning using diagrams. Can Fly Normal Facts Default Ostriches Birds Fred Tweety Default 47 A PROBLEM WITH NML x: Republican(x) M ~ Pacifist(x) ~ Pacifist(x) x: Quaker(x) M Pacifist(x) Pacifist(x) Republican(Dick) Quaker(Dick) 48 NOT QUITE THIS EASY Assuming we have some mechanism for representing defaults, there can still be problems: Pacifists Is Dick a pacifist? Republicans Quakers Dick 49 NML DILEMMA In general we must be prepared to deal with multiple, possibly conflicting consequences of a set of facts. One simple idea - rank all the assumptions and use rank to determine which to believe. 50 OTHER APPROACHES TO HANDLING CONFLICTING ASSUMPTIONS. Minimalist Reasoning Assume that there are fewer true statements that false statements in the world. Find the smallest interpretation that satisfies all the statements we know to be true. Closed World Assumption: the only objects that satisfy a predicate are those that must. forces positive assertions to take priority over negative assertions 51 CLOSED WORLD ASSUMPTION If we are told nothing about Tweety, other than Tweety is a bird, we assume that Tweety's feet are not in concrete, or Tweety's wings are not broken, this is the closed world assumption. Humans regularly make assumptions and when new evidence appears those assumptions can be changed, causing a different answer, thus behaving nonmonotonicaly. 52 USING PROBABILITIES Probabilities can also be used determine which defaults apply when contradictions arise. Label each fact with a probability of being true. There is a big split in the A.I. community over whether symbolic methods or numeric methods are best for handling these types of issues. 53 SUMMARY - NONMONOTONIC LOGIC VS. PROBABILTY Nonmonotonic logic systems may miss the importance of probability. Probabilistic reasoning can also represent uncertainty, and in a different (probabilistic) way. These systems exhibit a different set of properties, with which non-monotonic logic can not effectively deal with. 54 NONMONOTONIC VS. CLASSICAL LOGIC Nonmonotonic logic does not have many essential properties of classical first order logic, specifically semi-decidability. In classical logic, it is possible for a system to halt (be stuck in an infinite loop) trying to prove the negation of something for which there is insufficient information. In nonmonotonic default logic, rather than return with no answer, the process returns with a wrong (default answer). 55 SUMMARY - NONMONOTONIC VS. CLASSICAL LOGIC First order logic although descriptively universal, is not effective at handling large classes of problems. If computers are going to handle common sense we need to be able to have some form of default reasoning. Nonmonotonic logic can be used in many domains where classical logic falls short: such as in the areas of default diagnosis, diagnosis, action, and temporal logic. 56