Disjunctive normal form

In boolean logic, a disjunctive normal form (DNF) is a canonical normal form of a logical formula consisting of a disjunction of conjunctions; it can also be described as an OR of ANDs, a sum of products, or — in philosophical logic — a cluster concept. As a normal form, it is useful in automated theorem proving.

Definition
A logical formula is considered to be in DNF if it is a disjunction of one or more conjunctions of one or more literals. A DNF formula is in full disjunctive normal form if each of its variables appears exactly once in every conjunction and each conjunction appears at most once (up to the order of variables). As in conjunctive normal form (CNF), the only propositional operators in DNF are and ($$\wedge$$), or ($$\vee$$), and not ($$\neg$$). The not operator can only be used as part of a literal, which means that it can only precede a propositional variable.

The following is a context-free grammar for DNF: Where Variable is any variable.
 * 1) DNF → (Conjunction) $$\vee$$ DNF
 * 2) DNF → (Conjunction)
 * 3) Conjunction → Literal $$\wedge$$ Conjunction
 * 4) Conjunction → Literal
 * 5) Literal → $$\neg$$Variable
 * 6) Literal → Variable

For example, all of the following formulas are in DNF:


 * $$(A \land \neg B \land \neg C) \lor (\neg D \land E \land F \land D \land F)$$
 * $$(A \land B) \lor (C)$$
 * $$(A \land B)$$
 * $$(A)$$

The formula $$A \lor B$$ is in DNF, but not in full DNF; an equivalent full-DNF version is $$(A \land B) \lor (A \land \lnot B) \lor (\lnot A \land B)$$.

The following formulas are not in DNF:
 * $$\neg(A \lor B)$$, since an OR is nested within a NOT
 * $$\neg(A \land B) \lor C$$, since an AND is nested within a NOT
 * $$A \lor (B \land (C \lor D))$$, since an OR is nested within an AND

Conversion to DNF
In classical logic each propositional formula can be converted to DNF ...

... by syntactic means
The conversion involves using logical equivalences, such as double negation elimination, De Morgan's laws, and the distributive law. Formulas built from the primitive connectives $$\{\land,\lor,\lnot\}$$ can be converted to DNF by the following canonical term rewriting system:
 * $$\begin{array}{rcl}

(\lnot \lnot x) & \rightsquigarrow & x \\ (\lnot (x \lor y)) & \rightsquigarrow & ((\lnot x) \land (\lnot y)) \\ (\lnot (x \land y)) & \rightsquigarrow & ((\lnot x) \lor (\lnot y)) \\ (x \land (y \lor z)) & \rightsquigarrow & ((x \land y) \lor (x \land z)) \\ ((x \lor y) \land z) & \rightsquigarrow & ((x \land z) \lor (y \land z)) \\ \end{array}$$

... by semantic means
The full DNF of a formula can be read off its truth table. For example, consider the formula
 * $$\phi = ((\lnot (p \land q)) \leftrightarrow (\lnot r \uparrow (p \oplus q)))$$.

The corresponding truth table is
 * {| class="wikitable" style="text-align:center;"

! $$p$$ ! $$q$$ ! $$r$$ ! style="background:black"| ! $$($$ ! $$\lnot$$ ! $$(p \land q)$$ ! $$)$$ ! $$\leftrightarrow$$ ! $$($$ ! $$\lnot r$$ ! $$\uparrow$$ ! $$(p \oplus q)$$ ! $$)$$
 * T || T || T ||style="background:black"| || || F || T || || style="background:papayawhip" | F || || F || T || F ||
 * T || T || F ||style="background:black"| || || F || T || || style="background:papayawhip" | F || || T || T || F ||
 * style="background:lightgreen"|T || style="background:lightgreen"|F || style="background:lightgreen"|T ||style="background:black"| || || T || F || || style="background:papayawhip" | T || || F || T || T ||
 * T || F || F ||style="background:black"| || || T || F || || style="background:papayawhip" | F || || T || F || T ||
 * style="background:lightgreen"|F || style="background:lightgreen"|T || style="background:lightgreen"|T ||style="background:black"| || || T || F || || style="background:papayawhip" | T || || F || T || T ||
 * F || T || F ||style="background:black"| || || T || F || || style="background:papayawhip" | F || || T || F || T ||
 * style="background:lightgreen"|F || style="background:lightgreen"|F || style="background:lightgreen"|T ||style="background:black"| || || T || F || || style="background:papayawhip" | T || || F || T || F ||
 * style="background:lightgreen"|F || style="background:lightgreen"|F || style="background:lightgreen"|F ||style="background:black"| || || T || F || || style="background:papayawhip" | T || || T || T || F ||
 * }
 * style="background:lightgreen"|F || style="background:lightgreen"|T || style="background:lightgreen"|T ||style="background:black"| || || T || F || || style="background:papayawhip" | T || || F || T || T ||
 * F || T || F ||style="background:black"| || || T || F || || style="background:papayawhip" | F || || T || F || T ||
 * style="background:lightgreen"|F || style="background:lightgreen"|F || style="background:lightgreen"|T ||style="background:black"| || || T || F || || style="background:papayawhip" | T || || F || T || F ||
 * style="background:lightgreen"|F || style="background:lightgreen"|F || style="background:lightgreen"|F ||style="background:black"| || || T || F || || style="background:papayawhip" | T || || T || T || F ||
 * }
 * style="background:lightgreen"|F || style="background:lightgreen"|F || style="background:lightgreen"|F ||style="background:black"| || || T || F || || style="background:papayawhip" | T || || T || T || F ||
 * }
 * }


 * The full DNF equivalent of $$\phi$$ is

