Clausal Prolog

Clausal Prolog

Clausal Prolog unifies Python, the language of neural networks, with Prolog, the language of logic and constraints.

Zero friction

Same VM, same memory management, no embedded engine GIL issues in its default mode*, no process boundary.

*Note: Trealla and Scryer Prolog are still available embedded.

The best of both worlds: the full power of Prolog with Torch, JAX, System 1 models and the entire Python ecosystem accessible as logic predicates.

Clausal Prolog pushes the Neurosymbolic AI frontier.

Less is more

Clausal Prolog aims to be a fully-conforming ISO Prolog, but also has a restricted subset, Clausal Prolog syntax itself, that leaves out tricky control-flow predicates such as 'cut' that weaken purity and monotonicity in ISO Prolog.

This means that formalisations in Clausal Prolog use a pure monotonic subset of Prolog to access the full power of Prolog as it was originally envisaged.

For an excellent tutorial on this, see The Power of Prolog.

What it is

Clausal Prolog

  • Prolog implemented in Python, aiming at ISO Prolog conformity.
  • A neural network can call symbolic logic, which can call neural predicates, nested, in one Python process. No serialisation. No second runtime. No glue code.
  • Constraint solving: CLP(Z), CLP(B), CLP(Q), CLP(R) and finite domains.
  • Tabling, DCGs and a large standard library.
  • PyTorch integration through clausal-torch, on PyPI.
Inside Clausal Prolog: clauses compile to generators run on a trampoline, with tabling, asyncio and a C extension for variables and the trail; terms are Python objects, so nothing is marshalled at the Python boundary

Inside Clausal Prolog. Clauses compile to Python generators; tabling, asyncio and a C extension for variables and the trail sit around one trampoline.

Clausal Prolog is open source under the MIT licence.

The premise behind it: marry the two branches of AI

Why we use it

We think it is the ideal platform for neurosymbolic AI. Neural networks are good at language and perception. Logic is good at rules and proof. Clausal Prolog gives you the best of both worlds in one process, with nothing in between.

That is our conviction. Do not take our word for it: the code and the docs are public.

Read the docs at clausal.pl

Clausal Prolog on GitHub

Clausal Prolog runs our compliance reasoning: see it in GDPR breach notification.