Karnaugh Map Solver

Group a 2- to 6-variable map yourself and have every group marked right or wrong.

Variables

A Karnaugh map is drawn for 2 to 6 variables. Changing this keeps every minterm that still exists.

Variable names

rows AB · cols CD

Comma-separated. Results update as you type.

Input combinations that cannot occur, or whose output nobody cares about.

Editing mode

Draw your own groups and have each one graded. Cell values are locked.

Grade groups of

Groups hold 1s and don’t-cares, and each one becomes a product term.

Start from a worked example

To start a group, press Space on a cell. Use the arrow keys to move and Shift with an arrow key to extend the group across the map edges. Press Enter to create the group, or Escape to cancel.

Press and drag across the 1s you want to circle — or tap one cell, then tap the far corner. From the keyboard, press Space on a cell, extend with Shift and the arrow keys, and press Enter to create the group.

Next stepyour cover: 0 terms / 0 literals · minimum: 3 terms / 7 literals

Draw a group: press and drag across the 1s you want to circle, or press Space on a cell and use the arrow keys.

No groups yet. Every 1 has to end up in at least one group, groups hold a power-of-two number of cells, and they may overlap freely — and usually must.

The answer, and how it is read off the map

Minimal SOP

B′ · C′ + B′ · D′ + A′ · C′ · D

3 terms, 7 literals, 10 gate inputsExact minimumChecked against all 16 input combinations.
Minimal SOP — group by group
CellsConstantChanging (drops out)Term
0, 1, 8, 9B = 0, C = 0A, DB′ · C′
0, 2, 8, 10B = 0, D = 0A, CB′ · D′
1, 5A = 0, C = 0, D = 1BA′ · C′ · D

Minimal POS

(C′ + D′) · (B′ + D) · (A′ + B′)

3 terms, 6 literals, 9 gate inputsExact minimumChecked against all 16 input combinations.
Minimal POS — group by group
CellsConstantChanging (drops out)Term
3, 7, 11, 15C = 1, D = 1A, BC′ + D′
4, 6, 12, 14B = 1, D = 0A, CB′ + D
12, 13, 14, 15A = 1, B = 1C, DA′ + B′

Notation and operator precedence used here

Terms are written with · for AND, + for OR and a prime for NOT: B′ · C′ is “B is 0 and C is 0”. In the expression input, + is OR, juxtaposition is AND, ' is NOT, ^ is XOR, -> is implication and <-> is the biconditional. Precedence runs, highest to lowest, ( ) → NOT → AND → XOR/XNOR → NAND/NOR → OR → IMPLIES → IFF, and the fully parenthesised reading is echoed back so the parse is never in doubt.

Minterm numbering. The variable order is most-significant-bit first, so over A B C D the minterm index of A=1, B=0, C=0, D=1 is 9. Reorder the variable chips and every index changes; the map reprints the axis assignment (rows AB · cols CD) underneath so the axes are never a surprise.

The maxterm convention, for POS. In a sum term a variable appears complemented where its bit is 1 — so over A B C, M₅ (binary 101) is (A′ + B + C′), not (A + B′ + C). In POS mode the map grades groups of 0sand don't-cares.

The grouping rules, complete

  1. A group holds a power-of-two number of cells. 1, 2, 4, 8 and 16 — and the large ones are the ones that produce short answers. A tool that lists only 1, 2 and 4 has omitted exactly the groups that give single-literal and constant results.
  2. A group must be a rectangle on the torus. The edges wrap, top to bottom and left to right, so the four corners of a four-variable map are one legal group of four.
  3. Groups may overlap freely, and usually must. Covering a 1 twice costs nothing. On the majority map the triple overlap is forced by the geometry.
  4. Take the largest legal group first. Each doubling of a group removes exactly one literal from its term, so a bigger group is always a cheaper term.
  5. A group made only of don’t-cares is legal and useless. It is a real implicant, but it adds a term to the answer while covering nothing the function requires. The tool flags it rather than rejecting it.
  6. Every 1 must end up in at least one group. That is what makes the set of groups a cover. The verdict panel names any 1 that is still in no group.

Every group you draw is graded against those rules one at a time, and an illegal selection is told which rule it broke and what would fix it — a three-cell selection is offered the two legal sizes either side of it, and a non-rectangular one is offered the cells that would complete its hull.

Why the columns are labelled 00, 01, 11, 10

That is reflected Gray code, G(i) = i ⊕ (i ≫ 1), and it buys exactly one property: adjacent cells differ in one variable. That is precisely the condition under which A·B + A·B′ = A applies, so a group of two is one use of the adjacency law, a group of four is two, and a group of eight is three. Label the axes in plain binary order and the groups stop being rectangles. The Gray code converter shows the reflection that generates the order.

Every map size, with a live map

Two to six variables, each with the function that makes that size worth understanding. These are anchors on this page rather than separate pages, because one concept fragmented across five URLs splits its own authority and teaches the reader nothing extra.

