Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

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)

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 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


Download files

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

Files for minbool, version 1.0
Filename, size File type Python version Upload date Hashes
Filename, size minbool-1.0.tar.gz (13.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page