↓ Skip to main content

Simplifying Logic Functions: Minterms, Maxterms, and the Karnaugh Map

·4717 words·23 mins·
 Author
Author
Francisco Bustamante
Chemist, data scientist and Python programmer.
Table of Contents
Inside the Computer - This article is part of a series.
Part 3: This Article

Every digital circuit, from a simple adder to a modern processor, starts with a logic function described in a truth table. From there, the engineer needs to find the Boolean expression that implements that function with the smallest possible number of logic gates. Fewer gates mean a smaller, cheaper, and faster circuit.

This article is the practical companion to the previous article Boolean Algebra: the mathematical foundation of digital computing: while that article built the theoretical foundations (postulates, theorems, and identities), this one puts them to work simplifying logic functions. We present three methods: the canonical forms (minterms and maxterms), which translate any truth table directly into an algebraic expression; algebraic simplification, which applies the theorems already studied to reduce terms and literals; and the Karnaugh map, a graphical tool that makes the process visual and systematic, without depending on algebraic intuition.

From the truth table to the expression: canonical forms
#

The two forms presented below, sum of minterms and product of maxterms, are the so-called canonical forms of a logic function: any truth table can be written directly in each of them.

Minterms and the SOP form
#

Consider the majority voter for three voters A, B, C: the output \(F\) is 1 when two or more voters vote 1.

A B C F
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1

By inspection, we can write one expression for each row where \(F = 1\):

$$F = \bar{A}BC + A\bar{B}C + AB\bar{C} + ABC$$

Each of these products contains all three variables (in direct or complemented form). These complete products have a special name:

Minterm

A minterm of \(n\) variables is a logical product that contains all \(n\) variables, each appearing exactly once, in its direct or complemented form.

A minterm is 1 in exactly one row of the truth table. The sum of minterms (the SOP form, Sum of Products) represents the function at the points where it is 1.

Each minterm gets an index \(m_i\) equal to the decimal value of the input combination: we read the values of the variables as a binary number and convert it to decimal. For example, the combination A=0, B=1, C=1 forms the binary number \(011_2 = 3_{10}\), so the corresponding minterm is \(m_3\).

The index does not depend on the order of the table

When the truth table is built in increasing binary order (000, 001, 010, …, 111), the minterm index coincides with the row number (counting from zero). But this coincidence does not hold if the table is in another order. The index is always determined by the values of the variables, not by the position in the table.

The expression above can then be written in compact notation:

$$F = \bar{A}BC + A\bar{B}C + AB\bar{C} + ABC = m_3 + m_5 + m_6 + m_7$$$$\boxed{F(A,B,C) = \sum(3, 5, 6, 7)}$$

Maxterms and the POS form
#

The starting point is \(\bar{F}\), the complement of \(F\). Since \(F = 1\) in combinations 3, 5, 6, and 7, then \(\bar{F} = 1\) in the remaining combinations: 0, 1, 2, and 4. That is:

$$\bar{F} = m_0 + m_1 + m_2 + m_4$$

Now we apply De Morgan to the whole expression of \(\bar{F}\) to recover \(F\):

$$F = \overline{\bar{F}} = \overline{m_0 + m_1 + m_2 + m_4} = \bar{m}_0 \cdot \bar{m}_1 \cdot \bar{m}_2 \cdot \bar{m}_4$$

What is \(\bar{m}_i\)? It is De Morgan applied to a minterm. For example:

$$\bar{m}_0 = \overline{\bar{A}\bar{B}\bar{C}} = A + B + C$$

Generalizing: the negation of a minterm \(m_i\) is exactly the maxterm \(M_i\), in which the variables that were complemented become direct, and vice versa. Therefore:

$$F = \bar{m}_0 \cdot \bar{m}_1 \cdot \bar{m}_2 \cdot \bar{m}_4 = M_0 \cdot M_1 \cdot M_2 \cdot M_4$$
Maxterm

A maxterm of \(n\) variables is a logical sum that contains all \(n\) variables, each appearing exactly once.

A maxterm is 0 in exactly one row of the truth table. The product of maxterms (the POS form, Product of Sums) represents the function at the points where it is 0.

In compact notation:

$$\boxed{F(A,B,C) = \prod(0, 1, 2, 4)}$$
The SOP ↔ POS relation

