Title: Object-Oriented Representation
1Object-Oriented Representation Organizing and
indexing knowledge about objects and
events. From sentences to frames.
2Knowledge can be about a variety of different
entities -- physical objects, mental objects,
events, relations, etc. Concepts come in
types. Concepts have parts. Parts relate to
other parts and the whole in specified ways
dependent on the nature of the concepts
involved. Mutual constraints between parts of
concepts can be expressed procedurally, e.g., by
introducing a registration procedure to connect a
student with a course. There are many other
procedures, e.g., buying an airline
ticket, recognizing types of cars, etc.
3In a procedural object-oriented representation
system we consider the kinds of reasoning
operations that are relevant for the various
types of objects in an application and
design procedures to deal with them. Object-orien
ted groups of procedures to recognize and deal
with events in the world are called frames --
cf. Minsky 1975. Frames have been widely used
in AI applications.
4A Basic Frame-Oriented Representation
Language We introduce two types of frames
- individual frames describe single
objects generic frames represent categories or
classes of objects. A frame is a named
collection of property-value pairs. Typically, in
a frame-based language, properties are called
slots and values are called slot fillers or
simply fillers. (frame-name ltslot-name1
filler1gt ltslot-name2 filler2gt )
5Frame and slot names are atoms. Fillers, in the
simplest case, are either atoms (e.g., numbers,
strings) or frame names. BL introduce the
convention of capitalizing the names of generic
frames and marking individual frames using
uncapitalized mixed case (just like the function
symbols in FOL). Slot names will be introduced
by a colon and capitalized. (tripLeg123 ltINSTAN
CE-OF TripLeggt ltDestination torontogt ) (toron
to ltINSTANCE-OF CanadianCitygt ltProvince ontari
ogt ltPopulation 4,500,000gt) INSTANCE-OF is a
special slot whose filler is the name of
the generic frame indicating the category of the
object being represented.
6The basic syntax of generic frames is the same as
that of individual frames (CanadianCity ltIS-A
Citygt ltProvince CanadianProvincegt ltCountry
canadagt) The special slot IS-A points to a more
general generic frame. City is a generalization
of CanadianCity. CanadianCity is a specialization
of City.
7Slots in generic frames can also have attached
procedures, such as IF-ADDED and
IF-NEEDED. (Lecture ltDayOfWeek
WeekDaygt ltDate Date IF-ADDED
ComputeDayOfWeekgt ) When a Lecture frame is
instantiated and if the date of the lecture is
known, then the procedure ComputeDayOfWeek is
run. Note that a slot can have both a filler
and an attached procedure.
8Reasoning in frame-based systems centrally
involves instantiation -- creation of individual
instances of generic frames. This usually
involves filling some of the frame slots with
specific values and inferring the values of other
slot fillers. The main reasoning type is
filling the slots that were not
mentioned explicitly during instantiation with
fillers from the corresponding generic frame.
How do we determine the value of the Country
slot of the frame for Toronto? By using the
corresponding generic frame CanadianCity.
9The process of passing information from generic
frames to their specializations and eventually to
instances is called inheritance of properties --
or simply inheritance, meaning that the
child inherits its properties from the
parents. So, toronto inherits the Country
property from CanadianCity. If we did not fill
the property Province for toronto, we would
not have known that the filler was ontario but
would still know that it was an instance of
CanadianProvince.
10The inheritance of the attached procedures works
in a similar way. (Table ltClearance IF-NEEDED
ComputeClearanceFromLegsgt) If we create an
instance of Table and need to find a filler for
the Clearance slot for the instance, we can use
the attached IF-NEEDED procedure to compute the
clearance of that table from the height of its
legs. The same procedure would be used by
inheritance in the following situation (CoffeeTa
ble ltIS-A Tablegt) (MahoganyCoffeeTable ltIS-A
CoffeeTablegt) If we create an instance of the
Lecture frame with a date specified, then the
IF-ADDED procedure fires, calculates the day of
the week and records it in the DayOfTheWeek
slot. Should the Date be changed, the procedure
would run again and recalculate the day of the
week.
11Inheritance in frame systems is defeasible. This
means that an inherited value is used only if no
specific filler can be found. A slot filler in
a generic frame can be overridden in its
instances and in its specializations. (Elephant
ltIS-A Mammalgt lt EarSize largegt ltColor
greygt) Instances of elephants will have the
above values by default. But we can also
have (raja ltINSTANCE-OF ElephantgtltEarSize
smallgt) (RoyalElephant ltIS-A ElephantgtltColor
whitegt) (clyde ltINSTANCE-OF RoyalElephantgt) Ra
ja will have small ears though inheriting the
grey color. Clyde inherits large ears from
elephants and white color from royal elephants,
thus overriding the default from elephants.
12In many frame systems individual frames are
allowed to be instances (and generic frames,
specializations) of more than one generic
frame (AfricanElephant ltIS-A
Elephantgt ltIS-A AfricanAnimalgt )
13Procedures attached to frame slots provide a good
framework for computation. Reasoning with frames
usually starts with the systems recognizing an
object as an instance of a generic frame and
then applying procedures triggered by that
recognition. These procedure runs then create
additional data, and the KB changes and/or
additional procedures are called. The halting
condition is when no procedures are pending.
14- The basic reasoning loop in a frame system
- An object is declared to exist (by the user or an
external systemthat uses the frame system as its
KR substrate). - Any slot fillers in this instantiation that are
not provided explicitlybut can be inherited are
inherited. - For each slot with a filler, if any IF-ADDED
procedure that can beinherited is run, possibly
causing new slots to be filled or newframes to
be instantiated and the cycle repeats.
15- If the user or the external system requires the
value of a slot, then - If there is a filler stored in the slot, then
that value is returned. - Otherwise, any IF-NEEDED procedure that can be
inherited isrun, calculating the filler for the
slot but potentially also causing other slots to
be filled or new frames instantiated. - If the above does not produce a result, then the
value of the slot is - considered unknown.
- More types of procedures can be conceived --
IF-REMOVED, - IF-MODIFIED, IF-VIEWED, etc., as needed.
16Moving from individual frames and reasoning with
them to the global structure of a frame-based KB,
generic frames are typically created for all
major types of objects, events or situations
required in a particular problem solving domain.
Constraints between slots are expressed using
the IF-ADDED and IF-NEEDED procedures. The
reasoning can be either data-directed or
goal-directed. The early motivation for frame
systems was in the recognition of the typical,
that is, using default values to recognize an
object and then noting its idiosyncrasies. It was
noted that people did it that way.
17A frame knowledge base can be thought of as a
symbolic spreadsheet, with constraints between
objects propagated by attached procedures. Howeve
r, in a frame system procedures can support much
more complex reasoning.
18An example The TRAINS system. This form of
knowledge engineering is quite different from the
logical approach we covered earlier. The
example is a part of a system for planning trips.
Two main frames are involved Trip and
TravelStep. A Trip will have a sequence of
TravelSteps, linked through content of specific
slots. A TravelStep typically terminates in a
LodgingStay, except when there are more than one
travel legs in a single day or when it is the
last leg of a trip.
19To be able to track what is related to what, and
how it is related, a LodgingState will define
slots to point to its arriving TravelStep and its
departing TravelStep. Similarly, TravelSteps
will indicate the LodgingStays at their
origin and destination. A generic Trip may look
as follows (Trip ltFirstStep TravelStepgt ltTra
veler Persongt ltBeginDate Dategt ltEndDate Dategt
ltTotalCost Pricegt )
20A specific Trip, say, trip17, might look as
follows (trip17 ltINSTANCE-OF
Tripgt ltFirstStep TravelStep17agt ltTraveler cris
topherColumbusgt ltBeginDate 8/3/1492gt ltEndDate
10/12/1492gt ltTotalCost M2,145,633gt ) M
stands for maravedi, the main Spanish coin of
the day.
21Instances of TravelStep and LodgingStay will
share some properties (e.g., a cost), so we might
introduce a frame that subsumes TravelStep and
LodgingPart (TripPart ltBeginDate Dategt ltEndD
ate Dategt ltCost Pricegt ltPaymentMethod FormOfP
aymentgt )
22Then, (LodgingStay ltIS-A TripPartgt ltPlace
Citygt ltLodgingPlace LodgingPlacegt ltArrivingTra
velStep TravelStepgt ltDepartingTravelStep
TravelStepgt )
23And (TravelStep ltIS-A TripPartgt ltOrigin C
itygt ltDestination Citygt ltOriginLodgingStay Lo
dgingStaygt ltDestLodgingStay LodgingStaygt ltMean
s FormOfTransportationgt ltDepartureTime Timegt lt
ArrivalTime Timegt ltNextStep TravelStepgt ltPr
eviousStep TravelStepgt )
24Now we add default values and procedures that
will help to enforce constraints. We may posit
that trips are most often made by air, in which
case the default filler for the Means slot of a
TravelStep should be an airplane. If we pay for
parts of a trip with a Visa card, we list it as a
default value of the PaymentMethod slot. But if
we want to say that for travel steps (as opposed
to LodgingStays) we want to use a different card,
then we will override the above
default (TravelStep ltPaymentMethod americanExp
ressCardgt)
25Not all inherited fillers of slots will be
specified once and for all. Sometimes their
values should be computed in the context. For
example, it is appropriate to automatically set
up the origin of a travel step as our home
airport as long as there was no previous travel
step (our home airport will be the beginning of
the trip). To enable this, we need some new
notation if X refers to a frame and Y to a
slot, then XY refers to the filler of the slot
for the frame (its nice that the convention for
writing slots uses a colon at the
beginning!). SELF will be a way to refer to the
frame currently being processed.
26Now, the travel step description could be
augmented to look as follows
27Computing the total cost of the trip from the
costs of its parts
The procedure iterates through travel steps. At
each step, it adds the cost of the step (xCost)
to the previous result and, if there is a
subsequent step, the cost of the lodging stay
between those two step, if any (xDestinationLodg
ingStayCost).
28Creating a template for a lodging stay instance
each time a new travel step is added
The first thing done is to check whether the next
travel step begins on a different day from the
day the previous one ends.
The default Place of a LodgingStay could also be
calculated automatically (LodgingStay ltPlace
IF-NEEDED selfArrivingTravelStepDestinati
ongt)
29Describing a trip using the machinery just
defined. A trip to Toronto on December 21,
2006, returning the following day. Here are
frames for the entire trip and its first
step (trip18 ltINSTANCE-OF Tripgt ltFirstStep
travelStep18agt (travelStep18a
ltINSTANCE-OF TravelStepgt ltDestination torontogt
ltBeginDate 12/21/06gt ltEndDate 12/21/06gt)
30The second leg (travelStep18b
ltINSTANCE-OF TravelStepgt ltDestination newarkgt
ltBeginDate 12/22/06gt ltEndDate 12/22/06gt ltP
reviousStep travelStep18agt)
31This is the state of affairs in the planning
knowledge at this point.
Now we need to fill NextStep in travelStep18a
with travelStep18b (which could be done using an
IF-ADDED procedure on travelStepPreviousStep trig
gered from travelStep18b.
32As a consequence of the assignment of
travelStep18b as the NextStep of travelStep18a,
a default LodgingStay is automatically created
to represent the overnight stay between those two
legs of the trip (using the IF-ADDED procedure on
the NextStep slot) (lodgingStay18a ltINSTANCE-O
F LodgingStaygt ltBeginDate 12/21/06gt ltEndDate
12/22/06gt ltArrivingTravelStep
travelStep18agt ltDepartingTravelStep
travelStep18bgt ) The IF-NEEDED procedure for
the Place slot of LodgingStay would infer the
default filler of toronto for lodgingState18a, if
required! We can see now how the Means slot of
either step would be filled by default, and a
query about Origin slot of either step would
produce an appropriate default value
33(No Transcript)
34- If we filled the Cost slots of each of the
instances of TripPart as - follows
- travelStep18aCost 321
- travelStep18bCost 321
- lodgingStay18aCost 124.75
- then if we ask about the TotalCost of the
entire trip, the IF-NEEDED - procedure, would be called (if the value were not
filled in manually!) - result is initialized to 0 and x is initialized
to travelStep18a, so that xNextStep is
travelStep18b. - the first time around the repeat loop, result
is set to the sum of result (0), the cost of
x (321) and the cost of DestinationLodgingStay
of the current step, 124.75 x is then set to
travelStep18b. - on the next pass, because x does not have a
following step, the loop terminates and the
sum of result (445.75) and the cost of x (321)
are returned.The grand total, stored in
TotalCost of trip18, is 766.75.
35The above example showcases a general approach to
problem solving sketching the basic structure of
a domain and then embellishing it with defaults
and implied values, with consistency maintained
through the IF-ADDED and IF-NEEDED procedures.
Frames are useful in many knowledge
representation tasks, e.g., knowledge-based
monitoring of a database. Also, a frame-based
formalism is natural for representing knowledge
about language. Frame structures for typical
activities of people and organizations,
called scripts, have been suggested as the basic
knowledge support for reasoning in commonsense
situations.
36- Extensions to the Frame Formalism
- More procedures
- Multiple slot fillers
- Other slot facets
- Metaframes
37The inventory of procedures can be extended. We
considered questions like What is the total
cost of a trip? -- handled by an IF-NEEDED
procedure, or What should be done if one wants
to add a new leg of a trip? -- handled by an
IF-ADDED procedure. Some other question types
may include What should I do if I cancel a leg
of a trip? -- which requires an IF-REMOVED
procedure How do I recognize an overly
expensive trip? -- a special IF-NEEDED
procedure that takes into account a number of
different facts stored in a variety of slots of
different frames, etc.
38Multiple Slot Fillers We can allow sets to be
fillers of slots. Procedures attached to slots
can then operate on the entire set of fillers,
and constraints on the cardinality of the sets,
along with constraints on the types of set
elements, can be used in reasoning. The
question here is how to deal with inheritance
should the fillers of a slot that are given
explicitly be augmented by other fillers
through inheritance or should they override
inheritance?
39Slot facets A slot can have default fillers and
procedures associated with it. But it can also
have more elements associated with it, for
example, constraints that help to check whether a
suggested filler is legal.
40Metaframes Generic frames can sometimes usefully
be considered to be instances of higher-level
metaframes. For example, generic frames
like CanadianCity and NewJerseyCity represent a
type of city defined by a geographical region.
So, we might think of them as being
instances (not specializations) of a metaframe
like GeographicalCityType (GeographicalCityType
ltIS-A CityTypegt ltDefiningRegion
GeographicalRegiongt ltAveragePopulation NonNegati
veNumbergt) An instance of this frame, e.g.,
CanadianCity, would have a particular value for
the DefiningRegion slot, canada. The filler
for the AveragePopulation slot can be calculated
by an IF-NEEDED procedure.
41Individual cities do not themselves have a
defining region or an average population,so we
need to disallow inheritance of these slots from
CanadianCity in frames like toronto. This is
usually done by distinguishing member slots of
a generic frame, those applying to instances - or
members - of the frame (e.g., Country in
CanadianCity) from the own slots in a frame
which apply to the frame itself (like
AveragePopulation in CanadianCity).
42Frame-oriented knowledge bases are a kind of
object-oriented representation. Mapping generic
frames to categories of objects in a domain of
interest can yield a simple declarative knowledge
base emphasizing taxonomies of objects and their
structural relationships. Attached procedures
are very useful in maintaining the truth in the
KBs, to calculate implied values and to express
connections among the various symbols in the KB.
A frame system with procedures is a procedural
frame system. It is in many ways similar to the
conventional object-oriented programming systems.
The main difference is that the control in the
frame systems is usually (though not always)
centralized, whereas in OOP objects act as
small independent agents working through messages
they send one another.
43- Frame systems tend to work in a cycle
- Instantiate a frame and declare some slot fillers
- inherit values from more general frames
- trigger appropriate forward-chaining procedures
- when no action is possible, wait for the next
input. - OOP systems are less centralized. As a result,
there can be some - applications for which a frame-based system can
provide advantages - over a conventional OOP system, for instance, in
planning. - But if the primary use of a frame system is as an
organizing method - for procedures, this contrast should be examined
carefully to see - what control approach is best suited to the task.
44(No Transcript)
45(No Transcript)
46(No Transcript)
47(No Transcript)
48(No Transcript)
49(No Transcript)
50(No Transcript)