diff --git a/collects/datalog/scribblings/datalog.scrbl b/collects/datalog/scribblings/datalog.scrbl index a0973a0..415929e 100644 --- a/collects/datalog/scribblings/datalog.scrbl +++ b/collects/datalog/scribblings/datalog.scrbl @@ -3,18 +3,21 @@ scribble/eval scribble/basic scribble/bnf - (for-label racket/base - racket/contract - "../main.rkt") "utils.rkt") @title[#:tag "top"]{@bold{Datalog}: Deductive database programming} @author[(author+email "Jay McCarthy" "jay@racket-lang.org")] -This package contains a lightweight deductive database system. Queries and database updates are expressed -using @link["http://en.wikipedia.org/wiki/Datalog"]{Datalog}---a declarative logic language in which each +@link["http://en.wikipedia.org/wiki/Datalog"]{Datalog} is +@itemize[ + @item{a declarative logic language in which each formula is a function-free Horn clause, and every variable -in the head of a clause must appear in the body of the clause. The use of Datalog syntax and an implementation based +in the head of a clause must appear in the body of the clause.} + @item{a lightweight deductive database system where queries and database updates are expressed + in the logic language.} +] + +The use of Datalog syntax and an implementation based on tabling intermediate results ensures that all queries terminate. @table-of-contents[] @@ -23,10 +26,6 @@ on tabling intermediate results ensures that all queries terminate. @defmodulelang[datalog] -XXX Progress - -@subsection{Datalog Syntax} - In Datalog input, whitespace characters are ignored except when they separate adjacent tokens or when they occur in strings. Comments are also considered to be whitespace. The character @litchar["%"] introduces a comment, which extends to the next line break. Comments do not occur inside strings. @@ -70,17 +69,7 @@ END A program is a sequence of zero or more statements. A statement is an assertion, a retraction, or a query. An assertion is a clause followed by a period, and it adds the clause to the database if it is safe. A retraction is a clause followed by a tilde, and it removes the clause from -the database. A query is a literal followed by a question mark. The effect of reading a Datalog program is to modify the database as directed -by its statements, and then to return the literal designated as the query. If no query is specified, a reader returns a literal know to have no -answers. The following is a program: - -@verbatim[#:indent 4 #<simple-clause stx) - (syntax-case stx () + (syntax-case stx (:-) + [(_ (:- . r)) + (quasisyntax/loc stx + (:- . r))] [(_ e) (quasisyntax/loc stx (clause #'#,stx (->literal e) empty))])) @@ -44,10 +59,8 @@ (syntax-case stx () [(_ head body ...) (quasisyntax/loc stx - (eval-top-level-statement - (assertion #'#,stx - (clause #'#,stx (->literal head) - (list (->literal body) ...)))))])) + (clause #'#,stx (->literal head) + (list (->literal body) ...)))])) (define-syntax-rule (define-paren-stx op struct) (define-syntax (op stx) @@ -65,12 +78,14 @@ (quasisyntax/loc stx (eval-top-level-statement (query #'#,stx (->literal c))))])) +(define-syntax (= stx) + (quasisyntax/loc stx + (constant #'#,stx '=))) + (provide (rename-out [top #%top] - [datum #%datum] - #;[module-begin #%module-begin] - #;[top-interaction #%top-interaction]) - + [datum #%datum]) + #%top-interaction #%module-begin ! ~ ? - :- + :- = unquote) \ No newline at end of file