Skip to content
ComputeVerse.ai

Digital Logic DesignDesign workbench

Karnaugh Map Solver (2–5 Variables)

Click cells or enter minterms and watch the K-map group itself: exact Quine–McCluskey minimization drawn as highlighted groups, with the minimal SOP and POS and a proof of equivalence.

About this calculator

The Karnaugh map is the digital designer's geometric shortcut: arrange the truth table in Gray-code order so that logically adjacent minterms become physically adjacent cells, and minimization turns into spotting rectangles. This solver does the spotting for you — and does it exactly. The groupings are not heuristic: they come from a Quine–McCluskey minimization (with Petrick's method for the tie-breaking cover selection), so the picture and the algebra can never disagree, and the result is provably minimal two-level logic.

Click any cell to cycle it through 0 → 1 → × (don't-care) and the map re-groups live; every group is drawn with its own color, dash pattern, and legend entry stating the product term it represents and which variables it eliminated — a group of 2 removes one variable, 4 removes two, 8 removes three. Wrap-around adjacency (the map is a torus: edges and corners touch) is handled exactly like the textbooks promise, and five-variable problems render as the classic pair of four-variable maps that overlay each other.

Don't-cares are where K-maps earn their keep in real design — BCD inputs that never exceed 9, unused state codes — and the solver uses them the way the algorithm does: freely, wherever they enlarge a group, never as required outputs.

Every result is verified before it is shown: the minimized expression is expanded back against your truth table row by row, and the confirmation (or, if the impossible happens, an error) is part of the output. The worked solution walks the full Quine–McCluskey derivation — prime implicants, essential selection, cover — so the map, the algebra, and the method stay one story.

Design notes & common mistakes

  • Groups must be power-of-two rectangles (1, 2, 4, 8, 16 cells) in Gray-code adjacency — a 3-cell or L-shaped 'group' is the classic beginner error, and it corresponds to no single product term.
  • The map wraps: left edge touches right edge, top touches bottom, and the four corners are mutually adjacent. Missing the corner group is the most common hand-solving mistake at 4 variables.
  • Don't-cares are options, not obligations — include them in a group when they help, never chase covering them.
  • Two different minimal-cost covers can exist (the cyclic-map case). This solver returns one exact minimum; a hand solution with the same term and literal count is equally correct.

Assumptions

  • Two-level (SOP/POS) minimization of a single output — multi-output sharing and factoring beyond two levels are different problems.
  • Minimality is with respect to the standard cost order: fewest product terms first, then fewest literals.
  • Don't-cares are genuinely unspecified — if a 'can't happen' input actually can happen, its don't-care assignment becomes real behavior.

When to use this calculator

Appropriate for

  • Minimizing a Boolean function of 2–5 variables to exact minimal SOP or POS, with the groups shown on the map
  • Handling incompletely specified functions using don't-cares
  • Teaching K-map grouping and how it corresponds to algebraic minimization

Not suitable for

  • Functions of more than 5 variables, where the map stops being readable and tabular/heuristic methods take over
  • Multi-output minimization with shared terms, a different and harder optimization
  • Deriving a final netlist — two-level minimization says nothing about multi-level factoring, hazards, or technology mapping

What this calculator does not cover

  • 2 to 5 variables — beyond 5, maps stop being readable and tabular/heuristic methods (QM at larger scale, Espresso) take over; the 5-variable case is shown as the classic paired maps.
  • Single-output minimization only; sharing terms across multiple outputs is a different (harder) optimization.
  • Exact two-level minimization says nothing about multi-level factoring, hazards, or technology mapping — it is the starting point, not the netlist.
  • As with every calculator on this site: results are preliminary and educational, are not verified for any specific installation, and must be reviewed against the applicable code edition and stamped by a licensed Professional Engineer before real-world use.

Frequently asked questions

How are the groups chosen?

By the exact Quine–McCluskey algorithm: all prime implicants are derived, essential ones selected, and any remainder covered via Petrick's method with fewest-terms-then-fewest-literals cost. The map simply draws that cover, so the picture and the algebra always agree — and the result is re-verified against your truth table before it is displayed.

What do don't-cares (×) do?

They mark rows whose output you genuinely don't care about — unused BCD codes, impossible input combinations. The minimizer may count them as 1s when that enlarges a group (cheaper logic) and ignores them otherwise. They are never required to be covered.

Why is the column order 00, 01, 11, 10 instead of binary order?

That's Gray code: adjacent columns differ in exactly one bit, so physically neighboring cells are logically adjacent minterms — the property that makes rectangular groups correspond to product terms. Binary order would break adjacency between columns 01 and 10.

How does the 5-variable map work?

As two 4-variable maps, one for A = 0 and one for A = 1, imagined stacked on top of each other: cells at the same position in both maps are adjacent. A group that appears at the same spot in both maps eliminates A as well.

References

  • Mano, M. M. & Ciletti, M., Digital Design, 6th ed., Ch. 3 (K-maps, don't-cares) and the Quine–McCluskey treatment
  • Roth, C. H. & Kinney, L., Fundamentals of Logic Design, 7th ed. (map minimization, Petrick's method)
  • McCluskey, E. J., 'Minimization of Boolean Functions', Bell System Technical Journal 35 (1956)

Related calculators

Get the ComputeVerse.ai quick reference

A free engineering quick-reference PDF, plus a note when new calculators launch across the library — one or two emails a month, nothing else.