Giter Club home page Giter Club logo

pykarnaugh's Introduction

PyKarnaugh

Boolean algebra simplifier based on n-dimensional k-maps

Usage

Define a boolean function ( $\{ 0,1 \} ^n \to \{ 0,1 \}$ ) in python, e.g. lambda a, b, c : not (a or (a and b)) and c, and pass it, along with its arity $n$ (that is, the number of its parameters) to the simplify function, which will return a string containing the result of the simplification, in disjunctive normal form.

Examples

k_user.py contains two examples: the half and full adder. As a simple usage example, here is the full adder (c is the input remainder):

arity = 3
out = lambda a, b, c : 1 if (a + b + c == 1) or (a + b + c == 3) else 0
remainder = lambda a, b, c : 1 if a + b + c >= 2 else 0

print("output:")
print(simplify(out, arity))
print("remainder:")
print(simplify(remainder, arity))

The output will be:

output:
(~A)(~B)C + (~A)B(~C) + A(~B)(~C) + ABC
remainder:
AB + AC + BC

pykarnaugh's People

Contributors

mell-o-tron avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.