Constraint Handling Rules is a declarative constraint logic programming language.
Questions tagged [constraint-handling-rules]
19 questions
0
votes
0 answers
CHR in SWI Prolog: Rule guard containing "just removed" constraint does not return, blows stack
A little test code with no particular meaning:
:- use_module(library(chr)).
:- chr_constraint foo/1, bar/1, anyone/2.
foo(X) \ bar(Y) <=> anyone(X,Y).
anyone(_,Y) <=> bar(Y) | writef("bar(%w) exists\n",[Y]).
anyone(_,Y) <=> writef("bar(%w) does…

David Tonhofer
- 14,559
- 5
- 55
- 51
0
votes
1 answer
Creating a bidirectional rule in CHR and CLP/FD
As an example. Suppose that everything which is red has value 5. I write the following:
:- use_module(library(chr)).
:- use_module(library(clpfd)).
:- chr_type color ---> red ; blue.
:- chr_constraint hasColor(?any, ?color).
:- chr_constraint…

Mark Green
- 1,310
- 12
- 19
0
votes
1 answer
CHR behavior in SWI Prolog for simple and() rule
I was trying a simple program in SWI-Prolog using the CHR library.
The responses to the queries are obvious to me, but the tracing baffled me.
I started with only one rule.
and(X,Y,Z) <=> Y = 0 | Z = 0.
Tracing made sense
?- and(A,B,C).
CHR: …

jack malkovick
- 503
- 2
- 14
0
votes
1 answer
Representing logical disjunctions in Constraint Handling Rules
I am writing a constraint solver in Prolog that implements a simple logical formula:
"(alive(A) and animal(A)) iff (awake(A) or asleep(A))".
I found one way to implement it in Constraint Handling Rules, but it is much more verbose than the original…

Anderson Green
- 30,230
- 67
- 195
- 328