A small, dependency-free Prolog engine for Common Lisp. Rulebases are plain
data, proof search is continuation-passing, and the builtin goal set is
extensible. The public package is cl-prolog.
(require :asdf)
(asdf:load-asd (truename "cl-prolog.asd")) ; run from the repository root
(asdf:load-system :cl-prolog)
(in-package #:cl-prolog)
(define-rulebase *family*
((parent tom bob))
((parent bob alice))
((ancestor ?x ?y) (parent ?x ?y))
((ancestor ?x ?y) (parent ?x ?z) (ancestor ?z ?y)))
(query-prolog *family* '(ancestor tom ?who))
;; => (((?WHO . BOB)) ((?WHO . ALICE)))Prolog source text works too:
(query-prolog (consult-prolog #p"family.pl") (read-prolog-term "ancestor(tom, Who)"))cl-prolog is not on Quicklisp. Clone it and load its ASDF definition, or put the checkout on your ASDF source registry:
git clone https://github.com/nerima-lisp/cl-prolog.gitWith Nix, nix run github:nerima-lisp/cl-prolog runs the regression suite, and
as a flake input:
# flake.nix
inputs.cl-prolog = {
url = "github:nerima-lisp/cl-prolog/v1.0.1";
inputs.nixpkgs.follows = "nixpkgs";
};Note the pinned tag. A bare github:nerima-lisp/cl-prolog follows this
repository's default branch, so a push here would break your build without
warning.
Full documentation is published at https://nerima-lisp.github.io/cl-prolog/. The source for that site lives in docs/src/.
nix develop # SBCL with CL_SOURCE_REGISTRY already set
nix run .#test # run the test suite
nix flake check # tests + formatting + docs, the same gate CI uses
nix fmt # format Nix sources (treefmt)Tests live in t/ and run under cl-weave,
the org's test framework. Without Nix, sbcl --script run-tests.lisp runs the
same suite, provided cl-weave is on CL_SOURCE_REGISTRY.
See the org-wide CONTRIBUTING guide and the package standard. Release history is in CHANGELOG.md.
See SUPPORT.
MIT — see LICENSE.