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).

* 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)))))

* 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?

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.

Attachment: signature.asc
Description: PGP signature

Reply via email to