The minterm and maxterm indices of the same function are always complementary: if \(F = \sum(3,5,6,7)\), then necessarily \(F = \prod(0,1,2,4)\). The two sets add up to all \(2^n\) possible indices.

Which form to implement?

In practice, the choice between SOP and POS depends both on the result of the simplification (which form has fewer terms and literals) and on the available hardware:

  • NAND gates (the most common in CMOS technology) favor the SOP form: two levels of NAND gates directly implement any sum-of-products expression.
  • NOR gates favor the POS form: two levels of NOR gates directly implement any product-of-sums expression.

Therefore, it is advisable to simplify the function in both forms and compare the cost in literals before choosing which one to implement.

General table of minterms and maxterms (3 variables)
#

Row x y z Minterm \(m_i\) Maxterm \(M_i\)
0 0 0 0 \(\bar{x}\bar{y}\bar{z}\) \(x+y+z\)
1 0 0 1 \(\bar{x}\bar{y}z\) \(x+y+\bar{z}\)
2 0 1 0 \(\bar{x}y\bar{z}\) \(x+\bar{y}+z\)
3 0 1 1 \(\bar{x}yz\) \(x+\bar{y}+\bar{z}\)
4 1 0 0 \(x\bar{y}\bar{z}\) \(\bar{x}+y+z\)
5 1 0 1 \(x\bar{y}z\) \(\bar{x}+y+\bar{z}\)
6 1 1 0 \(xy\bar{z}\) \(\bar{x}+\bar{y}+z\)
7 1 1 1 \(xyz\) \(\bar{x}+\bar{y}+\bar{z}\)

Notice the pattern: in the minterm \(m_i\), a variable appears complemented if the corresponding bit of \(i\) is 0, and in direct form if it is 1. In the maxterm \(M_i\) the opposite happens.

For example, row 5 has \(x=1, y=0, z=1\), that is, \(i = 101_2 = 5_{10}\):

  • \(m_5 = x\bar{y}z\): x direct (bit 1), y complemented (bit 0), z direct (bit 1)
  • \(M_5 = \bar{x}+y+\bar{z}\): x complemented (bit 1), y direct (bit 0), z complemented (bit 1)

Exercises
#

Exercise 1: \(F(A,B,C) = \sum(1,3,5,7)\): represent it as a product of maxterms
Solution

The missing indices (where \(F = 0\)) are 0, 2, 4, 6. Therefore:

$$F(A,B,C) = \prod(0,2,4,6) = M_0 \cdot M_2 \cdot M_4 \cdot M_6$$

Expanding:

$$F = (A+B+C)(A+\bar{B}+C)(\bar{A}+B+C)(\bar{A}+\bar{B}+C)$$

Note that all the maxterms have \(C\) in direct form. This is a hint that \(C\) is the determining variable: \(\sum(1,3,5,7)\) are exactly the odd indices, that is, all the combinations with \(C=1\). Algebraic simplification confirms it:

Algebraic simplification
$$\begin{align} F &= \bar{A}\bar{B}C + \bar{A}BC + A\bar{B}C + ABC \\ &= \bar{A}C\underbrace{(\bar{B}+B)}_{=1} + AC\underbrace{(\bar{B}+B)}_{=1} \\ &= \bar{A}C + AC = C\underbrace{(\bar{A}+A)}_{=1} = \boxed{C} \end{align}$$
Exercise 2: Represent the function in the table as SOP and POS
A B C F
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 0
Solution

\(F = 1\) at indices 1, 2, 4 (combinations \(001_2\), \(010_2\), \(100_2\)):

$$F = \sum(1,2,4) = \bar{A}\bar{B}C + \bar{A}B\bar{C} + A\bar{B}\bar{C}$$

\(F = 0\) at indices 0, 3, 5, 6, 7 (combinations \(000_2\), \(011_2\), \(101_2\), \(110_2\), \(111_2\)):

$$F = \prod(0,3,5,6,7) = (A+B+C)(A+\bar{B}+\bar{C})(\bar{A}+B+\bar{C})(\bar{A}+\bar{B}+C)(\bar{A}+\bar{B}+\bar{C})$$
SOP and POS indices are always complementary

