Copyright © 1998, 2001 by Ian Horswill, see comment within this file.
Simple forward-chaining proposition inference can be coded directly in GRL using the built-in logic primitives and, or, etc. For example, the implication
near-the-object Ù facing-the-object Þ the-object-is-grippable
can be expressed, assuming the truth values of antecedents have been computed somehow, simply by saying:
(define-signal the-object-is-grippable?
(and near-the-object?
facing-the-object?))
or:
(define-signal alive? (or animal? vegetable?)) (define-signal animal? (or mammal? reptile? bird?)) (define-signal animate? (or animal? robot?))
Here, you must give all the inputs of the signal as part of the signal definition. It is often useful to leave the inputs implicit and instead declare the outputs of a signal, just as one commonly prefers to define classes by listing their superclasses rather than by exhaustively listing all their subclasses. This can be done using accumulators, as in:
(define-signal alive? (accumulate or)) (define-signal animate? (accumulate or))(define-signal animal? (accumulate or) (drives alive? animate)) (define-signal mammal? ... (drives animal?))(define-signal robot? ... (drives animate?))
or, to add a little syntactic sugar:
(define-syntax define-class (syntax-rules () ((define-class ?name (?superclasses ...)) (define-signal ?name (accumulate or) (drives ?superclasses ...)))))(define-class alive? ()) (defne-class animate? ())(define-class animal? (alive? animate)) (define-class mammal? (animal?))(define-class robot? (animate?))
which more closely matches the way we tend to think about implication rules and taxonomic definitions. For examples of fancier versions of this, see the rulesets package or the situations package.
In the following, a logic-expression is a signal that carries the true-value(s) of a proposition or a unary predicate. Unary predicates are represented as bit-vectors.
(goal (maintain
x)) is defined to be (maintain-goal x).Goal reduction allows you to specify that a given signal or signals should be activated when a given modality of a given signal is active.
The role-passing extensions implement circuit-semantics for a subset of modal logic in which quantification is limited to a finite domain consisting of linguistic roles. Roles are represented as bit-masks in which each role is reserved one position. This allows logical operations on sets of roles to be performed with single machine instructions.
The set of roles is determined in advance and is exported by the role-passing package. The current set of roles is: agent, patient, object, instrument, cause, origin, destination, trajectory, and trajector. This set will grow, although there are implementation reasons to want to limit it to 32 roles. Internally, roles are defined as an enumeration type; however, the type is not exposed in the API. Instead, programmers should use the following macros:
Binding is the process of tracking the relationships between roles and objects in the world. To represent a sentence like "take the green ball", we have to be able to represent the fact that the patient of the sentence is the green ball. This is done initially by tagging (binding) the representation of green in the lexicon, and eventually a visual tracker tracking the green ball, with the role tag patient.
The binding package contains support for context switching
between different sets of bindings. We still need to figure out the right
way to use these, but the hooks are there to do the context switching.
Here's the current (limited) API:
current-contextcontext-priority.context-prioritymax-contexts(make-shared-context-vector initial-value)max-contexts with initial
value initial-value.(make-shared-context-array length initial-value
&optional (name))max-contexts´length
array with initial value initial-value.See also the section on the context pool, below.
Pools implement representational modalities that can describe objects. They are typically either memories, in which case the items in the pool are some kind of register, or sensory systems, in which case the items are collections of functionally equivalent sensory processes that can be dynamically allocated to different tasks.
(make-pool name size-or-items)(pool-bound? pool)(pool-name pool)(pool-bindings pool)(pool-size pool)(pool-ref pool index)bound?(pool-lookup pool roleset default)(join-pools pool1 index1 pool2 index2
&optional (gate #t))The following plan macros are also available for establishing and clearing bindings:
(bind-item! pool item roleset)(pool-unbind! pool roleset)(global-unbind! roleset)In addition, the following low-level Scheme functions can be called from within transducers:
(%make-pool name size items)#f.(pool-bound? pool)(pool-name pool)(pool-bindings pool)(pool-size pool)(pool-set-bindings pool)(pool-access-times pool)(pool-ref pool index)(%pool-context-start pool context)(pool-slot-free? pool index)(pool-slot-free! pool index)(%pool-lookup pool context roleset
default)(%pool-lookup->slot pool context roleset)(%pool-allocate->slot! pool context roleset)(%bind-item! pool context item roleset)(%pool-unbind! pool context roleset)(%global-unbind! roleset)(pool-predicate pool vector)(pool-function pool vector default)role-count whose ith
element is the respective values from vector of whichever item in pool
is bound to the ith role. If no item is bound to that role,
then the element is default.In addition to normal bindings (called here "role-bindings", which would otherwise be redundant), whole sets of items can be bound to roles. These bindings are stored separately and are used for iterating over items with a some property.
(reset-sets! pool roleset)(select-all! pool roleset)(select! pool roleset vector)(for-each-selected-item pool role-index (begin
plan-expression ...))The following signal procedures can also be used for set operations:
(enumeration-exhausted? pool role-index)(enumeration-almost-exhausted? pool role-index)There are a number of pools that are exported by the binding
package.
Allocation and deallocation of contexts can be performed using the context-pool.
context-poolmax-contexts.context-bound?(spawn role priority action &rest action-args)Certain specially declared actions can also be bound to roles. These actions can then be called indirectly by role, have the status sensed by role, and can be active in some contexts but not others.
Caveat: reflected (bindable) actions can only take up to three arguments. All arguments must be integers.
(define-reflected-action defined-action-args ...)(define-reflected-plan defined-plan-args ...)(define-reflected-generc-action defined-generic-action-args
...)reflected-action-max-argsrunning?action-bound?(bind-action! name-or-action roleset)bound-action-names(call-indirect action-role &rest
action-args)(start-indirect action-role &rest
action-args)(wait-action-indirect action-role)(stop-indirect action-role)action-poolThere is also support to reflect arbitrary signals. However, a separate pool is generally needed for each signal type.
reflected-proposition-pool(bind-proposition! name-or-signal roleset)proposition-bound?reflected-predicate-pool(bind-predicate! name-or-signal roleset)predicate-bound?