Variable Range Definitions

All variables that appear in a constraint or query statement must be defined within a range. Variables must have an explicit range definition, with one exception. Constraints that are attached to classes can omit range definitions of those of their variables that range over the instance of those classes. In this case there is an implicit variable range definition of unbound variables over the instance of those classes.This can be used when you want the defrange of the constraint to apply to multiple classes that are not subclasses of a single class, as otherwise you would have to write the constraint in the scope of each class.  However, this should be used with caution, because if a constraint is de-attached from all of its classes, it will lose its implicit range definitions, and will have unbound variables.  

To define ranges interactively, use the right-click Range menu in the Range editor in the PAL Expression Editor.

Variables are either defined locally or globally.  A local variable is defined locally to the statement. A global variable is is shared, along with its range definition, by all constraints and queries in the knowledge base.

A variable range definition is a sentence of the form:

(defrange [variable] [type] [type-specific information])


  1. [variable] is the name of the variable, beginning either with '?' to indicate a local variable or with '%' to indicate a global variable;
  2. [type] is the type of the variable, one of :SET, :FRAME, :SYMBOL, :STRING, :INTEGER, :NUMBER;
  3. [type-specific information] depends on the type of the variable and is

Note: When using a class or slot name that contains a space, you must enclose the name in single quotes. For example, my class must be written as 'my class'.

In the newspaper example, the definition of a local variable ?editor that ranges over all instances of the class Editor is written as follows:

(defrange ?editor :FRAME Editor)

and, the definition of a local variable ?employee that ranges over solely instances of the class Employee that are values for the slot responsible_for (that is, those employees for whom an editor is responsible) is written as follows:

(defrange ?employee :FRAME Employee responsible_for)

Another example is the following, that defines a global variable %number_of_pages as an integer that is a value for the slot number_of_pages:

(defrange %number_of_pages :INTEGER number_of_pages)


Note: defset is currently broken, that is, you cannot create variable declarations for sets. 

When a variable ranges over the elements of a set (i.e., a variable of type :SET), this set also must be defined and given a name.

A set definition is a sentence of the form (defset [setname] [type] [list of values]), where:

  1. [setname] is the name of the set;
  2. [type] is the type of the elements of the set, one of: :FRAME, :SYMBOL, :STRING, :INTEGER, :NUMBER;
  3. [list of values] is the enumeration of the elements of the set, that must be of the specified type (i.e., a list of frame names, of integers, etc.).

For example, the definition of the set of weekdays symbols is written as follows:

(defset weekdays :SYMBOL (Monday Tuesday Wednesday Thursday Friday Saturday Sunday))

and, the definition of a variable ?day that ranges of the elements of the weekday set is written as follows:

(defrange ?day :SET weekdays)

The PAL Language and Frames/Variable Range Definitions

Next: PAL Constraint Statements

PAL Table of Contents