Skip to main content

Demonstration of the Quine-McCluskey algorithm for educational purposes

Project description

teachmeqmc

This package contains an implementation of the Quine-McCluskey algorithm and serves to educational purposes.

Its main goal is to produce a LaTeX document with detailed description of the performing of the Quine-McCluskey algorithm for a given input; the input is represented by a complete Disjunctive Normal Form (shortly DNF) which may contain duplicate minterms.

The motivation to write this program was to provide university students with automatically generated examples for better understanding the Quine-McCluskey algorithm and, furthermore, to randomly generate examen tests on this subject together with their detailed solutions to make the corrections of the tests easier.

Installation

Install the package from PyPI utilizing the pip module:

python -m pip install teachmeqmc

Example

A simple program using this package may look like this:

    from teachmeqmc import BooleanFunction

    f = BooleanFunction(4)
    f.addTerm((0, 0, 0, 0))
    f.addTerm((0, 0, 0, 1))
    f.addTerm((0, 0, 1, 0))
    f.addTerm((0, 0, 1, 1))
    f.addTerm((0, 1, 0, 0))
    f.addTerm((1, 1, 0, 0))
    f.addTerm((1, 1, 0, 1))
    f.addTerm((1, 0, 0, 1))
    f.addTerm((1, 0, 0, 1))

    f.performQuineMcCluskey()

    f.show()
    f.saveToTextFile("output.txt")
    f.saveToLaTeXFile("output.tex")

The program first imports the class BooleanFunction. Then it creates a new instance f of the class BooleanFunction which represents a Boolean function (a mapping from {0,1}^n to {0,1}) defined by its complete DNF. The parameter 4 gives the number of the inputs of the Boolean function.

Further, by calling the method addTerm it is defined by which minterms the complete DNF of the Boolean function is given; for example f.addTerm((0, 0, 1, 0)) states that the minterm a'b'cd' shall be a part of the defining complete DNF. Observe that the last two minterms are identical. However, both will be part of the defining complete DNF and in the output report it will be visualised that one of these terms has to be removed.

Then the Quine-McCluskey algorithm is performed; this method does not return anything, instead, it stores the result of the procedure to the attributes of BooleanFunction.

Finally, calling show prints the report on the processing of the Quine-McCluskey algorithm to the terminal output, calling saveToTextFile saves it to a plain text file, and calling saveToLaTeXFile saves it to a LaTeX file which can be further compiled to a PDF file e.g. by pdflatex.

Remark that also single parts of the report may be obtained. For such an output, see the methods of the class BooleanFunction in the form export...ToLaTeX and export...ToText.

Project details


Download files

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

Source Distribution

teachmeqmc-0.1.0.tar.gz (33.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

teachmeqmc-0.1.0-py3-none-any.whl (37.0 kB view details)

Uploaded Python 3

File details

Details for the file teachmeqmc-0.1.0.tar.gz.

File metadata

  • Download URL: teachmeqmc-0.1.0.tar.gz
  • Upload date:
  • Size: 33.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2

File hashes

Hashes for teachmeqmc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0e43e202d64f705079c577f752cdf0845201cc22a9cd676fd88e89f4390197f5
MD5 1e19a9aa02e669205bcf44d12387163d
BLAKE2b-256 34cdf39588028326b5fcd21ea39b8e407ca70688a687addc5367b58d709ec29d

See more details on using hashes here.

File details

Details for the file teachmeqmc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: teachmeqmc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 37.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2

File hashes

Hashes for teachmeqmc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 335ae9e87955894d0244f89cd345b8ea256755959ea95f54201fba0a7e6a5d81
MD5 fd378cf4594be1d7fa9a9d25d0c5ea9d
BLAKE2b-256 7aa77507199ca4e908189457c03c35759bbf467a02482afb1d8cdce6aa1c9e04

See more details on using hashes here.

Supported by

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