Skip to main content

Implementation of Quine-McCluskey algorithm for minimizing boolean expressions.

Project description

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.

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minbool-1.0.tar.gz (13.0 kB view details)

Uploaded Source

File details

Details for the file minbool-1.0.tar.gz.

File metadata

  • Download URL: minbool-1.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for minbool-1.0.tar.gz
Algorithm Hash digest
SHA256 b40a42dcfece39560da6134e9153a958748868e67ad2302870db7481a687c09c
MD5 cd2fe4b4184ee2649aa209b4ca27ee6d
BLAKE2b-256 8965fff7b3ca25f41195e9b42336684360536b7991e1fbcfe92b8239b71b5e2c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page