Knowledge Representation
First-order logic gives you the language; this lesson is about what to say in it. This first part builds the content: a general upper ontology from the top down, categories as first-class objects with taxonomies and inheritance, physical composition and the count-noun/mass-noun split, events and time reified through the event calculus, and belief modeled with modal logic — the machinery for representing the world an agent reasons about.
╌╌╌╌
First-order logic settles the syntax of a knowledge base: objects, relations, functions, quantifiers, and the inference that draws new sentences from old. It says nothing about what to write down. In a toy domain the choice barely matters — the wumpus world gets by with a handful of predicates and almost any encoding works. A domain like shopping on the Internet or driving a car needs general, reusable representations of concepts that recur everywhere: objects, substances, time, events, and beliefs. Designing those representations is ontological engineering, and it is the difference between a logic that could describe the world and a knowledge base that actually does.1
The plan of the chapter is to build the content first and the reasoning machinery second. We start with a general ontology and work down through categories, physical objects and stuff, events and time, and mental objects. Then we return to technology: reasoning systems built specifically for categories (semantic networks and description logics), and the handling of default information, where a conclusion holds only until some more specific fact overrides it.
The upper ontology
We will not write a complete description of everything — that would overflow even
a thousand-page book — but we can lay down the general framework and leave
placeholders where domain knowledge slots in later, the way an object-oriented
framework defines Window and expects you to subclass it into
SpreadsheetWindow. The framework of the most general concepts is an upper
ontology, so called because graphs are drawn with the general concepts at the
top and specializations below.
Two properties separate a general-purpose ontology from a pile of special-purpose ones. It should apply to essentially any domain, once you add domain-specific axioms — nothing can be finessed or omitted. And in a demanding domain, different areas of knowledge must unify, because one problem touches several at once: a circuit-repair robot reasons about electrical connectivity, physical layout, timing, and labor cost simultaneously, so the sentences about time must combine with the sentences about space and work equally well for nanoseconds and minutes as for angstroms and meters.
In practice, general ontological engineering has had only limited
success — none of the largest AI systems share one ontology, partly because
agreeing on an ontology is a social act. Every ontology is a treaty,
in Tom
Gruber's phrase. The ontologies that do exist were built four ways: hand-crafted
by trained logicians (CYC), imported from a structured database (DBpedia, from
Wikipedia), extracted by parsing text (TextRunner, from Web pages), or
crowdsourced from volunteers (OpenMind).
A second caveat is about the logic itself. We use first-order logic even though
parts of the world resist it: most generalizations have exceptions or hold only
to a degree. Tomatoes are red
is a useful rule, but some tomatoes are green,
yellow, or orange. Handling exceptions matters, but it is orthogonal to getting
the ontology right, so we defer it to the sections on default reasoning below and
the full treatment of uncertainty to
probability.
Categories and objects
Most reasoning happens at the level of categories, not individuals. A shopper wants a basketball, not the particular ball . Categories also drive prediction: from green-and-yellow mottled skin, a foot of diameter, red flesh, and a location in the fruit aisle you infer watermelon, and from that you infer it would be good in a fruit salad. Perception classifies; the class then predicts.
First-order logic offers two ways to represent a category. You can use a predicate, , or you can reify the category as an object, , and relate individuals to it with membership and subset relations. Reification — turning a proposition into an object you can quantify over and attach facts to — is what lets a category be a thing in its own right. Writing says is a member; says the first category is a subcategory (subclass, subset — we use the terms interchangeably) of the second.
Subclass relations organize categories into a taxonomy. Taxonomies are old and large: biology organizes roughly ten million living and extinct species into one hierarchy, and library science built the Dewey Decimal system to classify all of knowledge. The point of the hierarchy is inheritance: assert that every member of is edible, that and , and every apple inherits edibility without a separate axiom.
First-order logic states many kinds of category fact cleanly. An object is a member: . A category is a subclass: . Every member has a property: . Members can be recognized by properties, giving a sufficient condition for membership; and the category as a whole can have properties, as in — note that because is itself a member here, must be a category of categories.
Membership and subclass are not the only relations we need between categories. Two categories are disjoint if they share no members; a set of categories is an exhaustive decomposition of a larger one if every member of the larger belongs to at least one; and a disjoint exhaustive decomposition is a partition.
Categories can also be defined by necessary and sufficient conditions rather than merely described: . Such strict definitions are the exception, though. Most real-world categories are natural kinds with no clean definition — a tomato is typically dull scarlet, roughly spherical, two to four inches across, but there is variation at every feature and no crisp boundary. The practical response is to separate what is true of all members from what is true of typical ones, using a function , and to attach the soft facts to . This is the first appearance of default reasoning; we return to it below.
Physical composition
One object can be part of another. , , and so on up to ; the relation is transitive and reflexive, so a reasoner concludes . Categories of composite objects are characterized by structural relations among their parts. A biped has exactly two legs attached to a body:
with a further clause forcing any third leg to be one of the first two. The exactly two
idiom is awkward in first-order logic; description logics, later in this
lesson, make cardinality constraints like this far cleaner.
The mass of a composite object is the sum of its parts' masses — unlike a category, which has no mass even when its members do. To talk about the collective object formed from some parts without ascribing to it the abstract nothing-ness of a set, we use a bunch. If the apples are , then is a normal, if unstructured, object with those apples as parts, and it can have a weight where the set cannot. is defined as the smallest object of which each element of is a part — an instance of logical minimization, defining an object as the least one meeting a condition.
Measurements
Objects have height, mass, cost. The values assigned to such properties are measures, represented with a units function applied to a number. If is a line segment, ; conversions equate multiples of one unit to another, . Note is not a dollar bill — there is exactly one object named , though there can be many dollar bills — and and denote the same zero length while does not.
Not every measure has an agreed numerical scale. Exercises have difficulty, poems have beauty; imposing a number on beauty would be a mistake. What matters is not the number but that measures can be ordered. We can believe one exercise is tougher than another, and that a tougher exercise yields a lower expected score, using only and :
That is enough to decide which exercises to attempt, with no numerical difficulty ever assigned. Monotonic relationships of this kind are the basis of qualitative physics, which reasons about physical systems without solving their equations.
Objects: things and stuff
Some of reality resists individuation — division into distinct objects. Cut an aardvark in half and you do not get two aardvarks; cut a lump of butter in half and each piece is still butter. English marks the distinction with count nouns (aardvark, hole, theorem) and mass nouns (butter, water, energy). To represent stuff, put the gross lumps you interact with into the ontology as objects — is the lump you left on the table — alongside the category , whose members are all such lumps, with the rule that any part of a butter-object is also a butter-object:
The reason is that some properties are intrinsic — density, boiling point, color, flavor, ownership — belonging to the substance rather than the object, and retained under subdivision. Others are extrinsic — weight, length, shape — and are not. A category defined only by intrinsic properties is a substance, or mass noun; a category whose definition mentions any extrinsic property is a count noun. is the most general substance (no intrinsic properties specified); is the most general count noun.
The intrinsic/extrinsic split is the underlying distinction; the count-noun/mass-noun grammar reflects it. The test is behavior under subdivision. Take a lump of butter with density grams per cubic centimeter, weight grams, and temperature degrees Celsius, and cut it in half.
Density, temperature, and butter-hood are intrinsic and survive: both halves have density and both are butter, so the axiom holds. Weight is extrinsic and does not survive: each half weighs grams, not . If we had defined a category by its weight, cutting a member would produce two non-members — the count-noun behavior, where the weight clause smuggles an extrinsic property into the definition and turns a mass noun back into a count noun. This is why specifies no extrinsic property at all, and why every count noun's definition can be traced to at least one extrinsic clause.
Events
Situation calculus, from the planning material, describes a world where actions are discrete, instantaneous, and happen one at a time. That breaks down for a continuous action like filling a bathtub: it cannot describe what happens during the action, nor two actions overlapping in time. Event calculus fixes this by being built on points of time rather than situations.2
Event calculus reifies fluents and events. The fluent is an object naming the fact of Shankar being in Berkeley — it does not by itself assert that the fact holds. To assert a fluent is true at a time we use the predicate , as in . Events are members of event categories: . We then say to place the event over a time interval .
The complete vocabulary is compact:
| Predicate | Meaning |
|---|---|
| fluent is true at time | |
| event happens over interval | |
| event causes fluent to start holding at | |
| event causes fluent to cease holding at | |
| ceases to be true at some point during | |
| becomes true at some point during |
A distinguished event describes the initial state. The core axiom says a fluent holds now if some past event initiated it and no intervening event clipped it:
with a symmetric axiom for termination. This is the event-calculus analogue of a successor-state axiom, and domain-specific fluents are defined the same way — the wumpus agent gets an arrow only at the start and loses it only by shooting: and . Because events are reified, arbitrary extra facts attach freely: records that the flight was bumpy, with no need to grow a predicate's arity.
For example, run the arrow fluent all the way through the axioms. The wumpus agent's history opens with , and is the only event before the agent does anything. To show the agent still holds its arrow at time , given that nothing has been shot yet — the only events in the interval are movements and turns — instantiate the initiation axiom with , , , and :
Each conjunct discharges. The first is the initial-state event. The second follows from with bound to . The third follows from the structure of the domain: means some event terminates inside , and the only terminator of is a shooting; since no member of has happened in , nothing clips the fluent. The fourth is arithmetic. The core axiom's antecedent is satisfied, so it fires and concludes
Now let the agent shoot at : with . By the termination axiom, , and any attempt to prove now fails at the third conjunct, because clips the fluent in — holds. The fluent is true at 5 and false at 6, with no frame axiom listing the movements and turns that left it untouched. That is the whole point of the event-calculus treatment of the frame problem: persistence is the default, and only initiation and termination events are written down.
Processes
The events so far are discrete events — a definite beginning, middle, and end. Shankar's trip from San Francisco to Washington is one; interrupted halfway it would be a different event. But the category has a different quality: take any small sub-interval of the flight and it is still a member of . A category with this property is a process or liquid event:
Liquid versus discrete events mirrors the distinction between stuff and things — some call liquid events temporal substances and substances like butter spatial substances.
Time intervals
Event calculus lets us talk about time itself. Intervals come in two kinds: moments, with zero duration, and extended intervals — and . Fix an arbitrary time scale (midnight GMT, January 1, 1900, is time 0), and functions , , , and pick out endpoints, absolute times, and lengths.
The relations between two intervals — proposed by Allen — cover every way two intervals can sit relative to each other. holds when the end of is the start of ; the rest are defined by comparing endpoints.
is asymmetric here: holds only if begins before . With these relations we can say the reign of Elizabeth II immediately followed that of George VI, , and that the reign of Elvis overlapped the 1950s.
What makes the seven relations a usable calculus rather than a list is composition: given how relates to and how relates to , the possible relations between and are fixed, and the reasoner can chain constraints without ever looking at numerical endpoints. Some compositions pin the result to a single relation. If and , then the end of is the start of and the end of is the start of , so finishes strictly before starts: , and nothing else is possible. Chaining with likewise forces — the relation is transitive. Other compositions leave a disjunction. If and , then ends before starts and ends where starts, which still puts all of before : again . But composing with leaves several possibilities — might overlap , start it, or sit during it — and the entry in the composition table is a set of relations, not one.
The full table is a 13-by-13 grid (the seven relations here plus the inverses of the six asymmetric ones), and constraint propagation over it is how interval reasoners answer questions like whether two events could have coincided given only qualitative statements about their order.
Fluents and objects
A physical object can be viewed as a generalized event — a chunk of space-time. The USA began in 1776 as a union of thirteen states and continues today as a union of fifty; its changing properties are state fluents like . Consider . It cannot be a term that denotes a different person at different times, because a term denotes exactly one object in a model. Instead denotes a single object that is George Washington from 1789 to 1797, John Adams from 1797 to 1801, and so on — the four-dimensional object whose temporal slices are the successive presidents.
To say Washington was president throughout 1790 we write , using the function rather than the logical predicate — because takes an object, not a truth value, and because the two are not logically identical (that could never change over time); they are identical only in their 1790 subevents.
Mental objects and modal logic
The agents built so far have beliefs and deduce new ones, but none has knowledge
about belief. That is useful for controlling inference: if Alice asks Bob the
square root of 1764 and he says I don't know,
her think harder
is reasonable
because the answer is derivable; but think harder
about whether his mother is
sitting down is pointless — better to reason that his mother knows and could be
asked.
We model this with propositional attitudes an agent can hold toward a mental object: , , , , . These do not behave like ordinary predicates. Suppose we write . If Superman is Clark Kent, then equality reasoning — built into first-order logic — forces , which is false: Lois does not know Clark can fly. The cause is referential transparency: in ordinary logic the term used to name an object does not matter, only the object. For and the term does matter — this is referential opacity.
Modal logic addresses this by adding operators that take sentences as
arguments. Agent knows
is written . The semantics uses a
collection of possible worlds connected by accessibility relations, one per
modal operator: world is accessible from for agent if everything in
is consistent with what knows in .
Because modal sentences nest, we can reason about what one agent knows about another's knowledge. Even though Lois does not know Superman's secret identity, she knows that Superman knows it: . Standard axioms follow: an agent's knowledge is closed under implication, ; knowledge implies truth, ; and agents can introspect, . The remaining weakness is logical omniscience: the possible-worlds model forces an agent that knows some axioms to know all their consequences, which is implausible for belief. Attempts to bound rationality to reasoning steps have been largely unsatisfactory.
Where this continues
We now have the content of a knowledge base — an ontology, categories, composed objects, reified events threaded by time, and a modal account of belief. What we have not built is the machinery that makes such a base practical at scale: how to organize categories for fast inheritance, how to keep the core inferences tractable, and how to handle the fact that almost every useful rule holds only by default.
This continues in Reasoning Systems and Default Logic, which covers semantic networks and description logics with their subsumption and classification, default reasoning by circumscription and default logic, and truth maintenance systems that retract conclusions cleanly when the beliefs beneath them change.
Footnotes
- AIMA, Ch. 12 — Knowledge Representation, §12.1 Ontological Engineering: the question of what content to put in a knowledge base, the upper ontology of general concepts, and the four routes by which real ontologies (CYC, DBpedia, TextRunner, OpenMind) were built. ↩
- AIMA, §12.3 Events: event calculus based on time points rather than situations, reifying fluents and events, with the ///// vocabulary, processes as liquid events, and Allen's interval relations. ↩
╌╌ END ╌╌