HOME

TheInfoList



OR:

In
Boolean algebra 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 denot ...
, 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 betwe ...
is in conjunctive normal form (CNF) or clausal normal form if it is a conjunction of one or more
clauses In language, a clause is a Constituent (linguistics), constituent or Phrase (grammar), phrase that comprises a semantic predicand (expressed or not) and a semantic Predicate (grammar), predicate. A typical clause consists of a subject (grammar), ...
, where a clause is a
disjunction In logic, disjunction (also known as logical disjunction, logical or, logical addition, or inclusive disjunction) is a logical connective typically notated as \lor and read aloud as "or". For instance, the English language sentence "it is ...
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 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 operators in CNF are or (\vee), and (\and), 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 In mathematical logic, a propositional variable (also called a sentence letter, 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 ...
. The following is a
context-free grammar In formal language theory, a context-free grammar (CFG) is a formal grammar whose production rules can be applied to a nonterminal symbol regardless of its context. In particular, in a context-free grammar, each production rule is of the fo ...
for CNF: : ''CNF'' \, \to \, ''Disjunct'' \, \mid \, ''Disjunct'' \, \land \, ''CNF'' : ''Disjunct'' \, \to \, ''Literal'' \, \mid\, ''Literal'' \, \lor \, ''Disjunct'' : ''Literal'' \, \to \, ''Variable'' \, \mid \, \, \neg \, ''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 \lor \neg B \lor \neg C) \land (\neg D \lor E \lor F \lor D \lor F) * (A \lor B) \land (C) * (A \lor B) * (A) The following formulas are not in conjunctive normal form: * \neg (A \land B), since an AND is nested within a NOT *\neg(A \lor B) \land C, since an OR is nested within a NOT * A \land (B \lor (D \land E)), since an AND is nested within an OR


Conversion to CNF

In
classical logic Classical logic (or standard logic) or Frege–Russell logic is the intensively studied and most widely used class of deductive logic. Classical logic has had much influence on analytic philosophy. Characteristics Each logical system in this c ...
each propositional formula can be converted to an equivalent 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 ...
s:
double negation elimination In propositional logic, the double negation of a statement states that "it is not the case that the statement is not true". In classical logic, every statement is logically equivalent to its double negation, but this is not true in intuitionis ...
,
De Morgan's laws In propositional calculus, 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 Validity (logic), valid rule of inference, rules of inference. They are nam ...
, and the
distributive law In mathematics, the distributive property of binary operations is a generalization of 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 ...
.


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 \lnot \phi_ is converted to \phi_ 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.see \lnot \phi_ = (C_1 \lor C_2 \lor \ldots \lor C_i \lor \ldots \lor C_m), where each C_i is a conjunction of literals l_ \land l_ \land \ldots \land l_. Step 2: Negate \lnot \phi_. Then shift \lnot inwards by applying the (generalized) De Morgan's equivalences until no longer possible. \begin \phi &\leftrightarrow \lnot \lnot \phi_ \\ &= \lnot (C_1 \lor C_2 \lor \ldots \lor C_i \lor \ldots \lor C_m) \\ &\leftrightarrow \lnot C_1 \land \lnot C_2 \land \ldots \land \lnot C_i \land \ldots \land \lnot C_m &&\text \end where\begin \lnot C_i &= \lnot (l_ \land l_ \land \ldots \land l_) \\ &\leftrightarrow (\lnot l_ \lor \lnot l_ \lor \ldots \lor \lnot l_) &&\text \end Step 3: Remove all double negations. Example Convert to CNF the propositional formula \phi = ((\lnot (p \land q)) \leftrightarrow (\lnot r \uparrow (p \oplus q))). The (full) DNF equivalent of its negation is
\lnot \phi_ = ( 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) \begin \phi &\leftrightarrow \lnot \lnot \phi_ \\ &= \lnot \ \\ &\leftrightarrow \underline \land \underline \land \underline \land \underline &&\text \\ &\leftrightarrow (\lnot p \lor \lnot q \lor \lnot r) \land (\lnot p \lor \lnot q \lor \lnot \lnot r) \land (\lnot p \lor \lnot \lnot q \lor \lnot \lnot r) \land (\lnot \lnot p \lor \lnot q \lor \lnot \lnot r) &&\text (4 \times) \\ &\leftrightarrow (\lnot p \lor \lnot q \lor \lnot r) \land (\lnot p \lor \lnot q \lor r) \land (\lnot p \lor q \lor r) \land ( p \lor \lnot q \lor r) &&\text \lnot \lnot \\ &= \phi_ \end


Conversion by semantic means

