A library for generating and simplifying Boolean expressions from truth tables
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 boolgen-1.1.0.tar.gz.
File metadata
- Download URL: boolgen-1.1.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32c371c43494ffb8e94cb2cd50298df84aacf5ec72b1bb7aac71ba9de2dc07d7
|
|
| MD5 |
5d5e15b57c7bf090ded2b89d336e8435
|
|
| BLAKE2b-256 |
1b4561272a9f20cece652a3303ede1e18d1f7998ff76a82c7c09f6b5ae569527
|
File details
Details for the file boolgen-1.1.0-py3-none-any.whl.
File metadata
- Download URL: boolgen-1.1.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c418c0c3395b038c04610fa34a99101806b05fce3510f75f9151ef315391de9
|
|
| MD5 |
5f57fee686c6ed9901d2a0239de75f1c
|
|
| BLAKE2b-256 |
3f422f6c6656fe417a9408585098d84acdcb692001f09d6b56ba3e33795e5c08
|