minbool
minbool is a small library for minimizing boolean expressions. It does this using the the Quine-McCluskey algorithm.
Simplify an Expression
>>> import minbool
>>> result = minbool.simplify("A and not C or A and C")
>>> result
<minbool.ASTBooleanExpression object at 0xb723606c>
>>> result.ast()
<_ast.Name object at 0xb722ef2c>
>>> str(result)
'A'
Synthesize an Expression
It is sometimes useful to synthesize a boolean expression from an existing function:
>>> def f(A, B, C, D): ... return A if B else C or D ... >>> result = minbool.synthesize(f, 'A', 'B', 'C', 'D') >>> result <minbool.BooleanExpression object at 0xb72361cc> >>> str(result) '(not(B) and D) or (not(B) and C) or (A and B)'
Command Line Use
The minbool egg installs a console script: ‘simplify’:
$ simplify A and B or A and C and not C (A and B)
Performance
Performance is big O exponential. In each case a truthtable is constructed, where the number of rows is 2**N, where N is the number of variables in the expression.
Metadata
Release files for minbool 1.0
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 |
|---|---|---|---|---|
| minbool-1.0.tar.gz | 13.0 kB | Without provenance | Details for minbool-1.0.tar.gz |
Release files / minbool-1.0.tar.gz
| Download URL | minbool-1.0.tar.gz |
|---|---|
| Size | 13.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b40a42dcfece39560da6134e9153a958748868e67ad2302870db7481a687c09c
|
|
BLAKE2b-256 checksum How to use checksums |
8965fff7b3ca25f41195e9b42336684360536b7991e1fbcfe92b8239b71b5e2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for minbool 1.0
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.