[racket] racklog bug?

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Thu Oct 6 10:26:55 EDT 2011

Alright, I've looked into this.

First notice that

 (%which (eks why T) (%derive-type (list '+ eks why ) T )); => ((eks .
z) (why . y) (T . pls))

It has nothing to do with the X and Y on the outside being confused
with the X and Y on the inside.

Next, compare these two programs:

(define this-derive-type
 (let ([X #f] [Y #f])
  (lambda (thing)
   (match thing
    [(list '+ lhs rhs)
     (set! X lhs)
     (set! Y rhs)
     'pls]))))

(define that-derive-type
 (lambda (thing)
  (let ([X #f] [Y #f])
   (match thing
    [(list '+ lhs rhs)
     (set! X lhs)
     (set! Y rhs)
     'pls]))))

this-derive-type is like having the %let on the outside. The X and Y
logic variables are shared across all invocations of the relation.
Whereas that-derive-type is like putting the logic variables in the
%rel where they are local to the relation invocation.

So what happens is that by first running

(%which (T)     (%derive-type '(+ z y ) T )) ;=> ((T . pls))

It sets the logic variables that are in the relation to 'z and 'y

And then afterwards when you go back in, the test says that they must
be 'z and 'y, even if they are unbound. For example, this happens:

(%which (T) (%derive-type '(+ y z) T)) => #f

Because the lhs must be 'z and the rhs must be 'y

I think this is the correct behaviour of Racklog, although I'm not
totally confident.

Jay

On Thu, Oct 6, 2011 at 1:57 AM, Niitsuma Hirotaka
<hirotaka.niitsuma at gmail.com> wrote:
> plz note to case
> (%which (X Y T) (%derive-type (list '+ X Y ) T )); => ((X . z) (Y . y)
> (T . pls)) ;;why ? bug?
> ----------------------------------
> #lang scheme
> (require racklog)
>
>
> (define %derive-type
>  (%let ( X Y T)
>        (%rel ( ) [( (list '+ X Y  ) 'pls) ]
> )))
>
> (%which (T)     (%derive-type '(+ z y ) T )) ;=> ((T . pls))
> (%which (X Y T) (%derive-type (list '+ X Y ) T )); => ((X . z) (Y . y)
> (T . pls)) ;;why ? bug?
>
>
> (define %derive-type2
>
>   (%rel (X Y T )       [( (list '+ X Y  ) 'pls) ]
> ))
>
> (%which (T)     (%derive-type2 '(+ z y ) T ));=> ((T . pls))
> (%which (X Y T) (%derive-type2 (list '+ X Y ) T ));=>((X . _) (Y . _)
> (T . pls)) ;; its OK
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/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



Posted on the users mailing list.