Scryer-prolog: Repeat answers from CLP(ℤ)

Created on 1 May 2020  Â·  7Comments  Â·  Source: mthom/scryer-prolog

With the latest changes, this happens:

?- use_module(library(clpz)).
   true.
?- X #= 3 + 3.
   X = 6
;  X = 6
;  X = 6
;  false.
bug

All 7 comments

Thank you, I will look into it right away!

However, this is not a bug in the sense we have used the tag so far. A mistake in this sense would be to omit solutions that exist, or to yield answers that are wrong.

Here, the issue is that correct solutions are reported redundantly. It is a performance improvement to remove redundant answers.

As far as I can tell, this may be a problem that is limited to the toplevel interaction.

For example, when I define t/1 as follows:

?- [user].
:- dynamic(t/1).
:- use_module(library(clpz)).
t(X) :- X #= 3+3.

[Ctrl+d]

then I get, exactly as expected:

?- t(X).
   X = 6.

And the predicate is also defined as expected:


?- use_module(library(format)).
true.
?- listing(t/1).
t(A) :-
( integer(A) ->
A=:=6
; ( var(A) ->
A=6
; B=6,
clpz:clpz_equal(A,B)
)
).

Also, the interaction differs depending on the way library(clpz) is pulled into the system.

For instance, I get:

$ scryer-prolog 
?- use_module(library(clpz)).
   true.
?- X #= 3+3.
   X = 6
;  X = 6
;  X = 6
;  false.

However, when I put the following in f.pl:

:- use_module(library(clpz)).

then I get:

$ scryer-prolog f.pl
?- X #= 3+3.
   X = 6
;  false.

This is better, but not yet deterministic.

Only when I actually define t/1 as above, it works as it should: A single deterministic solution.

And irrespective of the actual result, the answer should definitely be the same in all three cases.

Such redundant answers are a bug. X #= 3+3 must have at most a single answer (unless some freeze/2 or the like is involved)

I would like to use this opportunity to express my encouragement and preference for prioritizing item (2) from the very exciting feature list you mentioned in https://github.com/mthom/scryer-prolog/issues/416#issuecomment-620934694.

library(sockets) would be a really great addition, and I am very much looking forward to it. However, for the time being, I think these reliability issues are more important. Also, faster loading times would be very welcome, and would make testing easier and more convenient.

Thanks for the explanation, I think I know what the cause is.

Alright, this is now fixed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Qqwy picture Qqwy  Â·  3Comments

mkohlhaas picture mkohlhaas  Â·  3Comments

dcnorris picture dcnorris  Â·  3Comments

notoria picture notoria  Â·  3Comments

UWN picture UWN  Â·  3Comments