A Karnaugh map (K-map) is a grid layout of a truth table, arranged so that adjacent cells differ in only one variable. That adjacency makes minimization visual: groups of s in adjacent cells correspond to product terms with one fewer variable.
Each cell is a minterm. Cells are ordered in Gray code (one bit change between neighbors) along both axes. The grid is toroidally connected — the leftmost column is adjacent to the rightmost, and the top row is adjacent to the bottom. So a in the corner can group with a in the opposite corner.

Why grouping works
Two minterms that differ in exactly one variable can combine: the variable that flips drops out. Algebraically, . On a K-map, those two minterms are in adjacent cells, and circling them as a group of two replaces both with the single product term .
Doubling the group size drops one more variable. Four adjacent cells (a block, or a row) eliminate two variables. Eight cells eliminate three. Always group in powers of two — that’s the only shape where the algebraic cancellation works out cleanly.
Building one
Pick the K-map shape based on the number of variables:
- 2 variables: grid.
- 3 variables: grid (one variable along rows, two along columns in Gray order).
- 4 variables: grid.
For SOP solutions, fill in s where the function is true (and s elsewhere). Then identify groups.



Solving
Strategy: cover every with as few groups as possible, and make each group as large as possible.
The product term for a group is read off by listing the variables that don’t change across the group’s cells. Variables that take both values in the group drop out. If a variable is constantly in the group, it appears uncomplemented; if constantly , it appears complemented.
Worked example for a 3-variable K-map with s at minterms 1, 4, 5, 6:

Two groups: gives (because and throughout, varies). gives . Result: , a 4-literal SOP from a 4-minterm function.
POS solutions
Same procedure but group the s instead. Each group becomes a maxterm. To read it off, take the complement of the literals: a group where throughout becomes .



Key terms
- Literal: an appearance of a variable in a product term, complemented or not.
- Implicant: a product term that makes the function true wherever it’s true. Visually, a rectangular group of s.
- Prime implicant: an implicant that can’t be combined into a larger group. The maximal rectangle.
- Essential prime implicant (EPI): a prime implicant covering at least one that no other prime implicant covers. EPIs are mandatory in any minimum cover.
- Cover: a set of implicants whose union accounts for every in the K-map.
The minimum-cost cover is found by:
- Identifying all prime implicants.
- Finding all EPIs and including them automatically.
- Picking additional prime implicants to cover any s left, choosing the largest available groups.
For example, given the function below with minterms grouped:

The expression comes out of three groups — two pairs and a single — each read by the variables that stay constant.
Don’t-cares
If some input combinations can’t occur (or you don’t care about the output for them), mark the cells with a instead of or . Don’t-cares are flexible: include them in a group when it makes the group bigger (they count as for SOP grouping); leave them out when they don’t help. See Don’t Care Condition.
Limits
K-maps are practical up to 4 variables and stretch to 5 or 6 with mirror-image conventions (treating two halves of the map as overlapping planes for the extra variable). Past 6 variables they become impractical and you switch to algorithmic methods (Quine-McCluskey, Espresso). For LUT-based FPGA design, the synthesis tool handles minimization automatically.
The expression that comes out of a K-map isn’t always fully minimum — sometimes a further algebraic step can shrink it more.