Introduction

Every Boolean function has two canonical representations that are unique up to term order: the sum of minterms (canonical SOP) and the product of maxterms (canonical POS). From those forms you can read the truth table directly, and you can ask which gate sets are functionally complete: able to express every Boolean function. NAND alone and NOR alone are complete; AND and OR together are not (no NOT).

The working skills are minterm and maxterm numbering, conversions between SOP and POS, and deciding whether a given gate set is complete (with a short functional-completeness argument).

Prerequisites

Core concepts

Minterms and maxterms

For nn variables x1,…,xnx_1,\ldots,x_n ordered left to right:

  • A minterm mim_i is the product that is 1 only for the input row whose binary index is ii. Example (n=3n=3): m5=m101=x1x2′x3m_5 = m_{101} = x_1 x_2' x_3.
  • A maxterm MiM_i is the sum that is 0 only for input row ii. Example: M5=x1′+x2+x3′M_5 = x_1' + x_2 + x_3' (each variable is complemented relative to the minterm pattern).

Relation: Mi=(mi)′M_i = (m_i)' as functions, and mi′=Mim_i' = M_i.

Canonical SOP and POS

If f=1f=1 on index set SS, then

f=∑i∈Smif = \sum_{i\in S} m_i

(the sum of those minterms). If f=0f=0 on index set TT, then

f=∏i∈TMif = \prod_{i\in T} M_i

(the product of those maxterms). The two sets partition {0,…,2n−1}\{0,\ldots,2^n-1\}: TT is the complement of SS.

Notation: f(x,y,z)=∑m(1,2,5)=∏M(0,3,4,6,7)f(x,y,z)=\sum m(1,2,5)=\prod M(0,3,4,6,7).

The four index lists of one function

With SS the 1-rows of ff and Sˉ\bar S the 0-rows:

FunctionAs a sum of mintermsAs a product of maxterms
ff∑m(S)\sum m(S)∏M(Sˉ)\prod M(\bar S)
f′f'∑m(Sˉ)\sum m(\bar S)∏M(S)\prod M(S)
fdf^d∑m({2n−1−i:i∈Sˉ})\sum m(\{2^n - 1 - i : i \in \bar S\})∏M({2n−1−i:i∈S})\prod M(\{2^n - 1 - i : i \in S\})

The dual row follows from fd(x)=f′(x′)f^d(x) = f'(x'): complementing all inputs maps row ii to row 2n−1−i2^n - 1 - i. For f=∑m(1,2,5)f = \sum m(1, 2, 5) with n=3n = 3: f′=∑m(0,3,4,6,7)=∏M(1,2,5)f' = \sum m(0, 3, 4, 6, 7) = \prod M(1, 2, 5) and fd=∏M(6,5,2)=∑m(0,1,3,4,7)f^d = \prod M(6, 5, 2) = \sum m(0, 1, 3, 4, 7).

Different count: minterms covered by a product term. A product of kk literals over nn variables covers 2n−k2^{n-k} minterms. So f(x,y,z)=x+y′zf(x, y, z) = x + y'z expands to x→m(4,5,6,7)x \to m(4, 5, 6, 7) and y′z→m(1,5)y'z \to m(1, 5), giving ∑m(1,4,5,6,7)\sum m(1, 4, 5, 6, 7): 5 minterms, not 6, because m5m_5 is shared. The number of functions of nn variables with exactly kk minterms is (2nk)\binom{2^n}{k}.

Standard (non-canonical) SOP and POS

A sum of products that is not necessarily minterms (some products omit variables) is an ordinary SOP. A product of sums that is not necessarily maxterms is an ordinary POS. Minimization seeks short SOP or POS forms; they are not unique, unlike the canonical ones.

Functional completeness

A set of Boolean operators is functionally complete (universal) if every Boolean function of any arity can be written using only operators from that set (and constants, or without constants, depending on the precise definition used in the question; this note allows composing the gates and using the input variables, and asks separately whether constants are needed).