2-variable Karnaugh map

Four cells. The pair {1, 3} is one group of two, and the variable that changes across it drops out.

Press Space or Enter on a cell to cycle its value between 0, 1 and don’t-care. Use the arrow keys to move; both axes wrap, because the map is a torus.

Minimal SOP

B

1 term, 1 literal, 0 gate inputsExact minimumChecked against all 4 input combinations.
2-variable Karnaugh map: Minimal SOP — group by group
CellsConstantChanging (drops out)Term
1, 3B = 1AB

Minimal POS

B

1 term, 1 literal, 0 gate inputsExact minimumChecked against all 4 input combinations.
2-variable Karnaugh map: Minimal POS — group by group
CellsConstantChanging (drops out)Term
0, 2B = 0AB

3-variable Karnaugh map

The 3-input majority function. Cell 7 is covered three times and the triple overlap is forced, not stylistic — there is no group of four.

Press Space or Enter on a cell to cycle its value between 0, 1 and don’t-care. Use the arrow keys to move; both axes wrap, because the map is a torus.

Minimal SOP

B · C + A · C + A · B

3 terms, 6 literals, 9 gate inputsExact minimumChecked against all 8 input combinations.
3-variable Karnaugh map: Minimal SOP — group by group
CellsConstantChanging (drops out)Term
3, 7B = 1, C = 1AB · C
5, 7A = 1, C = 1BA · C
6, 7A = 1, B = 1CA · B

Minimal POS

(A + B) · (A + C) · (B + C)

3 terms, 6 literals, 9 gate inputsExact minimumChecked against all 8 input combinations.
3-variable Karnaugh map: Minimal POS — group by group
CellsConstantChanging (drops out)Term
0, 1A = 0, B = 0CA + B
0, 2A = 0, C = 0BA + C
0, 4B = 0, C = 0AB + C

4-variable Karnaugh map

The four corners. One group of four that wraps both edges, which is the shape that proves the map is a torus.

Press Space or Enter on a cell to cycle its value between 0, 1 and don’t-care. Use the arrow keys to move; both axes wrap, because the map is a torus.

Minimal SOP

B′ · D′

1 term, 2 literals, 2 gate inputsExact minimumChecked against all 16 input combinations.
4-variable Karnaugh map: Minimal SOP — group by group
CellsConstantChanging (drops out)Term
0, 2, 8, 10B = 0, D = 0A, CB′ · D′

Minimal POS

D′ · B′

2 terms, 2 literals, 2 gate inputsExact minimumChecked against all 16 input combinations.
4-variable Karnaugh map: Minimal POS — group by group
CellsConstantChanging (drops out)Term
1, 3, 5, 7, 9, 11, 13, 15D = 1A, B, CD′
4, 5, 6, 7, 12, 13, 14, 15B = 1A, C, DB′

5-variable Karnaugh map

Two planes, A = 0 and A = 1. The same four cells on both planes are one group of eight spanning the stack — a group a single 4 × 8 strip could not draw.

Press Space or Enter on a cell to cycle its value between 0, 1 and don’t-care. Use the arrow keys to move; both axes wrap, because the map is a torus.

A = 0
A = 1

Minimal SOP

B′ · D′

1 term, 2 literals, 2 gate inputsExact minimumChecked against all 32 input combinations.
5-variable Karnaugh map: Minimal SOP — group by group
CellsConstantChanging (drops out)Term
0, 1, 4, 5, 16, 17, 20, 21B = 0, D = 0A, C, EB′ · D′

Minimal POS

D′ · B′

2 terms, 2 literals, 2 gate inputsExact minimumChecked against all 32 input combinations.
5-variable Karnaugh map: Minimal POS — group by group
CellsConstantChanging (drops out)Term
2, 3, 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31D = 1A, B, C, ED′
8, 9, 10, 11, 12, 13, 14, 15, 24, 25, 26, 27, 28, 29, 30, 31B = 1A, C, D, EB′

6-variable Karnaugh map

Four planes in a 2 × 2 stack, so the AB 4-cycle is visible. Cells in the same position on adjacent planes are adjacent.

Press Space or Enter on a cell to cycle its value between 0, 1 and don’t-care. Use the arrow keys to move; both axes wrap, because the map is a torus.

AB = 00
AB = 01
AB = 11
AB = 10

Minimal SOP

C′ · D′

1 term, 2 literals, 2 gate inputsExact minimumChecked against all 64 input combinations.
6-variable Karnaugh map: Minimal SOP — group by group
CellsConstantChanging (drops out)Term
0, 1, 2, 3, 16, 17, 18, 19, 32, 33, 34, 35, 48, 49, 50, 51C = 0, D = 0A, B, E, FC′ · D′

Minimal POS

D′ · C′

