next up previous

13.6.4 Displaying Matches for a Rule

For a specified rule, displays the list of the facts or instances which match each pattern in the rule's LHS, the partial matches for the rule, and the activations for the rule. Note that the patterns for which information is displayed include the patterns added or rearranged by CLIPS (see section 5.4.9). When listed as a partial match, the not, exists, and forall CEs are shown as a comma with no following pattern entity identifier (such as a fact-index or instance name). Other CEs contained within these CEs are not displayed as part of the information shown for a partial match. This function has no return value.

Syntax

(matches <rule-name>)

Example

The rule matches-example-1 has three patterns and none are added by CLIPS. Fact f-1 matches the first pattern, facts f-2 and f-3 match the the second pattern, and fact f-4 matches the third pattern. Issuing the run command will remove all of the rule's activations from the agenda.

CLIPS> (clear)
CLIPS>
(defrule matches-example-1
   (a ?)
   (b ?)
   (c ?)
   =>)
CLIPS> (reset)
CLIPS> (assert (a 1) (b 1) (b 2) (c 1))
<Fact-4>
CLIPS> (facts)
f-0     (initial-fact)
f-1     (a 1)
f-2     (b 1)
f-3     (b 2)
f-4     (c 1)
For a total of 5 facts.
CLIPS> (run)
CLIPS>

The rule matches-example-2has four patterns of which one was added by CLIPS (the initial-fact pattern is added to the very beginning of the rule). The initial-fact, f-0, matches the first pattern, there are no matches for the second pattern (since there are no d facts), facts f-2 and f-3 match the third pattern, and fact f-4 matches the forth pattern.

CLIPS>
(defrule matches-example-2
   (not (d ?))
   (exists (b ?x)
           (c ?x))
   =>)
CLIPS>

Listing the matches for the rule matches-example-1 displays the matches for the patterns indicated previously. There are two partial matches which satisfy the first two patterns and two partial matches which satisfy all three patterns. Since all of the rule's activations were allowed to fire there are none listed.

CLIPS> (matches matches-example-1)
Matches for Pattern 1
f-1
Matches for Pattern 2
f-2
f-3
Matches for Pattern 3
f-4
Partial matches for CEs 1 - 2
f-1,f-3
f-1,f-2
Partial matches for CEs 1 - 3
f-1,f-2,f-4
f-1,f-3,f-4
Activations
 None
CLIPS>

Listing the matches for the rule matches-example-2 displays the matches for the patterns indicated previously. There is one partial match which satisfies the first two patterns (the initial-fact pattern and the not CE). The match for the second CE is indicated by the comma followed by no additional pattern entity identifier. There is also one partial match which satisfies the first three patterns (the initial-fact pattern, the not CE, and the exists CE). Again, the match for the third CE is indicated by a command followed by no additional pattern entity identifier. Since none of the rule's activations were allowed to fire they are listed. The list of activations will always be a subset of the partial matches for all of the rule's CEs.

CLIPS> (matches matches-example-2)
Matches for Pattern 1
f-0
Matches for Pattern 2
 None
Matches for Pattern 3
f-2
f-3
Matches for Pattern 4
f-4
Partial matches for CEs 1 - 2
f-0,
Partial matches for CEs 1 - 3
f-0,,
Activations
f-0,,
CLIPS>

13.6.5 Setting a Breakpoint for a Rule

Sets a breakpoint for a given rule.

Syntax

(set-break <rule-name>)

If a breakpoint is set for a given rule, execution will stop prior to executing that rule. At least one rule must fire before a breakpoint will stop execution. This function has no return value.


next up previous