On Wed, Sep 16, 2015 at 2:50 PM, Eduardo Bellani <ebell...@gmail.com> wrote: > Hello list > > I'm trying to use racket's implementation of datalog as a query language > for a small database (5 gb). I'm running into some problems that I'd > appreciate your help with: > > * Is there support for negating a subgoal? E.g: [1] > > Get the names of employees who do not work on any project. > temp1(S) :- works_on(S,_,_). > answer(F,M,L) :- employee(F,M,L,S,_,_,_,_,_,_), not temp1(S).
No, but I have no objection to someone adding this. I believe it will require a different evaluation technique (bottom-up vs the present top-down) to run efficiently. > * Is there support for other comparison operators outside {=, !=}? E.g. > > (datalog *db* > ;; shareholders > (! (shareholder "Jorge" person)) > (! (shareholder "Bob" person)) > (! (shareholder "Googly" company)) > (! (shareholder "Megasoft" company)) > ;; ownership > (! (owns-a-share "Jorge" "Construction SA" 60.8)) > (! (owns-a-share "Bob" "Construction SA" 39.2)) > (! (owns-a-share "Bob" "WAKA SA" 100 )) > (! (owns-a-share "Googly" "Toys SA" 100 ))) > > > (let ((majority? (λ (percent) > (> percent 50)))) > (datalog *db* > (! (:- (major-stockholder COMPANY) > (shareholder SHAREHOLDER person) > (owns-a-share SHAREHOLDER COMPANY PERCENT) > (majority? PERCENT :- TEMP) > (= TEMP true))))) You could write (majority? PERCENT :- #t) Here's a tiny example #lang racket/base (require datalog) (datalog (make-theory) (! (number 0)) (! (number 1)) (! (number 2)) (! (number 3)) (! (:- (awesome N) (number N) (even? N :- #t))) (? (awesome N))) > * A syntax extension difficulty, not very much related to datalog per > se. I have this syntax extension: > > > (define-syntax (->relations stx) > ;; point here being getting true relations (sets) out of the results > (syntax-case stx () > [(_ rel-name rel-size) > (with-syntax ([rel-vars (for/list ([x (in-range (syntax->datum > #'rel-size))]) > (gensym 'X))]) > #`(map (λ (dic) > (list->set > (map (λ (rel-var) > (hash-ref dic rel-var)) > #'rel-vars))) > (datalog *db* (? (#,#'rel-name > #,@#'rel-vars)))))])) > > This is an case of an usage, in the context of the previous example: > > (->relations major-stockholder 1) > > I'm bumping in the following error: > > make-variable: contract violation > expected: (or/c #f (list/c any/c (or/c exact-positive-integer? #f) (or/c > exact-nonnegative-integer? #f) (or/c exact-nonnegative-integer? #f) (or/c > exact-positive-integer? #f))) > given: '(#f #f #f #f 0) > in: the 1st argument of > (-> > (or/c > #f > (list/c > any/c > (or/c exact-positive-integer? #f) > (or/c exact-nonnegative-integer? #f) > (or/c exact-nonnegative-integer? #f) > (or/c exact-positive-integer? #f))) > symbol? > variable?) > contract from: <pkgs>/datalog/ast.rkt > > Which I interpreted as the LOC being lost in the syntax generator. I > haven't being able to resolve that yet. Any light on the subject? This is an error on my part. It should be POS NONNEG POS NONNEG but I wrote POS NONNEG NONNEG POS. I just did a push, let me know if that fixes it (or you could just change it on your own copy.) Jay > Thanks in advance for any pointers. > > [1] http://tinman.cs.gsu.edu/~raj/8710/f05/datalog.pdf > > -- > Eduardo Bellani > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- Jay McCarthy http://jeapostrophe.github.io "Wherefore, be not weary in well-doing, for ye are laying the foundation of a great work. And out of small things proceedeth that which is great." - D&C 64:33 -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.