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-kit.
(require :asdf)
(asdf:load-asd (truename "cl-prolog-kit.asd")) ; run from the repository root
(asdf:load-system :cl-prolog-kit)
(in-package #:cl-prolog-kit)
(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-kit 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-kit.gitWith Nix, nix run github:nerima-lisp/cl-prolog-kit runs the regression suite, and
as a flake input:
# flake.nix
inputs.cl-prolog-kit = {
url = "github:nerima-lisp/cl-prolog-kit/v1.5.0";
inputs.nixpkgs.follows = "nixpkgs";
};Note the pinned tag. A bare github:nerima-lisp/cl-prolog-kit 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-kit/. 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 callgraph/test/ and run under
cl-weave, the org's test framework.
Without Nix, sbcl --script run-tests.lisp runs both suites, provided cl-weave
is on CL_SOURCE_REGISTRY.
See the org-wide CONTRIBUTING guide and the package standard. Release history is in the releases.
See SUPPORT.
MIT — see LICENSE.