Each minterm \(m_i\) is 1 exactly at combination \(i\), so the SOP lists the indices where \(F = 1\). Each maxterm \(M_i\) is 0 exactly at combination \(i\), so the POS lists the indices where \(F = 0\). Since every combination belongs to one of the two cases, \(\{1,2,4\} \cup \{0,3,5,6,7\} = \{0,\ldots,7\}\): the two sets partition the input space.

Also note the opposite complementation rule: for index 1 (\(001_2\)), the minterm is \(m_1 = \bar{A}\bar{B}C\) (bit 0 → complemented, bit 1 → direct), while the maxterm is \(M_1 = A+B+\bar{C}\) (bit 0 → direct, bit 1 → complemented). The same bit pattern generates opposite literals in the two forms.

Algebraic simplification
#

With the expression in canonical form in hand, we can apply the postulates and theorems of Boolean algebra to reduce the number of terms and literals. The result is an equivalent but simpler expression.

Example 1, majority voter: \(F(A,B,C) = \sum(3,5,6,7)\)
$$\begin{align} F &= \bar{A}BC + A\bar{B}C + AB\bar{C} + ABC \\ &= \bar{A}BC + A\bar{B}C + AB\underbrace{(\bar{C}+C)}_{=1} \\ &= \bar{A}BC + A\bar{B}C + AB \\ &= B\underbrace{(\bar{A}C + A)}_{\text{Theorem: }X + \bar{X}Y = X+Y} + A\bar{B}C \\ &= B(A + C) + A\bar{B}C \\ &= AB + BC + A\bar{B}C \\ &= AB + C\underbrace{(B + A\bar{B})}_{\text{Theorem: }X + \bar{X}Y = X+Y} \\ &= AB + C(B + A) \\ &\boxed{F = AB + AC + BC} \end{align}$$
Example 2: \(F(A,B,C) = \sum(3,7)\)
$$F = \bar{A}BC + ABC = BC\underbrace{(\bar{A}+A)}_{=1} = \boxed{BC}$$
Example 3: \(F(A,B,C) = \sum(4,5,6,7)\)
$$\begin{align} F &= A\bar{B}\bar{C} + A\bar{B}C + AB\bar{C} + ABC \\ &= A\bar{B}\underbrace{(\bar{C}+C)}_{=1} + AB\underbrace{(\bar{C}+C)}_{=1} \\ &= A\bar{B} + AB = A\underbrace{(\bar{B}+B)}_{=1} = \boxed{A} \end{align}$$
Example 4: \(F(A,B,C) = \sum(0,2,4,6)\)
$$\begin{align} F &= \bar{A}\bar{B}\bar{C} + \bar{A}B\bar{C} + A\bar{B}\bar{C} + AB\bar{C} \\ &= \bar{A}\bar{C}\underbrace{(\bar{B}+B)}_{=1} + A\bar{C}\underbrace{(\bar{B}+B)}_{=1} \\ &= \bar{A}\bar{C} + A\bar{C} = \bar{C}\underbrace{(\bar{A}+A)}_{=1} = \boxed{\bar{C}} \end{align}$$
Limitation of algebraic simplification

The method works well for simple functions, but it is not systematic: there is no guaranteed procedure that leads to the minimum, and the sequence of steps depends on intuition and experience. For functions with many minterms or many variables, the Karnaugh map is far more efficient.

Karnaugh map
#

To overcome these limitations, the Karnaugh map offers a visual and systematic procedure that leads to the minimal expression in sum of products (or in product of sums), as long as the groups are chosen correctly, without depending on algebraic intuition.

Definition

The Karnaugh map (K-map; Maurice Karnaugh, 1953, inspired by the Veitch diagram of 1952) is a graphical representation of the truth table where each cell corresponds to a minterm. The minterms are arranged so that neighboring cells differ in exactly one variable, which lets us see simplifiable groups visually.

The Gray code: why the order matters
#

The column sequence is not binary!

The columns (and rows) of the Karnaugh map follow the Gray code: each adjacent position differs in only 1 bit. For two bits, the sequence is:

$$00 \to 01 \to 11 \to 10$$

Note that the order is not 00 → 01 → 10 → 11 (ordinary binary). This peculiarity is what guarantees logical adjacency between neighboring cells.

2-variable map
#

For \(F(A,B)\), the map is a 2×2 grid:

