Adapted from Schelog by Dorai Sitaram for Racket by Dorai Sitaram, John Clements, and Jay McCarthy.
Racklog is an embedding of Prolog-style logic programming in Racket. “Embedding” means you don’t lose Racket: You can use Prolog-style and conventional Racket code fragments alongside each other. Racklog contains the full repertoire of Prolog features, including meta-logical and second-order (“set”) predicates, leaving out only those features that could more easily and more efficiently be done with Racket subexpressions.
The Racklog implementation uses the approach to logic programming for Scheme described in Felleisen [mf:prolog] and Haynes [logick]. In contrast to earlier Lisp simulations of Prolog [campbell], which used explicit continuation arguments to store failure (backtrack) information, the Felleisen and Haynes model uses the implicit reified continuations of Scheme. In Racket these are provided by the operator call-with-current-continuation (aka call/cc). This allows Racklog to be an embedding, ie, logic programming is not built as a new language on top of Racket, but is used alongside Racket’s other features. Both styles of programming may be mixed to any extent that a project needs.
The Racklog user does not need to know about the implementation mechanism or about call/cc and continuations to get on with the business of doing logic programming with Racklog.
This text is a gentle introduction to Racklog syntax and programming. It assumes a working knowledge of Racket and an awareness of, if not actual programming experience with, Prolog. If you need assistance for Prolog, you may consult [bratko, ok:prolog, aop] or many other excellent books and online documents available.