next up previous contents index
Next: Knowledge Base Operations Up: The Generic Frame Protocol Previous: Operations on Slot Values

Facet Functions

 

Most FRSs provide one or more ways of encoding information about slots in the KB. That information might apply globally to all uses of a slot within the frames of a KB, or it might apply to slots within specific class or instance frames. The facet functions allow the programmer to access and manipulate both types of information. Technically, however, the term facet applies to only the latter case: a facet is an attribute-value pair that is attached to a particular slot within a particular frame.

As an example, consider the slot age from class person in Section  3.2. If we view age as a function from people to integers, we could represent the domain of age by recording the value :integer on the :value-type facet of the template slot age, for the class frame person. Although :value-type is a standard facet (see Section 2.12), applications are free to define additional facets. For example, we could declare that the values of the age slot on instances of person are confidential by asserting the facet confidential with a value of t on that slot. The facet-access functions in this section are analogous to the slot-access functions of Section  3.2. In the Generic Frame Protocol, facet values are an unordered set.

In most FRSs, facets on template slots of a class are inherited as own slots to instances of the class. However, that functionality is not a necessary part of the GFP model. For example, if one defined a prompt-string facet for template slot S on class C, and gave the facet a value of "hello Mom", then the facet has this value on all own slots S on instances of C. Because the values of facets are the same for template and own slots, the GFP functions for facets take either class or instance frames for their frame argument, and either template or own slots for the slot argument.

The first paragraph of this section mentioned that some FRSs allow KB-wide assertions to be made about the properties of slots. For example, we might want to specify that in every frame in which it appears, the value of the slot mass must be a single number expressed in grams. Some FRSs store such information in a special frame for each slot (called a slotUnit in Cyc); other FRSs use special data structures to store such information (the relations of LOOM).

No matter how an FRS implements this notion, the GFP allows the programmer to access global information about slots by providing a frame argument of nil to the GFP facet functions.

In addition, the GFP model of facets stipulates that when the user attempts to retrieve information about a facet within a particular frame, and no information is found at that frame (including any inherited information that most FRSs would ask), the global information for the specified facet of the specified slot would also be sought. Examples: calling (get-facet-values 'jupiter 'mass 'units) might return the value earth-masses because the KB overrode the default units of mass by storing earth-masses on the units facet of the mass slot of the class planet (the parent of) Jupiter. Calling (get-facet-values 'baseball 'mass 'units) might return the value grams because although no explicit value for this facet is stored at baseball or any of its parents, get-facet-values  also retrieves the KB-wide value, grams.

The GFP facet functions automatically translate the standard facet names defined in Section 2.12.3 into the corresponding names used in each FRS. For example, asserting a value for the :maximum-slot-cardinality facet may produce an expression with a different name in the underlying FRS. However, when the facets are retrieved using the Generic Frame Protocol, the names are translated back. As a result, the FRS appears to support the standard names for these facets.

As with the set of slot value functions, several of the fact value manipulation functions must test whether a given slot value is equal to some designated object. These functions employ a keyword argument test that defaults to the class-specific equality testing function for the frame system in question (as specified by the default-test-fn behavior for that frame system). However, test can be reset as desired for a given function call.

create-facet  name frame slot &key kb create-p (slot-type :auto) kb-local-only-p

Creates a facet called name that can be applied to instances of frame if slot-type resolves to :template, or to frame if slot-type resolves to :own. If frame is nil the facet's frame domain is unconstrained. If slot is nil the slot domain of the facet is unconstrained.

get-facet-values  frame slot facet &key kb local-only-p (slot-type :auto) (number-of-values :all) kb-local-only-p

This function returns the entire set of values of the specified facet, in no guaranteed order. It always returns a list of values.

get-facet-value  frame slot facet &key kb local-only-p (slot-type :auto) kb-local-only-p

This function returns a single arbitrary member of the set of values of the specified facet. It is most commonly used when that set is expected to have one member.

