The syntax of CHR rules is the following:
|rules||::= rule rules|
|rule||::= name actual_rule pragma |
|name||::= atom |
|simplification_rule||::= head |
|propagation_rule||::= head |
|simpagation_rule||::= head |
|constraints||::= constraint constraint_id|
|constraints||::= constraint constraint_id |
|guard||::= goal disj|
|actual_pragmas||::= actual_pragma |
Note that the guard of a rule may not contain any goal that binds a variable in the head of the rule with a non-variable or with another variable in the head of the rule. It may however bind variables that do not appear in the head of the rule, e.g. an auxiliary variable introduced in the guard.
Note also that, unless
| has been declared as an operator,
; are indistinguishable as infix
operators—both are read as
; (see ref-syn-syn-sen). So if
e.g. a simplification rule is given as:
(P ; Q)
then CHR will break the ambiguity by treating P as the guard and Q as the body, which is probably not what you want. To get the intended interpretation, you must supply a dummy guard ‘true |’:
true | (P ; Q)
Please note: the above is true as long as you do not declare
as an infix operator, which is possible since release 4.3 for ISO compliance.
| as an infix operator will confuse CHR.