G27
Self-checkedTier 1 14 min readdl.kmap

Karnaugh maps

Minimising a Boolean function on a Karnaugh map: Gray-code layout, groups and wrap-around, prime and essential prime implicants, don't cares, products of sums, and the situations where the answer is not unique.

Why it exists

Algebraic simplification works only when you can see the pattern. A Karnaugh map (K-map) turns the search for patterns into a picture. The truth table is arranged on a grid so that cells that differ in exactly one variable are physically next to each other. Two adjacent 1-cells then merge into a term with one variable fewer (xy+xy′=xxy + xy' = x), four cells into a term with two fewer, and so on. GATE questions give you a function (as a truth table, minterms or an expression) and ask for the minimal SOP or POS, the number of prime implicants, the number of essential prime implicants, or how don't cares change the answer. Maps are practical for up to 4 variables (5 with some care).

Prerequisites

You need minterm and maxterm numbering from SOP, POS, minterms and maxterms and the combining law xy+xy′=xxy + xy' = x from Boolean algebra.

Precise definitions

Layout. A map for nn variables has 2n2^n cells, one per minterm. The labels along each side are in Gray-code order (00, 01, 11, 10), not in binary order, so that neighbouring labels differ in one bit. The cell in row label rr and column label cc is the minterm whose binary index is rr followed by cc. For four variables A,B,C,DA, B, C, D the rows are ABAB and the columns CDCD; for three variables the rows are AA (0, 1) and the columns BCBC (00, 01, 11, 10). With a 5th variable use two 4-variable maps (for E=0E = 0 and E=1E = 1); a cell is also adjacent to the cell in the same position on the other map.

Adjacency. Two cells are adjacent if their minterms differ in exactly one variable. On the map, neighbours across the edges count: the left and right edges are adjacent, the top and bottom edges are adjacent, and so the four corners are all neighbours of each other.

Group (implicant). A rectangle of 1-cells (or don't cares) whose number of cells is a power of two (1, 2, 4, 8, 16) and whose sides are aligned to the Gray-code layout; wrap-around is allowed, diagonals and L-shapes are not. A group of 2k2^k cells is a product term with n−kn - k literals: the kk variables that take both values inside the group are dropped, and each variable that is constant is kept (true form if constant 1, complemented if constant 0).

Prime implicant. A group that cannot be enlarged (it is not contained in a larger group). Essential prime implicant. A prime implicant that covers at least one 1-cell no other prime implicant covers; it must be in every minimal SOP. A 1 covered by only one prime implicant is what marks it as essential.

Minimal SOP (as defined on the forms page): the fewest product terms, and among those the fewest literals. Procedure:

  1. Fill in the map from the truth table or minterm list.
  2. Find all prime implicants (the largest possible groups).
  3. Select all the essential prime implicants and mark the cells they cover.
  4. Cover the remaining 1s with as few extra prime implicants as possible, preferring the largest.
  5. Read each group as a product term and OR them. Groups may overlap.

Don't cares. A cell marked X may be put in a group if it helps make the group larger, and it need not be covered. A don't care is never required in the answer.

Product of sums. Group the 0s (and the don't cares) of FF instead. Each group of 0s gives a sum term: a variable that is constant 0 over the group appears in true form, a variable that is constant 1 appears complemented. The AND of the sum terms is the minimal POS of FF. (Equivalently, minimise F′F' as an SOP and complement the result with De Morgan.)

Non-uniqueness. A function can have several different minimal SOPs of the same cost. This happens when no prime implicant is essential for some cells, as in the cyclic case below.

Limits. For n>5n > 5 or 6 a map becomes unreadable. The tabular method (Quine-McCluskey) does the same job algorithmically.

How it works

Each animation fills in the map, then adds groups one at a time, the essential prime implicants first, and finally reads the expression. The map labels are Gray-coded, the number in the corner of each cell is its minterm index, and the coloured dots show which groups cover a cell. Every group, every cell and every term is produced by an exact minimiser (not typed in), and re-derived in the tests.

Three variables: F = sum m(0, 2, 4, 5, 6): Fill in the map

Exact minimiser, not typed
A\BC00011110
010010312
114150716

Small number = minterm index. X = don't care. Row and column labels are in Gray-code order.

Groups so far (product terms)

None yet.

Step 1

Each cell is one row of the truth table. The row and column labels are in Gray-code order, so any two neighbouring cells, including cells on opposite edges, differ in exactly one variable.

1 / 4
computed by script: exact integer, Fraction and truth-table evaluation (IEEE 754 patterns via Python struct where used), not typed by hand. python3 scripts/gen-dl-traces.py

Worked examples

EX 1Three variables: F = sum m(0, 2, 4, 5, 6)

Easy

The animation above is this function.

Step 1. The four cells 0, 2, 4, 6 all have C=0C = 0. They are adjacent in a block (AA and BB vary, CC is constant 0), so they form one group of 4 reading C′C'.

Step 2. Cell 5 has a neighbour 4. The group {4,5}\{4, 5\} has A=1A = 1, B=0B = 0 constant and CC varying, so it reads AB′AB'.

Result. F=C′+AB′F = C' + AB'. Both groups are essential: cell 2 can only be covered by C′C' and cell 5 only by AB′AB'.

The program below checks the result against the minterm list on all rows.

#include <stdio.h>
 
static int f3(int m) { return m == 0 || m == 2 || m == 4 || m == 5 || m == 6; }
static int g3(int m) {
    int a = (m >> 2) & 1, b = (m >> 1) & 1, c = m & 1;
    return !c || (a && !b);
}
 
static int corners(int m) { return m == 0 || m == 2 || m == 5 || m == 7 || m == 8 || m == 10 || m == 13 || m == 15; }
static int xnor_bd(int m) {
    int b = (m >> 2) & 1, d = m & 1;
    return b == d;
}
 
static int sop1(int m) {
    int a = (m >> 3) & 1, c = (m >> 1) & 1, d = m & 1;
    return (!a && d) || (c && d);
}
static int sop2(int m) {
    int a = (m >> 3) & 1, b = (m >> 2) & 1, c = (m >> 1) & 1, d = m & 1;
    return (!a && !b) || (c && d);
}
 
int main(void) {
    int bad = 0;
    for (int m = 0; m < 8; m++) bad += f3(m) != g3(m);
    printf("C' + AB' differs from the sum m(0,2,4,5,6) on %d of 8 rows\n", bad);
    bad = 0;
    for (int m = 0; m < 16; m++) bad += corners(m) != xnor_bd(m);
    printf("B'D' + BD differs from the corner function on %d of 16 rows\n", bad);
    printf("A'D + CD and A'B' + CD differ on rows:");
    for (int m = 0; m < 16; m++)
        if (sop1(m) != sop2(m)) printf(" %d", m);
    printf("\n");
    int ones[] = {1, 3, 7, 11, 15};
    int ok = 1;
    for (int i = 0; i < 5; i++) ok = ok && sop1(ones[i]) && sop2(ones[i]);
    printf("both give 1 on every required minterm: %d\n", ok);
    return 0;
}
C' + AB' differs from the sum m(0,2,4,5,6) on 0 of 8 rows
B'D' + BD differs from the corner function on 0 of 16 rows
A'D + CD and A'B' + CD differ on rows: 0 2 5
both give 1 on every required minterm: 1

EX 2Four corners and the centre

Medium

Four corners and the centre: F = sum m(0, 2, 5, 7, 8, 10, 13, 15): Fill in the map

Exact minimiser, not typed
AB\CD00011110
0010010312
0104151706
11012113115014
101809011110

Small number = minterm index. X = don't care. Row and column labels are in Gray-code order.

Groups so far (product terms)

None yet.

Step 1

Cells 0, 2, 8 and 10 sit in the four corners. They look far apart, but the labels show they are neighbours around the edges: 0000 and 0010 differ only in D, and 0000 and 1000 only in A.

1 / 4
computed by script: exact integer, Fraction and truth-table evaluation (IEEE 754 patterns via Python struct where used), not typed by hand. python3 scripts/gen-dl-traces.py

Step 1. Cells 0, 2, 8, 10 are the four corners. Over the edges they are mutual neighbours: 0000 and 0010 differ only in DD, 0000 and 1000 only in AA. Together AA and CC vary while B=0B = 0 and D=0D = 0 are constant, so the group of 4 reads B′D′B'D'.

Step 2. Cells 5, 7, 13, 15 form a block in the middle (AA and CC vary, B=1B = 1 and D=1D = 1), reading BDBD.

Result. F=B′D′+BDF = B'D' + BD, which is B⊙DB \odot D (XNOR of BB and DD). Both prime implicants are essential, and the program above confirms the result on all 16 rows. A group never needs to be a visible rectangle: it is a rectangle on a surface where the opposite edges are glued together.

EX 3Don't cares: F = sum m(1, 3, 7, 11, 15) + d(0, 2, 5)

Medium

Don't cares: F = sum m(1, 3, 7, 11, 15) + d(0, 2, 5): Fill in the map

Exact minimiser, not typed
AB\CD00011110
00X01113X2
0104X51706
11012013115014
100809111010

Small number = minterm index. X = don't care. Row and column labels are in Gray-code order.

Groups so far (product terms)

None yet.

Step 1

Cells marked X may be treated as 1 or 0, whichever makes bigger groups. They need not be covered.

1 / 4
computed by script: exact integer, Fraction and truth-table evaluation (IEEE 754 patterns via Python struct where used), not typed by hand. python3 scripts/gen-dl-traces.py

Step 1. CDCD covers the column of cells 3, 7, 15, 11 (C=1C = 1, D=1D = 1). It is the only group that covers cell 11, so it is essential.

Step 2. The remaining 1 is cell 1. It can be covered by A′DA'D (cells 1, 3, 5, 7, using the don't care 5) or by A′B′A'B' (cells 0, 1, 2, 3, using the don't cares 0 and 2). Both groups have two literals.

Result. F=CD+A′DF = CD + A'D or F=CD+A′B′F = CD + A'B'. These are two minimal answers (2 terms, 4 literals). The program shows they differ only on rows 0, 2, 5, the don't cares, so both are correct for the specification. Without the don't cares the best SOP would be A′B′D+CDA'B'D + CD, with 5 literals.

EX 4Product of sums: group the zeros

Medium

Product of sums: group the 0s of F = prod M(4, 5, 6, 7, 12, 13): Fill in the map

Exact minimiser, not typed
AB\CD00011110
0010111312
0104050706
11012013115114
101819111110

Small number = minterm index. X = don't care. Row and column labels are in Gray-code order.

Groups so far (sum terms)

None yet.

Step 1

For a product of sums, group the 0s instead. Each group of 0s gives a sum term that is 0 exactly on that group: the variables that are 1 appear complemented.

1 / 4
computed by script: exact integer, Fraction and truth-table evaluation (IEEE 754 patterns via Python struct where used), not typed by hand. python3 scripts/gen-dl-traces.py

F=∏M(4,5,6,7,12,13)F = \prod M(4,5,6,7,12,13), so F=0F = 0 on those six rows.

Step 1. The zeros 4, 5, 6, 7 form a group of 4 with A=0A = 0 and B=1B = 1 constant (CC and DD vary). For a sum term, a variable that is constant 0 appears in true form and one that is constant 1 appears complemented: A+B′A + B'.

Step 2. The zeros 4, 5, 12, 13 form a second group of 4 with B=1B = 1 and C=0C = 0 constant (AA and DD vary; the rows 01 and 11 are neighbours and so are the columns 00 and 01). It reads B′+CB' + C. Cells 4 and 5 are in both groups, which is allowed.

Result. F=(A+B′)(B′+C)F = (A + B')(B' + C). Check: F=0F = 0 when A=0A = 0 and B=1B = 1 (rows 4 to 7) or when B=1B = 1 and C=0C = 0 (rows 4, 5, 12, 13): exactly the six zeros.

EX 5No essential prime implicant: two minimal answers

GATE level

Two equally good answers: F = sum m(0, 1, 2, 5, 6, 7): Fill in the map

Exact minimiser, not typed
A\BC00011110
010110312
104151716

Small number = minterm index. X = don't care. Row and column labels are in Gray-code order.

Groups so far (product terms)

None yet.

Step 1

Each cell is one row of the truth table. The row and column labels are in Gray-code order, so any two neighbouring cells, including cells on opposite edges, differ in exactly one variable.

1 / 5
computed by script: exact integer, Fraction and truth-table evaluation (IEEE 754 patterns via Python struct where used), not typed by hand. python3 scripts/gen-dl-traces.py

F=∑m(0,1,2,5,6,7)F = \sum m(0, 1, 2, 5, 6, 7). The six 1-cells form a ring: each is covered by exactly two of the six prime implicants A′B′A'B', A′C′A'C', B′CB'C, BC′BC', ACAC, ABAB (cells 0 and 1, 0 and 2, 1 and 5, 2 and 6, 5 and 7, 6 and 7). No cell is covered by only one, so there are no essential prime implicants.

Any three non-overlapping groups of two cover the ring, and there are exactly two minimal answers: A′B′+BC′+ACA'B' + BC' + AC and A′C′+B′C+ABA'C' + B'C + AB, each with 3 terms and 6 literals. The animation shows one of them. A question that asks for "the" minimal expression will list only one of the options as correct, and the other must not appear.

EX 6Counting prime implicants

GATE level
Functionprime implicantsessential
∑m(0,2,4,5,6)\sum m(0,2,4,5,6) (3 variables)2 (C′C', AB′AB')2
corners function (4 variables)2 (B′D′B'D', BDBD)2
∑m(1,3,7,11,15)+d(0,2,5)\sum m(1,3,7,11,15) + d(0,2,5)3 (CDCD, A′DA'D, A′B′A'B')1 (CDCD)
∑m(0,1,2,5,6,7)\sum m(0,1,2,5,6,7)60
parity ∑m(1,2,4,7)\sum m(1,2,4,7)44

For the parity function every 1-cell is isolated, so each minterm is a prime implicant on its own and is essential.

EX 7SOP is cheaper than POS for AB + CD

GATE level

For F=AB+CDF = AB + CD the minimal SOP has 2 terms, 4 literals. Its minimal POS is (A+C)(A+D)(B+C)(B+D)(A + C)(A + D)(B + C)(B + D): 4 sum terms, 8 literals. Whether the SOP or POS form is cheaper depends on the function. If a question asks for the cheaper two-level form, find both (group the 1s, then the 0s) and compare their literal or gate counts.

Cheat box

Cheat box

  • Gray-code labels: 00, 01, 11, 10. Edges wrap: the four corners of a 4-variable map are adjacent.
  • Group sizes 1, 2, 4, 8, 16 (powers of two), rectangles only. A group of 2k2^k cells drops kk variables (term has n−kn - k literals).
  • SOP from 1s: constant 1 gives the variable, constant 0 its complement. POS from 0s: constant 0 gives the variable, constant 1 its complement.
  • Essential prime implicant: covers a 1 nobody else covers. It is in every minimal answer.
  • Don't cares: use them only to enlarge groups; never cover a don't care on its own.
  • Overlap is allowed. The answer is not always unique (cyclic case: 2 answers, 0 essentials).
  • Parity (XOR of nn variables): checkerboard, no groups bigger than 1, 2n−12^{n-1} terms.
  • 5 variables: two 4-variable maps, with matching cells adjacent. Beyond that, use the tabular method.

Traps and GATE patterns

Connections

A K-map starts from the canonical forms in SOP, POS, minterms and maxterms and its answer feeds the gate networks of logic gates and the whole flow in combinational design. Two adjacent prime implicants that are not overlapped can cause a glitch; that is the subject of static hazards. The tabular method is the same idea in a form a program can carry out.

PYQs

5 previous year questions from your book. I re-solved each one myself (5 by running or simulating, 0 by reasoning only); the book's key is shown next to my answer. All PYQs

GATE 2026 · Set 1 · MSQQ2 · page 164 of the book
Consider a Boolean function F with the following
min-term expression:
F(P, Q, R, S) = Σm(1, 2, 3, 4, 5, 7, 10, 12, 13, 14)

Which of the following options is/are the minimal
sum-of-products expression(s) of F?
  • (a)P ̅S+ QR ̅ + P ̅Q ̅R+ Q ̅RS ̅
  • (b)P ̅S+ QR ̅ + P ̅QR ̅ + PRS ̅
  • (c)P ̅S+ QR ̅ + PQS ̅ + PRS ̅
  • (d)P ̅S+ QR ̅ + PQS ̅ + Q ̅RS ̅
GATE 2026 · Set 2 · MCQ · 2 marksQ3 · page 164 of the book
Consider the following 4-variable Boolean
function
F(A, B, C, D) = Σm(0, 1, 2, 3, 8, 9, 10, 11)

Consider A as MSB, D as LSB. Which one of the
following options represents the minimal sum of
products form for the above function?

Note: + is OR operation, · is AND operation, ' is
NOT operation
  • (a)A' + B' + C' + D'
  • (b)B'
  • (c)A'·B' + A·B
  • (d)A'
GATE 2015 · Set 2 · NAT · 2 marksQ15 · page 166 of the book
The number of min-terms after minimizing the
following Boolean expression is ________.

[D' + AB' + A'C + AC'D + A'C'D]'.
GATE 2007 · MCQ · 1 markQ26 · page 167 of the book
Let f(w,x,y,z) = Σ (0,4,5,7,8,9,13,15). Which of the
following expressions are NOT equivalent to f?

          P: x'y'z' + w'xy' + wy'z + xz

          Q: w'y'z' + wx'y' + xz

          R: w'y'z' + wx'y' + xyz + xy'z

DIGITAL LOGIC
          S: x'y'z' + wx'y' + w'y
  • (a)P only
  • (b)Q and S
  • (c)R and S
  • (d)S only
GATE 2006 · MCQ · 1 markQ28 · page 168 of the book
The boolean function for a combinational circuit
with four inputs is represented by the following
Karnaugh map.

Which of the product terms given below is an
essential prime implicant of the function?
  • (a)QRS
  • (b)PQS
  • (c)PQ'S'
  • (d)Q'S'

Self-check

Question 1

Minimise F=∑m(1,3,5,7)F = \sum m(1,3,5,7) over A,B,CA, B, C.

Show answer

All four cells have C=1C = 1 and AA, BB vary, so one group of 4 reads CC. F=CF = C.

Question 2

Minimise F=∑m(0,1,4,5,8,9,12,13)F = \sum m(0,1,4,5,8,9,12,13) over A,B,C,DA, B, C, D.

Show answer

All eight cells have C=0C = 0, DD varies in {0,1}\{0,1\} and AA, BB cover all four values, so AA, BB and DD are dropped in a group of 8 reading C′C'. F=C′F = C'.

Question 3

How many prime implicants and how many essential prime implicants does the three-variable parity function A⊕B⊕CA \oplus B \oplus C have?

Show answer

4 prime implicants (the four minterms A′B′CA'B'C, A′BC′A'BC', AB′C′AB'C', ABCABC) and all 4 are essential.

Question 4

A group of 8 cells on a four-variable map reads a term with how many literals?

Show answer

8=238 = 2^3, so three variables are dropped and the term has 4−3=14 - 3 = 1 literal.

Revision card

One-screen revision

  • Gray-code labels, wrap-around edges (corners are neighbours). Groups: rectangles of 2k2^k cells; a group drops kk variables.
  • Steps: fill, find prime implicants, take essential ones, cover the rest with the fewest groups, read terms.
  • SOP groups 1s (constant 1 gives the variable). POS groups 0s (constant 0 gives the variable).
  • Don't cares only help enlarge groups. The answer may not be unique (ring of six has 0 essentials, 2 answers).
  • Parity has no groups larger than one cell.

References

  • ·Mano and Ciletti, Digital Design, 5th ed., Chapter 3 Gate-Level Minimization (the map method, product-of-sums simplification, don't-care conditions)
  • ·Kohavi and Jha, Switching and Finite Automata Theory, Chapter 4 Minimization of switching functions

Verification

Every group, term and result in the animations comes from an exact minimiser (Quine-McCluskey prime implicants plus an exhaustive minimum cover, scripts/dl_minimize.py). tests/dl-traces.test.ts re-derives each term from the group's cells independently and checks the Gray-code labels, rectangle shape, power-of-two size and coverage. scripts/enum-checks/dl_forms.py checks minimal covers for all 256 three-variable functions, 300 random four-variable functions with don't cares (also against a second exhaustive search), the prime implicant counts and essential sets quoted here, and that every cube is a rectangle on the map. The C program is compiled and run by npm run verify:c. Textbook chapter titles are from memory; the independent second pass has not been run, so the page stays draft. SECOND PASS (2026-11-02, done by the assistant, not a human check): every Self-check question was solved before the printed answer was read and all agreed; the definitions, worked examples, cheat box and traps were read claim by claim and the numbers re-derived by hand or by a small script (conversions, signed ranges and flags, IEEE 754 fields and custom formats, Boolean identities and counts, K-map groups, adder carries, BCD correction, flip-flop conversions, counter sequences and T equations, state reduction, Quine-McCluskey rounds and covers, floating-point alignment and rounding); long C programs were not re-read line by line (they are compiled and compared by npm run verify:c, and their printed outputs were checked against the prose); tables and animations are machine output and were read, not re-run; No other defect found. Status raised to self-checked; verified needs a textbook or human check.

last verified: never