Synopsis
tt (truth table) is a library aiming to provide a Pythonic toolkit for working with Boolean expressions and truth tables. Please see the project site for guides and documentation, or check out bool.tools for a simple web application powered by this library.
Installation
tt is tested on CPython 2.7, 3.3, 3.4, 3.5, and 3.6. You can get the latest release from PyPI with:
pip install ttable
Features
Parse expressions:
>>> from tt import BooleanExpression
>>> b = BooleanExpression('A impl not (B nand C)')
>>> b.tokens
['A', 'impl', 'not', '(', 'B', 'nand', 'C', ')']
>>> print(b.tree)
impl
`----A
`----not
`----nand
`----B
`----C
Transform expressions:
>>> from tt import to_primitives, to_cnf
>>> to_primitives('A xor B')
<BooleanExpression "(A and not B) or (not A and B)">
>>> to_cnf('(A nand B) impl (C or D)')
<BooleanExpression "(A or C or D) and (B or C or D)">
Evaluate expressions:
>>> b = BooleanExpression('(A /\ B) -> (C \/ D)')
>>> b.evaluate(A=1, B=1, C=0, D=0)
False
>>> b.evaluate(A=1, B=1, C=1, D=0)
True
Interact with expression structure:
>>> b = BooleanExpression('(A and ~B and C) or (~C and D) or E')
>>> b.is_dnf
True
>>> for clause in b.iter_dnf_clauses():
... print(clause)
...
A and ~B and C
~C and D
E
Exhaust SAT solutions:
>>> b = BooleanExpression('~(A or B) xor C')
>>> for sat_solution in b.sat_all():
... print(sat_solution)
...
A=0, B=1, C=1
A=1, B=0, C=1
A=1, B=1, C=1
A=0, B=0, C=0
Find just a few:
>>> with b.constrain(A=1): ... for sat_solution in b.sat_all(): ... print(sat_solution) ... A=1, B=0, C=1 A=1, B=1, C=1
Or just one:
>>> b.sat_one() <BooleanValues [A=0, B=1, C=1]>
Build truth tables:
>>> from tt import TruthTable
>>> t = TruthTable('A iff B')
>>> print(t)
+---+---+---+
| A | B | |
+---+---+---+
| 0 | 0 | 1 |
+---+---+---+
| 0 | 1 | 0 |
+---+---+---+
| 1 | 0 | 0 |
+---+---+---+
| 1 | 1 | 1 |
+---+---+---+
And much more!
License
tt uses the MIT License.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ttable-0.6.3.tar.gz.
File metadata
- Download URL: ttable-0.6.3.tar.gz
- Upload date:
- Size: 791.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44e05969e27ebdc8735f62dea4a2d597ab02cf3324498a15e184e5f15e3c0fba
|
|
| MD5 |
acdd100f33fcf9be0bf9fb44730db183
|
|
| BLAKE2b-256 |
c675636584f710d15e00eed102e0e8ffa0597972a58aed715bbe190b86e50878
|
File details
Details for the file ttable-0.6.3-cp36-cp36m-win_amd64.whl.
File metadata
- Download URL: ttable-0.6.3-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 78.6 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d6110ff3840844ee111cf24bd8a712e342e7d5494b67aa0e119bc6202dca83c
|
|
| MD5 |
a4b19dfaecaca807d1854ae83b58c0fc
|
|
| BLAKE2b-256 |
921dddf1923aed0cec459204aa44443b17dddece667e60f9b2ca56761a1fc2f8
|
File details
Details for the file ttable-0.6.3-cp36-cp36m-win32.whl.
File metadata
- Download URL: ttable-0.6.3-cp36-cp36m-win32.whl
- Upload date:
- Size: 72.8 kB
- Tags: CPython 3.6m, Windows x86
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
acbffa3dad481700e3ad3897304fec91bb32b0172cd98f2c5a342ad7260ab76f
|
|
| MD5 |
2e86c171b8ed7db9b78dd074060211b9
|
|
| BLAKE2b-256 |
8269f4c6e6a42f8c9d98acf6de09a960e644c2818b4eb010181afb336da16bf8
|
File details
Details for the file ttable-0.6.3-cp35-cp35m-win_amd64.whl.
File metadata
- Download URL: ttable-0.6.3-cp35-cp35m-win_amd64.whl
- Upload date:
- Size: 78.6 kB
- Tags: CPython 3.5m, Windows x86-64
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
798e1116aa12a1a957d6cd1d8ff90bde79253313bb5600ee155212e21c88f957
|
|
| MD5 |
e9a279dc885a17b5581387d9918a7a59
|
|
| BLAKE2b-256 |
9924630f5d1074f0573f2966f53330e5c05f062aed8f45c14abacc18e20c4f5b
|
File details
Details for the file ttable-0.6.3-cp35-cp35m-win32.whl.
File metadata
- Download URL: ttable-0.6.3-cp35-cp35m-win32.whl
- Upload date:
- Size: 72.8 kB
- Tags: CPython 3.5m, Windows x86
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f84ad26f4d9df708c6cba7bed4e0c0421edba46decb334305352741e08cf1dbe
|
|
| MD5 |
ad2bd8c1f65c69b776e823ad1b615222
|
|
| BLAKE2b-256 |
57ef1f4189ee5912949ac03a6306efc3a9012ff5bb16f3c0b5d5d29cdac06a00
|
File details
Details for the file ttable-0.6.3-cp34-cp34m-win_amd64.whl.
File metadata
- Download URL: ttable-0.6.3-cp34-cp34m-win_amd64.whl
- Upload date:
- Size: 83.5 kB
- Tags: CPython 3.4m, Windows x86-64
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16f83689dd95b4ee0bdc257582d9466ff7a69eab373b46ce349759eed9093eea
|
|
| MD5 |
4ccc74bd21954889c0baf4c466edf177
|
|
| BLAKE2b-256 |
0a72e56ec00f03da5ee4b050dfb253fb4390a554aa5d48742aa0b15e5ca9e1e3
|
File details
Details for the file ttable-0.6.3-cp34-cp34m-win32.whl.
File metadata
- Download URL: ttable-0.6.3-cp34-cp34m-win32.whl
- Upload date:
- Size: 77.0 kB
- Tags: CPython 3.4m, Windows x86
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
126cc6b27f1b54b2a77023df6eb934b2200f98084d1653a540acfe32dab5af94
|
|
| MD5 |
735dc64da6137e2502ac14212dd86e4b
|
|
| BLAKE2b-256 |
fb516f7bcdb65790089c37de167417ce54f41ae94aba94c988baf36938529989
|
File details
Details for the file ttable-0.6.3-cp33-cp33m-win_amd64.whl.
File metadata
- Download URL: ttable-0.6.3-cp33-cp33m-win_amd64.whl
- Upload date:
- Size: 83.5 kB
- Tags: CPython 3.3m, Windows x86-64
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23c6f25f3130e698abad96636bd87ad1a80000732965e2f5649fe04f67ea9faf
|
|
| MD5 |
302eb86dbf70b8013d3e6890ef250fa6
|
|
| BLAKE2b-256 |
dc8473749b02c01c989d15e494e058357703d766eb5e94c25a724c402b0dc0f7
|
File details
Details for the file ttable-0.6.3-cp33-cp33m-win32.whl.
File metadata
- Download URL: ttable-0.6.3-cp33-cp33m-win32.whl
- Upload date:
- Size: 77.0 kB
- Tags: CPython 3.3m, Windows x86
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adae38d3f2c3e3fecf6908ff542ae5a2619859cf63c04cb1ae7131f0020bdf0d
|
|
| MD5 |
c04c0cba1225476c29d24d90465aa30a
|
|
| BLAKE2b-256 |
089698f98f785faa6c8434b55e90c177c04bb56bb5a9ad84cd565399151fc105
|
File details
Details for the file ttable-0.6.3-cp27-cp27m-win_amd64.whl.
File metadata
- Download URL: ttable-0.6.3-cp27-cp27m-win_amd64.whl
- Upload date:
- Size: 82.0 kB
- Tags: CPython 2.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36f205fd576ba3902708ec01836786a99b84c93688ff6a04eefe09301e332252
|
|
| MD5 |
e593289f68ef4c972c27b15217314a97
|
|
| BLAKE2b-256 |
159f1d272c548f2cf3e6f3f09b67c584fd339e0ca08039ea14b5948596112ad9
|
File details
Details for the file ttable-0.6.3-cp27-cp27m-win32.whl.
File metadata
- Download URL: ttable-0.6.3-cp27-cp27m-win32.whl
- Upload date:
- Size: 75.5 kB
- Tags: CPython 2.7m, Windows x86
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d53470305d988a51df9a5509259ce5646ed29a5dfcbe95dc05f97da5cd77a0f7
|
|
| MD5 |
c0949725a4b64ea9f051391f98501a1e
|
|
| BLAKE2b-256 |
395df5451087f8b6b6573e18dc6000e032e8d8cb7ac06e61254817ee3b8193d6
|