Skip to content

Examples

Jupyter notebooks showing 2PPy at work. Each page is a notebook with its outputs, which you can download (button at the top of the page) or find in the examples/ folder of the repository. The test suite runs them all.

Notebook Content Related guides
Terms and unification building, parsing, inspecting and converting terms; unification and substitutions Build and parse terms, Terms and variables
Knowledge bases and queries theories, solvers, queries, lazy solutions, dynamic knowledge bases, built-ins Your first logic program, Query solvers
Predicates and functions in Python extending solvers with Python functions, and their errors Define predicates in Python
Python objects from Prolog OOPLib: creating objects and calling methods from Prolog Use Python objects from Prolog
Input and output Python streams as solvers' channels, reading theories from files, IOLib Read and write streams
Probabilistic logic programming ProbLog programs and the probability of their solutions Run probabilistic programs
The N-queens puzzle a classic search problem, solved by backtracking Logic programming

Running the notebooks

Install 2PPy and Jupyter (pip install 2ppy jupyter), download a notebook, and open it with jupyter lab. From a clone of the repository, Jupyter is a development dependency:

uv sync && uv run poe build-jars
uv run jupyter lab examples/