9.3.2 CHR Constraint declaration
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • CHR: Constraint Handling Rules
        • CHR in SWI-Prolog Programs
          • CHR Constraint declaration
            • chr_constraint/1
            • chr_type/1
    • Packages
:- chr_constraint(+Specifier)
Every constraint used in CHR rules has to be declared with a chr_constraint/1 declaration by the constraint specifier. For convenience multiple constraints may be declared at once with the same chr_constraint/1 declaration followed by a comma-separated list of constraint specifiers.

A constraint specifier is, in its compact form, F/A where F and A are respectively the functor name and arity of the constraint, e.g.:

:- chr_constraint foo/1.
:- chr_constraint bar/2, baz/3.

In its extended form, a constraint specifier is c(A_1, ... ,A_n) where c is the constraint's functor, n its arity and the A_i are argument specifiers. An argument specifier is a mode, optionally followed by a type. Example:

:- chr_constraint get_value(+,?).
:- chr_constraint domain(?int, +list(int)),
                  alldifferent(?list(int)).