SetComplete?Reason sketch
{NAND}\{\text{NAND}\}yesNOT: x↑xx\uparrow x; AND: (x↑y)↑(x↑y)(x\uparrow y)\uparrow(x\uparrow y); OR via De Morgan
{NOR}\{\text{NOR}\}yesdual construction
{AND,NOT}\{\text{AND},\text{NOT}\}yesOR by De Morgan
{OR,NOT}\{\text{OR},\text{NOT}\}yesAND by De Morgan
{AND,OR}\{\text{AND},\text{OR}\}nocannot make NOT; monotone functions only
{XOR}\{\text{XOR}\}noevery result is linear and 0-preserving (x⊕x=0x \oplus x = 0 gives the constant 0, never 1)
{XOR,NOT}\{\text{XOR}, \text{NOT}\}noevery result is affine; constants do not help
{XOR,AND}\{\text{XOR},\text{AND}\}noboth preserve 0, so NOT is impossible
{XOR,AND,1}\{\text{XOR},\text{AND}, 1\}yesNOT is x⊕1x \oplus 1; AND and NOT suffice (Reed-Muller form)
{→}\{\to\} (implication x′+yx' + y)nopreserves 1: if all inputs are 1 the output is 1
{→,0}\{\to, 0\}yesx′=x→0x' = x \to 0; OR is x′→yx' \to y
{MAJ,NOT}\{\text{MAJ}, \text{NOT}\}noboth are self-dual, and compositions of self-dual functions are self-dual
{xy′}\{xy'\} (inhibition) with constant 1yes1⋅x′=x′1 \cdot x' = x', then x(y′)′=xyx(y')' = xy: AND and NOT

IMPERATIVE RULE. To show incompleteness, name an invariant preserved by the set (for example monotonicity for {AND,OR}\{\text{AND},\text{OR}\}, or linearity over GF(2)\mathrm{GF}(2) for {XOR}\{\text{XOR}\}) that some target function violates (NOT is not monotone; AND is not linear).

NOT, AND and OR built from NAND only, and from NOR only
Figure 1. Left: NAND realizations of NOT (x↑xx\uparrow x), AND and OR. Right: NOR realizations of the same three operations.

How it works

Listing minterms from a truth table

Number rows 0 to 2n−12^n-1 in binary order of (x1…xn)(x_1\ldots x_n). Every row where f=1f=1 contributes its minterm. That list is the canonical SOP.

SOP to POS

Complement the minterm list to get the maxterm list (the rows where f=0f=0), then write ∏Mi\prod M_i. Alternatively: take the SOP of f′f', then apply De Morgan once.

Gate conversion to NAND-only

  1. Obtain a minimal (or any) SOP.
  2. Apply double negation: f=((f)′)′f = ((f)')', push the inner NOT with De Morgan to get a NAND-NAND form, or replace every AND by NAND with complemented outputs bubble-pushed.

Why NAND-NAND equals AND-OR. f=P1+P2+⋯+Pk=(P1′P2′⋯Pk′)′f = P_1 + P_2 + \cdots + P_k = \big(P_1' P_2' \cdots P_k'\big)' by De Morgan, and each Pj′P_j' is a NAND of the literals of PjP_j. So a two-level NAND-NAND circuit realizes an SOP with the AND-OR levels replaced using NAND gates; the SOP is minimal only if it was minimized under the stated cost model, and this conversion alone does not prove gate-count optimality. Dually, NOR-NOR realizes a POS. A single literal entering the second level directly must be complemented.

The sixteen two-level forms

Taking any of AND, OR, NAND, NOR at each of the two levels gives 16 forms. Eight are degenerate: they collapse to a single gate. AND-AND and OR-OR are trivial; NAND-NOR and NOR-NAND collapse by De Morgan, for example ((ab)′+(cd)′)′=abcd\big((ab)' + (cd)'\big)' = abcd. The other eight compute an SOP or POS:

ComputesForms
SOP (sum of products)AND-OR, NAND-NAND, NOR-OR, OR-NAND
POS (product of sums)OR-AND, NOR-NOR, NAND-AND, AND-NOR
Single gate (degenerate)AND-AND, AND-NAND, OR-OR, OR-NOR, NAND-OR, NAND-NOR, NOR-AND, NOR-NAND

Read AND-NOR as (P1+⋯+Pk)′(P_1 + \cdots + P_k)', an AND-OR-INVERT that gives the complement of an SOP, which equals a POS of the complemented function. NOR-OR and OR-NAND use complemented literals at the first level.

Minimum gate counts with one universal gate (two-input gates)

TargetNAND gatesNOR gates
NOT11
AND23
OR32
XOR45
XNOR54

The 4-NAND XOR is t=(xy)′t = (xy)', then ((xt)′(yt)′)′\big((x t)'(y t)'\big)'. No circuit of fewer two-input NAND gates computes XOR; the counts in the table are minimum over all circuits, not only over two-level forms.

Algorithms and pseudocode

Text
MINTERM-LIST(truth_table, n)
1  S <- empty list
2  for i <- 0 to 2^n - 1
3      if truth_table[i] = 1 then append i to S
4  return S

CANONICAL-SOP(S, n)
1  return OR over i in S of MINTERM(i, n)

IS-COMPLETE-BY-NAND-BUILD(gateset)
1  // constructive check used in notes: can we build NOT, AND, OR?
2  return (NAND in gateset) or (NOR in gateset)
   or ({AND,NOT} subset gateset) or ({OR,NOT} subset gateset)

The constructive check is sufficient but not necessary: sets such as {→,0}\{\to, 0\} and {XOR,AND,1}\{\text{XOR}, \text{AND}, 1\} are complete without containing NAND, NOR or NOT directly. The exact test is Post's criteria below.

Algorithm costs, not gate delays. Use unit-cost indexed row lookup, word comparison and amortised constant-time output append; an index/loop word must hold 2n2^n. Inputs and output buffers are excluded from workspace. MINTERM-LIST reads all 2n2^n rows: Θ(2n)\Theta(2^n) time in best, average and worst cases, O(1)O(1) working words, and Θ(1+∣S∣)\Theta(1+|S|) output-list words. With iterative literal emission, CANONICAL-SOP takes Θ(1+n∣S∣)\Theta(1+n|S|) time and output tokens in every case, and O(1)O(1) workspace beyond the input/output. Empty SS emits constant 0; for n=0n=0, the sole selected zero-variable minterm emits constant 1. For IS-COMPLETE-BY-NAND-BUILD, precomputed membership flags for the fixed named basis make time and auxiliary space Θ(1)\Theta(1) in all cases, excluding the input and Boolean result. If gates arrive as an unsorted list of gg word-sized tags, first building those flags takes Θ(g+1)\Theta(g+1) time and O(1)O(1) words. These are representation-specific software costs, not arbitrary-precision or circuit-latency claims.

Mathematical explanation

Uniqueness. Canonical SOP is unique because each minterm corresponds to exactly one 1 in the truth table. Canonical POS is unique for the same reason on the 0s.

Post's criteria. Emil Post showed that a set FF of Boolean functions (with composition and the input variables freely available, constants only if they are in FF) is functionally complete if and only if, for each of the five classes below, FF contains at least one function outside that class. Each class is closed under composition, so a set lying inside one class can never leave it; that is the incompleteness argument.

ClassMember ff satisfiesExample memberExample non-member
T0T_0, 0-preservingf(0,…,0)=0f(0, \ldots, 0) = 0AND, OR, XORNOT, NAND, constant 1
T1T_1, 1-preservingf(1,…,1)=1f(1, \ldots, 1) = 1AND, OR, →\toNOT, XOR, constant 0
SS, self-dualf(x′)=f(x)′f(x') = f(x)'NOT, MAJ, x⊕y⊕zx \oplus y \oplus zAND, OR, constants
MM, monotonex≤yx \le y implies f(x)≤f(y)f(x) \le f(y)AND, OR, MAJ, constantsNOT, XOR, →\to
LL, affinef=c0⊕⨁cixif = c_0 \oplus \bigoplus c_i x_iNOT, XOR, XNOR, constantsAND, OR, NAND

Applying the test. Mark, for each function in the set, which classes it falls outside; the set is complete when every column has a mark.

  • NAND on its own: NAND(0,0)=1(0,0) = 1 (outside T0T_0), NAND(1,1)=0(1,1) = 0 (outside T1T_1), not monotone, not affine, and not self-dual (at x=0,y=1x = 0, y = 1, NAND gives 1 and at the complement x=1,y=0x = 1, y = 0 also 1). Complete.
  • {AND,OR}\{\text{AND}, \text{OR}\}: both lie in T0T_0, T1T_1 and MM. Incomplete (three reasons, one is enough).
  • {XOR,AND}\{\text{XOR}, \text{AND}\}: both in T0T_0. Incomplete. Add the constant 1 and every column gets a mark: 1 is outside T0T_0 and SS, XOR is outside T1T_1 and MM, and AND is outside LL. Complete.

A completeness question names a gate set (sometimes with constants 0 and 1 allowed) and asks if it is complete. Two steps settle it: try to construct NOT and either AND or OR; if that fails, find the class that contains every member of the set.

Worked examples

Example 1: f=∑m(1,2,5)f=\sum m(1,2,5) for xyzxyz

Rows: 001,010,101001, 010, 101. Canonical SOP: x′y′z+x′yz′+xy′zx'y'z + x'yz' + xy'z. Zeros at 0,3,4,6,70,3,4,6,7, so POS: M0M3M4M6M7M_0 M_3 M_4 M_6 M_7, that is (x+y+z)(x+y′+z′)(x′+y+z)(x′+y′+z)(x′+y′+z′)(x+y+z)(x+y'+z')(x'+y+z)(x'+y'+z)(x'+y'+z').

Example 2: NAND builds NOT

x↑x=(xx)′=x′x \uparrow x = (xx)' = x'.

Example 3: {AND,OR}\{\text{AND},\text{OR}\} cannot make NOT

Any expression using only AND and OR is monotone: flipping an input from 0 to 1 never flips the output from 1 to 0. NOT is not monotone, so it cannot be expressed.

Example 4: number of minterms

For n=4n=4 there are 16 minterms m0..m15m_0..m_{15}. A function with kk ones has exactly kk minterms in its canonical SOP.

Example 5: expand to canonical form and convert

f(a,b,c)=ab+c′f(a, b, c) = ab + c'. The term abab covers m6,m7m_6, m_7; c′c' covers m0,m2,m4,m6m_0, m_2, m_4, m_6. So f=∑m(0,2,4,6,7)=∏M(1,3,5)f = \sum m(0, 2, 4, 6, 7) = \prod M(1, 3, 5), that is f=(a+b+c′)(a+b′+c′)(a′+b+c′)f = (a + b + c')(a + b' + c')(a' + b + c'). The complement is f′=∑m(1,3,5)=a′c+b′cf' = \sum m(1, 3, 5) = a'c + b'c.

Example 6: is {f}\{f\} complete for f(x,y,z)=x′y+z′f(x, y, z) = x'y + z'?

Check the five classes. f(0,0,0)=1f(0,0,0) = 1: outside T0T_0. f(1,1,1)=0f(1,1,1) = 0: outside T1T_1. ff is not monotone (raising zz from 0 to 1 at x=1,y=0x = 1, y = 0 lowers the output from 1 to 0). It is not affine (it contains the product x′yx'y). Self-dual? At x=y=z=0x = y = z = 0 the value is 1, and at the complement input (1,1,1)(1, 1, 1) it is 0, which is consistent; but at (0,1,1)(0, 1, 1) the value is 1 and at (1,0,0)(1, 0, 0) it is also 1, so ff is not self-dual. All five marks: complete. Constructively, f(x,x,x)=x′f(x, x, x) = x' (since x′x=0x'x = 0), and NOT together with f(x,y,1)=x′yf(x, y, 1) = x'y gives AND.

Important properties and observations

  • mi+mi=mim_i + m_i = m_i and mi⋅mj=0m_i \cdot m_j = 0 for i≠ji\neq j.
  • Expanding a non-canonical product by inserting y+y′y+y' recovers minterms (Shannon expansion).
  • Active-low logic: a NAND network is natural when outputs assert 0; De Morgan dualizes the drawing.

Common misconceptions.

  • "SOP means canonical SOP." SOP is any sum of products; canonical means every product is a minterm.
  • "NAND is complete only with two inputs." Multi-input NAND is also complete; two-input NAND already is.
  • "XOR and NOT are complete." Without a constant or AND, you stay inside affine functions; check the question's allowed constants.
  • "Adding constants makes {XOR,NOT}\{\text{XOR}, \text{NOT}\} complete." Constants are affine too; the set stays inside LL.
  • "The dual of ∑m(S)\sum m(S) is ∏M(S)\prod M(S)." That is the complement written as a product. The dual uses the mirrored indices 2n−1−i2^n - 1 - i.
  • "A product of kk literals and another of jj literals together cover 2n−k+2n−j2^{n-k} + 2^{n-j} minterms." Only if they are disjoint; count the overlap once.

GATE examination perspective

  • MINTERM INDEXING. Confirm variable order; m5m_5 for ABCABC is AB′CAB'C when AA is MSB.
  • SOP TO POS. Complement the index list.
  • FUNCTIONAL COMPLETENESS. Prove by construction (build NOT, AND, OR) or by invariant (monotonicity, linearity).
  • COUNT ONES. Number of minterms equals number of 1s in the truth table.
  • POST TABLE. For an unfamiliar gate, test f(0..0)f(0..0), f(1..1)f(1..1), monotonicity, linearity and self-duality; one gate outside all five classes is complete on its own.
  • CONSTANTS ALLOWED? Read whether 0 and 1 are free inputs; {→}\{\to\} and {XOR,AND}\{\text{XOR}, \text{AND}\} change answer when they are.
  • TWO-LEVEL FORMS. NAND-NAND is SOP, NOR-NOR is POS; NAND-NOR and NOR-NAND are degenerate.
  • GATE COUNTS. XOR takes 4 two-input NANDs or 5 two-input NORs.

Summary

Sources

  1. M. Morris Mano, M. D. Ciletti, Digital Design, 5th ed., Pearson, 2013: Chapter 2, Sections 2.5 to 2.8 (Boolean functions, canonical and standard forms, other logic operations, digital logic gates).

Next steps