On this page:
1.1 Getting Started
1.2 Datalog Language for Dr Scheme

1 Datalog for PLT Scheme

1.1 Getting Started

The easiest way to get started using Datalog for PLT Scheme is with the main module:

 (require (planet jaymccarthy/datalog:1:3))

This module provides everything in the entire package. Subsequent sections of this manual describe the functionality of the individual libraries included, which can also be required individually.

Examples:

  > (define example-program
      "ancestor(A, B) :-\n    parent(A, B).\nancestor(A, B) :-\n    parent(A, C),\n    D = C,\n    ancestor(D, B).\nparent(john, douglas).\nparent(bob, john).\nparent(ebbon, bob).\nancestor(A, B)?")
  > (require (planet dherman/pprint))
  > (pretty-print
     (format-program
      (parse-program
       (open-input-string
        example-program))))

  ancestor(A, B) :- parent(A, B).

  ancestor(A, B) :- parent(A, C), D = C, ancestor(D, B).

  parent(john, douglas).

  parent(bob, john).

  parent(ebbon, bob).

  ancestor(A, B)?

  > (void
     (eval-program/fresh
      (parse-program
       (open-input-string
        example-program))))

  ancestor(ebbon, bob).

  ancestor(bob, john).

  ancestor(john, douglas).

  ancestor(bob, douglas).

  ancestor(ebbon, john).

  ancestor(ebbon, douglas).

  

1.2 Datalog Language for DrScheme

Installing this PLaneT package also automatically registers a DrScheme language called Datalog, filed under Experimental Languages. Selecting the Datalog language from DrScheme’s Language menu allows you to create and load Datalog programs and interact with Datalog at the REPL.

Datalog is also available as a module language. This can be used by beginning a Datalog source file with the line:

#lang planet jaymccarthy/datalog:1:3

You can omit the PLaneT version numbers if you prefer. Programs without the version number do not need to be updated when this PLaneT package is upgraded. However, it is then the responsibility of the programmer to address any backwards-incompatible changes to the Datalog semantics.