2 terms, 2 literals, 2 gate inputsExact minimumChecked against all 64 input combinations.
6-variable Karnaugh map: Minimal POS — group by group
CellsConstantChanging (drops out)Term
4, 5, 6, 7, 12, 13, 14, 15, 20, 21, 22, 23, 28, 29, 30, 31, 36, 37, 38, 39, 44, 45, 46, 47, 52, 53, 54, 55, 60, 61, 62, 63D = 1A, B, C, E, FD′
8, 9, 10, 11, 12, 13, 14, 15, 24, 25, 26, 27, 28, 29, 30, 31, 40, 41, 42, 43, 44, 45, 46, 47, 56, 57, 58, 59, 60, 61, 62, 63C = 1A, B, D, E, FC′

Five and six variables

Above four variables the map becomes 2 or 4 planes of a four-variable map, never one wide strip. With three bits on one axis, 6 of the 27 subcubes are not contiguous runs and 4 contiguous runs are not subcubes — so a strip would both reject legal groups and accept illegal ones. Cells in the same position on adjacent planes are adjacent, which is what makes the eight-cell group in the five-variable example above a single term.

Don’t-care conditions

A don't-care is an input combination that cannot occur, or one whose output nobody cares about. Read each as 1 exactly when doing so enlarges a group you already need, and never make a group that contains only don't-cares: it is a legal implicant that adds a term while covering nothing the function requires. The engine enforces both halves of that — it flags a don't-care-only group, and it drops prime implicants that cover no ON-set minterm before the chart is built, which is a real failure mode of the naive algorithm.

Every result restates which don't-cares were read as 1 and which were left as 0, because two covers of identical cost can disagree about a don't-care and printing that difference is what makes them comprehensible.

Prime, essential, irredundant, minimum: four different words

  • Prime — the group cannot be doubled.
  • Essential — it is the only group that can cover some 1. That 1 is its distinguishing cell, and the map marks it.
  • Irredundant — no group in your cover can be deleted.
  • Minimum — no cover costs less.

An irredundant cover can still have more terms than the minimum. Conflating the two is a mistake several published tools make, and it is why the verdict here distinguishes “complete and irredundant, but not minimum” from “correct”.

Why your answer can differ from the book’s and still be right

The map opens on Σm(0, 1, 2, 5, 8, 9, 10) over A B C D. It has 3 prime implicants, 3 of them essential, and exactly one minimum cover: minimal SOP B′ · C′ + B′ · D′ + A′ · C′ · D, minimal POS (C′ + D′) · (B′ + D) · (A′ + B′). Those numbers come from the engine at build time, not from a template.

Other functions are not so tidy. Σm(0, 1, 2, 5, 6, 7) over three variables has six prime implicants, noneessential, and two equally minimal covers — the chart is cyclic, which is exactly the case Petrick's method exists for. When that happens this page shows every cover and says so in the verdict, because a student whose grouping differs from the tool's but costs the same is right and should be told so.

Limits, stated plainly

A Karnaugh map is drawn for 2 to 6 variables. Above six, every axis would need three bits, and on a three-bit Gray axis a rectangle and a subcube stop being the same thing — so the map would reject legal groups and accept illegal ones. Use Quine–McCluskey instead.

Within those two to six variables the minimisation is exact, not heuristic. Enumeration of equally minimal covers stops at 200 displayed and 200 counted, and the badge says so when it stops rather than printing a number the engine did not prove. Worst-case prime-implicant count grows as Θ(3ⁿ/√n), which is why the limits exist and why they are printed rather than hidden.

Worked examples

Worked examples

Sources

  • Karnaugh, Maurice. “The Map Method for Synthesis of Combinational Logic Circuits.” Transactions of the AIEE, Part I 72, no. 5 (November 1953): 593–599. doi:10.1109/TCE.1953.6371932.
  • Veitch, Edward W. “A Chart Method for Simplifying Truth Functions.” In Proceedings of the 1952 ACM National Meeting (Pittsburgh), 127–133. New York: ACM, 1952. doi:10.1145/609784.609801.
  • Quine, Willard V. “The Problem of Simplifying Truth Functions.” The American Mathematical Monthly 59, no. 8 (October 1952): 521–531. doi:10.2307/2308219.
  • McCluskey, Edward J. “Minimization of Boolean Functions.” The Bell System Technical Journal 35, no. 6 (November 1956): 1417–1444. doi:10.1002/j.1538-7305.1956.tb03835.x.
  • Petrick, Stanley R. A Direct Determination of the Irredundant Forms of a Boolean Function from the Set of Prime Implicants. Technical Report AFCRC-TR-56-110. Bedford, MA: Air Force Cambridge Research Center, April 1956.
  • Chandra, Ashok K., and George Markowsky. “On the Number of Prime Implicants.” Discrete Mathematics 24, no. 1 (1978): 7–11. doi:10.1016/0012-365X(78)90168-1 — the Θ(3ⁿ/√n) bound quoted under Limits.
  • Gray, Frank. Pulse Code Communication. US Patent 2,632,058, filed 13 November 1947, issued 17 March 1953 — the reflected binary code the axes are labelled in.