Skip to content
KmapGen

5-Variable K-Map Solver

Solve a 5-variable Karnaugh map drawn as two 4×4 maps (A = 0 and A = 1), with groups that span both maps, don’t-cares and every minimal answer.

Variables
5-variable Karnaugh map (click cells to edit)A = 0BCDE000111100001111000111302041517061120130150141809011010A = 1BCDE0001111000011110016117119018020121123022028029031130X24025027126

Click or tap a cell to change it. Keyboard: Tab to the map, arrows move, Enter or Space cycles, 0 / 1 / X set the value. Small numbers are minterm numbers.

Minimal SOP (sum of products)

F = ABDE' + A'BD'E' + B'E

3 product terms, 10 literals
Unique minimal answer.

Minimal POS (product of sums)

F = (A + D' + E)(A' + D + E)(B + E)(B' + E')

4 sum terms, 10 literals
4 equally minimal answers:

Step-by-step solution

1. Groups on the map (SOP)

The 1s are covered by 3 groups. In each product term, a variable that stays 1 across the group appears as is and one that stays 0 appears complemented. Hover or tap a term to highlight its group.

  • ABDE' group of 2 · cells 26, 30 · pattern 11–10 essential

    A = 1, B = 1, D = 1, E = 0 in every cell; C changes inside the group and drops out. It is essential: m30 is covered by no other prime implicant.

  • A'BD'E' group of 2 · cells 8, 12 · pattern 01–00 essential

    A = 0, B = 1, D = 0, E = 0 in every cell; C changes inside the group and drops out. It is essential: m12 is covered by no other prime implicant.

  • B'E group of 8 · cells 1, 3, 5, 7, 17, 19, 21, 23 · pattern –0––1 essential wraps 2 sub-maps

    B = 0, E = 1 in every cell; A, C, D change inside the group and drop out. It is essential: m1, m3, m5, m7, m17, m19, m21, m23 are covered by no other prime implicant.

2. Prime implicants and essential primes

Each row is a prime implicant (a group that cannot be made larger). A ⊗ marks a minterm covered by a single prime: that prime is essential (*) and must be in every minimal answer.

PrimeTermPatternm1m3m5m7m8m12m17m19m21m23m26m30
P1 *B'E–0––1⊗⊗⊗⊗⊗⊗⊗⊗
P2 *A'BD'E'01–00×⊗
P3BC'D'E'–1000×
P4ABC'E'110–0×
P5 *ABDE'11–10×⊗

Essential: P1, P2, P5. The essential primes cover everything.

3. Petrick's method: choosing the cheapest cover

Not needed: the essential prime implicants already cover every required cell, so the answer is unique.

4. Quine–McCluskey tabulation

Cells are sorted by their number of 1 bits. Two entries in neighboring groups combine when their patterns differ in exactly one position (that position becomes –). ✓ = combined further; PI = could not be combined, so it is a prime implicant.

Groups of 1

1sCellsPattern
1100001✓
801000✓
2300011✓
500101✓
1201100✓
1710001✓
2411000✓
3700111✓
1910011✓
2110101✓
2611010✓
42310111✓
3011110✓

Groups of 2

1sCellsPattern
11,3000–1✓
1,500–01✓
1,17–0001✓
8,1201–00PI
8,24–1000PI
23,700–11✓
3,19–0011✓
5,7001–1✓
5,21–0101✓
17,19100–1✓
17,2110–01✓
24,26110–0PI
37,23–0111✓
19,2310–11✓
21,23101–1✓
26,3011–10PI

Groups of 4

1sCellsPattern
11,3,5,700––1✓
1,3,17,19–00–1✓
1,5,17,21–0–01✓
23,7,19,23–0–11✓
5,7,21,23–01–1✓
17,19,21,2310––1✓

Groups of 8

1sCellsPattern
11,3,5,7,17,19,21,23–0––1PI
5. Truth table, Σm, ΠM and canonical forms
#ABCDEF
0000000
1000011
2000100
3000111
4001000
5001011
6001100
7001111
8010001
9010010
10010100
11010110
12011001
13011010
14011100
15011110
16100000
17100011
18100100
19100111
20101000
21101011
22101100
23101111
2411000X
25110010
26110101
27110110
28111000
29111010
30111101
31111110

Minterm list: F = Σm(1, 3, 5, 7, 8, 12, 17, 19, 21, 23, 26, 30) + d(24)

Maxterm list: F = ΠM(0, 2, 4, 6, 9, 10, 11, 13, 14, 15, 16, 18, 20, 22, 25, 27, 28, 29, 31) · D(24)

Canonical SOP (one term per 1): A'B'C'D'E + A'B'C'DE + A'B'CD'E + A'B'CDE + A'BC'D'E' + A'BCD'E' + AB'C'D'E + AB'C'DE + AB'CD'E + AB'CDE + ABC'DE' + ABCDE'

Canonical POS (one clause per 0): (A + B + C + D + E)(A + B + C + D' + E)(A + B + C' + D + E)(A + B + C' + D' + E)(A + B' + C + D + E')(A + B' + C + D' + E)(A + B' + C + D' + E')(A + B' + C' + D + E')(A + B' + C' + D' + E)(A + B' + C' + D' + E')(A' + B + C + D + E)(A' + B + C + D' + E)(A' + B + C' + D + E)(A' + B + C' + D' + E)(A' + B' + C + D + E')(A' + B' + C + D' + E')(A' + B' + C' + D + E)(A' + B' + C' + D + E')(A' + B' + C' + D' + E')

