Sub topic 5
Canonical forms: minterms and maxterms
This chapter assumes you can convert between binary and decimal, read a truth table, and apply De Morgan's laws. A canonical form writes a Boolean function in one fixed, unique shape, so two expressions can be compared directly and later minimization steps start from a known point.
Why a canonical form is needed
Many different expressions describe the same function. For example, AB + A'C and AB + A'C + BC are equal, by the consensus theorem. A canonical form fixes one representation per function. It is a two-level expression in which every term contains every variable, either complemented or not. Two functions are equal exactly when their canonical forms match.
There are two canonical forms:
- Canonical SOP, or sum of minterms. It is an OR of AND terms.
- Canonical POS, or product of maxterms. It is an AND of OR terms.
Minterms
A minterm of n variables is an AND of all n variables. Each variable appears once, complemented if its bit in the row is 0 and plain if its bit is 1. A minterm equals 1 on exactly one row of the truth table.
Row index i is read as a binary number with the first variable as the most significant bit. For three variables A, B, C:
| Row i | ABC | Minterm m_i | Maxterm M_i |
|---|---|---|---|
| 0 | 000 | A'B'C' | A + B + C |
| 1 | 001 | A'B'C | A + B + C' |
| 2 | 010 | A'BC' | A + B' + C |
| 3 | 011 | A'BC | A + B' + C' |
| 4 | 100 | AB'C' | A' + B + C |
| 5 | 101 | AB'C | A' + B + C' |
| 6 | 110 | ABC' | A' + B' + C |
| 7 | 111 | ABC | A' + B' + C' |
Maxterms
A maxterm is an OR of all n variables. It is the opposite of a minterm: a variable is complemented when its bit is 1 and plain when its bit is 0. A maxterm equals 0 on exactly one row. This follows from De Morgan's law:
M_i = (m_i)'
Deriving both forms from a truth table
Take F(A,B,C) = AB + A'C and evaluate it on all eight rows.
| Row | ABC | AB | A'C | F |
|---|---|---|---|---|
| 0 | 000 | 0 | 0 | 0 |
| 1 | 001 | 0 | 1 | 1 |
| 2 | 010 | 0 | 0 | 0 |
| 3 | 011 | 0 | 1 | 1 |
| 4 | 100 | 0 | 0 | 0 |
| 5 | 101 | 0 | 0 | 0 |
| 6 | 110 | 1 | 0 | 1 |
| 7 | 111 | 1 | 1 | 1 |
The rules are:
- For SOP, OR together the minterms of the rows where F = 1.
- For POS, AND together the maxterms of the rows where F = 0.
The result is:
F = Σm(1,3,6,7) = A'B'C + A'BC + ABC' + ABCF = ΠM(0,2,4,5) = (A+B+C)(A+B'+C)(A'+B+C)(A'+B+C')
The index lists are complementary. Together they cover every row from 0 to 2^n − 1 exactly once, so a function with k minterms has 2^n − k maxterms.
The complement is obtained by swapping the lists:
F' = Σm(0,2,4,5) = ΠM(1,3,6,7)
Expanding a non-canonical expression
Sometimes you have an expression rather than a truth table. You can expand it by algebra.
For SOP, multiply each term that lacks a variable by (X + X'):
AB = AB(C + C') = ABC + ABC', which is m7 + m6.
A'C = A'C(B + B') = A'BC + A'B'C, which is m3 + m1.
Together this gives Σm(1,3,6,7), matching the table.
For POS, add X·X' to each sum that lacks a variable, then use the distributive law A + XX' = (A+X)(A+X'):
A + B = (A + B + CC') = (A+B+C)(A+B+C'), which is M0·M1.
Here is a small example in which POS is the natural form. G = (A+B)(A'+C) expands to:
A + B → (A+B+C)(A+B+C'), which is M0·M1A' + C → (A'+C+B)(A'+C+B'), which is M4·M6
So G = ΠM(0,1,4,6), and therefore G = Σm(2,3,5,7).
Doing it in code
A short program can derive both forms for any function. Variable order matters, because the first name is the most significant bit.
from itertools import product
def minterm(i, names):
bits = format(i, f"0{len(names)}b")
return "".join(x if b == "1" else x + "'" for x, b in zip(names, bits))
def maxterm(i, names):
bits = format(i, f"0{len(names)}b")
return "(" + "+".join(x + "'" if b == "1" else x
for x, b in zip(names, bits)) + ")"
def canonical(f, names):
ones, zeros = [], []
for i, v in enumerate(product([0, 1], repeat=len(names))):
(ones if f(*v) else zeros).append(i)
print("Sum of minterms: m", ones)
print(" =", " + ".join(minterm(i, names) for i in ones))
print("Product of maxterms: M", zeros)
print(" =", "".join(maxterm(i, names) for i in zeros))
canonical(lambda a, b, c: (a & b) | ((1 - a) & c), "ABC")The output is:
Sum of minterms: m [1, 3, 6, 7]
= A'B'C + A'BC + ABC' + ABC
Product of maxterms: M [0, 2, 4, 5]
= (A+B+C)(A+B'+C)(A'+B+C)(A'+B+C')Counting facts that appear in GATE
- A function of n variables has 2^n rows, 2^n possible minterms, and 2^(2^n) distinct functions. For n = 3 that is 256 functions.
- A product term with k literals is 1 on 2^(n−k) rows. In a 4-variable function,
AB'covers 4 minterms. - A sum term with k literals is 0 on 2^(n−k) rows, so it removes that many rows from F.
- The canonical SOP of a function has n literals in every term, so the literal count is
n × (number of minterms). - The sum of all 2^n minterms is the constant 1. The product of all 2^n maxterms is the constant 0.
- Any two distinct minterms have AND equal to 0, and any two distinct maxterms have OR equal to 1.
Σm(...)andΠM(...)use the same variable order. If the order changes, the index numbers change.
Common errors
- Reversing the maxterm convention. In a maxterm, bit 0 gives the plain variable and bit 1 gives the complemented variable. Check by evaluating the maxterm on its own row. It must give 0.
- Using the wrong list for POS. Maxterms come from the zero rows. Putting the minterm indices into
ΠMgivesF'. - Assuming canonical means minimal. The canonical form is generally the longest correct form. Minimization comes later, with algebra, K-maps, and the tabular method.
- Forgetting don't-cares. A don't-care row belongs to neither list during derivation. It is written as
Σm(...) + d(...)orΠM(...)·D(...), and you may choose its value later. - Mixing up variable order.
F(A,B,C)andF(C,B,A)give different index lists for the same function.
Exercise
A function of A, B, C, D is F = Σm(0,2,5,7,8,10,13,15). Write F in product-of-maxterms form. How many literals does the canonical POS form contain in total?
Show answer
There are 16 rows, and F has 8 minterms, so the maxterm indices are the other 8 rows: ΠM(1,3,4,6,9,11,12,14). Each maxterm has 4 literals, so the total is 8 × 4 = 32 literals.
Exercise
Find the canonical SOP of F = (A + B')(B + C) over variables A, B, C.
Show answer
Expand to POS first. A + B' = (A+B'+C)(A+B'+C') = M2·M3. B + C = (B+C+A)(B+C+A') = M0·M4. So F = ΠM(0,2,3,4). The missing rows are 1, 5, 6, 7, so F = Σm(1,5,6,7) = A'B'C + AB'C + ABC' + ABC.