(     p \land \lnot q \land       r) \lor (\lnot p \land      q \land       r) \lor (\lnot p \land \lnot q \land      r) \lor (\lnot p \land \lnot q \land \lnot r) $$
 * The full DNF equivalent of $$\lnot \phi$$ is

(     p \land       q \land       r) \lor (     p \land       q \land \lnot r) \lor (     p \land \lnot q \land \lnot r) \lor (\lnot p \land      q \land \lnot r) $$

Remark
A propositional formula can be represented by one and only one full DNF. In contrast, several plain DNFs may be possible. For example, by applying the rule $$((a \land b) \lor (\lnot a \land b)) \rightsquigarrow b$$ three times, the full DNF of the above $$\phi$$ can be simplified to $$(\lnot p \land \lnot q) \lor (\lnot p \land r) \lor (\lnot q \land r)$$. However, there are also equivalent DNF formulas that cannot be transformed one into another by this rule, see the pictures for an example.

Disjunctive Normal Form Theorem
It is a theorem that all consistent formulas in propositional logic can be converted to disjunctive normal form. This is called the Disjunctive Normal Form Theorem. The formal statement is as follows:"Disjunctive Normal Form Theorem: Suppose $X$ is a sentence in a propositional language $\mathcal{L}$ with $n$ sentence letters, which we shall denote by $A_1,...,A_n$. If $X$ is not a contradiction, then it is truth-functionally equivalent to a disjunction of conjunctions of the form $\pm A_1 \land ... \land \pm A_n$, where $+A_i=A_i$, and $-A_i= \neg A_i$."The proof follows from the procedure given above for generating DNFs from truth tables. Formally, the proof is as follows:"Suppose $X$ is a sentence in a propositional language whose sentence letters are $A, B, C, \ldots$. For each row of $X$'s truth table, write out a corresponding conjunction $\pm A \land \pm B \land \pm C \land \ldots$, where $\pm A$ is defined to be $A$ if $A$ takes the value $T$ at that row, and is $\neg A$ if $A$ takes the value $F$ at that row; similarly for $\pm B$, $\pm C$, etc. (the alphabetical ordering of $A, B, C, \ldots$ in the conjunctions is quite arbitrary; any other could be chosen instead). Now form the disjunction of all these conjunctions which correspond to $T$ rows of $X$'s truth table. This disjunction is a sentence in $\mathcal{L}[A, B, C, \ldots; \land, \lor, \neg]$, which by the reasoning above is truth-functionally equivalent to $X$. This construction obviously presupposes that $X$ takes the value $T$ on at least one row of its truth table; if $X$ doesn’t, i.e., if $X$ is a contradiction, then $X$ is equivalent to $A \land \neg A$, which is, of course, also a sentence in $\mathcal{L}[A, B, C, \ldots; \land, \lor, \neg]$."This theorem is a convenient way to derive many useful metalogical results in propositional logic, such as, trivially, the result that the set of connectives $$\{\land, \lor, \neg\}$$ is functionally complete.

Maximum number of conjunctions
 Any propositional formula is built from $$n$$ variables, where $$n \ge 1$$.

There are $$2n$$ possible literals: $$L = \{ p_1, \lnot p_1, p_2, \lnot p_2, \ldots, p_n, \lnot p_n\}$$.

$$L$$ has $$(2^{2n} -1)$$ non-empty subsets.

This is the maximum number of conjunctions a DNF can have.

A full DNF can have up to $$2^{n}$$ conjunctions, one for each row of the truth table.

Example 1

Consider a formula with two variables $$p$$ and $$q$$.

The longest possible DNF has $$2^{(2 \times 2)} -1 = 15$$ conjunctions:

\begin{array}{lcl} (\lnot p) \lor (p) \lor (\lnot q) \lor (q) \lor \\ (\lnot p \land      p) \lor \underline{(\lnot p \land \lnot q)} \lor \underline{(\lnot p \land      q)} \lor \underline{(     p \land \lnot q)} \lor \underline{(     p \land       q)} \lor (\lnot q \land      q) \lor \\ (\lnot p \land      p \land \lnot q) \lor (\lnot p \land      p \land       q) \lor (\lnot p \land \lnot q \land      q) \lor (     p \land \lnot q \land       q) \lor \\ (\lnot p \land      p \land \lnot q \land q) \end{array}$$

The longest possible full DNF has 4 conjunctions: they are underlined.

This formula is a tautology.

Example 2

Each DNF of the e.g. formula $$(X_1 \lor Y_1) \land (X_2 \lor Y_2) \land \dots \land (X_n \lor Y_n)$$ has $$2^n$$ conjunctions.

Computational complexity
The Boolean satisfiability problem on conjunctive normal form formulas is NP-complete. By the duality principle, so is the falsifiability problem on DNF formulas. Therefore, it is co-NP-hard to decide if a DNF formula is a tautology.

Conversely, a DNF formula is satisfiable if, and only if, one of its conjunctions is satisfiable. This can be decided in polynomial time simply by checking that at least one conjunction does not contain conflicting literals.

Variants
An important variation used in the study of computational complexity is k-DNF. A formula is in k-DNF if it is in DNF and each conjunction contains at most k literals.