Boologic
A lightweight Python library for working with boolean propositional logic expressions.
Boologic allows you to construct logical expressions either:
- explicitly with classes
- implicitly using Python operators
Expressions are rendered using proper logical symbols:
¬ ∧ ∨ → ↔
Features
- Clean symbolic boolean logic expressions
- Python operator overloading
- Explicit class-based API
- Unicode pretty-printing
- Mix-and-match syntax support
- Built-in logical constants
Installation
pip install boologic
uv add boologic
Quick Start
Create Variables
Use the Var class to create propositional variables:
from boologic import Var
A = Var("A")
B = Var("B")
Building Expressions
Operator Syntax (Recommended)
expr = (A & B) >> ~A
print(expr)
Output:
(A ∧ B) → ¬A
Explicit Class Syntax
from boologic import And, Implies, Not
expr = Implies(And(A, B), Not(A))
print(expr)
Output:
(A ∧ B) → ¬A
Mixed Syntax
Both styles can be combined safely:
from boologic import Implies
expr = Implies(A & B, ~A)
Supported Operators
| Logic | Python Operator | Symbol |
|---|---|---|
| NOT | ~A |
¬A |
| AND | A & B |
A ∧ B |
| OR | A | B |
A ∨ B |
| IMPLIES | A >> B |
A → B |
| BICONDITIONAL | A ^ B |
A ↔ B |
Constants
Boologic uses its own Const class instead of Python's built-in
True and False.
Example
from boologic import Const
expr = Const(True) | A
This is interpreted internally as:
Or(Const(True), A)
Important: Operator Precedence
Python's operator precedence rules do not match standard logical precedence.
Always use parentheses () to ensure expressions are evaluated correctly.
Recommended
expr = (A & B) >> C
Avoid
expr = A & B >> C
The second example may not behave as expected.
Binary Operator Design
All binary operators are primarily designed around handling two operands at a time.
For clarity and correctness, always prefer explicit grouping:
(A & B) & C
instead of:
A & B & C
Example Expressions
Negation
~A
Output:
¬A
Conjunction
A & B
Output:
A ∧ B
Disjunction
A | B
Output:
A ∨ B
Implication
A >> B
Output:
A → B
Biconditional
A ^ B
Output:
A ↔ B
Recommended Style
For best readability:
- use parentheses generously
- prefer operator syntax for concise expressions
- use explicit classes for complex/generated expressions
Full Example
from boologic import Const, Var
A = Var("A")
B = Var("B")
C = Var("C")
expr = ((A & B) >> C) | ~Const(False)
print(expr)
Output:
((A ∧ B) → C) ∨ ¬False
License
MIT License
Metadata
Release files for boologic 0.3.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| boologic-0.3.7.tar.gz | 61.8 kB | Without provenance | Details for boologic-0.3.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| boologic-0.3.7-py3-none-any.whl | Python 3 | none | any | Details for boologic-0.3.7-py3-none-any.whl |
Total release size: 69.8 kB
Release files / boologic-0.3.7.tar.gz
| Download URL | boologic-0.3.7.tar.gz |
|---|---|
| Size | 61.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7a584cad16317b2284a136ac143e304e9caf5c291bd5bceb32b6f01f59ff1a15
|
|
BLAKE2b-256 checksum How to use checksums |
95d0b551d9bcff9370bf0cc7685f911e4c989d1fcb8c023f337212934dd9ae85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / boologic-0.3.7-py3-none-any.whl
| Download URL | boologic-0.3.7-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a5cda61bd912f7a08970322d5ec134651e06e61523043838fcad0a1df4cf42c2
|
|
BLAKE2b-256 checksum How to use checksums |
d25f39c950d0920b0686551b497246e384f380785ef97a3718a8e11e50af8774
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for boologic 0.3.7
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.