scryer-prolog: Unexpected failure

To reproduce this issue, please download:

Place camels.pl and v3.pl in the same directory, and then invoke Scryer with:

$ scryer-prolog -g camels camels.pl v3.pl 

With Scryer Prolog 0.9.0 up to at least v0.9.1-422-gb6a81c51, I get the expected output:

% initial patterns:
[2,0,0].
[0,2,0].
[0,0,2].
% generated packing patterns:
[0,2,1].
[1,1,1].
% solution vector (coefficient of each pattern):
[0,0,1,0,13].

But starting with v0.9.1-515-gbbf92f27 (and potentially even earlier) up to the current release v0.9.2, I unexpectedly get:

% initial patterns:
[2,0,0].
[0,2,0].
[0,0,2].
% generated packing patterns:
Warning: initialization failed for: camels

So, between v0.9.1-422 and v0.9.1-515, a regression was introduced that causes Scryer to now unexpectedly fail in this example.

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Comments: 16 (16 by maintainers)

Most upvoted comments

Is it okay for me to comment on the code of this side

@cmpute Absolutely, comment away.

r.is_integer() for RBig isn’t correctly implemented. It returns true when r is 1 rdiv 2.

I will raise another PR soon with the changes suggested by @cmpute.

fayeed already created an PR: https://github.com/cmpute/dashu/pull/35. However, I’m afraid that most of the modifications will not be accepted, as most of them are due to improper usage rather than the lack of functionalities. Is it okay for me to comment on the code of this side

@fayeed Thanks. The issue isn’t fixed in scryer, though… the version of dashu being pushed from the coasys repository appears to use an older version of dashu-ratio (0.3.1) but the updated one has version number 0.3.2.

@mthom Pushed a fix.

@triska It is. The main repo RBig impl doesn’t have an is_integer function.

@fayeed @lucksus can you correct the bug in the dashu fork please? this and #1983. this implementation appears to be work:

#[inline]
    pub fn is_integer(&self) -> bool {
        self.denominator().is_one()
    }

assuming that the RBig implementation is always reduced, of course.

@triska I’ve verified that using the above implementation of is_integer fixes the regression.

Prior to introduction of dashu (v0.9.1-460-g762e6d3b), the program works correctly.

I’ve narrowed down one unexpected failure to:

?- use_module(library(simplex)).
   true.
?- H is 1 rdiv 2, maximize([H*x(0),H*x(1),H*x(2)],state(0,[],[c(0,[90*x(0),70*x(1),20*x(2)],=<,200),c(0,[30*x(0),20*x(1),50*x(2)],=<,100)],[x(2),x(1),x(0)]),A).
   false, unexpected.

I will try to narrow it down further.