Working with Range expressions in clpfd

Why it is not possible to call based on library
:- use_module(library(clpfd)).
something like this:
A=(1\/(2\/3))/\ (\3), range_to_fdset(A,FDA).

My aim also ist to build in clpfd something like the difference of two sets, means A \ B. The only way I get through it was based on this documentary

https://www.complang.tuwien.ac.at/sicstus/sicstus_32.html

(A /\ (\B))

Sicstus CLPFD library is different from SWI’s CLPFD library which in turn is different from GNU-Prolog’s CLPFD library. This is why syntax from one version may not work in another.

In your case, SWI’s clpfd doesn’t define /\ or \ as operators. You will have to look at the corresponding libraries to try and figure out an alternative.
e.g.

?- X in 1\/3,fd_set(X,XSet),fdset_complement(XSet,XCompliment),fdset_to_range(XCompliment,CompRange),Y in CompRange.
XSet = split(2, from_to(n(1), n(1)), from_to(n(3), n(3))),
XCompliment = split(1, from_to(inf, n(0)), split(3, from_to(n(2), n(2)), from_to(n(4), sup))),
CompRange = inf..0\/2\/4..sup,
X in 1\/3,
Y in inf..0\/2\/4..sup.

Note there exists fdset_subtract/3 which may help with your set difference implementation.

1 Like