Skip to main content

DeepLog

GitHub Release PyPI version License DOI

DeepLog is an operational framework for building neurosymbolic (NeSy) systems. Instead of presenting a monolithic stack, DeepLog provides high-performance building blocks that plug directly into PyTorch-first workflows so you can compose differentiable learning and symbolic reasoning with predictable interfaces.

Why DeepLog?

  • Symbol-first modeling – declare symbolic tensors and shapes, then let DeepLog check interfaces between modules before you wire them into larger systems.
  • Logic-aware modules – compile formulas into differentiable modules, wrap existing PyTorch components, and connect them to multiple reasoning backends.
  • Backend flexibility – start with the pure Python engine or enable the Janus/SWI-Prolog backend for lower latency inference without changing your training code.
  • Batteries included – tutorial notebooks, example projects (semantic loss, MNIST addition, …), and a Sphinx site walk you from “hello world” to custom NeSy stacks.
  • Research to production – typing, validation, and extensive tests keep advanced reasoning systems trustworthy when you move from prototypes to production workloads.

Installation

DeepLog publishes optional extras so you can extend the base install as needed:

Extra Description
pydeeplog[examples] Adds interactive notebook tooling (Jupyter) plus Lightning/torchvision/torchmetrics for tutorials.
pydeeplog[janus_engine] Installs the Janus SWI-Prolog bridge for the highest performance Prolog backend.
pydeeplog[mvsdd] Installs MV-SDD, the knowledge compiler for formulas that test several values of one variable, such as a digit classifier's ten classes in MNIST addition. Without it, such an expectation is enumerated.
pydeeplog[tests] Adds pytest, coverage and supporting utilities for contributors.
pydeeplog[site] Installs the documentation/notebook toolchain (Sphinx, PyData theme, myst-nb, Jupytext, ipykernel, Lightning/torchvision/torchmetrics, …).

Combine extras as needed, for example pip install ".[examples,tests]".

Optional: Janus/SWI-Prolog backend

The Janus backend depends on a local SWI-Prolog installation. On Ubuntu you can install it with:

sudo apt-get install software-properties-common
sudo apt-add-repository ppa:swi-prolog/stable && sudo apt-get update
sudo apt-get install swi-prolog

Once SWI-Prolog is available, install the Python bindings via pip install "pydeeplog[janus_engine]".

Install from source

git clone https://github.com/ML-KULeuven/deeplog.git
cd deeplog
pip install -e ".[examples,tests]"

Editable installs refresh automatically when you change the source tree, which is handy when contributing.

Quick start

import torch
from deeplog import SymTensor, WrappedModule, parse_symbol

# Wrap a plain PyTorch head with symbolic input/output shapes so DeepLog can
# validate every tensor that flows through it.
digits = SymTensor([parse_symbol("digit_a"), parse_symbol("digit_b")])
sigmoid_head = WrappedModule(torch.nn.Sigmoid(), digits, digits, name="sigmoid_head")

print(sigmoid_head(torch.tensor([[1.0, -2.0]])))
# tensor([[0.7311, 0.1192]])

WrappedModule validates tensor shapes against the symbolic specification, so interface mismatches surface as Python errors instead of silent shape bugs when you wire modules into larger reasoning systems.

For a taste of the symbolic side, compile a logical formula straight into a differentiable module:

from deeplog import parse_formula_to_module

# Count satisfying assignments of A ∨ B over booleans (= 3: TT, TF, FT):
# cast into the reals, where true is 1, and sum.
module = parse_formula_to_module(
    "sum(A): sum(B): (=(A,true)_boolean or =(B,true)_boolean)_real"
)
print(int(module()))  # 3

See examples/ for end-to-end notebooks (MNIST addition, semantic loss, LTN, …) and the full API reference on the docs site.

Documentation & tutorials

  • Landing page & docs – All documentation lives under site/. Build it locally with the steps in Building the documentation site.
  • Notebooks – The notebooks in examples/ teach DeepLog concept by concept; they are listed below. The docs site sequences a selection of them into two reading paths, one for ML practitioners and one for neurosymbolic developers, and each notebook's page there has an Open in Colab badge.
  • API reference – Generated automatically via sphinx-autoapi, covering symbols, shapes, modules, and engine utilities.

Notebooks

Foundations

