Installing SWI Prolog

DeepStochLog requires SWI Prolog to run.
Run the following commands to install:

sudo apt-add-repository ppa:swi-prolog/stable
sudo apt-get update
sudo apt-get install swi-prolog

Installing DeepStochLog package

To install DeepStochLog itself, run the following command:

pip install deepstochlog

Running the examples

Local dependencies

To see DeepStochLog in action, please first install SWI Prolog (as explained about),
as well as the requirements listed in requirements.txt

pip install -r requirements.txt


The datasets used in the tasks used to evaluate DeepStochLog can be found in our initial release.

Addition example

To see DeepStochLog in action, navigate to examples/addition and run

The neural definite clause grammar specification is provided in
The addition(N) predicate specifies/recognises that two handwritten digits N1 and N2 sum to N.
The neural probability nn(number, [X], Y, digit) makes the neural network with name number (a MNIST classifier) label input image X with the digit Y.

Credits & Paper citation

If use this work in an academic context, please consider citing the following paper:

The paper is also accepted to AAAI22.
Please cite that version of the paper when the proceedings are out.

  title={Deepstochlog: Neural stochastic logic programming},
  author={Winters, Thomas and Marra, Giuseppe and Manhaeve, Robin and De Raedt, Luc},
  journal={arXiv preprint arXiv:2106.12574},


View Github