Interactive ProbLog Book Example

Interactive ProbLog Book Example


This online book describes the process of building online interactive ProbLog materials using Jupyter Book, and hosting them on GitHub Pages. The source of this book can be found in the simply-logical/problog-book-template GitHub repository, which can also serve as a template and a starting point for building your own ProbLog book. This book repeats the same content on four consecutive pages to exemplify different source formats and technologies that can be used with the Jupyter Book platform:

In addition to Jupyter Book, we use ipywidgets and bespoke iPython cell magic to embed interactive ProbLog code boxes that can either be executed directly in the book with Thebe or launched as a Jupyter Notebook with MyBinder – these approaches require a running Python kernel to make the ProbLog code executable. Alternatively, the sphinx-problog Jupyter Book extension allows to embed native interactive ProbLog code boxes – no Python required. All pages of the book are accompanied by reveal.js slides composed from the sources underlying the respective sections of this book. Static slides are built with the jupyter nbconvert conversion tool – see the script for more details. Slides can also be launched with RISE from a Jupyter Notebook through MyBinder to allow interactive and executable content. Therefore, in our workflow a single source file can possibly produce:

  • computational notebooks;

  • static and interactive slides; and

  • sections of an online document/book.


To learn more about executing ProbLog programmes from within Python see the ProbLog as a Python library tutorial. To discover how to embed native ProbLog code boxes see the sphinx-problog Jupyter Book extension. The content of this book and its accompanying slides and notebooks come from the Bayesian networks ProbLog tutorial.

Building the Book

To build this book you need jupyter-book and a collection of Python packages specific to its content:

  • ipywidgets – for Python-based interactive ProbLog code boxes;

  • jupytext – to launch pages written in Markdown Notebooks in Jupyter;

  • notebook – to run Jupyter Notebook;

  • problog – for executing ProbLog programmes from within Python;

  • sphinx-problog – for creating native ProbLog code bexes within Jupyter Book; and

  • rise – to launch interactive and executable reveal.js presentations.

You can either install them individually with pip install ... or by using our dedicated requirements-jb.txt and requirements.txt files:

pip install -r requirements-jb.txt
pip install -r requirements.txt

Then, the book can be built with jb build . and the static slides with ./


For more details about installing necessary dependencies and building this book see the file included in the GitHub repository that holds the source of this book.