• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • CPACK
    • Home
    • List packs
    • Submit pack
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

9.3 CHR in SWI-Prolog Programs
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • CHR: Constraint Handling Rules
        • CHR in SWI-Prolog Programs
          • Embedding CHR in Prolog Programs
          • CHR Constraint declaration
          • CHR Compilation
    • Packages

9.3.3 CHR Compilation

The SWI-Prolog CHR compiler exploits term_expansion/2 rules to translate the constraint handling rules to plain Prolog. These rules are loaded from the library library(chr). They are activated if the compiled file has the .chr extension or after finding a declaration in the following format:
:- chr_constraint ...

It is advised to define CHR rules in a module file, where the module declaration is immediately followed by including the library(chr) library as exemplified below:

:- module(zebra, [ zebra/0 ]).
:- use_module(library(chr)).

:- chr_constraint ...

Using this style, CHR rules can be defined in ordinary Prolog .pl files and the operator definitions required by CHR do not leak into modules where they might cause conflicts.

ClioPatria (version V3.1.1-51-ga0b30a5)