Karnaugh Map Grouping Rules: Pairs, Quads, Octets and Wrap-Around

Learn the Karnaugh Map grouping rules for pairs, quads, octets, wrap-around groups, overlapping cells, corner groups, and don't-care conditions clearly.

Kalana Sandeep12 min read
Three Gray-code Karnaugh maps showing valid adjacent groups of two, four, and eight cells

Filling in a Karnaugh Map is usually the easy part. Deciding which cells to group is where most mistakes happen — a group that looks fine at first glance can be the wrong shape, the wrong size, or missing a wrap-around connection that isn't obvious on a flat grid.

Groups aren't arbitrary shapes drawn around whatever 1s happen to sit near each other. They follow specific rules around size, adjacency, overlap, and edge wrapping, and getting any one of those wrong changes the simplified expression you end up with.

This article covers those rules directly, without re-explaining what a K-Map is from scratch.

The Basic Rule: Group in Powers of Two

Every valid group size is a power of two:

  • 1 cell — singleton
  • 2 cells — pair
  • 4 cells — quad
  • 8 cells — octet
  • 16 cells — group of sixteen

In a 5-variable map, a 32-cell group is also possible when all 32 cells are eligible for the chosen SOP or POS grouping.

Not every map contains every possible group size. A given function might only produce pairs and quads, with no octet available anywhere.

Whatever the size, the group must form a rectangle once K-Map adjacency is taken into account, including wrap-around.

Arbitrary L-shapes, T-shapes, diagonal clusters, and three-cell groups are not valid.

Rule 1: Make Groups as Large as Usefully Possible

Bigger groups remove more changing variables.

  • A pair removes one changing variable.
  • A quad removes two.
  • An octet removes three.

This is relative to the full minterm description of the grouped cells and the number of variables in the function.

Larger is not automatically the correct choice in every situation. Expanding groups as far as the map allows is how you find the prime implicants, but the final expression comes from choosing which of those groups to keep. Grabbing the biggest shape you notice first does not guarantee the smallest overall expression, and a large group can turn out to be unnecessary, as the prime implicant section below shows.

A better rule is to prefer larger valid groups when they help cover the required cells using fewer terms or literals overall.

Rule 2: Every Required Cell Must Be Covered

For SOP, every required 1 must belong to at least one valid group.

For POS, every required 0 must belong to at least one valid group.

A required cell may appear in more than one group. It does not need to belong to exactly one. What matters is that none of the required target cells are left uncovered.

Rule 3: Groups May Overlap

A cell can belong to two different groups at the same time.

For example, it might be part of one horizontal quad and another vertical quad. That is not a mistake. Overlap is often useful because it lets you create larger groups or cover a difficult cell without settling for a smaller group.

The small example later in this article uses two overlapping pairs. The comparator at the end of the guide to converting a truth table to a Karnaugh Map has three groups that all share one cell.

Rule 4: Opposite Edges Are Adjacent

A K-Map is drawn as a flat rectangle, but its Gray-code layout means opposite edges are logically adjacent.

  • The left edge connects to the right edge.
  • The top edge connects to the bottom edge.

A cell in the leftmost column can therefore form a pair with the corresponding cell in the rightmost column of the same logical row. The same principle applies vertically.

Rule 5: The Four Corners Can Form One Group

In a 4-variable K-Map, the four corner cells can form a valid quad.

This happens because wrap-around works in both directions at once. The left and right edges connect. The top and bottom edges connect. The four corners sit where those two wrap-around relationships meet.

The corners are NOT grouped because diagonal cells are adjacent. Diagonal adjacency does not exist in a normal K-Map. They form one group because of edge wrap-around.

Two Gray-code Karnaugh maps showing the four-corner wrap-around quad m0, m2, m8, m10 and a pair expanded to a quad using optional X cells

The four corners connect through edge wrap-around, not diagonal adjacency; don't-care cells can join a group when they help create a larger valid block.

Rule 6: Diagonal Cells Are Not Adjacent

Two cells that only touch at a corner point are not adjacent on a K-Map.

Even if both contain 1, they cannot form a pair by themselves. Gray-code adjacency works horizontally and vertically, including legitimate wrap-around connections. It does not create diagonal neighbors.

Rule 7: Groups Must Be Rectangular

Valid group shapes can include:

  • 1×2
  • 2×1
  • 1×4
  • 4×1
  • 2×2
  • 2×4
  • 4×2
  • 4×4

depending on the map size and available cells.

A group may cross an edge and still be logically rectangular because opposite edges are adjacent.

Invalid examples include:

  • L-shapes
  • T-shapes
  • three-cell clusters
  • diagonal patterns

Those shapes do not correspond to proper elimination of changing variables.

Rule 8: Do Not Include the Wrong Required Values

For SOP, a group cannot contain a required 0.

Every cell in an SOP group must be:

  • a required 1
  • or a usable don't-care X

