Skip to content
Topos Uranos

The normal form algorithm and its applications

Summary

The lesson on normal forms proved that every formula is equivalent to a disjunctive normal form and to a conjunctive one; this one teaches how to compute them without the table and how to make use of them. The computation is a rewriting algorithm in three phases: the biconditional, exclusive disjunction, joint denial and implication are eliminated; the negations are driven down to the variables with De Morgan's laws and double negation; and one distributes, conjunction over disjunction for the disjunctive form and disjunction over conjunction for the conjunctive one. Its correctness, which is a consequence of semantic replacement, and its termination, with a numerical measure that decreases at each step of each phase, are proved; and its limit is proved as well: the conjunctive form of a disjunction of nn conjunctions of two variables necessarily has 2n2^n clauses. Then the normal forms are obtained from the truth table of a device whose interior cannot be seen, they are simplified by merging adjacent rows, and they are turned into circuits of switches in series and in parallel. The problem of a device with four switches is solved completely, with its table, its two forms and its circuits; the one with five is left as a challenge.

Learning objectives

  1. Apply the rewriting algorithm to obtain a disjunctive normal form and a conjunctive normal form of a formula, choosing the elimination of the biconditional that suits the place where it occurs.
  2. Prove that the algorithm is correct, by semantic replacement, and that it terminates, with measures that decrease at each step; and explain why the conjunctive form can be exponentially longer than the starting formula.
  3. Construct the normal forms of a black box from its truth table and simplify them by merging adjacent rows.
  4. Represent circuits of switches in series and in parallel by formulas, and design and simplify circuits that meet a specification given in natural language.

The lesson on normal forms gave two proofs of their existence. The first goes through the truth table, which has 2n2^n rows for nn variables; the second runs through the formula from the variables, following its single formation rule. Neither of them says how to proceed with a formula written with implications, biconditionals and nested negations, which is how formulas usually present themselves. If this is so, what is missing is a procedure that works on the written form itself, that can be carried out without thinking, that is known to terminate and that yields an equivalent formula. That is an algorithm, and its study is the first object of this lesson; the second is what is done with it: describing with formulas the behavior of a device and building a circuit that reproduces it.

Written forms and replacement

Recall that the formulas of the course are strings of circles and disks, and that ¬\neg, ∨\vee, ∧\wedge, →\rightarrow, ↔\leftrightarrow and ⊻\veebar are abbreviations defined from joint denial (lesson on the language of propositional logic). When we write ((p∨q)→(¬q∧p))((p \vee q) \rightarrow (\neg q \wedge p)) we do not write the string, but a written form of it: a tree whose leaves are variables and whose nodes are the connectives ¬\neg, ∧\wedge, ∨\vee, →\rightarrow, ↔\leftrightarrow, ⊻\veebar and ↓\downarrow, each with its components. Every written form designates a single formula, the one that results from unfolding its abbreviations; and one and the same formula can have several written forms: the lesson on normal forms observed that ¬¬φ\neg\neg\varphi and (φ∨φ)(\varphi \vee \varphi) are the same string. The algorithm reads the written form, not the string; that is why it pays to distinguish them. Since the distinction matters only for knowing where each step acts, we shall use the letters φ\varphi, ψ\psi, χ\chi for written forms and for the formulas they designate, and we shall write φ≡ψ\varphi \eqsem \psi when the designated formulas are semantically equivalent. A written subform of a written form is the subtree hanging from one of its nodes.

A step of the algorithm replaces one written subform by another. The instrument that guarantees that this change does not alter the meaning is the semantic replacement theorem of the lesson on semantic consequence and equivalence; but that theorem replaces one occurrence in the string, and a written subform may correspond to several occurrences in the string, because each abbreviation copies its components: in (φ∨ψ)=((φ↓ψ)↓(φ↓ψ))(\varphi \vee \psi) = ((\varphi \downarrow \psi) \downarrow (\varphi \downarrow \psi)), the component φ\varphi appears twice. The following lemma adapts replacement to written forms.

LemmaReplacement in a written form

Let χ\chi be a written form, θ\theta one of its written subforms and θ′\theta' a written form with θ≡θ′\theta \eqsem \theta'. If χ′\chi' results from replacing, in χ\chi, that written subform by θ′\theta', then χ≡χ′\chi \eqsem \chi'.

Proof

  1. χ′=θ′≡θ=χ\chi' = \theta' \eqsem \theta = \chi

    By induction on the depth of the node from which θ\theta hangs, that is, the number of connectives of χ\chi that lie above it. If the depth is 00, the written subform is the whole written form.

  2. χ=c(χ1,χ2),χ′=c(χ1′,χ2),χ1′≡χ1\dato{hi}{\chi = c(\chi_1, \chi_2), \qquad \chi' = c(\resaltar{\chi_1'}, \chi_2), \qquad \chi_1' \eqsem \chi_1}

    If it is greater than 00, the root of χ\chi is a connective cc with components χ1\chi_1 (and χ2\chi_2, if cc is binary), and θ\theta hangs from one of them, say χ1\chi_1, at a smaller depth. By the induction hypothesis, the change inside χ1\chi_1 yields an equivalent written form.

  3. v(χ′)=Fc(v(χ1′),v(χ2))=Fc(v(χ1),v(χ2))=v(χ)v(\chi') = F_c\left( v(\chi_1'), v(\chi_2) \right) = F_c\left( v(\chi_1), v(\chi_2) \right) = v(\chi)

    By the theorem on the values of the defined connectives (lesson on the semantics of propositional logic) and by the clause for joint denial, the value of c(χ1,χ2)c(\chi_1, \chi_2) in a valuation is a function of the values of χ1\chi_1 and χ2\chi_2, and these do not change. Hence χ\chi and χ′\chi' have the same value in every valuation.

Here FcF_c is the truth function of the connective: F¬(a)=1−aF_\neg(a) = 1 - a, F∧(a,b)=abF_\wedge(a, b) = ab, and so on for the others. The same result is obtained from the semantic replacement theorem by applying it once for each copy of θ\theta in the string and chaining the equivalences by transitivity; the proof through the written form is shorter because it counts the written connectives and not the copies.