Conjunctive normal form

1

In Boolean logic, 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.

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](https://bliptext.com/articles/disjunctive-n[or](https://bliptext.com/articles/logical-disjunction)mal-f[or](https://bliptext.com/articles/logical-disjunction)m) (DNF), the only propositional operators in CNF are or (\vee), and (\wedge), 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 CNF: 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: The following formulas are not in conjunctive normal form:

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 \phi builds upon \lnot \phi in disjunctive normal form (DNF): step 1. Then is converted to \phi_{CNF} by swapping ANDs with ORs and vice versa while negating all the literals. Remove all \lnot \lnot.

Conversion by syntactic means

Convert to CNF the propositional formula \phi. Step 1: Convert its negation to disjunctive normal form. , where each C_i is a conjunction of literals. Step 2: Negate. Then shift \lnot inwards by applying the (generalized) De Morgan's equivalences until no longer possible. where Step 3: Remove all double negations. Example Convert to CNF the propositional formula . The (full) DNF equivalent of its negation is

Conversion by semantic means

A CNF equivalent of a formula can be derived from its truth table. Again, consider the formula . The corresponding truth table is A CNF equivalent of \phi is Each disjunction reflects an assignment of variables for which \phi evaluates to F(alse). If in such an assignment a variable V

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 into CNF produces a formula with 2^n clauses: Each clause contains either X_i or Y_i 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 as follows: An interpretation satisfies this formula only if at least one of the new variables is true. If this variable is Z_i, then both X_i and Y_i 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 Z_i 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, includes also the clauses. With these clauses, the formula implies ; this formula is often regarded to "define" Z_i to be a name for.

Maximum number of disjunctions

<span id="max_disjunctions"> Consider a propositional formula with n variables, n \ge 1. There are 2n possible literals:. L has (2^{2n} -1) non-empty subsets. This is the maximum number of disjunctions a CNF can have. All truth-functional combinations can be expressed with 2^{n} 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 disjunctions: This formula is a [contradiction](https://bliptext.com/articles/contradiction).

Computational complexity

An important set of problems in computational complexity involves finding assignments to the variables of a Boolean formula expressed in conjunctive normal form, such that the formula is true. The k-SAT problem is the problem of finding a satisfying assignment to a Boolean formula expressed in CNF in which each disjunction contains at most k variables. 3-SAT is NP-complete (like any other k-SAT problem with k>2) while 2-SAT is known to have solutions in polynomial time. As a consequence, the task of converting a formula into a DNF, preserving satisfiability, is NP-hard; dually, converting into CNF, preserving validity, is also NP-hard; hence equivalence-preserving conversion into DNF or CNF is again NP-hard. Typical problems in this case involve formulas in "3CNF": conjunctive normal form with no more than three variables per conjunct. Examples of such formulas encountered in practice can be very large, for example with 100,000 variables and 1,000,000 conjuncts. A formula in CNF can be converted into an equisatisfiable formula in "kCNF" (for k≥3) by replacing each conjunct with more than k variables by two conjuncts and with Z a new variable, and repeating as often as necessary.

First-order logic

In first order logic, conjunctive normal form can be taken further to yield the clausal normal form of a logical formula, which can be then used to perform first-order resolution. In resolution-based automated theorem-proving, a CNF formula See below for an example.

Converting from first-order logic

To convert first-order logic to CNF: Example As an example, the formula saying "Anyone who loves all animals, is in turn loved by someone" is converted into CNF (and subsequently into clause form in the last line) as follows (highlighting replacement rule redexes in ): Informally, the Skolem function g(x) can be thought of as yielding the person by whom x is loved, while f(x) yields the animal (if any) that x doesn't love. The 3rd last line from below then reads as "x doesn't love the animal f(x), or else x is loved by g(x)". The 2nd last line from above,, is the CNF.

This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.

Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc.
Bliptext is not affiliated with or endorsed by Wikipedia or the Wikimedia Foundation.

View original