[racket] Parameterizing tables in Datalog queries

From: Mikko Tiihonen (mikko.tiihonen at tmtiihonen.fi)
Date: Fri Aug 16 07:08:06 EDT 2013

Hi!

I've been trying to parameterize Datalog queries and have stumbled into a problem with the tables in queries. As an example (from Datalog documentation):

#lang racket
(require datalog)
(define family (make-theory))
(datalog family
         (! (parent joseph2 joseph1))
         (! (parent joseph2 lucy))
         (! (parent joseph3 joseph2)))

-now if I run the query as shown in the documentation

	(let ([x 'joseph2])
	  (datalog family
     	      (? (parent x X))))

the answer is as expected:

	'(#hasheq((X . joseph1)) #hasheq((X . lucy)))

However, if I parameterize the table:

	(let ([x 'parent])
	  (datalog family
     	      (? (x 'joseph2 X))))

the query fails:

	'()

Are there any workarounds for this? I am grateful for any suggestions...

Best regards,

Mikko Tiihonen





Posted on the users mailing list.