The most basic constraint which can be used in a pattern CE is one which precisely defines the exact value that will match a field. This is called a literal constraint. A literal pattern CE consists entirely of constants such as floats, integers, symbols, strings, and instance names. It does not contain any variables or wildcards. All constraints in a literal pattern must be matched exactly by all fields of a pattern entity.
Syntax
An ordered pattern conditional element containing only literals has the following basic syntax:
(<constant-1> ... <constant-n>)
A deftemplate pattern conditional element containing only literals has the following basic syntax:
(<deftemplate-name> (<slot-name-1> <constant-1>) ï ï ï (<slot-name-n> <constant-n>))
Example 1
This example utilizes the datafacts deffacts shown in section 5.4.1.
CLIPS> (clear) CLIPS> (defrule find-data (data 1 blue red) =>) CLIPS> (reset) CLIPS> (agenda) 0 find-data: f-3 For a total of 1 activation. CLIPS> (facts) f-0 (initial-fact) f-1 (data 1.0 blue "red") f-2 (data 1 blue) f-3 (data 1 blue red) f-4 (data 1 blue RED) f-5 (data 1 blue red 6.9) For a total of 6 facts. CLIPS>
Example 2
This example utilizes the person deftemplate and people deffacts shown in section 5.4.1.
CLIPS> (clear) CLIPS> (defrule Find-Bob (person (name Bob) (age 20)) =>) CLIPS> (defrule Find-Sue (person (age 34) (name Sue)) =>) CLIPS> (reset) CLIPS> (agenda) 0 Find-Sue: f-4 0 Find-Bob: f-2 For a total of 2 activations. CLIPS> (facts) f-0 (initial-fact) f-1 (person (name Joe) (age 20) (friends)) f-2 (person (name Bob) (age 20) (friends)) f-3 (person (name Joe) (age 34) (friends)) f-4 (person (name Sue) (age 34) (friends)) f-5 (person (name Sue) (age 20) (friends)) For a total of 6 facts. CLIPS>