Skip to main content

boolgen

boolgen is a Python library and command-line tool for generating and simplifying Boolean expressions from truth tables.

The library implements a version of the Quine-McCluskey method to perform the simplification. I created it to help with designing digital logic circuits from truth tables.

Installation

To install boolgen, use pip:

pip install boolgen

If you download the source, you can run the unit tests.

Command-Line Interface

The boolgen tool can be used from the command line to process truth tables stored in files and output simplified Boolean expressions.

Syntax

boolgen <input_file>
  • <input_file>: Path to the input file containing the truth table.

If no filename is provided, then boolgen will try to read the table from STDIN.

Example Input File

Create a file named input.txt with the following content:

A B C D= E=
0 0 0 0 1
0 0 1 1 0
0 1 0 1 0
1 0 0 1 0
1 1 1 0 1

Input and output variables can be identified with any alphanumeric string (including underscores). Output variables are identified by a pre- or postfix '='. If no output variable is explicitly declared, the last column in the table is assumed to be the output.

Output

boolgen will output the simplified Boolean expressions for each output variable in the truth table.

D = A | B & ~C
E = ~A & ~B & ~C | A & B & C

In degenerate cases, an output variable might be set to 0 or 1.

Library

You can also import boolgen into your own project. See the function definitions for an idea of how it all works.

Contributing

Contributions are welcome! Please fork the repository and submit pull requests.

License

This project is licensed under the MIT License. See LICENSE.md for details.

TBQH I used ChatGPT liberally when creating this module, so if you find your own code in here, please let me know so I can remove it or else attribute you properly.

Release files for boolgen 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for boolgen 1.1.0
File Size Uploaded
boolgen-1.1.0.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for boolgen 1.1.0
File Interpreter ABI Platform
boolgen-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.1 kB

Release files / boolgen-1.1.0.tar.gz

Download URL boolgen-1.1.0.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
32c371c43494ffb8e94cb2cd50298df84aacf5ec72b1bb7aac71ba9de2dc07d7
BLAKE2b-256 checksum
How to use checksums
1b4561272a9f20cece652a3303ede1e18d1f7998ff76a82c7c09f6b5ae569527
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.6

Release files / boolgen-1.1.0-py3-none-any.whl

Download URL boolgen-1.1.0-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c418c0c3395b038c04610fa34a99101806b05fce3510f75f9151ef315391de9
BLAKE2b-256 checksum
How to use checksums
3f422f6c6656fe417a9408585098d84acdcb692001f09d6b56ba3e33795e5c08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page