C7 · Lesson 5 · Canonical forms and NAND logic
Minterms, maxterms, and building everything from one gate
Any Boolean function can be written straight from its truth table, with no cleverness at all: OR together one AND term for every row where it's 1. That canonical form is usually far from the simplest, but it always exists, it's unique, and it's the starting point for every simplification method. Turn it over with De Morgan's laws and the same function becomes a network of nothing but NAND gates, which is why a chip can be built from a single kind of gate.
- Two circuits for the same function: F written as a sum of products, , and G built from NAND gates only.
- Flip the inputs, or read the truth table: F and G agree in every row.
- The NAND version is two levels of NAND where the sum of products had AND then OR: De Morgan's laws turn one into the other.
Predict
How many different Boolean functions of three inputs are there?
- A truth table for three inputs has 8 rows, and each row's output can be 0 or 1 independently, so there are = 256 different tables. With four inputs there are = 65,536.
Name it
Minterms and maxterms
For n inputs, each row of the truth table has a minterm: the AND of every input, inverted where the row has a 0. Row 5 of a three-input table (A = 1, B = 0, C = 1) has minterm , which is 1 only in that row. Every function is the OR of the minterms of its 1 rows, its canonical sum of products:
Each row also has a maxterm: the OR of every input, inverted where the row has a 1, which is 0 only in that row: . Every function is the AND of the maxterms of its 0 rows, its canonical product of sums: . The two lists always split the rows between them.
Useful theorems
- De Morgan: and .
- Consensus: ; the term BC is covered by the other two.
- Duality: swap AND with OR and 0 with 1, and any true identity stays true.
One gate is enough
A sum of products is two levels, AND then OR. By De Morgan, : NAND then NAND. So any function in SOP form becomes NAND–NAND logic with the same structure, and a product of sums becomes NOR–NOR. NAND alone (or NOR alone) is functionally complete: NOT is a NAND with its inputs tied, AND is a NAND followed by a NOT, and OR is a NAND of inverted inputs. CMOS builds NAND and NOR more cheaply than AND and OR (lesson 8), so real logic is full of them.
Worked example
A function of A, B, C is 1 in rows 1, 3, 6 and 7. Write its canonical SOP and POS, then simplify.
Show the solution
- Canonical SOP.
- Canonical POS.
- Simplify. Rows 1 and 3 share , rows 6 and 7 share AB, so the function in the sim.
Answer the SOP is , the POS is , and both simplify to .
Worked example
Build from two-input NAND gates only. How many?
Show the solution
- Make . One NAND with both inputs tied to A makes .
- Make the two products, inverted. Two more NANDs make and .
- Combine them. A final NAND of those two gives .
Answer four two-input NAND gates.
Worked example
Write in canonical sum-of-products form. Can it be simplified?
Show the solution
- Find the rows. The three-input XOR is 1 when an odd number of inputs are 1: rows 1, 2, 4 and 7.
- Write the canonical SOP.
- Try to combine terms. No two of those minterms differ in just one variable, so no pair combines: the sum of products stays at four three-literal terms.
- Use XOR gates. Two XOR gates do the same job, which is why parity and adder circuits use XOR rather than AND–OR logic.
Answer , which can't be simplified as a sum of products.
Check
Write a function of A, B, C equal to (rows counted from 0 with A as the top bit).
Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.
Check
Write a function of A, B, C equal to .
Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.
Check
Simplify .
Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.
Check
Write using inversions only on single variables.
Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.
Check
How many different Boolean functions of 3 inputs are there?
Check
A function of 4 inputs has 3 minterms. How many maxterms does its canonical product of sums have?
Check
Which single gate type can build any Boolean function on its own?
Check
Write using only XOR.
Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.
Check
A function has n inputs.
Step 1
How many rows does its truth table have?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
How many different functions of n inputs are there?
Step 3
How many literals does the n-input parity function's canonical SOP have in all? (It has minterms of n literals.)
Explain why
Why can any truth table be built as a sum of products?
A minterm is an AND of every input, each inverted or not, chosen so it's 1 in exactly one row of the truth table and 0 in all the others. OR together the minterms of every row where the function should be 1: in each of those rows exactly one minterm is 1, so the OR is 1, and in every other row all the minterms are 0, so the OR is 0. That reproduces the table exactly, whatever it is. It's rarely the simplest circuit, but it proves every function can be built from AND, OR and NOT.
Practice
Keep practicing
5 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.