next up previous contents index
Next: Negation and Non-Monotonic Reasoning Up: Special Forms Previous: Calling Lisp from Algernon

Controlled Retrieval

 

There are six main controlled-retrieval forms, summarized as follows:

tabular560

(:a  variable [. path])
(:a (variable tex2html_wrap_inline1330 ) [. path])

:a creates new frames to bind to the specified variable(s), and asserts path about those frames. (:a generalizes and replaces :create .) For example, (:a ?x (name ?x "Tom")) will create a new frame, bind ?x to it, and assert the value "Tom" into its name slot. Algernon's naming heuristics may also be able to use the Lisp atom Tom to hold the frame, but this is not guaranteed.

(:forc  variable . path)
(:forc (variable tex2html_wrap_inline1330 ) . path)

:forc implements ``find-or-create'' retrieval. :forc first queries path. If this query succeeds then the :forc succeeds (binding variable). If the path fails then a new frame is created, variable is bound to it, and the path is asserted. (:forc (variable tex2html_wrap_inline1330 ) . path) is similar, but allows multiple variables.

One use of :forc is to guarantee that certain slots always hold some value. For example, one might express ``Every car has a steering wheel.'' as:

(:rules cars
 ((steering-wheel ?c ?w) <- (:forc ?w (steering-wheel ?c ?w))))
Care must be taken with such rules, however, as they can easily cause infinite chains (e.g., ``Every man has a father'') -- see [Crawford, 90].

(:the  variable . path)
(:the (variable tex2html_wrap_inline1330 ) . path)

:the is just like :forc except that it fails if the query of its path returns multiple bindings for its variables.

It is used for definite descriptions, when a referring phrase is presumed to designate a unique entity.

(:any  . path)

If there are multiple bindings found when following the path, an arbitrary one is selected and returned. Used to force a unique element, or failure.

(:cut  . path)

Like :any, returns a single binding on success, but does depth-first search through the path to find a single binding, unlike most Algernon retrieval which does breadth-first retrieval of all bindings. The Algernon rule (p <- (:cut a b) c d) should be roughly equivalent to p :- a,b,!,c,d in Prolog.

(:retrieve  atomic-formula)
(:db  atomic-formula)

:retrieve (and its synonym :db) suppress the usual application of deduction rules while querying its atomic-formula. It should be used only in queries. :retrieve distributes over functional forms: ((:retrieve (p (f ?x) ?y))) expands to ((:retrieve (f ?x ?$X2)) (:retrieve (p ?$X2 ?y))).


next up previous contents index
Next: Negation and Non-Monotonic Reasoning Up: Special Forms Previous: Calling Lisp from Algernon

Micheal S. Hewett
Tue Oct 29 11:28:38 CST 1996