Row number = minterm number, with A as the most significant bit.

6. Logic circuit (AND–OR)

Two-level AND–OR realization: one AND gate per term (a single-literal term is wired straight through), then one OR gate. 8 gates including inverters, 13 gate inputs. Replacing every AND and the final OR with NAND gates gives the equivalent NAND–NAND circuit with the same wiring (single-literal terms then need their complement).

AA′BB′DD′EE′F

Two maps, one function

The first variable, A, chooses the map; the other four are laid out exactly like a 4-variable K-map with BC on the rows and DE on the columns.

A = 0: minterm numbers
BC \ DE 00011110
00 m0m1m3m2
01 m4m5m7m6
11 m12m13m15m14
10 m8m9m11m10
A = 1: minterm numbers
BC \ DE 00011110
00 m16m17m19m18
01 m20m21m23m22
11 m28m29m31m30
10 m24m25m27m26

Grouping rules for 5 variables

  • Inside one map, the usual 4-variable rules apply, including wrap-around at the edges. A group drawn in one map only keeps A (A′ in the left map, A in the right map).
  • A group can extend to the other map only if the same cells are grouped in both maps. It then loses A and doubles in size.
  • Look for cross-map groups first: they are the ones people miss, and they are often essential.

Worked example: F = Σm(0, 2, 4, 6, 9, 13, 21, 23, 25, 29, 31)

In the A = 0 map, m0, m2, m4 and m6 form a group of four (A′B′E′). m13 in the A = 0 map and m29 in the A = 1 map are in the same position, as are m9 and m25, so BD′E spans both maps. What is left in the A = 1 map, m21, m23 and m31 with m29, groups as ACE.

Solved 5-variable K-map for Σm(0, 2, 4, 6, 9, 13, 21, 23, 25, 29, 31)A = 0BCDE000111100001111010010312140507160121130150140819011010A = 1BCDE0001111000011110016017019018020121123022028129131030024125027026
F = Σm(0, 2, 4, 6, 9, 13, 21, 23, 25, 29, 31) → F = ACE + A'B'E' + BD'E
  1. ACE: group of 4 (m21, m23, m29, m31), essential. A = 1, C = 1, E = 1 in every cell; B, D change inside the group and drop out.
  2. A'B'E': group of 4 (m0, m2, m4, m6), wrapping left–right edges, essential. A = 0, B = 0, E = 0 in every cell; C, D change inside the group and drop out.
  3. BD'E: group of 4 (m9, m13, m25, m29), wrapping 2 sub-maps, essential. B = 1, D = 0, E = 1 in every cell; A, C change inside the group and drop out.

Result: F = ACE + A'B'E' + BD'E, 3 terms and 9 literals. Open this example in the solver.

A second example with a don’t-care

F = Σm(0, 1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 30, 31) + d(7). The 1s with D = 0 in the left map form A′D′ (eight cells), the cells with B = 0 and D = 0 appear in both maps (B′D′), and m30 with m31 gives ABCD. The don’t-care m7 is left out because it would not make any group larger.

Solved 5-variable K-map for Σm(0, 1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 30, 31) + d(7)A = 0BCDE0001111000011110101103021415X7061121130150141819011010A = 1BCDE0001111000011110116117019018120121023022028029131130024025027026
F = Σm(0, 1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 30, 31) + d(7) → F = ABCD + A'D' + B'D'
  1. ABCD: group of 2 (m30, m31), essential. A = 1, B = 1, C = 1, D = 1 in every cell; E changes inside the group and drops out.
  2. A'D': group of 8 (m0, m1, m4, m5, m8, m9, m12, m13), essential. A = 0, D = 0 in every cell; B, C, E change inside the group and drop out.
  3. B'D': group of 8 (m0, m1, m4, m5, m16, m17, m20, m21), wrapping 2 sub-maps, essential. B = 0, D = 0 in every cell; A, C, E change inside the group and drop out.

Result: F = ABCD + A'D' + B'D', 3 terms and 8 literals. Open this example in the solver.

Frequently asked questions

How do you draw a 5-variable K-map?

As two 4×4 maps side by side, one for A = 0 (minterms 0–15) and one for A = 1 (minterms 16–31). Inside each map, BC labels the rows and DE the columns in the usual Gray-code order. Each cell in the A = 1 map is the cell in the same position in the A = 0 map plus 16.

Which cells are adjacent across the two maps?

Cells in the same position: m5 (A = 0) and m21 (A = 1) differ only in A. Picture the two maps stacked on top of each other. A group that appears in exactly the same place on both maps is one group, and A drops out of its term.

Why not draw a single 4×8 map?

You can, using the 3-bit reflected Gray code 000, 001, 011, 010, 110, 111, 101, 100 for the columns, but then some adjacencies are “mirror” pairs that are not next to each other: column 000 is adjacent to column 010, three places to its right, by reflection about the center of the left half. The two-map layout makes every adjacency a same-position match, which is easier to see.

How large can a group be in a 5-variable K-map?

1, 2, 4, 8, 16 or 32 cells. A 16-cell group leaves a single literal; for example all cells with E = 0 are two columns in each map, eight cells per map.