Notebook What it teaches
symbols_and_shapes Symbol, the tuple that names terms, atoms and values with their algebra, and SymTensor, which names every entry of a tensor.
deeplogmodule DeepLogModule — the shape-aware torch.nn.Module subclass everything downstream builds on.
composition Combining modules using Sequential and compose_modules, and handling automatic shape transformations.

Core concepts

Notebook What it teaches
formula_to_module A constraint compiled into a DeepLogModule with parse_formula_to_module: fed a batch, differentiated, wired to a network, and computed by counting, enumeration or sampling.
formula_ast The formula AST: reading it, building it from Python, and the proofs a grounder returns as ASTs.
predicates Predicate modules: how symbolic atoms become executable tensor operations.
aggregation_basics Aggregation syntax, finite domains, aggregation operators, and expectations under a distribution.
free_variables_and_batching Free variables are module inputs.
circuits The Circuit DAG and to_module().
language Tour of the textual DeepLog formula language and its parser.

Applications

Notebook What it teaches
problog Running ProbLog programs: probabilistic facts, rules, queries, and conditioning on evidence with :- integrity constraints (P(q | e)).
deepproblog Neural predicates: a fact's probability comes from a network instead of a constant (an annotated disjunction compiled via the MV-SDD backend), building up to the classic MNIST-addition experiment, counted exactly or estimated by sampling. Slow.
semantic_loss A full ML training loop that uses a DeepLog formula as a differentiable loss term (semantic loss). Slow.
ltn Reproducing a subset of the Logic Tensor Networks tutorial on top of DeepLog.

Development workflow

See CONTRIBUTING.md for code quality and testing guidelines.

Public bug reports, questions, and feature requests live on GitHub. Development and code review happen privately, and tagged releases (v*) are mirrored to the public GitHub repository after release.

Building the documentation site

The landing page and docs live under site/ (Sphinx + PyData theme). To preview them locally:

  1. Install the site tooling (from the repo root):

    pip install -r site/requirements.txt
    
  2. Build the static HTML:

    (cd site && make html)
    
  3. Serve the generated pages from site/build/html. Any static file server works, e.g.:

    python -m http.server --directory site/build/html 8000
    

Visit http://localhost:8000 to browse the site. Tools like sphinx-autobuild can provide live reloads, but the steps above are the canonical way to build the site.

Support & community

  • Bugs & questions – Open an issue on GitHub and include reproduction steps plus relevant version information.
  • Security reports – Please do not file public issues for security vulnerabilities; instead reach the maintainers privately (see CONTRIBUTING.md for details).
  • Roadmap discussions – Feature proposals, architectural questions, and broader discussions are welcome via issues.

Contributing

We welcome contributions of all kinds—bug reports, docs, examples, and new modules. Review the contributing guide for coding standards, triage practices, and tips for a smooth review cycle. If you are looking for a first issue, check the tracker for good first issue and help wanted labels.

License

DeepLog is released under the LGPL-2.1 license © DTAI Research Group, KU Leuven.

Metadata

Release files for pydeeplog 5.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydeeplog 5.0.0
File Size Uploaded
pydeeplog-5.0.0.tar.gz 169.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pydeeplog 5.0.0
File Interpreter ABI Platform
pydeeplog-5.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 372.9 kB

Release files / pydeeplog-5.0.0.tar.gz

Download URL pydeeplog-5.0.0.tar.gz
Size 169.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c072f171ceaa89a03ac5eec64998d0d2e116d22acbe74d8263beaa2f2c7b1b8a
BLAKE2b-256 checksum
How to use checksums
1edcd969f54234b711fa65eb87d0961be4ffaffe719cac9c30dd80f397311521
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.

Transparency log

Release files / pydeeplog-5.0.0-py3-none-any.whl

Download URL pydeeplog-5.0.0-py3-none-any.whl
Size 203.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
09745adfa3949be50e02c9af8eafdfead58a9c842b482b2a93215eadc986c68b
BLAKE2b-256 checksum
How to use checksums
5e0a5b5d147ea0b2b7de39652229c30951fa0a6fb8f7e4951be760a5daeca89d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

5.0.0 This release

2 release files

4.1.1

2 release files

4.1.0

2 release files

4.0.3

2 release files

4.0.2

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.0.5

2 release files

3.0.3

2 release files

3.0.2

2 release files

3.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page