Home › Logic › Lesson 2

Truth Functions, Functional Completeness and Normal Forms

Lesson 2 of 13

Key idea of this section

There are 22ⁿ Boolean functions of n variables.
{¬, ∧, ∨} is functionally complete; so is {↑} (NAND) alone.
Post: a set is complete iff it escapes each of five maximal clones.

Boolean functions

An n-ary Boolean function is a map F : {0, 1}ⁿ → {0, 1}. Since {0, 1}ⁿ has 2ⁿ elements and each can be sent to 0 or 1, there are exactly 22ⁿ such functions: 4 unary, 16 binary and 256 ternary ones. Every formula φ(p₁, …, pₙ) defines a Boolean function Fφ by Fφ(a₁, …, aₙ) = v̄(φ) where v(pᵢ) = aᵢ, and φ ≡ ψ exactly when Fφ = Fψ. Hence there are, up to logical equivalence, exactly 22ⁿ formulas in n given atoms. A set S of connectives is functionally complete if every Boolean function of every arity n ≥ 1 is Fφ for some formula φ built from atoms using only connectives from S.

Theorem 2.1. {¬, ∧, ∨} is functionally complete.

Proof. Let F be n-ary. If F is identically 0, it is defined by p₁ ∧ ¬p₁. Otherwise, for each a = (a₁, …, aₙ) with F(a) = 1 form the minterm μa = ℓ₁ ∧ … ∧ ℓₙ where ℓᵢ = pᵢ if aᵢ = 1 and ℓᵢ = ¬pᵢ if aᵢ = 0. Then μa is true at exactly the single point a. The disjunction of all such minterms is true exactly at the points where F is 1. ∎

The formula constructed is the full disjunctive normal form of F. A formula is in disjunctive normal form (DNF) if it is a disjunction of conjunctions of literals (atoms or negated atoms), and in conjunctive normal form (CNF) if it is a conjunction of disjunctions of literals, called clauses. Applying the theorem to ¬F and using De Morgan's laws, ¬(α ∨ β) ≡ ¬α ∧ ¬β and ¬(α ∧ β) ≡ ¬α ∨ ¬β, shows that every formula is also equivalent to a CNF: one clause for each falsifying assignment, the clause being false exactly at that assignment.

Corollary 2.2. {¬, ∧}, {¬, ∨}, {¬, →} and {→, ⊥} are functionally complete, and so are {↑} and {↓}, where p ↑ q = ¬(p ∧ q) (NAND, the Sheffer stroke) and p ↓ q = ¬(p ∨ q) (NOR).

Proof. It suffices to define the members of a known complete set. α ∨ β ≡ ¬(¬α ∧ ¬β); α ∧ β ≡ ¬(¬α ∨ ¬β); α ∨ β ≡ ¬α → β; ¬α ≡ α → ⊥. For NAND, ¬α ≡ α ↑ α and α ∧ β ≡ (α ↑ β) ↑ (α ↑ β). For NOR, ¬α ≡ α ↓ α and α ∨ β ≡ (α ↓ β) ↓ (α ↓ β). ∎

Sheffer showed in 1913 that ↑ alone suffices, though Peirce had observed it around 1880; it is a classical theorem that ↑ and ↓ are the only binary connectives that are functionally complete by themselves. This is why NAND gates are the universal building block of digital circuits.

Proving incompleteness: invariants

To show a set is not complete, find a property shared by every function definable from it but not by all Boolean functions. A function F preserves 0 if F(0, …, 0) = 0. Every formula built from atoms using only ∧ and ∨ defines a function preserving 0 and preserving 1, and moreover a monotone function (a ≤ b coordinatewise implies F(a) ≤ F(b)). Since ¬ is not monotone, {∧, ∨} is not complete. Similarly, every formula using only → defines a function preserving 1, since 1 → 1 = 1; hence ¬ is not definable from → alone and {→} is incomplete. Every formula built from ¬ and ↔ defines an affine function, one of the form a₀ ⊕ a₁x₁ ⊕ … ⊕ aₙxₙ over the field 𝔽₂ (here ⊕ is addition mod 2, and α ↔ β corresponds to α ⊕ β ⊕ 1); since ∧ is not affine, {¬, ↔} is incomplete.

Theorem 2.3 (Post, 1941). A set S of Boolean functions is functionally complete if and only if, for each of the following five classes, S contains a function not in that class: the 0-preserving functions, the 1-preserving functions, the monotone functions, the affine functions, and the self-dual functions (those with F(¬a₁, …, ¬aₙ) = ¬F(a₁, …, aₙ)).

Each of the five classes is closed under composition and contains the projections, so the "only if" direction follows from the invariance argument above. The "if" direction is a pleasant exercise (Problem 49): from a non-0-preserving, a non-1-preserving and a non-self-dual function one obtains ¬ and the constants; then a non-monotone function and a non-affine function yield ∧. The five classes are exactly the maximal clones in Post's lattice of all clones on {0, 1}, which Post classified completely — a countably infinite lattice.

The cost of normal forms

Normal forms can be exponentially long. The parity function x₁ ⊕ … ⊕ xₙ is 1 at exactly 2ⁿ⁻¹ points, and no conjunction of fewer than n literals can be true only at points of odd parity (fixing fewer than n coordinates leaves a subcube containing both parities). So every DNF of parity has at least 2ⁿ⁻¹ terms, and by symmetry every CNF has at least 2ⁿ⁻¹ clauses. For satisfiability purposes this blow-up can be avoided by the Tseitin transformation: introduce a new atom for each subformula and assert, by a few clauses, that it is equivalent to its definition. The result is a CNF of size linear in the original formula that is equisatisfiable with it (satisfiable if and only if the original is), though not logically equivalent to it.

Exercise

  • (a)
    Give the full DNF of the majority function M(p, q, r), which is 1 when at least two arguments are 1. Then give a shorter equivalent DNF.
  • (b)
    Express p → q using only ↑.
  • (c)
    Is the set {∧, ⊕, ⊤} functionally complete? Here ⊤ is the constant 1.
Show solution

Answers: (a) Full DNF: (p ∧ q ∧ r) ∨ (p ∧ q ∧ ¬r) ∨ (p ∧ ¬q ∧ r) ∨ (¬p ∧ q ∧ r). Shorter: (p ∧ q) ∨ (p ∧ r) ∨ (q ∧ r). (b) p → q ≡ ¬(p ∧ ¬q) = p ↑ ¬q = p ↑ (q ↑ q). (c) Yes: ¬α ≡ α ⊕ ⊤, and {¬, ∧} is complete. In Post's terms, ⊤ is not 0-preserving, ⊕ is not 1-preserving, ∧ is neither affine nor self-dual, and ⊕ is not monotone. This set gives the algebraic normal form (Zhegalkin polynomials) of Boolean functions.

V.3.1