\(A \backslash B\) \(B=0\) \(B=1\)
\(A=0\) \(m_0\) \(m_1\)
\(A=1\) \(m_2\) \(m_3\)

Example: \(F(A,B) = \bar{A}B + A\bar{B}\)

karnaugh2x2
Example of a Karnaugh map for 2 variables
The cells \(m_1\) and \(m_2\) are 1 and are diagonally opposite on the map, so they do not form any valid adjacent group. The canonical expression is already the minimal form: \(F = A \oplus B\) (XOR).

3-variable map
#

For \(F(A,B,C)\), the map is a 2×4 grid, with the columns labeled by the pair \(BC\) in Gray sequence:

\(A \backslash BC\) 00 01 11 10
0 \(m_0\) \(m_1\) \(m_3\) \(m_2\)
1 \(m_4\) \(m_5\) \(m_7\) \(m_6\)

Example: \(F(A,B,C) = \bar{A}\bar{B}\bar{C} + \bar{A}BC + A\bar{B}\bar{C} + ABC\)

\(A \backslash BC\) 00 01 11 10
0 1 0 1 0
1 1 0 1 0

The cells \(m_0, m_3, m_4, m_7\) are 1, which is equivalent to \(F(A,B,C) = \sum(0,3,4,7)\).

Next, we will see how these maps let us simplify logic functions.

Simplification rules with Karnaugh
#

Before looking at examples, it is worth systematizing the rules:

Group size Variables eliminated Variables remaining
1 cell 0 \(n\)
2 cells 1 \(n-1\)
4 cells 2 \(n-2\)
8 cells 3 \(n-3\)

The simplification algorithm follows this order:

  1. 1

    Isolated cells first

    Minterms with no neighbor equal to 1; they do not simplify, but they are part of the function.
  2. 2

    Only one possibility

    Minterms that can belong to only one group; that group is mandatory (an essential prime implicant).
  3. 3

    Maximum number of cells

    For the remaining minterms, form the largest possible group (a power of 2).
  4. 4

    Avoid redundancy

    If all the minterms of a group have already been covered by previous groups, that group generates a redundant term and must be discarded.
Implicant and prime implicant
  • Implicant of \(F\): any product of literals \(P\) such that, whenever \(P = 1\), also \(F = 1\). On the K-map, it corresponds to any valid group of 1s.
  • Prime implicant: an implicant from which no literal can be removed without it ceasing to be an implicant, that is, the largest possible group covering certain minterms.
  • Essential prime implicant: a prime implicant that is the only one covering at least one minterm. It must be part of the minimal cover.
Groups only with powers of 2

Groups of 3, 5, 6, or any number that is not a power of 2 are invalid. The size must always be 1, 2, 4, 8, 16…

POS simplification: group the 0s

The procedure presented here, which groups the 1s, produces the SOP form (sum of products). To obtain the POS form (product of sums) directly from the K-map, we apply the same process to the 0s of the map: each group of 0s generates a simplified maxterm, and the final result is the product of these maxterms.

Simplification: 3-variable map
#

Returning to the example \(F(A,B,C) = \sum(0,3,4,7)\) presented above, there are two groups of adjacent cells with value 1. The following figure highlights them:

karnaugh3x4
Example of a Karnaugh map for 3 variables, with the groups highlighted

  • Group 1: \(m_0\) and \(m_4\) (column 00, both rows) → \(\bar{B}\bar{C}\)
  • Group 2: \(m_3\) and \(m_7\) (column 11, both rows) → \(BC\)

Therefore, the function can be simplified to:

$$\boxed{F = \bar{B}\bar{C} + BC}$$

4-variable map
#

For \(F(A,B,C,D)\), the map is a 4×4 grid, with rows labeled by \(AB\) and columns by \(CD\), both in Gray sequence:

\(AB \backslash CD\) 00 01 11 10
00 \(m_0\) \(m_1\) \(m_3\) \(m_2\)
01 \(m_4\) \(m_5\) \(m_7\) \(m_6\)
11 \(m_{12}\) \(m_{13}\) \(m_{15}\) \(m_{14}\)
10 \(m_8\) \(m_9\) \(m_{11}\) \(m_{10}\)
The map is toroidal: the edges touch

The Karnaugh map should be imagined as a torus: the first and last columns are adjacent, and the same holds for the first and last rows. This means that the four corners (\(m_0, m_2, m_8, m_{10}\)) also form a valid group!