get-frame-with-facet-value  frame slot facet value &key kb local-only-p (slot-type :auto) kb-local-only-p

When called with a putative value of facet in slot in frame, returns the frame in which the facet value was asserted locally, or nil if the system is unable to find the owner of the facet value. No commitment is made about the means by which the facet value was associated with the frame when local-only-p is nil. Any given FRS might use simple class/subclass inheritance to derive the facet value, or some more sophisticated inference. The purpose of this function is to allow user interfaces to take users from a value displayed as a facet value on a particular frame to the place that asserted the value. Many FRSs will not be able to implement this operation, so it is important for client programs not to rely on getting a non-nil result. If the value argument is not in fact a value of the facet in question then the result will be nil.

put-facet-values  frame slot facet values &key kb (slot-type :auto) kb-local-only-p

This function sets the value of the specified facet to be values, which is assumed to be a set. The order of the elements of values will not necessarily be maintained by the FRS.

put-facet-value  frame slot facet value &key kb (slot-type :auto) kb-local-only-p

This sets the value of the specified facet to be a set consisting of a single element: value.

add-facet-value  frame slot facet value &key kb test (slot-type :auto) kb-local-only-p

If the specified facet does not already contain value, then value is added to the set of values of the facet.

replace-facet-value  frame slot facet old-value new-value &key kb test (slot-type :auto) kb-local-only-p

If old-value is currently a member of the set of values of the specified facet, then old-value is replaced by new-value in the the facet.

remove-facet-value  kb frame slot facet value &key kb test (slot-type :auto) kb-local-only-p

If value is currently a member of the set of values of the specified facet, then value is removed from the values of the facet.

remove-local-facet-values  frame slot facet &key kb (slot-type :auto) kb-local-only-p

Removes all values stored locally in the specified facet.

member-facet-value-p  frame slot facet value &key kb test kb-local-only-p

Returns non-nil iff value is a value in the specified facet.

facet-has-value-p  frame slot facet &key kb kb-local-only-p

Returns true iff the specified facet has a value.

facet-p  frame slot thing &key kb (slot-type :auto) kb-local-only-p

Returns true iff thing is a valid facet in slot of frame. A valid facet either has a value or is defined on some template slot of the same name in a type or superclass of frame.

get-slot-facets  frame slot &key kb local-only-p (slot-type :auto) kb-local-only-p

Returns the list of facets that are associated with slot in frame. A facet is associated with a slot if it has a value for that slot or is defined on some template slot of the same name in a type or super of frame. If local-only-p is non-NIL, then only the local facets of the slot are returned. Local facets are those which can be retrieved by the FRS without performing inference (e.g., inheritance or rule firing); local values are asserted explicitly by a user or application.

mapcar-facet-values  frame slot facet function &key kb local-only-p (slot-type :auto) (number-of-values :all) kb-local-only-p

Map function over every value in the specified facet.

mapc-facet-values  frame slot facet function &key kb local-only-p (slot-type :auto) (number-of-values :all) kb-local-only-p

Map function over every value in the specified facet.

do-facet-values  (var frame slot facet &key kb local-only-p (slot-type :auto) (number-of-values :all) kb-local-only-p) &body body Macro

Repeatedly executes body; on each repetition, var is bound to a different value in the specified facet.

mapcar-slot-facets  frame slot function &key kb local-only-p (slot-type :auto) kb-local-only-p

Map function over all facets in slot of frame.

mapc-slot-facets  frame slot function &key kb local-only-p (slot-type :auto) kb-local-only-p

Map function over all facets in slot of frame.

do-slot-facets  (var frame slot &key kb local-only-p (slot-type :auto) kb-local-only-p) &body body Macro

Repeatedly executes body; on each repetition, var is bound to a different facet in the specified slot.


next up previous contents index
Next: Knowledge Base Operations Up: The Generic Frame Protocol Previous: Operations on Slot Values

  • Peter Karp