Skip to main content

classical-logic - Tools for Classical Logic

Documentation Status GitHub license

classical-logic is a Python package that allows you to work with logical propositions as Python objects.

It's extremely simple to use:

from classical_logic import prop

p = prop('P & Q')
assert p(P=True, Q=True) is True
assert p(P=True, Q=False) is False

Features

Parse proposition objects:

from classical_logic import prop

# Can parse simple propositions:
p = prop('P | Q')
# As well as complex ones!
p = prop('P & (Q | (Q -> R)) <-> S')

Compose proposition objects:

p = prop('P')
q = prop('Q')

# Create conjunctions and disjunctions with & and |:
u = p & (q | p)   # P & (Q | P)

# Create conditionals and biconditionals as well:
u = p.implies(q)  # P -> Q
u = p.iff(q)      # P <-> Q

Decompose propositions:

u = prop('P & Q')

# Use indexing to 
assert u[0] == prop('P')
assert u[1] == prop('Q')

# You can also use Python's unpacking feature!
p, q = u
assert p == prop('P')
assert q == prop('Q')

Interpret propositions (assign truth values):

u = prop('P <-> Q')

# Call the proposition like a function to interpret it
assert u(P=True, Q=True) is True
assert u(P=True, Q=False) is False
assert u(P=False, Q=False) is True

No dependencies. This package doesn't use any dependencies.

Want to use this package? See the documentation!

Links

Documentation @ ReadTheDocs

Github Repository

PyPI Page

Installation

This package can be installed using Pip:

pip install classical-logic

Please make sure you use a dash (-) instead of an underscore (_).

Bug Reports and Feature Requests

You can report a bug or suggest a feature on the Github repo.

See the Issues page on Github.

Contributions

Contributions to this project are welcome. :)

See the pull requests page on Github.

Metadata

Release files for classical-logic 0.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 classical-logic 0.1.1
File Size Uploaded
classical_logic-0.1.1.tar.gz 11.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for classical-logic 0.1.1
File Interpreter ABI Platform
classical_logic-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 23.0 kB

Release files / classical_logic-0.1.1.tar.gz

Download URL classical_logic-0.1.1.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
30c751ff2ff8b63a449b86a259da663f5e698b5dfe942d93e920d78799508078
BLAKE2b-256 checksum
How to use checksums
731637cb69021d3ddb263750427f1c0f72d18ef655fdc115d6115e6deaec2a50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.10.8 Windows/10

Release files / classical_logic-0.1.1-py3-none-any.whl

Download URL classical_logic-0.1.1-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c955d605d9c28f4db58529e687fc7b5b3f90e9425dd021e8615732dda861335
BLAKE2b-256 checksum
How to use checksums
fe0d2a20421b70ee0cbe6fe4ef92286d4e0d0710ee88748237977be74caf7c16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.10.8 Windows/10

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

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