martinfinke / qm

The Quine-McCluskey Algorithm for Minimization of Boolean Functions. Ported to Haskell from Python.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The Quine-McCluskey Algorithm in Haskell

Ported to Haskell from the Python qm Package and the improved qm (including Petrick's method) by George Prekas.

Installation

From GitHub

git clone https://github.com/martinfinke/qm

From Hackage

cabal install qm

Installing Dependencies

cabal install --only-dependencies --enable-tests

Running the Tests

cabal test

Usage

Note: When showing terms, leading zeros are dropped. So 0-10 is shown as -10.

Set of Primes

Finding the set of all primes:

import Qm
let terms = Set.fromList $ map getTerm $ map fromString [
        "0010", "0101", "0110", "1011", "1100", "1110", "1111"
        ]
compute_primes terms -- fromList [-10, 101, -110, 1-11, 11-0, 111-]

Minimum Cover

Find the minimum cover for a list of minterms:

import Qm
let terms = map getTerm $ map fromString [
        "0010", "0101", "0110", "1011", "1100", "1110", "1111"
        ]
qm terms [] [] -- [-10,101,1-11,11-0]

License

See LICENSE file.

About

The Quine-McCluskey Algorithm for Minimization of Boolean Functions. Ported to Haskell from Python.

License:Other


Languages

Language:Haskell 100.0%