[racket] Datalog extensions

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Tue Dec 31 11:34:29 EST 2013

Hi Evan,

I was planning on working on this per your previous email to the list.

Basically all that needs to be done is document datalog/runtime and
maybe provide some helpers for constructing queries via datalog/ast.

The runtime is very simple:

(provide/contract
 [safe-clause? (clause? . -> . boolean?)]
 [theory/c contract?]
 [make-theory (-> theory/c)]
 [assume! (theory/c safe-clause? . -> . void)]
 [retract! (theory/c clause? . -> . void)]
 [prove (theory/c question/c . -> . (listof question/c))])

where clause? and question/c are just the obvious encoding of Datalog
terms (except they also carry source location information). For
instance:

#lang racket/base
(require racket/list
         rackunit
         datalog/runtime
         datalog/ast)

(define t (make-theory))

(assume! t (clause #f (literal #f 'parent (list (constant #f 'joseph)
                                                (constant #f 'david)))
                   empty))

(check-equal?
 (prove t (literal #f 'parent (list (constant #f 'joseph)
                                    (variable #f 'X))))
 (list (literal #f 'parent (list (constant #f 'joseph)
                                 (constant #f 'david)))))

So, there's no real implementation work involved, just documenting a few things.

I would also suggest looking at cKanren. I haven't used it a lot, but
I am very impressed by it and want to use it.

Jay



On Mon, Dec 30, 2013 at 7:59 AM, Matthias Felleisen
<matthias at ccs.neu.edu> wrote:
>
> On Dec 30, 2013, at 12:01 AM, Evan Donahue <emdonahu at gmail.com> wrote:
>
>> Hello,
>>
>> I am curious about the current status and future plans for the datalog package. I am working on an interactive system that uses datalog for its internal data storage, and am finding it difficult to map dynamic user actions onto the available datalog syntactic abstractions even with the racket interop extensions. Issues include:
>>
>> - table names unknown until runtime
>> - difficulty abstracting common use patterns due to an ostensibly inadequate mental model of the interplay between syntax expansion and the datalog machinery
>>
>> What I would like to know is whether people would be open to a patch that exposed a runtime api for modifying theories for use in hooking into alternative interfaces/syntaxes, and, if so, whether anyone had any extant thoughts on the best way to fit that into the current code.
>
>
> Evan, I am sure Jay would be happy to work with you. Have you considered using cKanren instead? It's also a logic language (though parenthesized) and exposes this incremental API that you seem to be looking for. -- Matthias
>
>
> ____________________
>   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


Posted on the users mailing list.