Karnaugh Map Solver

Solve a Karnaugh map for 2 to 6 variables with don't cares. Click cells or enter minterms or an expression to get the minimal SOP and POS, colour-coded groups and every prime implicant.

Privacy: solved in your browser; nothing is sent or stored.

Separated by commas. The first is the most significant bit of the cell number.
Enter the function

Tap a cell to cycle it through 0 → 1 → X (don't care). The small number in each cell is its minterm number.

Groups shown on the map

Tap a group to outline its cells. Coloured dots in each cell show which groups cover it.

Prime implicants (working)

TermPatternCellsEssential

An essential prime implicant is the only group that covers some cell, so every minimal answer must use it. The remaining cells are covered with the fewest extra groups, then the fewest literals, by searching every combination (Petrick's method).

How to use the Karnaugh map solver

  1. Choose 2 to 6 variables and, if you like, rename them (for example x, y, z).
  2. Fill the map: tap cells to cycle 0 → 1 → X, type the minterm numbers and don't cares, or type an expression.
  3. Read the minimal SOP and POS. The coloured groups on the map match the terms, and POS: groups of 0s switches the map to the product-of-sums grouping.

How a K-map works

A Karnaugh map lays out the truth table so that cells next to each other differ in exactly one variable. Rows and columns are numbered in Gray code (00, 01, 11, 10), and the map wraps around: the left edge touches the right edge and the top touches the bottom. A group of 1, 2, 4, 8 or 16 adjacent cells drops the variables that change inside it, so bigger groups give shorter terms.

For 5 variables the solver draws two 4 × 4 maps, one for A = 0 and one for A = 1; for 6 variables it draws four, for AB = 00, 01, 11 and 10. A cell is adjacent to the cell in the same position on the neighbouring map, so a group can span maps.

How the answer is found

Grouping by eye can miss the best answer on large or tricky maps. This solver uses the Quine–McCluskey method to list every prime implicant (a group that cannot be made any bigger), keeps the essential ones, and then searches every combination of the rest (as in Petrick's method) for the cover with the fewest terms and then the fewest literals. When several covers tie, all of them are listed, up to 12. Don't-care cells are used only when they make a group bigger.

Frequently asked questions

What is the difference between the SOP and POS answers?

The SOP (sum of products) groups the 1s and reads each group as an AND term. The POS (product of sums) groups the 0s and reads each group as an OR term with the literals complemented. Both describe the same function; pick whichever needs fewer gates.

Which cell is which minterm?

Each cell shows its minterm number in the corner. The number is the row of the truth table, with the first variable as the most significant bit: for A, B, C, D the cell A = 1, B = 0, C = 1, D = 1 is 1011 in binary, minterm 11.

Why do the groups differ from my textbook?

When a function has more than one minimal answer, any of them is correct. Check the list of equally small answers under the minimal SOP or POS.

Can I share or save a map?

Use Copy link. The map is stored in the part of the link after #, which is not sent to our server.

Related tools

References

  • M. Karnaugh, “The map method for synthesis of combinational logic circuits”, Transactions of the AIEE, Part I 72 (1953) 593–598.
  • W. V. Quine, “The problem of simplifying truth functions”, American Mathematical Monthly 59 (1952) 521–531.
  • E. J. McCluskey, “Minimization of Boolean functions”, Bell System Technical Journal 35 (1956) 1417–1444.
  • S. R. Petrick, “A direct determination of the irredundant forms of a Boolean function from the set of prime implicants”, AFCRC report TR-56-110 (1956).