For POS, the rule reverses. A POS zero-group cannot contain a required 1. It may contain required 0s and useful X cells.

Including an opposite required value produces an expression that no longer matches the original function.

A Small Example: Wrong and Right Groupings

The rules are easiest to see on a two-variable map, where every cell can be checked at a glance. Take:

F(A, B) = Σm(0, 1, 2)

The function is 1 for every input except A = 1, B = 1. On a map with A on the rows and B on the columns, m0 and m1 are in the top row and m2 and m3 are in the bottom row:

A \ B01
011
110

The Wrong Grouping

The three 1s at m0, m1 and m2 form an L-shape, and it is tempting to circle all three. That is not a legal group, for two connected reasons.

First, a legal group has a power-of-two number of cells. A group of 2ᵏ cells is exactly the set of inputs in which k variables take every combination while the others stay fixed. Three cells cannot be that set.

Second, the L-shape gives no usable term. Across m0, m1 and m2, A takes both values and so does B, so no variable stays constant. A group with nothing left constant would produce the term 1, which claims the function is 1 everywhere, but F(1, 1) = 0. The cells m1 and m2 are also only diagonal neighbours, which do not count as adjacent.

The Right Grouping

Two overlapping pairs cover the same three cells legally:

  • Pair m0, m1: the top row. A stays 0 and B changes, so the term is A'.
  • Pair m0, m2: the left column. B stays 0 and A changes, so the term is B'.

The result is F = A' + B'. The cell m0 belongs to both pairs, which is allowed: m0 is one input, and at that input both terms happen to be 1. The table below checks the expression on all four inputs.

mABA'B'A' + B'F
0001111
1011011
2100111
3110000

The A' + B' column matches F in every row. It is 1 for exactly m0, m1 and m2, and 0 for m3, so it covers the three required cells and nothing else.

Why Not Three Singletons?

Three single-cell groups, A'B' + A'B + AB', would also be correct, because every 1 is covered and m3 is not. A singleton is a legal group. It is simply wasteful: that cover has three terms and six literals, while A' + B' has two terms and two literals. Each pair removed one variable from its term.

To reproduce this in the Karnaugh Map Solver, choose 2 variables, select the Minterms input, enter 0, 1, 2 and press Apply. The SOP result should read A' + B'.

How Don't-Care Values Affect Grouping

A don't-care cell is marked X. To explore worked examples and when to use or ignore X values, see our guide on don't-care conditions in Karnaugh Maps.

For SOP, an X may be treated like 1 when doing so creates a useful larger group. For POS, it may be treated like 0. It may also be ignored completely.

The X is optional.

For example, suppose two adjacent required 1 cells sit beside two X cells. If all four cells form a valid quad, using the X cells lets the pair expand into a quad. That larger group removes an additional changing variable.

If the X cells do not improve the grouping, there is no reason to use them.

Pairs, Quads, and Octets

Each doubling of group size frees one more variable, and the term keeps only the variables that stay constant. On a 4-variable map:

GroupCellsVariables that changeLiterals in the term
Pair213
Quad422
Octet831
Whole map164none, the function is 1

A quad can be a row of four, a column of four, a 2×2 block or a wrap-around block. The four corners of a 4-variable map are one example of a wrap-around quad. On a 4×4 map an octet is two adjacent rows or two adjacent columns, and the top and bottom rows (or the left and right columns) count as adjacent. Because three variables disappear, an octet often produces a very short term.

Prime Implicants and Essential Prime Implicants

A prime implicant is a valid group that cannot be enlarged without including a cell that is not allowed. For example, an SOP group cannot be enlarged through a required 0.

An essential prime implicant is a prime implicant that covers at least one required cell no other prime implicant covers. Because that cell has no alternative coverage, the essential prime implicant must appear in the final cover.

Choosing a cover is really three separate jobs, and they are easy to blur together when you work by eye:

  1. Find the prime implicants. Expand each required cell into the largest valid group it can belong to. The groups that cannot grow any further are the prime implicants.
  2. Mark the essential ones. A required cell that only one prime implicant covers forces that prime implicant into the answer.
  3. Cover whatever is left as cheaply as possible. Among the remaining prime implicants, choose a set that covers every leftover required cell. The Karnaugh Map Solver ranks competing covers by fewest terms first, then fewest literals. That is the rule this tool uses to compare expressions. It is not a measure of physical gate cost, which depends on the circuit technology you build with.

In the two-variable example above, A' and B' are the only prime implicants, and both are essential: m1 appears only in A' and m2 only in B'.

When the Largest Group Is Not in the Best Cover

Larger groups usually help, but the largest prime implicant is not guaranteed to belong to the best cover. Consider:

F(A, B, C, D) = Σm(0, 1, 2, 3, 4, 7, 9, 10)

AB \ CD00011110
001111
011010
110000
100101