To understand the geometry, think of folding the rectangle twice: first joining the side edges (forming a cylinder), then joining the circular edges of the cylinder (forming the torus):

Transformation of a rectangle into a torus
From the flat rectangle to the torus: first the side edges join, then the top and bottom edges. Source: Wikipedia

The final result, with the minterms placed on the toroidal surface:

Karnaugh map as a toroidal surface
Toroidal representation of the Karnaugh map, with opposite edges adjacent. Source: Wikipedia

Source: Karnaugh map: Wikipedia

The figure below shows how the function \(F(A,B,C,D) = \bar{A}\bar{B}\bar{C}D + \bar{A}\bar{B}C\bar{D} + \bar{A}\bar{B}CD + \bar{A}BC\bar{D} + \bar{A}BCD + A\bar{B}\bar{C}D + AB\bar{C}\bar{D} \) can be simplified using the Karnaugh map:

karnaugh4x4
Example of a Karnaugh map for 4 variables, with the groups highlighted

The filled map, equivalent to \(F = \sum(1,2,3,6,7,9,12)\), is:

\(AB \backslash CD\) 00 01 11 10
00 0 1 1 1
01 0 0 1 1
11 1 0 0 0
10 0 1 0 0

The groups identified are:

  • Group of 4: \(m_2, m_3, m_6, m_7\), columns \(CD = 10\) and \(CD = 11\), rows \(AB = 00\) and \(AB = 01\); fixed variables \(A = 0\) and \(C = 1\) → \(\bar{A}C\)
  • Group of 2 (toroidal): \(m_1, m_9\), column \(CD = 01\), rows \(AB = 00\) and \(AB = 10\) (the top and bottom edges touch on the torus); fixed variables \(B = 0, C = 0, D = 1\) → \(\bar{B}\bar{C}D\)
  • Isolated cell: \(m_{12}\), all four neighbors are 0; \(A = 1, B = 1, C = 0, D = 0\) → \(AB\bar{C}\bar{D}\)
$$\boxed{F = \bar{A}C + \bar{B}\bar{C}D + AB\bar{C}\bar{D}}$$

5-variable map
#

For \(F(A,B,C,D,E)\), the map grows to 32 cells, beyond the practical limit for manual work, but the structure follows the same principle. We use two 4×4 grids side by side: one for \(A=0\) and another for \(A=1\). In each grid, the rows are labeled by \(BC\) and the columns by \(DE\), both in Gray code (00 → 01 → 11 → 10).

Adjacency works normally within each grid. In addition, there is cross adjacency between the two grids: a cell at position \((i,j)\) of the \(A=0\) grid is adjacent to the cell at the same position of the \(A=1\) grid, since the two differ only in \(A\). Groups can therefore extend across both grids.

Example: \(F(A,B,C,D,E) = \sum(0,1,16,17,31)\)

Grid \(A=0\):

\(BC \backslash DE\) 00 01 11 10
00 1 1 0 0
01 0 0 0 0
11 0 0 0 0
10 0 0 0 0

Grid \(A=1\):

\(BC \backslash DE\) 00 01 11 10
00 1 1 0 0
01 0 0 0 0
11 0 0 1 0
10 0 0 0 0

Groups identified:

  • Group of 4 (crossed): \(\{m_0, m_1\}\) in grid \(A=0\) and \(\{m_{16}, m_{17}\}\) in grid \(A=1\), at the same position (row \(BC=00\), columns \(DE=00\) and \(DE=01\)). The four cells differ only in \(A\) and \(E\); what stays fixed is \(B=0, C=0, D=0\) → \(\bar{B}\bar{C}\bar{D}\).
  • Isolated cell: \(m_{31}\) in grid \(A=1\), row \(BC=11\), column \(DE=11\) → \(A=1, B=1, C=1, D=1, E=1\) → \(ABCDE\).
$$\boxed{F = \bar{B}\bar{C}\bar{D} + ABCDE}$$

For functions with 6 or more variables the K-map becomes impractical; at that point, the Quine-McCluskey method (algorithmic) is the natural alternative.

Don’t-care conditions
#

In many real systems, some input combinations never occur or, if they do, the output does not matter. These conditions are called don’t-care conditions and are marked with X on the map.

