In short: On a four-variable K-map you circle rectangular groups of 1s whose size is a power of two (pairs, quads, octets), allow groups to wrap around the edges, and read off only the variables that stay constant inside each group; the biggest legal groups give the smallest sum-of-products.
A four-variable Karnaugh map is the largest map most engineers can still solve by eye, and it is a favourite in interviews because it tests three skills at once: Gray-code ordering, spotting adjacency across the edges, and knowing when to stop grouping. If you are new to the idea, start with the 3-variable K-map guide and come back; here we scale the same logic to 16 cells.
Why a K-map works: adjacency is one bit of difference
Boolean algebra simplifies by the identity X·Y + X·Y' = X. Two minterms that differ in exactly one variable can therefore be merged, and that variable disappears. The K-map is a drawing trick that places every such pair physically next to each other. To achieve this, the row labels (AB) and column labels (CD) are written in Gray code, 00, 01, 11, 10, not in binary counting order. Only one bit changes between neighbours, so any two touching cells are logically adjacent.
The 16 cells hold minterms m0 to m15. The minterm number equals 4 × (row AB value) + (column CD value), so the second row reads m4, m5, m7, m6, and the third row reads m12, m13, m15, m14. Memorise that scrambled order; it is the most common source of transcription errors.
Key fact: The map is really a torus. The left edge touches the right edge and the top edge touches the bottom edge, so the four corner cells m0, m2, m8 and m10 are all neighbours of each other.
The grouping rules that actually matter
- Groups contain only 1s (or don't-cares) and must be rectangles, never diagonals or L-shapes.
- Group sizes must be 1, 2, 4, 8 or 16. A group of three is illegal because it cannot be described by fixing a subset of variables.
- Every 1 must be covered at least once, and overlapping groups are allowed and often necessary.
- Use the largest group available for each 1; larger group means fewer literals.
- Use as few groups as possible once every 1 is covered.
The payoff is directly measurable. A lone minterm needs all four literals (a 4-input AND). A pair drops one variable, a quad drops two, an octet drops three, and a group of all 16 cells collapses to the constant 1.
| Group | Cells | Variables eliminated | Literals left |
|---|---|---|---|
| Single | 1 | 0 | 4 |
| Pair | 2 | 1 | 3 |
| Quad | 4 | 2 | 2 |
| Octet | 8 | 3 | 1 |
| Full map | 16 | 4 | constant 1 |
Reading a group: keep what does not change
For each group, ask which variables hold one fixed value across every cell. In the figure above, the corner quad has B = 0 and D = 0 in all four cells, while A and C take both values, so the term is B'D'. The centre quad has B = 1 and D = 1 throughout, giving BD. The sum is B'D' + BD, which is exactly an XNOR. Written as raw minterms this function needs eight 4-literal products; the map reduces it to two 2-literal products, a saving of 24 literals.
Key fact: Complement a variable in the term when it is constantly 0 in the group, and leave it plain when it is constantly 1. Variables that change inside the group never appear.
Wrap-around groups, step by step
Wrap-around is where candidates lose marks. There are three flavours. A horizontal wrap joins m0 with m2 (left and right edges of row 00), and similarly m4 with m6, m12 with m14 and m8 with m10. A vertical wrap joins m0 with m8, m1 with m9, m3 with m11 and m2 with m10. The corner quad joins all four. A whole outer ring of eight cells is not a legal octet, since it is not one rectangle on the torus, but the entire left-edge column pair (columns 00 and 10, which are adjacent through the wrap) is a legal octet when full, equal to D'.
Watch the animation below: it cycles through the two quads from the first example, lighting the corner group first and then the centre group, while the product term appears beneath.
Prime and essential implicants, and don't-cares
A prime implicant is a group that cannot be enlarged without including a 0. An essential prime implicant is one that is the only group covering at least one particular 1; it must appear in the answer. The method: mark essentials first, then cover the remaining 1s with the fewest extra primes. When two covers tie, both are correct, and examiners usually accept either.
Don't-care cells (X) are conditions that never occur or whose output is unspecified. Treat each X as 1 only if doing so enlarges a group. Take F = Σm(1,3,7,11,15) with don't-cares d(0,2,5). Counting X at m0 and m2 gives the quad m0, m1, m2, m3 = A'B'. The column m3, m7, m11, m15 is a quad too, giving CD. So F = A'B' + CD, with just two AND gates and one OR, whereas ignoring don't-cares would cost an extra literal in the first term. The cell at m5 is not used, and that is fine: you never have to cover an X.
Key fact: Never add a group that covers only don't-cares or only already-covered cells. It adds hardware without changing the function.
Common mistakes and a hazard warning
- Writing the rows in binary order (00, 01, 10, 11), which breaks adjacency.
- Stopping at pairs when a quad was available, which leaves an extra literal in the term.
- Forgetting the wrap, so the corners get three separate terms instead of one.
- Reading complemented and uncomplemented variables the wrong way round.
A subtler point: the minimum two-level cover is not always the safest circuit. If two groups merely touch, a single input change that moves between them can produce a brief glitch, a static-1 hazard. Designers add a redundant consensus group that bridges the pair. Logic synthesis tools such as Synopsys Design Compiler and Cadence Genus do not use a K-map, since it does not scale beyond about six variables, but the Espresso heuristic minimiser and Quine-McCluskey follow the same prime-implicant logic, and glitch-sensitive paths still need engineering review. If you want to see how such logic is turned into silicon, the physical design and DFT tracks at ChipXpert VLSI training continue where this article stops. For a bigger picture of combinational building blocks, read our combinational logic design guide.
Ready to practise with timed exercises and worked solutions? Explore the Digital Electronics track in CourseTron courses and master K-maps, state machines and timing from the ground up.
Frequently asked questions
Why does the K-map use Gray code?
Gray code guarantees that neighbouring rows and columns differ in exactly one variable, which is the condition for two minterms to merge by the identity X·Y + X·Y' = X.
Can I group the four corners of a 4-variable K-map?
Yes. Because the map wraps both horizontally and vertically, m0, m2, m8 and m10 are mutually adjacent and form a quad that simplifies to B'D'.
Is a group of 6 cells allowed?
No. Only powers of two are legal. Cover six adjacent 1s with an overlapping quad and pair instead; overlapping is allowed.
Do I use a K-map for large designs?
No. K-maps are practical to about five or six variables. Larger functions go through algorithmic minimisation in EDA tools, but the same prime-implicant ideas apply.