A CNF equivalent of a formula can be derived from its
truth table A truth table is a mathematical table used in logic—specifically in connection with Boolean algebra, Boolean functions, and propositional calculus—which sets out the functional values of logical expressions on each of their functional arg ...
. Again, consider the formula \phi = ((\lnot (p \land q)) \leftrightarrow (\lnot r \uparrow (p \oplus q))). The corresponding
truth table A truth table is a mathematical table used in logic—specifically in connection with Boolean algebra, Boolean functions, and propositional calculus—which sets out the functional values of logical expressions on each of their functional arg ...
is A CNF equivalent of \phi is (\lnot p \lor \lnot q \lor \lnot r) \land (\lnot p \lor \lnot q \lor r) \land (\lnot p \lor q \lor r) \land ( p \lor \lnot q \lor r) Each disjunction reflects an assignment of variables for which \phi evaluates to F(alse).
If in such an assignment a variable V * is T(rue), then the literal is set to \lnot 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 (X_1 \wedge Y_1) \vee (X_2 \wedge Y_2) \vee \ldots \vee (X_n \wedge Y_n) into CNF produces a formula with 2^n clauses: (X_1 \vee X_2 \vee \ldots \vee X_n) \wedge (Y_1 \vee X_2 \vee \ldots \vee X_n) \wedge (X_1 \vee Y_2 \vee \ldots \vee X_n) \wedge (Y_1 \vee Y_2 \vee \ldots \vee X_n) \wedge \ldots \wedge (Y_1 \vee Y_2 \vee \ldots \vee Y_n). 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. 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 \ldots \vee Z_n) \wedge (\neg Z_1 \vee X_1) \wedge (\neg Z_1 \vee Y_1) \wedge \ldots \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 plans of a building in late 16th-century English, and derived via French and Italian ultimately from Latin , . Models can be divided in ...
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 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.


Maximum number of disjunctions

Consider a propositional formula with n variables, n \ge 1. There are 2n possible literals: L = \. L has (2^ -1) non-empty subsets. This is the maximum number of disjunctions a CNF can have. All truth-functional combinations can be expressed with 2^ 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^ -1 = 15 disjunctions: \begin (\lnot p) \land (p) \land (\lnot q) \land (q) \land \\ (\lnot p \or p) \land \underline \land \underline \land \underline \land \underline \land (\lnot q \or q) \land \\ (\lnot p \or p \or \lnot q) \land (\lnot p \or p \or q) \land (\lnot p \or \lnot q \or q) \land ( p \or \lnot q \or q) \land \\ (\lnot p \or p \or \lnot q \or q) \end This formula is a
contradiction In traditional logic, a contradiction involves a proposition conflicting either with itself or established fact. It is often used as a tool to detect disingenuous beliefs and bias. Illustrating a general tendency in applied logic, Aristotle's ...
. It can be simplified to (\neg p \land p) or to (\neg q \land q), which are also contradictions, as well as valid CNFs.


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 is
NP-complete In computational complexity theory, NP-complete problems are the hardest of the problems to which ''solutions'' can be verified ''quickly''. Somewhat more precisely, a problem is NP-complete when: # It is a decision problem, meaning that for any ...
(like any other ''k''-SAT problem with ''k''>2) while 2-SAT is known to have solutions in
polynomial time In theoretical 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 p ...
. As a consequence, the task of converting a formula into a DNF, preserving satisfiability, is
NP-hard In computational complexity theory, a computational problem ''H'' is called NP-hard if, for every problem ''L'' which can be solved in non-deterministic polynomial-time, there is a polynomial-time reduction from ''L'' to ''H''. That is, assumi ...
; 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 "''k''CNF" (for ''k''≥3) by replacing each conjunct with more than ''k'' variables X_1 \vee \ldots \vee X_k \vee \ldots \vee X_n by two conjuncts X_1 \vee \ldots \vee X_ \vee Z and \neg Z \vee X_k \lor \ldots \vee X_n with 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 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 for an example.


Converting from first-order logic

To convert
first-order logic First-order logic, also called predicate logic, predicate calculus, or quantificational logic, is a collection of formal systems used in mathematics, philosophy, linguistics, and computer science. First-order logic uses quantified variables over ...
to CNF: #Convert to negation normal form. ## 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 mathemat ...
. 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". 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). 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 In language, a clause is a Constituent (linguistics), constituent or Phrase (grammar), phrase that comprises a semantic predicand (expressed or not) and a semantic Predicate (grammar), predicate. A typical clause consists of a subject (grammar), ...
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, (\mathrm(f(x)) \lor \mathrm(g(x), x)) \land (\lnot \mathrm(x, f(x)) \lor \mathrm(g(x), x)), is the CNF.


See also

* Algebraic normal form * Conjunction/disjunction duality *
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 that gives it useful properties for use in logic programming, formal specification, universal algebra and model theory. Horn clauses are ...
– A Horn clause is a disjunctive
clause In language, a clause is a Constituent (linguistics), constituent or Phrase (grammar), phrase that comprises a semantic predicand (expressed or not) and a semantic Predicate (grammar), predicate. A typical clause consists of a subject (grammar), ...
(a
disjunction In logic, disjunction (also known as logical disjunction, logical or, logical addition, or inclusive disjunction) is a logical connective typically notated as \lor and read aloud as "or". For instance, the English language sentence "it is ...
of literals) with at most one positive, i.e. unnegated, literal. * Quine–McCluskey algorithm


Notes


References

* * * * * * *


External links

* * Normal forms (logic) Knowledge compilation {{Normal forms in logic