The classic example is the BCD decoder (Binary-Coded Decimal): the decimal digits 0 to 9 use only the combinations 0000 to 1001. The combinations 1010 to 1111 (10 to 15) are invalid: they never appear as input. Therefore, the behavior of the output for these cells is irrelevant and can be marked as X.

Rules for using the Xs on the map
  • Use the Xs to enlarge groups when that results in a larger group (a larger power of 2) and, therefore, a simpler term.
  • Never form a group made only of Xs: those minterms do not need to be covered, and including them unnecessarily only adds terms.
  • An X that does not help any group can simply be ignored.
Example with don’t care

Suppose \(F(A,B,C,D) = \sum m(1,3,5,7) + \sum d(9,11,13,15)\), where \(d\) indicates the don’t-cares.

\(AB \backslash CD\) 00 01 11 10
00 0 1 1 0
01 0 1 1 0
11 0 X X 0
10 0 X X 0

Without the Xs, minterms 1, 3, 5, 7 form a group of 4 (\(A=0\), \(D=1\)) → \(\bar{A}D\).

With the Xs available, minterms 1, 3, 5, 7 can join 9, 11, 13, and 15 to form a group of 8 (the entire column \(D=1\)). Result: simply \(\boxed{F = D}\).

The minimal solution may not be unique

Depending on the grouping choices, the same Karnaugh map can generate two or more equally valid minimal expressions. This happens when a minterm can be included in different groups without changing the number of terms or literals of the final result.

For example, on a 3-variable map, \(m_4\) can be grouped either with \(\{m_0, m_4\}\) → \(\bar{B}\bar{C}\) or with \(\{m_4, m_6\}\) → \(A\bar{C}\); both choices produce correct minimal expressions.

In practice, any minimal solution is acceptable. Logic synthesis tools choose automatically among the available alternatives.

Redundant groups and hazards

In hardware design, engineers sometimes intentionally add redundant groups to the K-map, even if they cover no new minterm, in order to eliminate hazards (glitches): spurious pulses at the output caused by the propagation delay between adjacent groups when the inputs change. This refinement goes beyond pure logic minimization and belongs to the timing analysis of combinational circuits.

Worked exercises
#

Ex. 1: \(F(A,B,C) = \sum(0,2,4,5,6)\)
#

\(A \backslash BC\) 00 01 11 10
0 1 0 0 1
1 1 1 0 1

On the map below, the two groups are highlighted in color. The red group crosses the side edge, which on the torus is a neighbor of the opposite edge:

Karnaugh map: Exercise 1
Karnaugh map for F(A,B,C) = Σ(0,2,4,5,6)

  • Group of 4 cells (red): \(m_0, m_2, m_4, m_6\) (columns 00 and 10, both rows) → \(\bar{C}\)
  • Group of 2 cells (green): \(m_4, m_5\) (row \(A=1\), columns 00 and 01) → \(A\bar{B}\)
$$\boxed{F = \bar{C} + A\bar{B}}$$

Ex. 2: \(F(A,B,C,D) = \sum(3,4,5,7,9,13,14,15)\)
#

\(AB \backslash CD\) 00 01 11 10
00 0 0 1 0
01 1 1 1 0
11 0 1 1 1
10 0 1 0 0

The figure below highlights the four groups, each in its own color:

Karnaugh map: Exercise 2
Karnaugh map for F(A,B,C,D) = Σ(3,4,5,7,9,13,14,15): four essential prime implicants highlighted

Identifying the essential prime implicants:

Expression Color on the map Minterms Fixed variables Why essential
\(\bar{A}CD\) red \(\{3,7\}\) \(A=0, C=1, D=1\) only group covering \(m_3\)
\(\bar{A}B\bar{C}\) green \(\{4,5\}\) \(A=0, B=1, C=0\) only group covering \(m_4\)
\(A\bar{C}D\) yellow \(\{9,13\}\) \(A=1, C=0, D=1\) only group covering \(m_9\)
\(ABC\) cyan \(\{14,15\}\) \(A=1, B=1, C=1\) only group covering \(m_{14}\)

Check: \(\{3,7\} \cup \{4,5\} \cup \{9,13\} \cup \{14,15\} = \{3,4,5,7,9,13,14,15\}\) ✓

