ToolSphere

Karnaugh Map Solver

Computer science

Simplify a Boolean function on a 2, 3 or 4-variable Karnaugh map. Toggle minterms and copy the minimum sum-of-products expression instantly.

Karnaugh map solver

Click cells to mark them as 1 (true). The minimized sum-of-products expression updates automatically using Quine-McCluskey minimization.

Variables:
AB\CD00011110
00
01
11
10
Minimized sum of products
F = A'C' + BC'

On this browser only

Give feedback

Did this tool help?

Tell us what worked, what didn’t, or what you’d like next.

Opens Google Forms in a new tab with this tool’s name filled in. No sign-in or email required. Feedback is optional.

How to use Karnaugh Map Solver

  1. 1Choose two, three or four variables. Changing the variable count clears the selected cells.
  2. 2Find each required minterm using the small m-number in its cell; the map axes use Gray code order.
  3. 3Click every cell where the function should equal 1. Click again to return a cell to 0.
  4. 4Read the minimum sum-of-products expression below the map. A prime mark means NOT, adjacent letters mean AND and + means OR.
  5. 5Copy the expression and verify it against the original truth table. Unselected cells are strict zeros; this interface has no don’t-care state.

About Karnaugh Map Solver

Simplify a Boolean function with a Karnaugh map

This K-map solver turns a set of true input combinations into a minimum sum-of-products expression. Choose a two-, three- or four-variable map, click the cells that should produce a true output, and read the expression below it. The result updates after each click, which makes it useful for checking digital logic homework or exploring how a pattern of minterms simplifies.

The interface starts with a four-variable example. It labels the variables A, B, C and D and shows each cell's minterm number beneath its current value. You can copy the resulting expression with the copy control. The map does not draw grouping loops or show a sequence of hand-simplification steps; use the result alongside your own grouping diagram when your assignment requires the working.

Read the map axes and minterm numbers

A truth table normally lists input combinations in binary counting order. A Karnaugh map rearranges those combinations into Gray code order so neighboring cells differ in only one variable. Where an axis has two bits, its labels read 00, 01, 11, 10. Do not enter cells by counting across the screen as if the columns were ordinary binary order.

For two variables, the row is A and the column is B. For three variables, the row is A and the columns are BC. For four variables, the rows are AB and the columns are CD. In every case A is the most significant bit of the minterm number. The small m-label is the quickest way to match a list from a textbook with the right cells.

The map has 4, 8 or 16 cells for two, three or four variables respectively. Changing the variable count clears the selection, so choose the size before entering a function. An unselected cell means a required zero, rather than a value the solver is free to ignore.

The sum-of-products notation

A product term combines literals with AND. A literal is a variable or its complement, so A'C means NOT A AND C. A sum joins product terms with OR, so A'C + BC means that either product may make the output true. The prime mark after a letter means complement; it is unrelated to the derivative notation used in calculus.

A hand grouping eliminates variables that change inside a valid group. The solver computes prime implicants with Quine–McCluskey and searches their covers exactly. Its objective is the fewest product terms, then the fewest literals among covers with that term count. If several covers tie, the displayed expression is one valid optimum rather than a list of every equivalent answer.

This objective concerns a sum-of-products formula. It does not optimize an arbitrary multilevel circuit, account for available gate packages or produce a product-of-sums form. A factored implementation can look different while expressing the same function.

Worked example: the default four-variable map

The default selected minterms are 0, 1, 4, 5, 12 and 13. The following binary assignments and the resulting expression were checked using the tool's Boolean libraries. All other input combinations must produce zero.

Minterm ABCD Required output
m0 0000 1
m1 0001 1
m4 0100 1
m5 0101 1
m12 1100 1
m13 1101 1

The minimum result is F = A'C' + BC'. The first term covers minterms 0, 1, 4 and 5; the second covers 4, 5, 12 and 13. Overlap is allowed, so the shared cells do not cause a problem. D disappears because changing D never changes the required output within either group.

Compare the formula with your own grouping before copying it into a report. In particular, check that each product covers only selected cells and that every selected cell is covered by at least one product. Those two checks establish the required truth table even when the expression's term order differs from your answer.

Wrap-around adjacency and common mistakes

The left and right edges are adjacent, as are the top and bottom edges where the axis has multiple rows. Corners may therefore belong to the same rectangular wrap-around group. Diagonal contact alone is not adjacency. When checking a map by hand, use rectangular groups whose cell counts are powers of two and avoid groups that contain a required zero.

Do not treat a blank-looking or unclicked cell as a don't-care. This interface toggles only between zero and one; there is no X entry. It also accepts input through cell clicks, not by pasting a minterm list or entering a Boolean formula. Retain your original list separately so you can check the selection after editing.

Selecting no cells yields F = 0, while selecting every cell yields F = 1. These are constant functions and need no variable terms. For ordinary functions, a different-looking expression may still be equivalent, especially when multiple minimum covers exist.

Verify the result and continue

Use the truth table generator to compare a formula with the selected minterms. Its NOT syntax is prefix ! rather than an apostrophe, so translate A'C' + BC' to !A*!C + B*!C and omit the leading F = when entering it. The truth-table interface does not automatically import the map selection.

For the reasoning behind the layout, read the Karnaugh map simplification guide. To review the operators individually, try the logic gate simulator or the logic gates and truth tables guide.

Guides and tutorials

Frequently asked questions

How do I use this K-map calculator?

Choose the variable count and click the minterms where the output should be true. The sum-of-products result updates automatically below the map.

Does it support two-, three- and four-variable maps?

Yes, those are the available sizes. Switching size clears the existing selection, so set it before entering your minterms.

Can I enter don’t-care conditions?

No, each cell is either zero or one. Every unselected cell is treated as a required zero, so do not use this interface as an X-enabled map.

Why are the columns ordered 00, 01, 11, 10?

This is Gray code order. It makes neighboring combinations differ in one bit and preserves the logical adjacency used for grouping.

Does the solver show grouping loops?

It displays the selected cells and the minimum expression, but does not draw grouping loops. Use your own annotated map when your course requires a visual derivation.

What do apostrophes and plus signs mean?

An apostrophe complements the preceding variable, adjacent letters mean AND, and + means OR. For example, A’B is true when A is false and B is true.

Can the edges of a Karnaugh map be grouped together?

Yes, opposite edges are adjacent under the Gray code arrangement. A diagonal pair alone is not a valid adjacent group.

Why does my answer look different from the solver’s?

A function can have multiple equivalent expressions, including multiple covers with the same minimum cost. Compare the truth tables before deciding that a different term order or grouping is wrong.

Does it return SOP or POS?

It returns sum of products, with minimum term count and then minimum literal count. It has no product-of-sums output mode.

Can I paste the answer into the truth table generator?

Translate complemented literals into prefix NOT syntax, such as A’ into !A, and remove F = first. The truth table generator does not accept apostrophe notation directly.

Have a suggestion for Karnaugh Map Solver?Share your feedback ↗