Skip to content
KmapGen

How to Solve a K-Map, Step by Step

Updated 2026-11-22 · 9 min read

A Karnaugh map turns Boolean simplification into a pattern-spotting exercise. The method below works for 2 to 6 variables and always gives a correct answer; with a little care it gives a minimal one. Three worked examples follow, including one with two correct answers.

The method in six steps

  1. Write the function as a list of minterms. Turn the truth table or expression into the list of rows where F = 1 (Σm), plus any don’t-cares.
  2. Draw the map with Gray-code labels. Use a 2×2, 2×4 or 4×4 grid (two or four grids for 5 or 6 variables) and label rows and columns 00, 01, 11, 10.
  3. Fill in the cells. Put a 1 in each minterm’s cell, an X in each don’t-care cell and 0 everywhere else.
  4. Circle the essential groups first. Find 1s that can be covered by only one largest possible group and circle that group. Groups are rectangles of 1, 2, 4, 8 or 16 cells and may wrap around the edges.
  5. Cover the remaining 1s with as few, as large groups as possible. Every 1 must be inside at least one group; groups may overlap; never add a group whose 1s are all already covered.
  6. Write one term per group and OR them. In each group keep the variables that do not change: plain if they are 1, complemented if they are 0. The sum of these terms is the minimal SOP.

Why it works

Two cells that touch on a K-map differ in exactly one variable, because the labels follow the Gray code (00, 01, 11, 10). If both cells are 1, the function is 1 whether that variable is 0 or 1, so the variable can be dropped: ABC′ + ABC = AB(C′ + C) = AB. A block of 2k cells removes k variables at once. Circling a group is the picture of that algebra.

3-variable K-map with minterm numbersABC0001111001m0m1m3m2m4m5m7m6
Cell numbers in a 3-variable map. Note the column order 00, 01, 11, 10: m3 comes before m2.

Example 1: a 3-variable map

Simplify F(A, B, C) = Σm(1, 3, 4, 5, 6).

  1. Fill in 1s at m1, m3, m4, m5 and m6, and 0s at m0, m2 and m7.
  2. m3 has three neighbors, m1, m2 and m7, and only m1 is a 1. So m3 can only be covered by the pair m1–m3, where A = 0 and C = 1 stay fixed: A′C is essential.
  3. m6 is at the right edge; its neighbors are m7, m2 and, across the edge, m4. Only m4 is a 1, so the wrap-around pair m4–m6 is essential: AC′.
  4. Only m5 is left. It can pair with m4 (AB′) or with m1 (B′C). Both cost the same, so this function has two minimal answers: A′C + AC′ + AB′ and A′C + AC′ + B′C.
Solved 3-variable K-map for Σm(1, 3, 4, 5, 6)ABC00011110010011130214150716
F = Σm(1, 3, 4, 5, 6) → F = AC' + A'C + B'C (one of 2 minimal answers)
  1. AC': group of 2 (m4, m6), wrapping left–right edges, essential. A = 1, C = 0 in every cell; B changes inside the group and drops out.
  2. A'C: group of 2 (m1, m3), essential. A = 0, C = 1 in every cell; B changes inside the group and drops out.
  3. B'C: group of 2 (m1, m5). B = 0, C = 1 in every cell; A changes inside the group and drops out.

Result: F = AC' + A'C + B'C, 3 terms and 6 literals. Open this example in the solver.

Solved 3-variable K-map for Σm(1, 3, 4, 5, 6)ABC00011110010011130214150716
F = Σm(1, 3, 4, 5, 6) → F = AB' + AC' + A'C (one of 2 minimal answers)
  1. AB': group of 2 (m4, m5). A = 1, B = 0 in every cell; C changes inside the group and drops out.
  2. AC': group of 2 (m4, m6), wrapping left–right edges, essential. A = 1, C = 0 in every cell; B changes inside the group and drops out.
  3. A'C: group of 2 (m1, m3), essential. A = 0, C = 1 in every cell; B changes inside the group and drops out.

Result: F = AB' + AC' + A'C, 3 terms and 6 literals. Open this example in the solver.

Example 2: a 4-variable map with corners

Simplify F(A, B, C, D) = Σm(0, 2, 5, 7, 8, 10, 13, 15).

The four corners m0, m2, m8 and m10 all have B = 0 and D = 0: they form one group because the map wraps both ways. The middle square m5, m7, m13, m15 has B = 1 and D = 1. Two groups of four cover everything.

