Skip to main content

2PPy (tuProlog in Python)

Experimental porting of 2P-Kt on Python, via JPype.

This is a work in progress.

Introduction

Object-oriented and modular ecosystem for symbolic AI and logic programming, currently featuring:

  • a command-line interface, in the form of a REPL

  • a module for logic terms and clauses representation, namely tuprolog.core

  • a module for logic unification, namely tuprolog.unify

  • a module for in-memory indexing and storing logic theories, namely tuprolog.theory

  • a module for other indexed collections of logic clauses (multi-sets and queues), namely tuprolog.collections

  • a module providing generic API for resolution of logic queries, namely tuprolog.solve

    • a module that implements deterministic logic programming and solving, namely tuprolog.solve.prolog
    • a module that implements probabilistic logic programming and solving, namely tuprolog.solve.problog
  • two parsing modules: one aimed at parsing terms, namely tuprolog.core.parsing, and the other aimed at parsing theories, namely tuprolog.theory.parsing

How to use 2ppy

Installing 2ppy

Install 2PPy from PyPI (Python 3.10 or later):

pip install 2ppy        # or: uv add 2ppy

The package ships 2P-Kt's JARs, and depends on jdk4py, which bundles a Java runtime: no separate Java installation is required. The JVM is started when tuprolog is first imported.

Use 2ppy as a Python library

  1. Import tuprolog.* modules in your Python scripts
  2. Use the Pythonic API to write, parse or solve your logic programs. You can find some examples in the tests folder.
  3. Python values are converted where terms are expected (e.g. struct("f", "a", 1) is f(a, 1), see tuprolog.core.to_term). Methods without a Pythonic counterpart are forwarded to the underlying JVM objects, so they may return JVM types (e.g. java.lang.String).

Use 2PPy as an interactive REPL

  1. Python shell mode: run python -m tuprolog
  2. Logic solver REPL:
    1. run python -m tuprolog.repl.prolog for Prolog
    2. run python -m tuprolog.repl.problog for ProbLog

How to contribute to 2PPy

The project follows template-python-project-uv. Requirements: uv and Apache Maven (mvn on the PATH), which downloads 2P-Kt's JARs from Maven Central, as declared in pom.xml.

uv sync                      # create the environment, with the development tools
uv run poe fetch-jars        # download the JARs into tuprolog/libs/ (needed before testing or building)
uv run poe test              # run the tests
uv run poe static-checks     # compileall, ruff format --check, ruff check, mypy (what CI runs)
uv run poe static-fixes      # ruff check --fix + ruff format
uv run poe coverage && uv run poe coverage-report
uv build                     # wheel and sdist in dist/ (JARs included)

Write the code inside tuprolog/ and the tests inside tests/. Contributor notes (layout, conventions) are in AGENTS.md. Optional local Git hooks: uv run poe install-hooks [HOOK...] (pre-commit, conventional-commits, no-ai-signature, pre-push).

Releases

Commits follow Conventional Commits: on every push to master, semantic-release derives the next version from them, publishes it on PyPI, and creates the corresponding GitHub Release. pyproject.toml is the only version source: never bump it by hand. The release workflow needs the PYPI_TOKEN and RELEASE_TOKEN repository secrets.

CI runs the static checks and the tests on Ubuntu, Windows and macOS, with Python 3.10 to 3.13. Dependencies are kept up to date by Renovate.

Metadata

Release files for 2ppy 1.1.1

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

Source distribution (sdist)

Source distribution for 2ppy 1.1.1
File Size Uploaded Provenance
2ppy-1.1.1.tar.gz 12.2 MB Without provenance Details

Built distribution (wheel)

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

Total release size: 24.5 MB

Release files / 2ppy-1.1.1.tar.gz

Download URL 2ppy-1.1.1.tar.gz
Size 12.2 MB
Tags Source
SHA-256 checksum
How to use checksums
6b554bcd32a5cd1af777a5b39ea62d92b0ee962c4628123399e694927d9ab9a9
BLAKE2b-256 checksum
How to use checksums
3e0d667ba6750095598b8463a263f1476ccbb9dbce66873c4739f0623f4c6e04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / 2ppy-1.1.1-py3-none-any.whl

Download URL 2ppy-1.1.1-py3-none-any.whl
Size 12.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
dd50d1633609e587b0a26e40230186a2cbb48b1aec5bb8e59f5375830a55bcd3
BLAKE2b-256 checksum
How to use checksums
848aea7765e5cb9bdc44538481a7fc2f487a13260a26f841bd6966fa76854ea6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for 2ppy 1.1.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files No provenance

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