K-Map Basics

Simplifying a Boolean expression with algebra works, but it depends on spotting the right law at the right moment. A Karnaugh map, or K-map, turns the same job into a picture. You fill in a grid from the truth table, circle groups of 1s, and read the simplified expression directly from the circles. For up to four variables it is usually the fastest reliable method.

Learning objectives

By the end of this lesson you will be able to:

  • Draw 2, 3 and 4 variable K-maps with the correct Gray code order.
  • Fill a K-map from minterms or a truth table.
  • Group adjacent 1s following the grouping rules.
  • Read a minimal sum-of-products expression from the groups.
  • Use don't-care conditions to get a simpler result.

Why the cells are in Gray code order

Each cell of a K-map stands for one minterm. The cells are arranged so that neighbouring cells differ in exactly one variable. That is what lets a group of cells eliminate a variable: if two adjacent cells are both 1, the variable that changes between them drops out.

To get this property, the row and column labels use Gray code order: 00, 01, 11, 10, not the usual binary 00, 01, 10, 11. The map also wraps around, so the left and right edges are neighbours, and so are the top and bottom edges.

The 3-variable map with the minterm number in each cell:

A \ BC 00 01 11 10
0 0 1 3 2
1 4 5 7 6

The 4-variable map:

AB \ CD 00 01 11 10
00 0 1 3 2
01 4 5 7 6
11 12 13 15 14
10 8 9 11 10

Notice that minterm 0 is next to 2, 4 and 8 on the 4-variable map, even though they look far apart. Use the truth table generator to get the minterm numbers of any expression.

The grouping rules

  1. Groups contain only 1s (or don't cares, covered below).
  2. The size of a group must be a power of two: 1, 2, 4, 8 or 16.
  3. Groups must be rectangles, including rectangles that wrap around the edges.
  4. Make each group as large as possible.
  5. Cover every 1 at least once. Overlapping groups are allowed and often needed.
  6. Use as few groups as possible.

A group of 2 eliminates one variable, a group of 4 eliminates two, and a group of 8 eliminates three. Bigger groups mean fewer literals in the product term.

Reading a group

For each group, keep the variables that stay the same across all its cells and drop the ones that change. A variable that is always 1 is written plain. A variable that is always 0 is written with a prime. Add the product terms of all the groups to get the sum of products.

Worked example 1: Three variables, one group of four

F(A, B, C) = sum of minterms (1, 3, 5, 7).

A \ BC 00 01 11 10
0 0 1 1 0
1 0 1 1 0

The four 1s form a single group of four: the two middle columns. Across this group A changes (0 and 1) and B changes (0 and 1), but C is always 1. So two variables drop out and the answer is

F = C

This agrees with the minterms: 1, 3, 5 and 7 are exactly the numbers whose last bit is 1.

Worked example 2: Wrap-around grouping

F(A, B, C) = sum of minterms (0, 2, 4, 5, 6).

A \ BC 00 01 11 10
0 1 0 0 1
1 1 1 0 1
  • Group 1: the four cells at the left and right edges (minterms 0, 2, 4, 6). They are neighbours because the map wraps around. C is always 0, while A and B change, so this group is C'.
  • Group 2: minterms 4 and 5, in the bottom row. A = 1 and B = 0 stay the same, and C changes, so this group is AB'.

F = C' + AB'

The 1 at minterm 4 is used in both groups, which is allowed. Using the left edge column alone would have produced a pair and a larger expression.

Worked example 3: Four variables, two groups of four

F(A, B, C, D) = sum of minterms (0, 2, 5, 7, 8, 10, 13, 15).

AB \ CD 00 01 11 10
00 1 0 0 1
01 0 1 1 0
11 0 1 1 0
10 1 0 0 1
  • Group 1: the four corners (minterms 0, 2, 8, 10). They are all neighbours through the wrap-around. B = 0 and D = 0 in all four, while A and C change, so the term is B'D'.
  • Group 2: the centre block (minterms 5, 7, 13, 15). B = 1 and D = 1 stay the same, so the term is BD.

F = B'D' + BD

Eight minterms of four variables, 32 literals if written out in full, become two terms of two literals each. Check the result with the K-map solver.

Don't-care conditions

Sometimes an input combination can never occur, or the output does not matter for it. Mark such cells with X. A don't care can be treated as 1 if that makes a group larger, and ignored otherwise. You are never required to cover an X.

Example: F(A, B, C, D) has minterms 1, 3, 7, 11, 15 and don't cares 0, 2, 5.

AB \ CD 00 01 11 10
00 X 1 1 X
01 0 X 1 0
11 0 0 1 0
10 0 0 1 0
  • The whole column CD = 11 (minterms 3, 7, 15, 11) forms a group of four, giving CD.
  • The top row, with the don't cares at 0 and 2 counted as 1, gives a group of four (minterms 0, 1, 3, 2), giving A'B'. This covers the remaining 1 at minterm 1.

F = A'B' + CD

Another minimal answer, A'D + CD, also works, because it uses the don't care at minterm 5 instead.

Minimal vs prime implicants

Each maximal group is called a prime implicant. A prime implicant that covers a 1 no other group covers is essential and must be included. The usual method is to circle the essential groups first, then add as few extra groups as needed to cover what remains. For larger problems with more than four variables, use the Quine-McCluskey method.

Common mistakes

  • Using binary order for the labels. The labels must be in Gray code, 00 01 11 10.
  • Groups of 3, 5 or 6. Group sizes must be powers of two.
  • Forgetting the wrap-around. The corners and the left and right edges are neighbours.
  • Stopping at small groups. A smaller group than necessary leaves variables in the term.
  • Covering don't cares as if they were required. Only use an X when it enlarges a group.

Practice problems

Problem 1. Simplify F(A, B, C, D) = sum of minterms (0, 1, 2, 3, 4, 5, 12, 13).

Answer: A'B' + BC'. The top row (0, 1, 3, 2) gives A'B', and minterms 4, 5, 13, 12 give BC'.

Problem 2. Simplify F(A, B, C) = sum of minterms (1, 2, 3, 5).

Answer: A'B + B'C. Minterms 2 and 3 give A'B, and minterms 1 and 5 give B'C.

Problem 3. Simplify F(A, B, C, D) = sum of minterms (4, 5, 6, 7, 12, 13, 14, 15).

Answer: B. The two middle rows form a group of eight where only B stays constant.

Problem 4. Simplify F(A, B, C) = sum of minterms (0, 1, 4, 5, 7).

Answer: B' + AC. Minterms 0, 1, 4, 5 give B', and minterms 5 and 7 give AC.

Frequently asked questions

Why not use ordinary binary order on a K-map? Because neighbouring cells would differ in more than one variable, and groups would no longer eliminate variables cleanly.

Can a K-map handle five or six variables? Yes, but it becomes hard to read because it needs several stacked maps. Beyond four variables a tabular method or software is usually better.

Does a K-map give the minimal product of sums as well? Yes. Group the 0s instead of the 1s and read the groups as sum terms, which gives a minimal product-of-sums form.

Next lesson: continue with SOP and POS Forms to learn the standard forms behind these results.