3-CNF
   HOME

TheInfoList



OR:

In
Boolean logic In mathematics and mathematical logic, Boolean algebra is a branch of algebra. It differs from elementary algebra in two ways. First, the values of the variable (mathematics), variables are the truth values ''true'' and ''false'', usually denote ...
, a
formula In science, a formula is a concise way of expressing information symbolically, as in a mathematical formula or a ''chemical formula''. The informal use of the term ''formula'' in science refers to the general construct of a relationship betwee ...
is in conjunctive normal form (CNF) or clausal normal form if it is a
conjunction Conjunction may refer to: * Conjunction (grammar), a part of speech * Logical conjunction, a mathematical operator ** Conjunction introduction, a rule of inference of propositional logic * Conjunction (astronomy), in which two astronomical bodies ...
of one or more
clauses In language, a clause is a constituent that comprises a semantic predicand (expressed or not) and a semantic predicate. A typical clause consists of a subject and a syntactic predicate, the latter typically a verb phrase composed of a verb with ...
, where a clause is a
disjunction In logic, disjunction is a logical connective typically notated as \lor and read aloud as "or". For instance, the English language sentence "it is raining or it is snowing" can be represented in logic using the disjunctive formula R \lor S ...
of literals; otherwise put, it is a product of sums or an AND of ORs. As a
canonical normal form In Boolean algebra, any Boolean function can be expressed in the canonical disjunctive normal form ( CDNF) or minterm canonical form and its dual canonical conjunctive normal form ( CCNF) or maxterm canonical form. Other canonical forms include ...
, it is useful in
automated theorem proving Automated theorem proving (also known as ATP or automated deduction) is a subfield of automated reasoning and mathematical logic dealing with proving mathematical theorems by computer programs. Automated reasoning over mathematical proof was a maj ...
and
circuit theory Circuit may refer to: Science and technology Electrical engineering * Electrical circuit, a complete electrical network with a closed-loop giving a return path for current ** Analog circuit, uses continuous signal levels ** Balanced circui ...
. All conjunctions of literals and all disjunctions of literals are in CNF, as they can be seen as conjunctions of one-literal clauses and conjunctions of a single clause, respectively. As in the
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 c ...
(DNF), the only propositional connectives a formula in CNF can contain are
and or AND may refer to: Logic, grammar, and computing * Conjunction (grammar), connecting two words, phrases, or clauses * Logical conjunction in mathematical logic, notated as "∧", "⋅", "&", or simple juxtaposition * Bitwise AND, a boole ...
, or, and not. The not operator can only be used as part of a literal, which means that it can only precede a
propositional variable In mathematical logic, a propositional variable (also called a sentential variable or sentential letter) is an input variable (that can either be true or false) of a truth function. Propositional variables are the basic building-blocks of propositi ...
or a
predicate symbol In mathematical logic, a predicate variable is a predicate letter which functions as a "placeholder" for a relation (between terms), but which has not been specifically assigned any particular relation (or meaning). Common symbols for denoting predi ...
. 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.


Examples and non-examples

All of the following formulas in the variables A,B,C,D,E, and F are in conjunctive normal form: * (A \lor \neg B \lor \neg C) \land (\neg D \lor E \lor F) * (A \lor B) \land (C) * (A \lor B) * (A) For clarity, the disjunctive clauses are written inside parentheses above. In
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 c ...
with parenthesized conjunctive clauses, the last case is the same, but the next to last is (A) \lor (B). The constants ''true'' and ''false'' are denoted by the empty conjunct and one clause consisting of the empty disjunct, but are normally written explicitly. The following formulas are not in conjunctive normal form: * \neg (B \lor C), since an OR is nested within a NOT * (A \land B) \lor C * A \land (B \lor (D \land E)), since an AND is nested within an OR Every formula can be equivalently written as a formula in conjunctive normal form. The three non-examples in CNF are: * (\neg B) \land (\neg C) * (A \lor C) \land (B \lor C) * (A) \land (B \lor D) \land (B \lor E).


Conversion into CNF

