Page Numbers: Yes First Page: 1 Not-on-first-page
Heading:
October 19, 1978[IVY]<KRL>document>match-seek-new
Notes on New Seek, Describe, and Overwrite
The syntax and semantics for Seek, Describe, and Overwrite have been redefined as described below. The intention is that these new forms will replace the old Seek, Describe, OverWrite, *My (e.g., SeekMy), and *Me (e.g., DescribeMe) forms. Operations that cannot be specified using the new forms can be done using the Align statement. (Note: if there is demand for the old forms, they can be reinstated using new names where necessary, such as PatternSeek, PatternDecribe, and PatternOverwrite. Check with Richard Fikes about such reinstatement.)
These new forms and their accompanying compiler and run time functions (designed and implemented by Richard Fikes, Bill Laaser, and Danny Bobrow) compile faster, produce compiled code that takes less space, run faster, use less space at run time, provide new expressive power, and allow more concise, readable, and editable source code. These forms are intended primarily for simple knowledge base reads and writes. They do not allow for pattern matching within a Seek (e.g., you can say "(Seek the foo from a Bar thatis Fie)", but you cannot specify that you want the Bar whose fum is "PaloAlto"). Also, they do not allow many of the generality features available for Align, such as disjunctive patterns, non-standard match tables, return of more than one value, etc. However, they seem to suffice for a wide range of interactions with KRL structures. For example, in the spring 1978 KBA trip planning system there are less than half-a-dozen cases where an Align was preferred or needed rather than one of the new forms.
New Syntax
seekForm = "(Seek" targetAnchorSpecifier ["ofType" type] ["inWorld" world] ["using" matchTable]")"
Note: "type" is assumed to be "Post" if not specified, "world" is assumed to be the run time value of DefaultWorld if not specified, and "matchTable" is assumed to be "Triggers" if not specified.
describeOverwriteForm = "(" ("Describe" | "Overwrite") targetAnchorSpecifier [("as" | "with") newDescription] ["inWorld" world] ["using" matchTable]")"
Note: "type" is assumed to be "Post" if not specified, "world" is assumed to be the run time value of DefaultWorld if not specified, and "matchTable" is assumed to be "Triggers" if not specified. "NewDescription" may be left unspecified in an Overwrite, in which case it means remove any existing filler.
targetAnchorSpecifier = ["metaOf"] (fillerAnchorSpecifier topAnchorSpecifier | slotPointerSpecifier | anchor | "my" slotName | "Me")
Note: the "targetAnchor" is the anchor from which the read or into which the write is being done. When the targetAnchor is in a filler pair of a map descriptor, then it is a "fillerAnchor" and an additional "topAnchor", i.e. the anchor that contains the map descriptor, must be specified.
fillerAnchorSpecifier = ["the" slotName "from"] ("a" | "an") prototypeName
Note: When the slotName is not specified, "self" is assumed.
topAnchorSpecifier = ("that" | "whose" slotName) ("is" | "describes") targetAnchorSpecifier
Note: "that is" is equivalent to "whose self is".
slotPointerSpecifier = "slot" slotName ("fromUnit" | "inUnit") prototypeName
type = "Primary" | "Post" | "Anchor" | "Hook" | "Pointer" | LispForm | fillerAnchorSpecifier
Note the inverse quote mode. LispForm is assumed to evaluate to one of the atoms Primary, Post, Anchor, Hook, or Pointer. When a prototype or a slot and prototype are given, a map descriptor is sought with the given focus slot.
matchTable = "Triggers" | "NoTriggers" | LispForm
Note the inverse quote mode. LispForm is assumed to evaluate to one of the atoms Triggers or NoTriggers.
newDescription = targetAnchorSpecifier | descriptor | LispPointer
Note: the value of newDescription is coerced at run time. If the value is a labeled anchor, then it is treated as a coreference containing that anchor. If the value is an unlabeled anchor, then all of its descriptors are considered to be the new description. If the value is a Lisp object (as opposed to a KRL object), then it is treated as a LispPointer pointing to that object.
descriptor = LispForm
LispPointer = LispForm
world = LispForm
slotName = name
prototypeName = name
anchor = LispForm
name = !"N" LispForm | atom
Note the inverse quote mode.
Examples of Seek
Example 1
(OldSeek ’Primary \The dateField from A TravelArea thatIs !C newArea //)
(OldSeekMy ’Primary ’dateField ’TravelArea newArea)
(Seek the dateField fromA TravelArea thatIs newArea ofType Primary), or
(Seek the dateField fromA TravelArea thatIs newArea)
Example 2
(OldSeek ’Primary \The dateField
from A TravelArea
thatIs !C (FetchMem metaAnchor of newArea)//)
(OldSeekMy ’Primary ’dateField ’TravelArea (FetchMem metaAnchor of newArea))
(Seek the dateField fromA TravelArea thatIs metaOf newArea ofType Primary), or
(Seek the dateField fromA TravelArea thatIs metaOf newArea)
Example 3
(OldSeek ’Pointer
\The record
from A Date
thatIs !C (OldSeekMy ’Primary ’date) //)
(OldSeekMy ’Pointer ’record ’Date (OldSeekMy ’Primary ’date))
(Seek the ’record fromA ’Date thatIs my ’date ofType Pointer), or
(Seek the record fromA Date thatIs my date)
Example 4
(OldSeek ’Pointer
\The printString
from A WorldEntity
thatIs The homeAirport
from A Traveler
thatIs The traveler from A Trip thatIs !C thisTrip //)
(OldSeekMy ’Pointer ’printString ’WorldEntity
(OldSeekMy ’Primary ’homeAirport ’Traveler
(OldSeekMy ’Primary ’traveler ’Trip thisTrip)))
(Seek the printString fromA WorldEntity thatIs
(Seek the homeAirport fromA Traveler thatIs
(Seek the traveler from a Trip thatIs thisTrip ofType Primary)
ofType Primary)
ofType Pointer), or
(Seek the printString fromA WorldEntity thatIs the homeAirport fromA Traveler thatIs the traveler from a Trip thatIs thisTrip)
Example 5
(SeekValue ’x (CAR(Align thisTrip
\A Traveler↑1
1: (Bind x Descriptor))))
Note: I simply want to fetch from anchor myTrip the first map descriptor with prototype Traveler. I think this is what the current KRL syntax would require. In practice, there are a collection of private functions that do this type of thing.
(Seek thisTrip ofType a Traveler)
Example 6
(OldSeekMy ’Primary ’dateField)
(Seek my dateField ofType Primary), or
(Seek my dateField))
Example 7
(SeekValue ’x (CAR(Align thisTraveler
\The traveler from
A Trip with
self = @Do(’(Bind x ’Primary))//]
(Seek a Trip whose traveler is thisTraveler)
Examples of Describe
Example 1
(OldDescribe \The dateField from A TravelArea thatIs !C newArea / \~!C (SeekMy ’Primary ’date) /)
(OldDescribeMy ’dateField \~!C (SeekMy ’Primary ’date) / ’TravelArea newArea)
(Describe the dateField fromA TravelArea thatIs newArea as my date)
Example 2
(OldDescribe \The dateField
from A TravelArea
thatIs !C (FetchMem metaAnchor of newArea)/
\~!C date /)
(OldDescribeMy ’dateField \~!C date / ’TravelArea (FetchMem metaAnchor of newArea))
(Describe the dateField fromA TravelArea thatIs metaOf newArea as date)
Example 3
(OldDescribe
\The record
from A Date
thatIs !C (SeekMy ’Primary ’date) / \~!L dateRecord /)
(OldDescribeMy ’record \~!L dateRecord / ’Date (SeekMy ’Primary ’date))
(Describe the record fromA Date thatIs my date as dateRecord)
Example 4
(OldDescribe
\The printString
from A WorldEntity
thatIs The homeAirport
from A Traveler
thatIs The traveler from A Trip thatIs !C thisTrip / \~!L "SFO" /)
(OldDescribeMy ’printString \~!L "SFO" / ’WorldEntity
(OldSeekMy ’Primary ’homeAirport ’Traveler
(OldSeekMy ’Primary ’traveler ’Trip thisTrip)))
(Describe the printString fromA WorldEntity thatIs the homeAirport fromA Traveler thatIs the traveler from a Trip thatIs thisTrip as "SFO")
Example 5
(Describe \~!C thisTrip / \A Traveler/)
(Describe thisTrip as \A Traveler/)
Example 6
(OldDescribeMy ’dateField \~!L date /)
(Describe my dateField as date)