Next: Negation and Non-Monotonic Reasoning Up: Special Forms Previous: Declaring Rules

### Controlled Retrieval

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

(:a  variable form )
(:a (variable ) form )
:a creates new frames to bind to the specified variable(s), and asserts the given 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 form )
(:forc (variable ) form )
:forc implements ``find-or-create'' retrieval. :forc first queries the path form . If this query succeeds then the :forc succeeds (binding the variable variable ). If the path fails then a new frame is created, variable is bound to it, and the path is asserted. (:forc (variable ) form ) 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 loops (e.g., ``Every man has a father'') -- see [Crawford, 90].

(:the  variable form )
(:the (variable ) form )
: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  form )
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.

(:retrieve  predicate)
:retrieve suppresses the usual application of deduction rules while querying its predicate. 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: Negation and Non-Monotonic Reasoning Up: Special Forms Previous: Declaring Rules

Micheal S. Hewett
Tue Oct 29 11:15:33 CST 1996