Python package for propositional logic.
Project description
classical-logic - Tools for Classical Logic
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
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for classical_logic-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30ee16255f98fff90236d05f3155a36fcf37e6fbcfc4b0482510a8e903ab6910 |
|
MD5 | 643a11921365b33bea87a862d1603859 |
|
BLAKE2b-256 | 6d8cebf5b34aa944509e57f64a22fba96617adae0599025fb1cb07f911853c2a |