next up previous

2.4.1 Facts

Facts are one of the basic highlevel forms for representing information in a CLIPS system. Each fact represents a piece of information which has been placed in the current list of facts, called the factlist. Facts are the fundamental unit of data used by rules (see section 2.5.1).

Facts may be added to the factlist (using the assert command), removed from the factlist (using the retract command), modified (using the modify command), or duplicated (using the duplicate command) through explicit user interaction or as a CLIPS program executes. The number of facts in the factlist and the amount of information that can be stored in a fact is limited only by the amount of memory in the computer. If a fact is asserted into the factlist that exactly matches an already existing fact, the new assertion will be ignored (however, this behavior can be changed, see sections 13.4.4 and 13.4.5).

Some commands, such as the retract, modify, and duplicate commands, require a fact to be specified. A fact can be specified either by factindex or factaddress. Whenever a fact is added (or modified) it is given a unique integer index called a factindex. Factindices start at zero and are incremented by one for each new or changed fact. Whenever a reset or clear command is given, the factindices restart at zero. A fact may also be specified through the use of a factaddress. A factaddress can be obtained by capturing the return value of commands which return fact addresses (such as assert, modify, and duplicate) or by binding a variable to the fact address of a fact which matches a pattern on the LHS of a rule (see section 5.4.1.8 for details).

A fact identifier is a shorthand notation for displaying a fact. It consists of the character ìfî, followed by a dash, followed by the factindex of the fact. For example, f10 refers to the fact with factindex 10.

A fact is stored in one of two formats: ordered or nonordered.

2.4.1.1 Ordered Facts

2.4.1.2 Nonordered Facts

2.4.1.3 Initial Facts



next up previous