Home / Learn / Karnaugh Maps

Karnaugh Maps: Simplifying Boolean Expressions Step by Step

By Han · Published

A Karnaugh map, or K-map, is a grid that rearranges a truth table so that groups of terms which can be combined sit physically next to each other. It turns Boolean simplification from a search for algebraic tricks into a visual pattern-spotting task, and for functions of up to four or five variables it is faster and far less error-prone than manipulating the algebra by hand. The method was introduced by Maurice Karnaugh in 1953 and has been a fixture of digital logic courses ever since.

The whole method rests on one idea: two product terms that differ in exactly one variable can be merged into a single, smaller term. For instance AB'C + ABC = AC(B' + B) = AC. A K-map is arranged so that any two adjacent cells always differ in exactly one variable, so merging becomes as simple as circling neighbours.

How the grid is laid out

A function of n variables has 2n cells, one for each minterm, exactly as many as the rows of its truth table. What matters is the ordering. The rows and columns are not labelled in ordinary binary count order (00, 01, 10, 11) but in Gray code order (00, 01, 11, 10), where each step changes only one bit. That is the property that guarantees horizontal and vertical neighbours differ in a single variable.

The map also wraps around: the leftmost column is adjacent to the rightmost, and the top row is adjacent to the bottom, as if the grid were rolled into a cylinder in both directions. The four corners of a four-variable map, for example, are all mutually adjacent. Forgetting the wrap-around is the most common reason students miss the simplest grouping.

The grouping rules

  • Circle only the cells containing 1 (for a Sum of Products result).
  • Every group must be a rectangle whose size is a power of two: 1, 2, 4, 8, or 16 cells. No groups of 3 or 6.
  • Make each group as large as possible. A larger group means fewer variables in that term.
  • Every 1 must be covered by at least one group, and you should use as few groups as possible.
  • Groups may overlap, and a 1 may belong to more than one group if that helps make groups larger.
  • Groups may wrap across the edges and corners of the map.

Once the groups are chosen, each group becomes one product term: keep only the variables that stay constant across the whole group, using the variable if it is 1 and its complement if it is 0, and drop the variables that change. OR the terms together and you have the simplified expression.

Three-variable worked example

Take F(A, B, C) = Σm(1, 3, 4, 5, 6, 7), meaning F is 1 for minterms 1, 3, 4, 5, 6, and 7. The map uses A for the row and BC for the columns, both in Gray-code order. The shaded cells are the 1s:

A \ BC00011110
00110
11111

Two groups cover every 1. The entire bottom row (A = 1) is a group of four cells; across it only A stays constant, so that term is simply A. The two middle columns (BC = 01 and BC = 11) form a group of four spanning both rows; across it C stays 1 while A and B both change, so that term is C. There is nothing left uncovered, so:

F = A + C

Six minterms collapse to a two-gate expression. Enter A OR C in the CMOS Generator and check its truth table against the original minterm list to confirm they match.

Four-variable worked example

Now take F(A, B, C, D) = Σm(0, 2, 5, 7, 8, 10, 13, 15). With four variables the map is 4 by 4, rows labelled AB and columns CD, both in Gray-code order:

AB \ CD00011110
001001
010110
110110
101001

The pattern is symmetric. The four corner cells (minterms 0, 2, 8, 10) form one group of four by the wrap-around rule; across them B = 0 and D = 0 stay constant while A and C change, giving the term B'D'. The four cells in the centre block (minterms 5, 7, 13, 15) form a second group; across them B = 1 and D = 1, giving BD. So:

F = B'D' + BD

That expression is the XNOR of B and D: it is 1 exactly when B and D are equal, and A and C turn out to be irrelevant to the function. A messy eight-minterm list reduces to a single equality check, which is the kind of insight a K-map surfaces almost for free.

Don't-care conditions

Sometimes certain input combinations can never occur, or the output genuinely does not matter for them. These are marked with an X in the map and are called don't-care conditions. The rule is simple: treat each X as a 1 when doing so lets you enlarge a group, and treat it as a 0 otherwise. You are never obliged to cover an X, but you are free to use it. Exploiting don't-cares often shrinks the final circuit noticeably, which is why real specifications leave them in rather than forcing an arbitrary output.

Getting Product of Sums, and when to stop using K-maps

Everything above produces a Sum of Products result by grouping the 1s. To get a Product of Sums result instead, group the 0s in exactly the same way to simplify F', then apply De Morgan's theorem to complement it back. In the four-variable example the 0s give F' = B'D + BD', and complementing that returns the same function in POS form. The relationship between the two forms is covered on the SOP vs POS page.

K-maps stay manageable up to four variables, are workable with care at five, and become impractical beyond six because human eyes cannot spot adjacencies in that many dimensions. At that point the tabular Quine-McCluskey method or a software minimiser takes over. For coursework-sized problems, though, the K-map remains the fastest reliable tool, and you can always verify your simplified expression instantly in the CMOS Generator.

Frequently Asked Questions

Why are Karnaugh map columns in Gray code order?
Gray code changes only one bit between adjacent values, so neighbouring cells differ in exactly one variable. That is what makes two adjacent 1s combinable into a single smaller term.
Can a Karnaugh map group have three cells?
No. Groups must contain a power-of-two number of cells: 1, 2, 4, 8, or 16. A group of three cannot be written as a single product term.
What does a don’t-care condition mean in a K-map?
A don’t-care, marked X, is an input combination whose output does not matter. You may treat it as 1 to enlarge a group or as 0 if it does not help, whichever gives the simpler result.
How do I get a Product of Sums answer from a K-map?
Group the 0s instead of the 1s to simplify the complement F prime, then apply De Morgan to complement it back into Product of Sums form.
What is the largest function a K-map can handle?
Four variables comfortably, five with care using a paired map. Beyond six variables the adjacencies are too hard to see, so the Quine-McCluskey method or software is used instead.

Keep learning

References: M. M. Mano and M. D. Ciletti, Digital Design; M. Karnaugh, “The Map Method for Synthesis of Combinational Logic Circuits,” Transactions of the AIEE, 1953.