The largest group is the top row, the quad m0, m1, m2, m3, which gives A'B'. Taking it first looks natural. The cells m4, m7, m9 and m10 are then still uncovered, and each of them can only join one group, a pair:

  • m0, m4 gives A'C'D'.
  • m3, m7 gives A'CD.
  • m1, m9 gives B'C'D. These cells are in the top and bottom rows, which are adjacent through wrap-around.
  • m2, m10 gives B'CD', again across the wrap-around.

All four pairs are essential, because m4, m7, m9 and m10 each have only that one group. They also cover m0, m3, m1 and m2 between them, so the quad A'B' adds nothing. Starting greedily with the quad gives A'B' + A'C'D' + A'CD + B'C'D + B'CD', which has 5 terms and 14 literals. Dropping the quad gives:

F = A'C'D' + B'C'D + B'CD' + A'CD

That is 4 terms and 12 literals. The quad is a genuine prime implicant, but it is redundant once the essential ones are chosen. After selecting the essential prime implicants, always check whether any required cell is still uncovered. If none is, nothing more should be added. Entering 0, 1, 2, 3, 4, 7, 9, 10 in the solver gives the four-term result, and its step trace lists the quad among the prime implicants without selecting it.

Where several prime implicants remain after the essential ones, more than one cover may tie, which is why different but equally minimal expressions can occasionally exist for the same function. To learn how a prime implicant chart systematically identifies unique coverage and minimal covers, see our detailed guide on prime implicants.

Grouping Rules for SOP vs POS

The geometric rules are identical for both forms. Only the target cells change: group the required 1s for SOP and the required 0s for POS. Don't-care X cells can help either one. How the resulting terms are written differs, and SOP vs POS in Karnaugh Maps covers that in detail.

Common Grouping Mistakes

  • Forming groups of 3, 6, or another non-power-of-two size.
  • Treating diagonal cells as adjacent.
  • Forgetting wrap-around along opposite edges.
  • Circling an L-shape or any other three-cell cluster instead of splitting it into overlapping pairs.
  • Settling for a smaller group when a better larger group is available.
  • Assuming the largest group must be in the final cover, and keeping a prime implicant whose required cells are all covered by other chosen groups.
  • Refusing to overlap groups when overlap improves the cover.
  • Using an X merely because it exists, even when it gives no benefit.
  • Treating a don't-care as a required value.
  • Including a required 0 inside an SOP group.
  • Including a required 1 inside a POS group.
  • Mixing SOP and POS grouping logic.
  • Assuming corner grouping works because of diagonal adjacency instead of wrap-around.

Quick Grouping Checklist

  1. Decide whether you are working in SOP or POS.
  2. Identify the required 1s or required 0s.
  3. Note the don't-care cells.
  4. Look for useful large power-of-two groups.
  5. Check opposite-edge adjacency.
  6. Allow overlap when it improves the cover.
  7. Make sure every required target cell is covered.
  8. Derive each term from the variables that remain constant.
  9. Check whether another valid cover uses fewer terms or literals, and drop any group whose required cells are all covered by the others.

Verifying a Manual Grouping

These rules become much easier once the map itself is familiar.

If needed, read what a Karnaugh Map is first.

After grouping a map manually, you can also compare the result with the Karnaugh Map Solver.

This is especially useful on 4- and 5-variable maps where wrap-around, overlap, and multiple possible covers can make a visual check harder. For these rules applied step by step to a full four-variable function, see the 4-variable Karnaugh Map guide, or explore two-map grouping in our 5-variable Karnaugh Map tutorial.

Frequently Asked Questions

What sizes can K-Map groups be?

Valid group sizes are powers of two: 1, 2, 4, 8, and 16 cells. A 5-variable map can also use a 32-cell group when all 32 cells are eligible for that grouping.

Can K-Map groups overlap?

Yes. A cell may belong to more than one group, and overlap is often useful when it allows larger or simpler groups.

Can K-Map groups wrap around the edges?

Yes. The left and right edges are logically adjacent, and the top and bottom edges are logically adjacent.

Are diagonal K-Map cells adjacent?

No. Cells that only touch at a corner are not adjacent.

Can the four corners form one group?

Yes. In a 4-variable map, the four corners can form a quad because both pairs of opposite edges wrap around. It is not diagonal adjacency.

Do I have to use every don't-care value?

No. An X is optional. Use it when it helps create a better valid group; otherwise, leave it unused.

Why can't I group three cells in a K-Map?

A legal group must contain a power-of-two number of cells, because a group of 2ᵏ cells lets exactly k variables take every combination while the others stay fixed. Three cells cannot do that. Split them into overlapping pairs instead.

Is the largest group always part of the minimal expression?

Not always. Expanding groups finds the prime implicants, but a large one can be redundant when other groups already cover all of its required cells. Choose the essential prime implicants first, then pick the remaining groups to minimise terms and literals.