:CLASS
Purpose
Verifies that one frame is a direct or indirect instance of another, or returns all
direct or indirect classes of an instance.
Parameters
- instance
- The instance frame.
- class
- Either a class to be tested or a variable to be bound.
- :INCLUSIVE (optional)
- If the :INCLUSIVE keyword is present and the class argument
is a variable, the instance will be included as one of the
bindings of the variable.
Examples
(:CLASS Rover Canines) ;; Succeeds because Canines is a superclass of Rover
(:CLASS Rover ?x) ;; Retrieves all direct and indirect superclasses of Rover
(:CLASS Rover ?x :INCLUSIVE) ;; Retrieves Rover and all superclasses of Rover
;; The following path is guaranteed to be true
((:INSTANCE Canines ?canine)
(:CLASS ?canine Canines))
Success criteria
The argument instance must be an instance.
If the clause is ground, succeeds if the relationship is true.
If the clause is not ground, succeeds if it retrieves at least one class.
Failure criteria
Fails if instance is not an instance, if the instance-class relationship
is not true, or if the instance has no class (which is impossible in
many KBMS).
Notes
- You usually want to retrieve the :DIRECT-CLASS of an instance.
- :CLASS can also be used to restrict the type of a variable.
For example, if the clause (:CLASS ?x Horses)
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