[racket] [bug?] Racklog cut differs from Prolog cut

From: Ryan Culpepper (ryan at cs.utah.edu)
Date: Mon Aug 13 16:17:44 EDT 2012

As I understand it, cuts are delimited by the relations they appear in. 
So it would go something more like this (using a notation I just made up):

a(X)
---->
b(X) ; c(X)
---->
[delimit b(1) ; b(2) ] ; c(X)
---->
[delimit X=1, ! ; b(2) ] ; c(X)
---->
X=1 ; c(X)
---->
X=1 ; c(2)
---->
X=1 ; X=2

I've omitted the delimit brackets for a and c because they don't 
interact with any cuts.

Ryan


On 08/13/2012 02:15 PM, Jay McCarthy wrote:
> Can you help me understand this example and why x should be 2? My
> understanding of cut and prolog is that this should happen:
>
> a(X)                [X = _ ]
> ---->
> b(X) ; c(X)       [ X = _ ]
> ---->
> b(1) ; b(2); c(X) [ X = _ ]
> ---->
> X = 1; ! ; b(2) ; c(X)    [ X = _ ]
> ---->
> ! ; b(2) ; c(X)              [ X = 1 ]
>
> ! evaluates to succeed and then we get the X = 1 solution.
>
> But because we cut, the change to the X logic variable won't be
> undone, so when we try we get to...
>
> b(2) ; c(X)
> ----->
> 1 = 2 ; c(X)
> ---->
> fail ; c(X)
> ---->
> c(X)
> ---->
> c(2)
> ----->
> 1 = 2
> ---->
> fail
>
> and never see that X = 2
>
> I must be wrong because you show that prologs actually give 2, but
> could you help me see why?
>
> Jay
>
> On Sat, Aug 11, 2012 at 11:32 PM, Erik Dominikus
> <erik.dominikus71 at gmail.com> wrote:
>> Racket version:
>>
>> 5.2.
>>
>> Output of 'uname -a':
>>
>> Linux kire 2.6.32-41-generic #91-Ubuntu SMP Wed Jun 13 11:43:55 UTC 2012
>> x86_64 GNU/Linux
>>
>> Symptom:
>>
>> In SWI Prolog (or any Prolog interpreter I think), querying a(X) gives
>> X=1 and X=2. Racklog only gives x=1.
>>
>> How to reproduce:
>>
>> Download 'a.pl' (attached).
>> Run 'prolog -f a.pl' (if using SWI Prolog).
>> Enter 'a(X).'.
>> Press ';' (semicolon) key until it prints false.
>>
>> Download 'a.rkt' (attached).
>> Run 'racket a.rkt'.
>>
>> Expectation:
>>
>> Racklog gives x=1 and x=2.
>>
>>
>> Thank you.
>>
>> ____________________
>>    Racket Users list:
>>    http://lists.racket-lang.org/users
>>
>
>
>


Posted on the users mailing list.