clpz icon indicating copy to clipboard operation
clpz copied to clipboard

Stronger propagation for exponentiation

Open triska opened this issue 7 years ago • 5 comments

Enhance propagation in the following cases, if possible:

?-  X^Y #= 0.
X^Y#=0.

and:

?- X in 0..100, 2^I #= X.
X in 0..100,
2^I#=X.

Suggested by @JCumin. These cases must be checked carefully.

triska avatar Oct 24 '16 22:10 triska

Another case where stronger propagation should be possible (tested on SWI's CLP(FD), I'm assuming those cases hold for CLP(Z)):

?- X in 0..sup, Y in inf.. -1, X^I #= Y.
X in 0..sup,
X^I#=Y,
Y in inf.. -1

X is positive and Y is not, therefore it should fail.

This is particularely noticeable when there is only one unknown:

?- 2^I #= -4.
2^I#= -4.      % should fail without needing labeling

The same thing happens when X is negative:

?- (-2)^I #= -4.
-2^I#= -4

(Though it can be less obvious to fail when possible in the general case because of odd powers yielding negative numbers)

JCumin avatar Apr 06 '17 12:04 JCumin

@JCumin : Still not using clpz?

UWN avatar Apr 06 '17 20:04 UWN

@UWN I only have a recreational use for Prolog, as such I don't feel like it is worth investing money into a SICStus license (whether it be paid by me or anyone else). Moreover, SICStus top-level did not really make a great impression on me.

JCumin avatar Apr 07 '17 06:04 JCumin

@JCumin - so you did not even take the offer?? For the top level, I do agree - but at least it has better naming of variables.

UWN avatar Apr 07 '17 12:04 UWN

@UWN No I did not. I would feel bad having someone spend a significant amount of money for how little I use Prolog. Moreover my main project needs to be runnable on a free distribution, so I wouldn't work on porting it to SICStus anyway.

JCumin avatar Apr 07 '17 12:04 JCumin