$$\boxed{F = \bar{A}CD + \bar{A}B\bar{C} + A\bar{C}D + ABC}$$

Ex. 3: \(F(A,B,C,D) = \sum(0,2,5,7,8,10,13,15)\)
#

\(AB \backslash CD\) 00 01 11 10
00 1 0 0 1
01 0 1 1 0
11 0 1 1 0
10 1 0 0 1

The figure below shows the two groups: the four corners, in red, and the central block, in green.

Karnaugh map: Exercise 3
Karnaugh map for F(A,B,C,D) = Σ(0,2,5,7,8,10,13,15): two groups of 4 that do not touch, the four corners and the central block

  • Group of 4 (red): \(m_0, m_2, m_8, m_{10}\) (four corners in columns 00/10, rows 00/10) → \(\bar{B}\bar{D}\)
  • Group of 4 (green): \(m_5, m_7, m_{13}, m_{15}\) → \(BD\)
$$\boxed{F = \bar{B}\bar{D} + BD = \overline{B \oplus D}}$$
An elegant result

This is the function XNOR(B, D): the output is 1 when B and D have the same value. On the map, it appears as two groups that do not touch: the four corners, where \(B = D = 0\), and the central block, where \(B = D = 1\). Neither can grow, because changing only \(B\) or only \(D\) flips the output. This is how XOR and XNOR usually appear on a Karnaugh map: in groups that do not merge into a single term.

Ex. 4: \(F(A,B,C,D) = \sum(0,2,3,4,6,9,10,11,12,14)\)
#

\(AB \backslash CD\) 00 01 11 10
00 1 0 1 1
01 1 0 0 1
11 1 0 0 1
10 0 1 1 1

The figure below highlights the four groups. Cells that belong to more than one group appear with overlapping colors:

Karnaugh map: Exercise 4
Karnaugh map for F(A,B,C,D) = Σ(0,2,3,4,6,9,10,11,12,14): four groups highlighted

Expression Color on the map Minterms Fixed variables Why essential
\(\bar{A}\bar{D}\) red \(\{0,2,4,6\}\) \(A=0, D=0\) only group covering \(m_0\)
\(\bar{B}C\) green \(\{2,3,10,11\}\) \(B=0, C=1\) only group covering \(m_3\)
\(B\bar{D}\) yellow \(\{4,6,12,14\}\) \(B=1, D=0\) only group covering \(m_{12}\)
\(A\bar{B}D\) cyan \(\{9,11\}\) \(A=1, B=0, D=1\) only group covering \(m_9\)
$$\boxed{F = \bar{A}\bar{D} + \bar{B}C + B\bar{D} + A\bar{B}D}$$

Ex. 5: \(F(A,B,C,D) = \sum(0,1,2,4,8,9,10,12,14)\)
#

\(AB \backslash CD\) 00 01 11 10
00 1 1 0 1
01 1 0 0 0
11 1 0 0 1
10 1 1 0 1

The figure below highlights the four groups, again with overlapping colors in the shared cells:

Karnaugh map: Exercise 5
Karnaugh map for F(A,B,C,D) = Σ(0,1,2,4,8,9,10,12,14): four groups highlighted

Expression Color on the map Minterms Fixed variables Why essential
\(\bar{B}\bar{C}\) red \(\{0,1,8,9\}\) \(B=0, C=0\) only group covering \(m_1\)
\(\bar{B}\bar{D}\) green \(\{0,2,8,10\}\) \(B=0, D=0\) only group covering \(m_2\)
\(\bar{C}\bar{D}\) yellow \(\{0,4,8,12\}\) \(C=0, D=0\) only group covering \(m_4\)
\(A\bar{D}\) cyan \(\{8,10,12,14\}\) \(A=1, D=0\) only group covering \(m_{14}\)

In this exercise the four groups are concentrated in a few cells: \(m_0\) belongs to three of them and \(m_8\) to all four, and the overlapping colors of the previous figure are hard to tell apart. The figure below shows the same groups, one per map, with the same colors as the table:

The four groups of Exercise 5 on separate maps
Exercise 5 with one group per map: red (m0, m1, m8, m9), green (the four corners), yellow (the column CD = 00), and cyan (m8, m10, m12, m14), each with its expression and the minterm that only it covers

$$\boxed{F(A,B,C,D) = \bar{B}\bar{C} + \bar{B}\bar{D} + \bar{C}\bar{D} + A\bar{D}}$$

