Show/Hide Toolbars

RiverSoftAVG Products Help

The DefTemplate, or Fact template, construct defines a fact type or class.  It serves as a definition for a group of facts, similar to how a pascal record definition or class definition defines the structure for all variables of that type.  The deftemplate, as it is known in CLIPS, or fact template, defines the relation name for a group of facts plus zero or more slots that encapsulate properties about the class.  For example, the following deftemplate defines a class of facts which are persons with characteristics such as name, hair-color, age, etc:


(deftemplate person "Person Template"

     (slot name)

     (slot hair-color)

     (slot age))


From this fact template, new facts can be created such as '(person (name tom) (hair-color brown))' which defines a piece of knowledge about a person whose name is tom and has brown hair.


Note that facts can be created without defining a fact template first.  However, this is inadvisable because this creates a fact without any structure to help decipher the meanings of facts.For example, suppose I created a fact (without defining a fact template) such as '(person tom brown)'.  What is the meaning of brown?  Does it refer to hair color? eye color?  Is the fact '(person brown tom)' equal?  Such facts are considered ordered facts because they only contain the relation name and one default slot, which may contain multiple values and ordering is crucial.  The two facts above are not equivalent.  However, if we had defined the fact template above, creating two facts like '(person (name tom) (hair-color brown))' and '(person (hair-color brown) (name tom))' equal because their relation and all slot values equal.


See the Fact Templates definition for the syntax of a fact template.


RiverSoftAVG Products Help © 1996-2016 Thomas G. Grubb