In boolean logic, a disjunctive normal form (DNF) is a 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. The disjunctive normal form and its counterpart, the conjunctive normal form, are the most common standardized ways of representing boolean expressions. They are widely used in various applications such as circuit design or 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 (<math>\wedge</math>), or (<math>\vee</math>), and not (<math>\neg</math>). 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:
: DNF <math>\, \to \,</math> (Disjunct) <math>\, \mid \, </math> (Disjunct) <math>\, \lor \,</math> DNF
: Disjunct <math>\, \to \,</math> Literal <math>\, \mid\, </math> Literal <math>\, \land \,</math> Disjunct
: Literal <math>\, \to \,</math> Variable <math>\, \mid \,</math> <math>\, \neg \,</math> Variable
Where Variable is any variable.
For example, all of the following formulas are in DNF:
- <math>(A \land \neg B \land \neg C) \lor (\neg D \land E \land F \land D \land F)</math>
- <math>(A \land B) \lor (C)</math>
- <math>(A \land B)</math>
- <math>(A)</math>
The formula <math>A \lor B</math> is in DNF, but not in full DNF; an equivalent full-DNF version is <math>(A \land B) \lor (A \land \lnot B) \lor (\lnot A \land B)</math>.
The following formulas are not in DNF:
- <math>\neg(A \lor B)</math>, since an OR is nested within a NOT
- <math>\neg(A \land B) \lor C</math>, since an AND is nested within a NOT
- <math>A \lor (B \land (C \lor D))</math>, since an OR is nested within an AND
Conversion to DNF
In classical logic each propositional formula can be converted to DNF ...
thumb|[[Karnaugh map of the disjunctive normal form ∨ ∨ ∨ ]]
thumb|Karnaugh map of the disjunctive normal form ∨ ∨ ∨ . Despite the different grouping, the same fields contain a "1" as in the previous map.
... 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 <math>\{\land,\lor,\lnot\}</math> can be converted to DNF by the following canonical term rewriting system:
:<math>\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}</math>
... by semantic means
The full DNF of a formula can be read off its truth table. For example, consider the formula
:<math>\phi = ((\lnot (p \land q)) \leftrightarrow (\lnot r \uparrow (p \oplus q)))</math>.
The corresponding truth table is
:{| class="wikitable" style="text-align:center;"
! <math>p</math>
! <math>q</math>
! <math>r</math>
! style="background:black"|
! <math>(</math>
! <math>\lnot</math>
! <math>(p \land q)</math>
! <math>)</math>
! <math>\leftrightarrow</math>
! <math>(</math>
! <math>\lnot r</math>
! <math>\uparrow</math>
! <math>(p \oplus q)</math>
! <math>)</math>
|-
| 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 ||
|}
- The full DNF equivalent of <math>\phi</math> is
:<math>
( 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)
</math>
- The full DNF equivalent of <math>\lnot \phi</math> is
:<math>
( 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)
</math>
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 <math>((a \land b) \lor (\lnot a \land b)) \rightsquigarrow b</math> three times, the full DNF of the above <math>\phi</math> can be simplified to <math>(\lnot p \land \lnot q) \lor (\lnot p \land r) \lor (\lnot q \land r)</math>. 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.</blockquote>The proof follows from the procedure given above for generating DNFs from truth tables. Formally, the proof is as follows:<blockquote>Suppose <math>X</math> is a sentence in a propositional language whose sentence letters are <math>A, B, C, \ldots</math>. For each row of <math>X</math>'s truth table, write out a corresponding conjunction <math>\pm A \land \pm B \land \pm C \land \ldots</math>, where <math>\pm A</math> is defined to be <math>A</math> if <math>A</math> takes the value <math>T</math> at that row, and is <math>\neg A</math> if <math>A</math> takes the value <math>F</math> at that row; similarly for <math>\pm B</math>, <math>\pm C</math>, etc. (the alphabetical ordering of <math>A, B, C, \ldots</math> in the conjunctions is quite arbitrary; any other could be chosen instead). Now form the disjunction of all these conjunctions which correspond to <math>T</math> rows of <math>X</math>'s truth table. This disjunction is a sentence in <math>\mathcal{L}[A, B, C, \ldots; \land, \lor, \neg]</math>, which by the reasoning above is truth-functionally equivalent to <math>X</math>. This construction obviously presupposes that <math>X</math> takes the value <math>T</math> on at least one row of its truth table; if <math>X</math> doesn’t, i.e., if <math>X</math> is a contradiction, then <math>X</math> is equivalent to <math>A \land \neg A</math>, which is, of course, also a sentence in <math>\mathcal{L}[A, B, C, \ldots; \land, \lor, \neg]</math>.
This is the maximum number of conjunctions a DNF can have.