Checking with Python
#

Solving maps by hand is the goal of this article, but the check can be automatic. The SymPy library, which has a whole series here on the site, provides in the sympy.logic module the functions SOPform and POSform: they take the list of minterms and return the minimal expression in each form, the same problem the Karnaugh map solves. The block below checks Ex. 5:

from sympy import symbols
from sympy.logic import SOPform, POSform

A, B, C, D = symbols("A B C D")
minterms = [0, 1, 2, 4, 8, 9, 10, 12, 14]

sop = SOPform([A, B, C, D], minterms)
print(sop)
# (A & ~D) | (~B & ~C) | (~B & ~D) | (~C & ~D)

pos = POSform([A, B, C, D], minterms)
print(pos)
# (~B | ~D) & (~C | ~D) & (A | ~B | ~C)

# Answer obtained with the Karnaugh map
map_answer = (~B & ~C) | (~B & ~D) | (~C & ~D) | (A & ~D)
print(sop.equals(map_answer))
# True

The SOP form is the same as the map’s, just with the terms in a different order. The novelty is the POS form: three terms and 7 literals, against four terms and 8 literals for the SOP. This is exactly the comparison that the note “Which form to implement?” recommends making before choosing the circuit. To get there with the map, it would be enough to group the 0s: \(\{5,7,13,15\}\) gives \(\bar{B}+\bar{D}\), \(\{3,7,11,15\}\) gives \(\bar{C}+\bar{D}\), and \(\{6,7\}\) gives \(A+\bar{B}+\bar{C}\). For an expression already written, instead of a list of minterms, the simplify_logic function from the same module plays the equivalent role.

If you prefer to check without installing anything, Charlie Coleman’s interactive Karnaugh map solver takes the list of minterms, draws the map with the groups, and returns the minimal expression in SOP or POS, all in the browser.

Comparing the methods
#

The two methods presented in this article (algebraic simplification and the Karnaugh map) attack the same problem with very different approaches. The table below compares them and includes the Quine-McCluskey algorithm, a third alternative for computational use that was not detailed here:

Method Advantage Limitation
Algebraic Works with any number of variables Not systematic; depends on intuition
Karnaugh Visual and intuitive; easy to identify groups Practical only up to 4 or 5 variables
Quine-McCluskey Systematic and algorithmically implementable Practical only for computational implementation

The Quine-McCluskey algorithm is essentially the Karnaugh map converted into a tabular procedure: it finds all the prime implicants by systematically comparing minterms and then selects the minimal cover. The central idea is to group the minterms by the number of 1s in their binary representation and compare only adjacent groups, since two minterms can combine only if they differ in exactly one bit, and this implies that the number of 1s differs by exactly one. Because it is deterministic and mechanical, it is the reference for exact minimization (the logic synthesis tools used in industry for large functions usually resort to heuristics, such as Espresso, which gives up the guarantee of an exact minimum to gain speed), but its complexity grows exponentially with the number of variables, making it impractical by hand for large functions.

Conclusion
#

Starting from a truth table, we learned to:

  1. Write the canonical form (sum of minterms, SOP, or product of maxterms, POS) directly by inspection.
  2. Simplify algebraically, applying the theorems of Boolean algebra in sequence.
  3. Use the Karnaugh map to identify groups of adjacent minterms and obtain the minimal expression visually.

The result of each simplification is a more economical digital circuit, with fewer gates and lower power consumption. This process is at the base of the design of all digital hardware.

To go deeper into the theorems and identities used throughout this article, see Boolean Algebra: the mathematical foundation of digital computing.

In the next article of the series, we leave the isolated logic gate behind and move on to the first major subsystem of the machine: the memory hierarchy. We will see how cells, addresses, and buses are organized to store data and instructions, and why every computer combines memories of such different speed, capacity, and cost.

See you then!

Inside the Computer - This article is part of a series.
Part 3: This Article

Related

Venn Diagrams and Set Operations

·3803 words·18 mins
Union, intersection, difference, and complement are the basic operations on sets, and they show up in SQL as UNION, INTERSECT, and EXCEPT. We see each one in Venn diagrams, along with De Morgan’s laws, distributivity, and the difference between a Venn diagram and an Euler diagram.