In Boolean algebra, a formula is in conjunctive normal form (CNF) or clausal normal form if it is a conjunction of one or more clauses, where a clause is a disjunction of literals; otherwise put, it is a product of sums or an AND of ORs. In automated theorem proving, the notion "clausal normal form" is often used in a narrower sense, meaning a particular representation of a CNF formula as a set of sets of literals (i.e., the product and sum operations are left implicit).
Definition A logical formula is considered to be in CNF if it is a conjunction of one or more disjunctions of one or more literals. As in disjunctive normal form (DNF), the only propositional operators in CNF are or (∨), and (∧), and not (¬). 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 CNF:
CNF → Disjunct ∣ Disjunct ∧ CNF Disjunct → Literal ∣ Literal ∨ Disjunct Literal → Variable ∣ ¬ Variable Where Variable is any variable. All of the following formulas in the variables A,B,C,D,E, and F are in conjunctive normal form:
(A∨¬B∨¬C)∧(¬D∨E∨F) (A∨B)∧(C) (A∨B) (A) The following formulas are not in conjunctive normal form:
¬(A∧B), since an AND is nested within a NOT ¬(A∨B)∧C, since an OR is nested within a NOT A∧(B∨(D∧E)), since an AND is nested within an OR A∧(B∨(C∨D)), since a nested OR should be written without parenthesis
Conversion to CNF In classical logic each propositional formula can be converted to an equivalent formula that is in CNF. This transformation is based on rules about logical equivalences: double negation elimination, De Morgan's laws, and the distributive law.
Basic algorithm The algorithm to compute a CNF-equivalent of a given propositional formula ϕ builds upon ¬ϕ in disjunctive normal form (DNF): step 1. Then ¬ϕDNF is converted to ϕCNF by swapping ANDs with ORs and vice versa while negating all the literals. Remove all ¬¬.
Conversion by syntactic means Convert to CNF the propositional formula ϕ. Step 1: Convert its negation to disjunctive normal form. ¬ϕDNF=(C1∨C2∨…∨Ci∨…∨Cm), where each Ci is a conjunction of literals li1∧li2∧…∧lini. Step 2: Negate ¬ϕDNF. Then shift ¬ inwards by applying the (generalized) De Morgan's equivalences until no longer possible. ϕ↔¬¬ϕDNF=¬(C1∨C2∨…∨Ci∨…∨Cm)↔¬C1∧¬C2∧…∧¬Ci∧…∧¬Cm// (generalized) D.M. where¬Ci=¬(li1∧li2∧…∧lini)↔(¬li1∨¬li2∨…∨¬lini)// (generalized) D.M. Step 3: Remove all double negations. Example Convert to CNF the propositional formula ϕ=((¬(p∧q))↔(¬r↑(p⊕q))). The (full) DNF equivalent of its negation is ¬ϕDNF=(p∧q∧r)∨(p∧q∧¬r)∨(p∧¬q∧¬r)∨(¬p∧q∧¬r) ϕ↔¬¬ϕDNF=¬{(p∧q∧r)∨(p∧q∧¬r)∨(p∧¬q∧¬r)∨(¬p∧q∧¬r)}↔¬(p∧q∧r)_∧¬(p∧q∧¬r)_∧¬(p∧¬q∧¬r)_∧¬(¬p∧q∧¬r)_// generalized D.M. ↔(¬p∨¬q∨¬r)∧(¬p∨¬q∨¬¬r)∧(¬p∨¬¬q∨¬¬r)∧(¬¬p∨¬q∨¬¬r)// generalized D.M. (4×)↔(¬p∨¬q∨¬r)∧(¬p∨¬q∨r)∧(¬p∨q∨r)∧(p∨¬q∨r)// remove all ¬¬=ϕCNF
Conversion by semantic means A CNF equivalent of a formula can be derived from its truth table. Again, consider the formula ϕ=((¬(p∧q))↔(¬r↑(p⊕q))). The corresponding truth table is
A CNF equivalent of ϕ is (¬p∨¬q∨¬r)∧(¬p∨¬q∨r)∧(¬p∨q∨r)∧(p∨¬q∨r) Each disjunction reflects an assignment of variables for which ϕ evaluates to F(alse). If in such an assignment a variable V
is T(rue), then the literal is set to ¬V in the disjunction, is F(alse), then the literal is set to V in the disjunction.
Other approaches Since all propositional formulas can be converted into an equivalent formula in conjunctive normal form, proofs are often based on the assumption that all formulae are CNF. However, in some cases this conversion to CNF can lead to an exponential explosion of the formula. For example, translating the non-CNF formula (X1∧Y1)∨(X2∧Y2)∨…∨(Xn∧Yn) into CNF produces a formula with 2n clauses: (X1∨X2∨…∨Xn)∧(Y1∨X2∨…∨Xn)∧(X1∨Y2∨…∨Xn)∧(Y1∨Y2∨…∨Xn)∧…∧(Y1∨Y2∨…∨Yn). Each clause contains either Xi or Yi for each i. There exist transformations into CNF that avoid an exponential increase in size by preserving satisfiability rather than equivalence. These transformations are guaranteed to only linearly increase the size of the formula, but introduce new variables. For example, the above formula can be transformed into CNF by adding variables Z1,…,Zn as follows: (Z1∨…∨Zn)∧(¬Z1∨X1)∧(¬Z1∨Y1)∧…∧(¬Zn∨Xn)∧(¬Zn∨Yn). An interpretation satisfies this formula only if at least one of the new variables is true. If this variable is Zi, then both Xi and Yi are true as well. This means that every model that satisfies this formula also satisfies the original one. On the other hand, only some of the models of the original formula satisfy this one: since the Zi are not mentioned in the original formula, their values are irrelevant to satisfaction of it, which is not the case in the last formula. This means that the original formula and the result of the translation are equisatisfiable but not equivalent. An alternative translation, the Tseitin transformation, also includes the clauses Zi∨¬Xi∨¬Yi. With these clauses, the formula implies Zi≡Xi∧Yi; this formula is often regarded to "define" Zi to be a name for Xi∧Yi.
Maximum number of disjunctions
Consider a propositional formula with n variables, n≥1. There are 2n possible literals: L={p1,¬p1,p2,¬p2,…,pn,¬pn}. L has (22n−1) non-empty subsets. This is the maximum number of disjunctions a CNF can have. All truth-functional combinations can be expressed with 2n disjunctions, one for each row of the truth table.In the example below they are underlined. Example Consider a formula with two variables p and q. The longest possible CNF has 2(2×2)−1=15 disjunctions: (¬p)∧(p)∧(¬q)∧(q)∧(¬p∨p)∧(¬p∨¬q)_∧(¬p∨q)_∧(p∨¬q)_∧(p∨q)_∧(¬q∨q)∧(¬p∨p∨¬q)∧(¬p∨p∨q)∧(¬p∨¬q∨q)∧(p∨¬q∨q)∧(¬p∨p∨¬q∨q) This formula is a contradiction. It can be simplified to (¬p∧p) or to (¬q∧q), which are also contradictions, as well as valid CNFs.
… excerpt ends here. Continue reading the full article.