Karnaugh maps
Simplifying a Boolean function by hand is one of those things that look easy and get complicated fast. In 1953 Maurice Karnaugh, an engineer at Bell Labs, proposed a more intuitive way to do it: arrange the truth table on a grid where simplifying becomes finding patterns.
That grid is what we now call a Karnaugh map (or K-Map). Karnaugh started from a diagram Edward Veitch had published a year earlier; his contribution was to reorder the rows and columns so the patterns would jump out.
Why a map, if there are already laws and theorems to simplify?
Good question. With two or three variables Boolean algebra works fine. The trouble starts when the function grows: you have to decide which law to apply, in what order and to which terms, and nothing tells you that you are heading the wrong way.
It is easy to make a mistake, and even easier to get stuck with an expression you no longer know how to reduce, without knowing whether it is the minimal one. The map solves exactly that: it gives you a visual procedure and, for a few variables, it guarantees you reach the minimal expression (as a sum of products or as a product of sums).
# What you will find
The guide has four parts. First, how the map is built, which is where the Gray code comes in; then how the cells are grouped to get the minimal expression; then what to do with 5 or more variables; and finally Mahoney maps, another way to arrange the same map. Every part has animations and examples you can play with.
Building the map
The Gray code, rotary encoders, how the cells are laid out and why the edges of the map touch.
Grouping
Why grouping simplifies, the rules with examples, typical mistakes and how to group zeros.
Maps of 5 or more variables
4-variable sub-maps, how to group across them and why the full map mirrors them.
# References
M. Karnaugh, "The Map Method for Synthesis of Combinational Logic Circuits", Transactions of the AIEE, Part I, vol. 72, no. 5, pp. 593-599, 1953.
F. Gray, "Pulse code communication", US patent 2,632,058, 1953.
Karnaugh map and Gray code, Wikipedia.
# Third-party software
For large functions the solver uses Espresso, the logic minimizer of the University of California, Berkeley (version 2.3, part of Oct Tools 3.0), developed by R. Brayton, G. Hachtel, C. McMullen, A. Sangiovanni-Vincentelli and R. Rudell. It was compiled to WebAssembly from the copy bundled with PyEDA (Chris Drake). Its license requires every distribution of Espresso or of derivative works to include this notice:
Oct Tools Distribution 3.0 Copyright (c) 1988, 1989, Regents of the University of California. All rights reserved. Use and copying of this software and preparation of derivative works based upon this software are permitted. However, any distribution of this software or derivative works must include the above copyright notice. This software is made available AS IS, and neither the Electronics Research Laboratory or the University of California make any warranty about the software, its performance or its conformity to any specification.
Reference: R. Brayton, G. Hachtel, C. McMullen and A. Sangiovanni-Vincentelli, Logic Minimization Algorithms for VLSI Synthesis, Kluwer Academic Publishers, 1984.
The page also uses these libraries, all under the MIT license:
- .NET and Blazor WebAssembly: Copyright (c) .NET Foundation and Contributors.
- MudBlazor and MudBlazor.ThemeManager: Copyright (c) 2021 MudBlazor.
- Bootstrap 5.3.3: Copyright 2011-2024 The Bootstrap Authors.
- Prism 1.23.0: Copyright (c) 2012 Lea Verou.
- Emscripten: Copyright (c) 2010-2014 Emscripten authors (its runtime is part of espresso.js and reducer.js; it is also available under the University of Illinois/NCSA license).
- KaTeX: Copyright (c) 2013-2020 Khan Academy and other contributors (loaded from jsDelivr).
Text of the MIT license, shared by all of them:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
