Scryer-prolog: clpz: unexpected redundant answer

Created on 12 Aug 2020  路  3Comments  路  Source: mthom/scryer-prolog

?- A in 0..1, B in 1..3,A*B#>C,labeling([],[A,B]),B=1, A=1, v(A,C)=v(1,0).
   A = 1, B = 1, C = 0
;  false.
?- A in 0..1, B in 1..3,A*B#>C,labeling([],[A,B]),B=1,      v(A,C)=v(1,0).
   A = 1, B = 1, C = 0
;  A = 1, B = 1, C = 0            % unexpected
;  false.

Most helpful comment

It seems to me that this issue is connected to simultaneous unifications.

@mthom, please consider this example, which works as intended:

?- A in 0..1, B in 1..3,A*B#>C,labeling([],[A,B]), B = 1, A = 1, C = 0.
%@    A = 1, B = 1, C = 0
%@ ;  false.

However, when I perform the last two unifications simultaneously, I get:

?- A in 0..1, B in 1..3,A*B#>C,labeling([],[A,B]), B = 1, v(A,C) = v(1,0).
%@    A = 1, B = 1, C = 0
%@ ;  A = 1, B = 1, C = 0
%@ ;  false.

In such cases (A-C = X-Y), all newly created bindings must be undone before verify_attributes/3 is invoked. Is this currently the case?

One naive (and possibly slower) workaround is to queue all bindings, and then work them off one after the other. For instance, in the cases above, v(A,C) = v(1,0) would be internally treated as A = 1, followed by C = 0, with verify_attributes/3 invoked after each such binding.

All 3 comments

?- A in 0..1, B in 1..3,A*B#>C,(A=0;A=1),labeling([],[B]), ( B=0 ; v(A,C) = v(1,0) ).

   A = 1, B = 1, C = 0
;  A = 1, B = 0, clpz:(C+1#=_A), clpz:(0#>=_A), clpz:(_A in inf..3), clpz:(C in inf..2)   % unexpected
;  A = 1, B = 0, C = 0                                                                    % unexpected
;  A = 1, B = 1, C = 0
;  A = 1, B = 2, C = 0
;  A = 1, B = 3, C = 0
?- A in 0..1, B in 1..3,A*B#>=C,(A=0;A=1),labeling([],[B]), ( B=0 ; v(A,C) = v(1,0), false ).
   A = 1, B = 0, clpz:(0#>=C), clpz:(C in inf..3)    % unexpected
;  false.

And here the residual should be just C inf..0 if that would be a meaningful result, but due to B = 0 that is impossible

It seems to me that this issue is connected to simultaneous unifications.

@mthom, please consider this example, which works as intended:

?- A in 0..1, B in 1..3,A*B#>C,labeling([],[A,B]), B = 1, A = 1, C = 0.
%@    A = 1, B = 1, C = 0
%@ ;  false.

However, when I perform the last two unifications simultaneously, I get:

?- A in 0..1, B in 1..3,A*B#>C,labeling([],[A,B]), B = 1, v(A,C) = v(1,0).
%@    A = 1, B = 1, C = 0
%@ ;  A = 1, B = 1, C = 0
%@ ;  false.

In such cases (A-C = X-Y), all newly created bindings must be undone before verify_attributes/3 is invoked. Is this currently the case?

One naive (and possibly slower) workaround is to queue all bindings, and then work them off one after the other. For instance, in the cases above, v(A,C) = v(1,0) would be internally treated as A = 1, followed by C = 0, with verify_attributes/3 invoked after each such binding.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cduret picture cduret  路  4Comments

triska picture triska  路  3Comments

mkohlhaas picture mkohlhaas  路  3Comments

jburse picture jburse  路  5Comments

dcnorris picture dcnorris  路  3Comments