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

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
*>*
*
--
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay
"The glory of God is Intelligence" - D&C 93