users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange variables...


From: Daniel Diaz
Subject: Re: Strange variables...
Date: Fri, 16 Jan 2015 19:27:39 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0

Hi Fred,

thank you for this report. This is a bug in the compiler.
Fixed in the git and will be available in the 1.4.5 version.

Daniel


Le 08/01/2015 20:57, Fred Bapst a écrit :
I'm observing a rather strange behaviour (GnuProlog 1.4.4 on Windows and Linux,
idem for older versions) and I'm not able to completely isolate it; it seems to
be related to singleton variables and backtracking. Here is a stupid code
demonstrating the issue:

%--------------
z(A,B, A,B).
z(A,B, B,A).

p5(Ls):-
     _ = [B, C],
     % write(B), % write(C),
     Ls = [A, E],
     z(A, _, 1, 2),
     E=3,
     z(A, _, B, C).

%--------------

Asking for every solution leads to an infinite loop...

   ?- p5(X).
   X = [1,3] ? a
      ...... [infinine loop].....

Writing B and C removes the problem; and writing only one of them leads to
another strange behavior.

Running the call with the tracer also changes the behavior, and reveals
strange d(...) sub-terms:

{trace}
| ?- p5(X).
       1    1  Call: p5(_23) ?
       2    2  Call: z(_53,_57,1,2) ?
       2    2  Exit: z(1,2,1,2) ?
       3    2  Call: z(1,_85,_126,_127) ?
       3    2  Exit: z(1,_85,1,_85) ?
       1    1  Exit: p5([1,3]) ?
X = [1,3] ? a
       1    1  Redo: p5([1,3]) ?
       3    2  Redo: z(1,_85,1,_85) ?
       3    2  Exit: z(1,_85,_85,1) ?
       1    1  Exit: p5([1,3]) ?
X = [1,3]
       1    1  Redo: p5([1,3]) ?
       2    2  Redo: z(1,2,1,2) ?
       2    2  Exit: z(2,1,1,2) ?
       3    2  Call:
z(2,_85,d(3,[a(z(2,_85,d(3,[a(z(2,_85,...),3,2,...),a(p5(...),1,...)]),2),3,2,144),a(p5([2,3]),1,1,87)]),2)
?
       3    2  Exit:
z(2,d(3,[a(z(2,d(3,[a(z(2,d(...,...),...),3,2,...),a(p5(...),1,...)]),d(3,[a(z(2,d(...,...),...),3,2,...),a(p5(...),1,...)]),2),3,2,144),a(p5([2,3]),1,1,87)]),d(3,[a(z(2,d(3,[a(z(2,d(...,...),...),3,2,...),a(p5(...),1,...)]),d(3,[a(z(2,d(...,...),...),3,2,...),a(p5(...),1,...)]),2),3,2,144),a(p5([2,3]),1,1,87)]),2)
?
       1    1  Exit: p5([2,3]) ?
X = [2,3]
(16 ms) yes
{trace}


_______________________________________________
Users-prolog mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/users-prolog



--
Ce message a ete verifie par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a ete trouve.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]