I'm trying to write a program that generates new constraints at runtime in SWI-Prolog. is_true([A,means,B])
is intended to generate another constraint at runtime:
:- use_module(library(chr)).
:- chr_constraint is_true/1.
is_true([A,means,B]) ==> (is_true(A) ==> is_true(B),writeln('asserted')).
is_true([[A,is,true],means,[A,is,not,false]]).
is_true([something,is,true]).
But when I type these queries, the is_true
constraint seems to have no effect. is_true([something, is, not, false])
does not return true
:
?- is_true([something,is,true]).
true .
?- is_true([something,is,not,false]).
is_true([something, is, not, false]).
Asserting a constraint in the console seems to have no effect, either:
?- asserta(is_true(A>B)==>(is_true(B<A),writeln("asserted"))).
true.
?- is_true(4>3).
is_true(4>3).
Is there another way to define new CHR constraints at runtime?