Every
propositional formula In propositional logic, a propositional formula is a type of syntactic formula which is well formed and has a truth value. If the values of all variables in a propositional formula are given, it determines a unique truth value. A propositional fo ...
can be converted into an
equivalent Equivalence or Equivalent may refer to: Arts and entertainment *Album-equivalent unit, a measurement unit in the music industry *Equivalence class (music) *''Equivalent VIII'', or ''The Bricks'', a minimalist sculpture by Carl Andre *''Equivale ...
formula that is in CNF. This transformation is based on rules about
logical equivalence In logic and mathematics, statements p and q are said to be logically equivalent if they have the same truth value in every model. The logical equivalence of p and q is sometimes expressed as p \equiv q, p :: q, \textsfpq, or p \iff q, depending on ...
s:
double negation elimination In propositional logic, double negation is the theorem that states that "If a statement is true, then it is not the case that the statement is not true." This is expressed by saying that a proposition ''A'' is logically equivalent to ''not (not ...
,
De Morgan's laws In propositional logic and Boolean algebra, De Morgan's laws, also known as De Morgan's theorem, are a pair of transformation rules that are both valid rules of inference. They are named after Augustus De Morgan, a 19th-century British mathem ...
, and the
distributive law In mathematics, the distributive property of binary operations generalizes the distributive law, which asserts that the equality x \cdot (y + z) = x \cdot y + x \cdot z is always true in elementary algebra. For example, in elementary arithmetic, ...
. 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 following non-CNF formula into CNF produces a formula with 2^n clauses: :(X_1 \wedge Y_1) \vee (X_2 \wedge Y_2) \vee \dots \vee (X_n \wedge Y_n). In particular, the generated formula is: :(X_1 \vee X_2 \vee \cdots \vee X_n) \wedge (Y_1 \vee X_2 \vee \cdots \vee X_n) \wedge (X_1 \vee Y_2 \vee \cdots \vee X_n) \wedge (Y_1 \vee Y_2 \vee \cdots \vee X_n) \wedge \cdots \wedge (Y_1 \vee Y_2 \vee \cdots \vee Y_n). This formula contains 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 In mathematical logic, a formula is ''satisfiable'' if it is true under some assignment of values to its variables. For example, the formula x+3=y is satisfiable because it is true when x=3 and y=6, while the formula x+1=x is not satisfiable over ...
rather than
equivalence Equivalence or Equivalent may refer to: Arts and entertainment *Album-equivalent unit, a measurement unit in the music industry *Equivalence class (music) *''Equivalent VIII'', or ''The Bricks'', a minimalist sculpture by Carl Andre *'' Equival ...
. 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 Z_1,\ldots,Z_n as follows: :(Z_1 \vee \cdots \vee Z_n) \wedge (\neg Z_1 \vee X_1) \wedge (\neg Z_1 \vee Y_1) \wedge \cdots \wedge (\neg Z_n \vee X_n) \wedge (\neg Z_n \vee Y_n). 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 A model is an informative representation of an object, person or system. The term originally denoted the Plan_(drawing), plans of a building in late 16th-century English, and derived via French and Italian ultimately from Latin ''modulus'', a mea ...
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 In Mathematical logic (a subtopic within the field of formal logic), two formulae are equisatisfiable if the first formula is satisfiable whenever the second is and vice versa; in other words, either both formulae are satisfiable or both are not. E ...
but not
equivalent Equivalence or Equivalent may refer to: Arts and entertainment *Album-equivalent unit, a measurement unit in the music industry *Equivalence class (music) *''Equivalent VIII'', or ''The Bricks'', a minimalist sculpture by Carl Andre *''Equivale ...
. An alternative translation, the
Tseitin transformation The Tseytin transformation, alternatively written Tseitin transformation, takes as input an arbitrary combinatorial logic circuit and produces a boolean formula in conjunctive normal form (CNF), which can be solved by a CNF-SAT solver. The lengt ...
, includes also the clauses Z_i \vee \neg X_i \vee \neg Y_i. With these clauses, the formula implies Z_i \equiv X_i \wedge Y_i; this formula is often regarded to "define" Z_i to be a name for X_i \wedge Y_i.


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 mathematical logic and automated theorem proving, resolution is a rule of inference leading to a refutation complete theorem-proving technique for sentences in propositional logic and first-order logic. For propositional logic, systematically ...
. In resolution-based automated theorem-proving, a CNF formula See
below Below may refer to: *Earth *Ground (disambiguation) *Soil *Floor *Bottom (disambiguation) Bottom may refer to: Anatomy and sex * Bottom (BDSM), the partner in a BDSM who takes the passive, receiving, or obedient role, to that of the top or ...
for an example.


Computational complexity

An important set of problems in
computational complexity In computer science, the computational complexity or simply complexity of an algorithm is the amount of resources required to run it. Particular focus is given to computation time (generally measured by the number of needed elementary operations) ...
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 In logic and computer science, the Boolean satisfiability problem (sometimes called propositional satisfiability problem and abbreviated SATISFIABILITY, SAT or B-SAT) is the problem of determining if there exists an interpretation that satisfie ...
is
NP-complete In computational complexity theory, a problem is NP-complete when: # it is a problem for which the correctness of each solution can be verified quickly (namely, in polynomial time) and a brute-force search algorithm can find a solution by tryi ...
(like any other ''k''-SAT problem with ''k''>2) while
2-SAT In computer science, 2-satisfiability, 2-SAT or just 2SAT is a computational problem of assigning values to variables, each of which has two possible values, in order to satisfy a system of Constraint (mathematics), constraints on pairs of variabl ...
is known to have solutions in
polynomial time In computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations performed by ...
. As a consequence,since one way to check a CNF for satisfiability is to convert it into a DNF, the satisfiability of which can be checked in
linear time In computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations performed by ...
the task of converting a formula into a DNF, preserving satisfiability, is
NP-hard In computational complexity theory, NP-hardness ( non-deterministic polynomial-time hardness) is the defining property of a class of problems that are informally "at least as hard as the hardest problems in NP". A simple example of an NP-hard pr ...
;
dually Dually may refer to: *Dualla, County Tipperary, a village in Ireland *A pickup truck with dual wheels on the rear axle * DUALLy, s platform for architectural languages interoperability * Dual-processor See also * Dual (disambiguation) Dual or ...
, converting into CNF, preserving
validity Validity or Valid may refer to: Science/mathematics/statistics: * Validity (logic), a property of a logical argument * Scientific: ** Internal validity, the validity of causal inferences within scientific studies, usually based on experiments ** ...
, 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 "''k''CNF" (for ''k''≥3) by replacing each conjunct with more than ''k'' variables X_1 \vee \cdots \vee X_k \vee \cdots \vee X_n by two conjuncts X_1 \vee \cdots \vee X_ \vee Z and \neg Z \vee X_k \cdots \vee X_n with a new variable, and repeating as often as necessary.


Converting from first-order logic

To convert
first-order logic First-order logic—also known as predicate logic, quantificational logic, and first-order predicate calculus—is a collection of formal systems used in mathematics, philosophy, linguistics, and computer science. First-order logic uses quantifie ...
to CNF:Artificial Intelligence: A modern Approach
995...Russell and Norvig
#Convert to
negation normal form In mathematical logic, a formula is in negation normal form (NNF) if the negation operator (\lnot, ) is only applied to variables and the only other allowed Boolean operators are conjunction (\land, ) and disjunction (\lor, ). Negation normal for ...
. ## Eliminate implications and equivalences: repeatedly replace P \rightarrow Q with \lnot P \lor Q; replace P \leftrightarrow Q with (P \lor \lnot Q) \land (\lnot P \lor Q). Eventually, this will eliminate all occurrences of \rightarrow and \leftrightarrow. ##Move NOTs inwards by repeatedly applying
De Morgan's law In propositional logic and Boolean algebra, De Morgan's laws, also known as De Morgan's theorem, are a pair of transformation rules that are both valid rules of inference. They are named after Augustus De Morgan, a 19th-century British mathem ...
. Specifically, replace \lnot (P \lor Q) with (\lnot P) \land (\lnot Q); replace \lnot (P \land Q) with (\lnot P) \lor (\lnot Q); and replace \lnot\lnot P with P; replace \lnot (\forall x P(x)) with \exists x \lnot P(x); \lnot (\exists x P(x)) with \forall x \lnot P(x). After that, a \lnot may occur only immediately before a predicate symbol. #Standardize variables ##For sentences like (\forall x P(x)) \lor (\exists x Q(x)) which use the same variable name twice, change the name of one of the variables. This avoids confusion later when dropping quantifiers. For example, \forall x exists y \mathrm(y) \land \lnot \mathrm(x, y)\lor exists y \mathrm(y, x)/math> is renamed to \forall x exists y \mathrm(y) \land \lnot \mathrm(x, y)\lor exists z \mathrm(z,x)/math>. # Skolemize the statement ##Move quantifiers outwards: repeatedly replace P \land (\forall x Q(x)) with \forall x (P \land Q(x)); replace P \lor (\forall x Q(x)) with \forall x (P \lor Q(x)); replace P \land (\exists x Q(x)) with \exists x (P \land Q(x)); replace P \lor (\exists x Q(x)) with \exists x (P \lor Q(x)). These replacements preserve equivalence, since the previous variable standardization step ensured that x doesn't occur in P. After these replacements, a quantifier may occur only in the initial prefix of the formula, but never inside a \lnot, \land, or \lor. ##Repeatedly replace \forall x_1 \ldots \forall x_n \; \exists y \; P(y) with \forall x_1 \ldots \forall x_n \; P(f(x_1,\ldots,x_n)), where f is a new n-ary function symbol, a so-called "
Skolem function In mathematical logic, a formula of first-order logic is in Skolem normal form if it is in prenex normal form with only universal first-order quantifiers. Every first-order formula may be converted into Skolem normal form while not changing its ...
". This is the only step that preserves only satisfiability rather than equivalence. It eliminates all existential quantifiers. #Drop all universal quantifiers. #Distribute ORs inwards over ANDs: repeatedly replace P \lor (Q \land R) with (P \lor Q) \land (P \lor R). 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 In language, a clause is a constituent that comprises a semantic predicand (expressed or not) and a semantic predicate. A typical clause consists of a subject and a syntactic predicate, the latter typically a verb phrase composed of a verb with ...
form in the last line) as follows (highlighting replacement rule
redex In mathematics, computer science, and logic, rewriting covers a wide range of methods of replacing subterms of a formula with other terms. Such methods may be achieved by rewriting systems (also known as rewrite systems, rewrite engines, or reduc ...
es 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, (\mathrm(f(x)) \lor \mathrm(g(x), x)) \land (\lnot \mathrm(x, f(x)) \lor \mathrm(g(x), x)), is the CNF.


Notes


See also

*
Algebraic normal form In Boolean algebra, the algebraic normal form (ANF), ring sum normal form (RSNF or RNF), '' Zhegalkin normal form'', or '' Reed–Muller expansion'' is a way of writing logical formulas in one of three subforms: * The entire formula is purely tr ...
*
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 c ...
*
Horn clause In mathematical logic and logic programming, a Horn clause is a logical formula of a particular rule-like form which gives it useful properties for use in logic programming, formal specification, and model theory. Horn clauses are named for the log ...
*
Quine–McCluskey algorithm The Quine–McCluskey algorithm (QMC), also known as the method of prime implicants, is a method used for minimization of Boolean functions that was developed by Willard V. Quine in 1952 and extended by Edward J. McCluskey in 1956. As a genera ...


References

* * * Paul Jackson, Daniel Sheridan
Clause Form Conversions for Boolean Circuits
In: Holger H. Hoos, David G. Mitchell (Eds.): Theory and Applications of Satisfiability Testing, 7th International Conference, SAT 2004, Vancouver, BC, Canada, May 10–13, 2004, Revised Selected Papers. Lecture Notes in Computer Science 3542, Springer 2005, pp. 183–198 * G.S. Tseitin
On the complexity of derivation in propositional calculus
In: Slisenko, A.O. (ed.) Structures in Constructive Mathematics and Mathematical Logic, Part II, Seminars in Mathematics (translated from Russian), pp. 115–125. Steklov Mathematical Institute (1968)


External links

* {{springer, title=Conjunctive normal form, id=p/c025090


Java applet for converting to CNF and DNF, showing laws used
Normal forms (logic)