# defset [*Macro*]

## Purpose

The **defset** macro defines or redefines a symbolic set.

## Syntax

**defset** *name* `&optional` *documentation* `&key` *is annotations identifier kb*

## Arguments

The *name* argument is a symbol. If *name* is null, the set is given a system-generated name.
The *documentation* argument is a string which attaches a comment to the set being defined. This string can be retrieved by calling the Lisp **documentation** function with **type** as the doc-type argument.

The *is* argument is a set-forming expression (see Remarks below) that defines the set as a group of ordered or unordered symbolic constants.

The *annotations* argument is a list of facts to be asserted about the set being defined. Each element of the list is either a concept name or an expression having the form **(***RelationName instance***)**, where *instance* is either a constant or a symbol that identifies a Loom instance.

The *identifier* argument is the name under which the set will be interned in the **:instances** partition of its knowledge base. This argument defaults to *name*.

The *kb* argument is a string or symbol that names the knowledge base in which the set is to be interned. This defaults to the current knowledge base.

## Value

The defined or redefined set is returned.

## Remarks

All symbolic set members appearing in a **defset** should be quoted.
The **defconcept** macro should be used for defining non-symbolic sets such as numeric intervals or sets of Loom objects.

set-expr ::=
SetName |
( {:AND | :OR} set-expr+ ) |
( {:ONE-OF | :THE-ORDERED-SET} Symbol+ ) |
( :THROUGH Symbol Symbol ) ;

The set-forming expressions that appear in the *is* argument above have the following syntax:
The set-forming operators have the following semantics:

- If C = (
**:and** C1...Cn), a member of C is a member of the intersection of the sets C1...Cn.
- If C = (
**:or** C1...Cn), a member of C is a member of the union of the sets C1...Cn.
- If C = (
**:one-of** S1...Sn), a member of C is one of the symbols S1...Sn.
- If C = (
**:the-ordered-set** S1...Sn), a member of C is one of the symbols S1...Sn, where for i from 1 to n-1, Si<Si+1.
- If C = (
**:through** Si Sj), where Si and Sj are members of an ordered set, a member of C is a symbol in the closed interval [Si,Sj].

## Examples

(defset Color :is (:one-of 'Red 'Green 'Blue \ldots)) ==> |C|COLOR

(defset Day :is (:the-ordered-set 'Monday 'Tuesday \ldots 'Sunday))

(defset Weekday :is (:and Day (:through 'Monday 'Friday)))

## See Also

Last modified: Jun 1 1995