Wrong answer produced by clp(q) after a copy_term/2 · Issue #94 · SWI-Prolog/issues · GitHub
Skip to content

Wrong answer produced by clp(q) after a copy_term/2  #94

Open

Description

@maximilianocristia

Hi!

We've found the following error.

Version of SWI-Prolog and operating system:

OS: Linux 4.15.0-74-generic #84-Ubuntu SMP Thu Dec 19 08:06:28 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

SWI-Prolog (threaded, 64 bits, version 7.6.4)

Program that produces the error:

use_module(library(clpq)).
G=(M=<X, X=<N, N1>=0, K>=1, N1 = K-1, K = N-M+1),
{G},
copy_term(G,T),
T=(F,R),
{F}.

The answer is:

false

but it should be something along the lines:

G = (M=<X,X=<N,N1>=0,K>=1,N1=K-1,K=N-M+1),
T = (_A=<_B,_B=<_C,_D>=0,_E>=1,_D=_E-1,_E=_C-_A+1),
F = (_A=<_B),
R = (_B=<_C,_D>=0,_E>=1,_D=_E-1,_E=_C-_A+1),
{N1= -1+K},
{N= -1+M+K},
{M-X=<0},
{_A-_B=<0},
{M-X+K>=1}

According to Paulo Moura this is the answer given by Sictus Prolog.

Besides, the same goal where the order of the integer constraints in G is slightly changed:

G=(M=<X, X=<N, N1>=0, K>=1, K = N-M+1, N1 = K-1),
{G},
copy_term(G,T),
T=(F,R),
{F}.

produces a correct answer.

This error was found by Gianfranco Rossi and me.

All the best,
Maxi

Activity

  1. andreaf96 commented on Feb 2, 2020

    @andreaf96

    This goal @maximilianocristia

    G=(M=<X, X=<N, N1>=0, K>=1, N1 = K-1, K = N-M+1),
    {G},
    copy_term_nat(G,T),
    T=(F,R),
    {F}.
    

    produces this output (with the latest development version of CLP(Q,R)).

    G = (M=<X, X=<N, N1>=0, K>=1, N1=K-1, K=N-M+1),
    T = (_59190=<_59192, _59192=<_59204, _59214>=0, _59226>=1, _59214=_59226-1, _59226=_59204-_59190+1),
    F = (_59190=<_59192),
    R = (_59192=<_59204, _59214>=0, _59226>=1, _59214=_59226-1, _59226=_59204-_59190+1),
    {K>=1, N1= -1+K, _59338>=0, N= -1+M+K, X= ... + ... - _59338+K, _59404= ... - ... + K, _59338-K=< -1},
    {_59192=_59190+_59458, _59458>=0}.

    From https://www.swi-prolog.org/pldoc/doc_for?object=copy_term_nat/2

    copy_term_nat(+Term, -Copy)
    As copy_term/2. Attributes, however, are not copied but replaced by fresh variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions