At first sight a CHR query involving the operator form of a constraint doesn't work at all.
However if we compile an auxiliary source re-defining the operator it works.
The following session demonstrates that.
leq.pl contains the standard example from the online doc plus operator definition added:
:- op( 500, xfx, leq).
1 ?- consult('leq.pl').
% library(chr) compiled into chr 0.21 sec, 4,004,312 bytes
================================================================================
CHR compiler:
The K.U.Leuven CHR System
Contributors: Tom Schrijvers, Jon Sneyers, Bart Demoen,
Jan Wielemaker
Copyright: K.U.Leuven, Belgium
URL:
http://www.cs.kuleuven.be/~toms/CHR/================================================================================
% leq.pl compiled into leq 0.22 sec, 4,047,568 bytes
true.
2 ?- a leq b, b leq c.
ERROR: Syntax error: Operator expected
ERROR: a
ERROR: ** here **
ERROR: leq b, b leq c .
2 ?- % however the non-operator query works:
| leq(a,b), leq(b,c).
leq(a, c)
leq(b, c)
leq(a, b)
true .
leq(a, c)
leq(b, c)
leq(a, b)
3 ?- % now if we compile an auxiliary source re-defining the operator it works:
| consult('leqop.pl').
% leqop.pl compiled 0.00 sec, 600 bytes
true.
4 ?- a leq b, b leq c.
a leq c
b leq c
a leq b
true .
a leq c
b leq c
a leq b
6 ?- halt.
$ cat leqop.pl
:- op( 500, xfx, leq).
$ cat leq.pl
:- module(leq,[leq/2]).
:- use_module(library(chr)).
:- chr_constraint leq/2.
:- op( 500, xfx, leq).
reflexivity @ X leq Y <=> X=Y | true.
antisymmetry @ X leq Y , Y leq X <=> X=Y.
idempotence @ X leq Y \ X leq Y <=> true.
transitivity @ X leq Y , Y leq Z ==> X leq Z.
--
Jean-Marc Vanel
http://jmvanel.free.fr/