Skip to main content

PropLogic

PropLogic is a small Python library for tokenizing, parsing, and transforming propositional logic expressions with Boolean laws.

Features

  • Lexer for ASCII and mathematical operator spellings
  • Recursive-descent parser with an explicit AST
  • Dataclass-based expression nodes
  • Local transformations for common Boolean laws
  • src-layout packaging and automated GitHub/PyPI releases

Requirements

  • Python 3.11 or newer

Installation

Install the published package:

python -m pip install prop-logic-lib

Install an editable development copy with tooling:

python -m pip install -e '.[dev]'

The distribution name is prop-logic-lib; the Python import package is proplogic.

Quick Start

from proplogic.lexer import Lexer
from proplogic.laws import Identity
from proplogic.parser import Parser

ast = Parser(Lexer("A and T").parse_tokens()).parse()
if ast is None:
	raise ValueError("Expression was empty")

simplified = Identity.apply(ast.root)
print(simplified)  # A

Expressions can use words or symbols:

from proplogic.lexer import Lexer
from proplogic.parser import Parser

ast = Parser(Lexer("¬(A ∨ B) -> C").parse_tokens()).parse()
print(ast)

See Expression Syntax for the complete operator table and Architecture for the processing pipeline.

Interactive Module

The current interactive entry point is available as a module:

python -m proplogic.proplogic

Enter an expression at the prompt. Type quit or exit to leave.

Boolean Laws

Law implementations are available in proplogic.laws. Each law provides:

Law.name() -> str
Law.description() -> str
Law.apply(node: NodeExpr) -> NodeExpr

Available transformations include identity, domination, negation, idempotence, commutativity, associativity, distributivity, double negation, De Morgan's theorems, absorption, conditional, biconditional, tautology, and contradiction.

Law application is local: apply transforms the supplied node and does not perform a complete recursive simplification pass.

Development

Install the hooks and development tools:

python -m pip install -e '.[dev]'
pre-commit install

Apply Ruff lint fixes and formatting:

python scripts/format.py

Run all validation hooks:

python -m pre_commit run --all-files

See CONTRIBUTING.md for the development workflow and release process.

Releases

The version is defined in src/proplogic/__init__.py. Pushing a version change to main triggers separate workflows that build the package, create a v<version> GitHub release, and publish to PyPI.

PyPI trusted publishing uses the pypi-prop-logic GitHub environment and the prop-logic-lib PyPI project. See CONTRIBUTING.md for the required publisher configuration.

License

PropLogic is distributed under the GNU General Public License v3.0. See LICENSE for the full text.

Metadata

Release files for prop-logic-lib 0.1.4

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

Source distribution (sdist)

Source distribution for prop-logic-lib 0.1.4
File Size Uploaded Provenance Actions
prop_logic_lib-0.1.4.tar.gz 44.0 kB With provenance Details for prop_logic_lib-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for prop-logic-lib 0.1.4
File Interpreter ABI Platform Actions
prop_logic_lib-0.1.4-py3-none-any.whl Python 3 none any Details for prop_logic_lib-0.1.4-py3-none-any.whl

Total release size: 76.0 kB

Release files / prop_logic_lib-0.1.4.tar.gz

Download URL prop_logic_lib-0.1.4.tar.gz
Size 44.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6d96cefa32b683e5d87a22741a6b37e0175e7d82e5338278542557398b9359af
BLAKE2b-256 checksum
How to use checksums
cd85e0aaca2224b1541fbc6e5833727cbc8ff8c9070b7598baa29ba4d14c23dc
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 Sep 12, 2026.

Transparency log

Release files / prop_logic_lib-0.1.4-py3-none-any.whl

Download URL prop_logic_lib-0.1.4-py3-none-any.whl
Size 32.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a910aca3c1f8be82c3952da5d9b3d8c155ecd7728028cac8388dddfd9bcc422e
BLAKE2b-256 checksum
How to use checksums
8513ca3425b85c63c4ef4ec6113b13d9233bcb0379983bf4416595b5cbeabee0
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 Sep 12, 2026.

Transparency log

Security for prop-logic-lib 0.1.4

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for prop_logic_lib-0.1.4.tar.gz

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 Sep 12, 2026.

Transparency log

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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