:INSTANCE
Purpose
Verifies that one frame is a direct or indirect instance of another, or returns all
direct or indirect instances of an instance.
Parameters
- class
- The class frame.
- instance
- Either an instance to be tested or a variable to be bound.
- If the :INCLUSIVE keyword is present and the instance argument
is a variable, the class will be included as one of the
bindings of the variable.
Examples
(:INSTANCE Canines Rover)
(:INSTANCE Canines ?x)
(:INSTANCE Canines ?x :INCLUSIVE)
(:INSTANCE Physical_Objects Rover ?rover) ;; succeeds if Rover is an instance of Physical_Objects and binds a variable to Rover.
;; The following path is guaranteed to be true
((:INSTANCE Canines ?canine)
(:CLASS ?canine Canines))
Success criteria
The argument class must be a class.
If the clause is ground, succeeds if the relationship is true.
If the clause is not ground, succeeds if it retrieves at least one instance.
Failure criteria
Fails if class is not a class, if the class-instance relationship
is not true, or if the class has no instances.
Notes
- More often, you will want to retrieve the :DIRECT-INSTANCEs of a class.
- :INSTANCE can also be used to restrict the type of a variable.
For example, if the clause (:INSTANCE Horses ?x)
succeeds,
the variable ?x
is guaranteed to be of type Horses
.
The compiler restricts the type of ?x
to Horses
for
future clauses in the path.
This can help to bypass some compiler errors and adds very little overhead
to the computation.
Related commands
Back to...
Algernon commands
Algernon Documentation Central
Algernon home page