Solved 4-variable K-map for Σm(0, 2, 5, 7, 8, 10, 13, 15)ABCD000111100001111010010312041517060121131150141809011110
F = Σm(0, 2, 5, 7, 8, 10, 13, 15) → F = BD + B'D'
  1. BD: group of 4 (m5, m7, m13, m15), essential. B = 1, D = 1 in every cell; A, C change inside the group and drop out.
  2. B'D': group of 4 (m0, m2, m8, m10), wrapping left–right edges and top–bottom edges, essential. B = 0, D = 0 in every cell; A, C change inside the group and drop out.

Result: F = BD + B'D', 2 terms and 4 literals. Open this example in the solver.

Example 3: two correct answers

Simplify F(A, B, C) = Σm(0, 1, 2, 5, 6, 7). Here every 1 belongs to two different pairs, and no pair is essential. Picking any pair forces the rest of the cover, and the two possible starting choices lead to two different answers with the same cost:

Solved 3-variable K-map for Σm(0, 1, 2, 5, 6, 7)ABC00011110011011031204151716
F = Σm(0, 1, 2, 5, 6, 7) → F = AC + A'B' + BC' (one of 2 minimal answers)
  1. AC: group of 2 (m5, m7). A = 1, C = 1 in every cell; B changes inside the group and drops out.
  2. A'B': group of 2 (m0, m1). A = 0, B = 0 in every cell; C changes inside the group and drops out.
  3. BC': group of 2 (m2, m6). B = 1, C = 0 in every cell; A changes inside the group and drops out.

Result: F = AC + A'B' + BC', 3 terms and 6 literals. Open this example in the solver.

Solved 3-variable K-map for Σm(0, 1, 2, 5, 6, 7)ABC00011110011011031204151716
F = Σm(0, 1, 2, 5, 6, 7) → F = AB + A'C' + B'C (one of 2 minimal answers)
  1. AB: group of 2 (m6, m7). A = 1, B = 1 in every cell; C changes inside the group and drops out.
  2. A'C': group of 2 (m0, m2), wrapping left–right edges. A = 0, C = 0 in every cell; B changes inside the group and drops out.
  3. B'C: group of 2 (m1, m5). B = 0, C = 1 in every cell; A changes inside the group and drops out.

Result: F = AB + A'C' + B'C, 3 terms and 6 literals. Open this example in the solver.

When a map has no essential group, write down one complete cover, then check whether starting from another group gives a shorter or equally short cover.

Solving for a product of sums

Do the same with the 0s. For Example 1 the 0s are m0, m2 and m7. m0 and m2 (A = 0, C = 0) give the sum term (A + C); m7 alone gives (A′ + B′ + C′). So F = (A + C)(A′ + B′ + C′). Each variable appears plain where it is 0 in the group and complemented where it is 1: the opposite of the SOP rule.

Mistakes that cost marks

  • Binary instead of Gray order. With 00, 01, 10, 11, the middle columns 01 and 10 touch although they differ in two bits, while 01 and 11, which differ in one bit, are separated.
  • Ignoring wrap-around. The left and right edges touch, the top and bottom edges touch, and in a 4×4 map all four corners form a group.
  • Illegal shapes. No groups of 3, 5, 6 or 7; no L shapes; no diagonals.
  • Groups that are too small. A pair that could be part of a quad gives a term with one literal too many.
  • Redundant groups. A group whose 1s are all covered by other groups adds a term for nothing.
  • Assuming the answer is unique. Compare with the alternatives; your instructor’s answer may be a different, equally minimal one.

To practice, enter your own map in the K-map solver, solve it by hand first, then open the steps to compare. The grouping rules page has more pictures of legal and illegal groups.

Frequently asked questions

What is the first step in solving a K-map?

Get the function as a minterm list (which rows are 1) and draw a map with the right number of cells and Gray-code labels. Filling the map from a truth table is mechanical once the cell numbers are in place.

Do I group 1s or 0s?

Group 1s for a sum of products (SOP). Group 0s for a product of sums (POS); each group of 0s gives a sum term in which a variable that is 0 across the group appears plain and one that is 1 appears complemented.

How do I know my answer is minimal?

Check three things: every group is as large as it can be (it is a prime implicant), no group is redundant (each has a 1 that no other chosen group covers), and no other selection uses fewer groups or fewer literals. The last check is the hard one by hand; the K-map solver does it exactly and lists all equally minimal answers.

What are the most common K-map mistakes?

Labeling columns 00, 01, 10, 11 instead of 00, 01, 11, 10; forgetting that the edges and corners wrap around; making groups of 3, 5 or 6 cells; grouping diagonally; and adding an extra group for 1s that are already covered.

Sources

  • M. Karnaugh, “The Map Method for Synthesis of Combinational Logic Circuits,” Transactions of the AIEE, Part I, 72(5):593–599, 1953.
  • E. J. McCluskey, “Minimization of Boolean Functions,” Bell System Technical Journal, 35(6):1417–1444, 1956.