Birthday problem: Difference between revisions

From formulasearchengine
Jump to navigation Jump to search
No edit summary
en>Squarebracket
m →‎In Fiction: Corrected typo: than -> that
Line 1: Line 1:
In [[Boolean logic]], a [[Formula (mathematical logic)|formula]] is in '''conjunctive normal form (CNF)''' or '''clausal normal form''' if it is a [[logical conjunction|conjunction]] of [[clause (logic)|clauses]], where a clause is a [[logical disjunction|disjunction]] of [[literal (mathematical logic)|literal]]s; otherwise put, it is an AND of ORs. As a [[Normal_form_(mathematics)#Rewriting_systems|normal form]], it is useful in [[automated theorem proving]]. It is similar to the [[Canonical form (Boolean algebra)|product of sums form]] used in [[circuit theory]].
My name: Duane Lawrenson<br>Age: 22<br>Country: Switzerland<br>Town: Courchapoix <br>Post code: 2825<br>Address: Bosch 35<br><br>Check out my webpage: [http://hemorrhoidtreatmentfix.com/hemorrhoid-symptoms hemorrhoids symptoms]
 
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]] (DNF), the only propositional connectives a formula in CNF can contain are [[logical conjunction|and]], [[logical disjunction|or]], and [[logical negation|not]]. The not operator can only be used as part of a literal, which means that it can only precede a [[propositional variable]] or a [[First-order_logic#Formulas|predicate symbol]].
 
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 counterexamples==
All of the following formulas are '''in CNF''':
 
:<math>\neg A \wedge (B \vee C)</math>
:<math>(A \vee B) \wedge (\neg B \vee C \vee \neg D) \wedge (D \vee \neg E)</math>
:<math>A \lor B</math>
:<math>A \wedge B</math>
 
The last formula is in CNF because it can be seen as the conjunction of the two single-literal clauses <math>A</math> and <math>B</math>. Incidentally, the last two formulae are also in [[disjunctive normal form]].
 
The following formulas are '''not in CNF''':
:<math>\neg (B \vee C)</math>
:<math>(A \wedge B) \vee C</math>
:<math>A \wedge (B \vee (D \wedge E)).</math>
 
The above three formulas are respectively equivalent to the following three formulas that are '''in CNF''':
:<math>\neg B \wedge \neg C</math>
:<math>(A \vee C) \wedge (B \vee C)</math>
:<math>A \wedge (B \vee D) \wedge (B \vee E).</math>
 
==Conversion into CNF==
 
Every [[propositional formula]] can be converted into an [[logical equivalence|equivalent]] formula that is in CNF. This transformation is based on rules about [[logical equivalence]]s: the [[double negative elimination|double negative law]], [[De Morgan's laws]], and the [[distributivity|distributive law]].
 
Since all logical formulae 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 <math>2^n</math> clauses:
 
:<math>(X_1 \wedge Y_1) \vee (X_2 \wedge Y_2) \vee \dots \vee (X_n \wedge Y_n).</math>
 
In particular, the generated formula is:
 
:<math>(X_1 \vee \cdots \vee X_{n-1} \vee X_n) \wedge
(X_1 \vee \cdots \vee X_{n-1} \vee Y_n) \wedge
\cdots \wedge
(Y_1 \vee \cdots \vee Y_{n-1} \vee Y_n).</math>
 
This formula contains <math>2^n</math> clauses; each clause contains either <math>X_i</math> or <math>Y_i</math> for each <math>i</math>.
 
There exist transformations into CNF that avoid an exponential increase in size by preserving [[Boolean satisfiability problem|satisfiability]] rather than [[logical equivalence|equivalence]].<ref>Tseitin (1968)</ref><ref>Jackson and Sheridan (2004)</ref> 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 <math>Z_1,\ldots,Z_n</math> as follows:
 
:<math>(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). </math>
 
An interpretation satisfies this formula only if at least one of the new variables is true. If this variable is <math>Z_i</math>, then both <math>X_i</math> and <math>Y_i</math> are true as well. This means that every [[Model Theory|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 <math>Z_i</math> 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 [[logical equivalence|equivalent]].
 
An alternative translation includes also the clauses <math>Z_i \vee \neg X_i \vee \neg Y_i</math>. With these clauses, the formula implies <math>Z_i \equiv X_i \wedge Y_i</math>; this formula is often regarded to "define" <math>Z_i</math> to be a name for <math>X_i \wedge Y_i</math>.
 
==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
{|
|-
||
|| <math>(</math>
|| <math>l_{11}</math>
|| <math>\lor</math>
|| <math>\ldots</math>
|| <math>\lor</math>
|| <math>l_{1n_1}</math>
|| <math>)</math>
|| <math>\land</math>
|| <math>\ldots</math>
|| <math>\land</math>
|| <math>(</math>
|| <math>l_{m1}</math>
|| <math>\lor</math>
|| <math>\ldots</math>
|| <math>\lor</math>
|| <math>l_{mn_m}</math>
|| <math>)</math>
||
|| , with <math>l_{ij}</math> literals, is commonly represented as a set of sets
|-
|| <math>\{</math>
|| <math>\{</math>
|| <math>l_{11}</math>
|| <math>,</math>
|| <math>\ldots</math>
|| <math>,</math>
|| <math>l_{1n_1}</math>
|| <math>\}</math>
|| <math>,</math>
|| <math>\ldots</math>
|| <math>,</math>
|| <math>\{</math>
|| <math>l_{m1}</math>
|| <math>,</math>
|| <math>\ldots</math>
|| <math>,</math>
|| <math>l_{mn_m}</math>
|| <math>\}</math>
|| <math>\}</math>
|| .
|}
See [[#Converting_from_first-order_logic|below]] for an example.
 
==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. [[Boolean satisfiability problem|3-SAT]] is [[NP-complete]] (like any other ''k''-SAT problem with ''k''>2) while [[2-satisfiability|2-SAT]] is known to have solutions in [[polynomial time]].
As a consequence,<ref>since one way to check a CNF for satisfiability is to convert it into a [[Disjunctive normal form|DNF]], the satisfiability of which can be checked in [[Time complexity#Linear_time|linear time]]</ref> the task of converting a formula into a [[Disjunctive normal form|DNF]], preserving satisfiability, is [[NP-hard]]; [[Boolean_algebra#Duality_principle|dually]], converting into CNF, preserving [[Satisfiability and validity|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 <math>X_1 \vee \cdots \vee X_k \vee \cdots \vee X_n</math> by two conjuncts <math>X_1 \vee \cdots \vee X_{k-1} \vee Z</math> and <math>\neg Z \vee X_k \cdots \vee X_n</math> with <math>Z</math> a new variable, and repeating as often as necessary.
 
==Converting from first-order logic==
 
To convert [[first order logic|first-order logic]] to CNF:<ref>Artificial Intelligence: A modern Approach [1995...] Russel and Norvig</ref>
#Convert to [[negation normal form]].
## Eliminate implications and equivalences: repeatedly replace <math>P \rightarrow Q</math> with <math>\lnot P \lor Q</math>; replace <math>P \leftrightarrow Q</math> with <math>(P \lor \lnot Q) \land (\lnot P \lor Q)</math>. Eventually, this will eliminate all occurrences of <math>\rightarrow</math> and <math>\leftrightarrow</math>.
##Move NOTs inwards by repeatedly applying [[De Morgan's Law]].  Specifically, replace <math>\lnot (P \lor Q)</math> with <math>(\lnot P) \land (\lnot Q)</math>; replace <math>\lnot (P \land Q)</math> with <math>(\lnot P) \lor (\lnot Q)</math>; and replace <math>\lnot\lnot P</math> with <math>P</math>; replace <math>\lnot (\forall x P(x))</math> with <math>\exists x \lnot P(x)</math>; <math>\lnot (\exists x P(x))</math> with <math>\forall x \lnot P(x)</math>. After that, a <math>\lnot</math> may occur only immediately before a predicate symbol.
#Standardize variables
##For sentences like <math>(\forall x P(x)) \lor (\exists x Q(x))</math> which use the same variable name twice, change the name of one of the variables. This avoids confusion later when dropping quantifiers later. For example, <math>\forall x [\exists y Animal(y) \land \lnot Loves(x, y)] \lor [\exists y Loves(y, x)]</math> is renamed to <math>\forall x [\exists y Animal(y) \land \lnot Loves(x, y)] \lor [\exists z Loves(z,x)]</math>.
#[[Skolemize]] the statement
##Move quantifiers outwards: repeatedly replace <math>P \land (\forall x Q(x))</math> with <math>\forall x (P \land Q(x))</math>; replace <math>P \lor (\forall x Q(x))</math> with <math>\forall x (P \lor Q(x))</math>; replace <math>P \land (\exists x Q(x))</math> with <math>\exists x (P \land Q(x))</math>; replace <math>P \lor (\exists x Q(x))</math> with <math>\exists x (P \lor Q(x))</math>. These replacements preserve equivalence, since the previous variable standardization step ensured that <math>x</math> doesn't occur in <math>P</math>. After these replacements, a quantifier may occur only in the initial prefix of the formula, but never inside a <math>\lnot</math>, <math>\land</math>, or <math>\lor</math>.
##Repeatedly replace <math>\forall x_1 \ldots \forall x_n \; \exists y \; P(y)</math> with <math>\forall x_1 \ldots \forall x_n \; P(f(x_1,\ldots,x_n))</math>, where <math>f</math> is a new <math>n</math>-ary function symbol, a so-called "[[Skolem normal form|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 <math>P \lor (Q \land R)</math> with <math>(P \lor Q) \land (P \lor R)</math>.
 
As an example, the formula saying ''"Who loves all animals, is in turn loved by someone"'' is converted into CNF (and subsequently into [[clause (logic)|clause]] form in the last line) as follows (highlighting replacement rule redices in <math>\color{red}\text{red}</math>):
 
{|
|-
||<math>\forall x</math>
||
||
||
||<math>(</math>
||<math>\forall y</math>
||
||
||
||
||<math>Animal(</math>
||<math>y</math>
||<math>)</math>
||<math>\color{red}\rightarrow</math>
||
||<math>Loves(x,</math>
||<math>y</math>
||<math>)</math>
||
||<math>)</math>
||<math>\rightarrow</math>
||<math>(</math>
||<math>\exists</math>
||<math>y</math>
||<math>Loves(</math>
||<math>y</math>
||<math>,x)</math>
||<math>)</math>
||
||
||
||
||
||
||
||
||
 
|-
||<math>\forall x</math>
||
||
||
||<math>(</math>
||<math>\forall y</math>
||
||
||
||<math>\lnot</math>
||<math>Animal(</math>
||<math>y</math>
||<math>)</math>
||<math>\lor</math>
||
||<math>Loves(x,</math>
||<math>y</math>
||<math>)</math>
||
||<math>)</math>
||<math>\color{red}\rightarrow</math>
||<math>(</math>
||<math>\exists</math>
||<math>y</math>
||<math>Loves(</math>
||<math>y</math>
||<math>,x)</math>
||<math>)</math>
||
||
||
||
||
||
||
||
||by 1.1
 
|-
||<math>\forall x</math>
||<math>\color{red}\lnot</math>
||
||
||<math>(</math>
||<math>\color{red}\forall y</math>
||
||
||
||<math>\lnot</math>
||<math>Animal(</math>
||<math>y</math>
||<math>)</math>
||<math>\lor</math>
||
||<math>Loves(x,</math>
||<math>y</math>
||<math>)</math>
||
||<math>)</math>
||<math>\lor</math>
||<math>(</math>
||<math>\exists</math>
||<math>y</math>
||<math>Loves(</math>
||<math>y</math>
||<math>,x)</math>
||<math>)</math>
||
||
||
||
||
||
||
||
||by 1.1
 
|-
||<math>\forall x</math>
||
||
||
||<math>(</math>
||<math>\exists y</math>
||<math>\color{red}\lnot</math>
||<math>(</math>
||
||<math>\lnot</math>
||<math>Animal(</math>
||<math>y</math>
||<math>)</math>
||<math>\color{red}\lor</math>
||
||<math>Loves(x,</math>
||<math>y</math>
||<math>)</math>
||<math>)</math>
||<math>)</math>
||<math>\lor</math>
||<math>(</math>
||<math>\exists</math>
||<math>y</math>
||<math>Loves(</math>
||<math>y</math>
||<math>,x)</math>
||<math>)</math>
||
||
||
||
||
||
||
||
||by 1.2
 
|-
||<math>\forall x</math>
||
||
||
||<math>(</math>
||<math>\exists y</math>
||
||
||<math>\color{red}\lnot</math>
||<math>\color{red}\lnot</math>
||<math>Animal(</math>
||<math>y</math>
||<math>)</math>
||<math>\land</math>
||<math>\lnot</math>
||<math>Loves(x,</math>
||<math>y</math>
||<math>)</math>
||
||<math>)</math>
||<math>\lor</math>
||<math>(</math>
||<math>\exists</math>
||<math>y</math>
||<math>Loves(</math>
||<math>y</math>
||<math>,x)</math>
||<math>)</math>
||
||
||
||
||
||
||
||
||by 1.2
 
|-
||<math>\forall x</math>
||
||
||
||<math>(</math>
||<math>\color{red}\exists y</math>
||
||
||
||
||<math>Animal(</math>
||<math>y</math>
||<math>)</math>
||<math>\land</math>
||<math>\lnot</math>
||<math>Loves(x,</math>
||<math>y</math>
||<math>)</math>
||
||<math>)</math>
||<math>\lor</math>
||<math>(</math>
||<math>\color{red}\exists</math>
||<math>\color{red}y</math>
||<math>Loves(</math>
||<math>y</math>
||<math>,x)</math>
||<math>)</math>
||
||
||
||
||
||
||
||
||by 1.2
 
|-
||<math>\forall x</math>
||
||
||
||<math>(</math>
||<math>\exists y</math>
||
||
||
||
||<math>Animal(</math>
||<math>y</math>
||<math>)</math>
||<math>\land</math>
||<math>\lnot</math>
||<math>Loves(x,</math>
||<math>y</math>
||<math>)</math>
||
||<math>)</math>
||<math>\color{red}\lor</math>
||<math>(</math>
||<math>\color{red}\exists</math>
||<math>\color{red}z</math>
||<math>Loves(</math>
||<math>z</math>
||<math>,x)</math>
||<math>)</math>
||
||
||
||
||
||
||
||
||by 2
 
|-
||<math>\forall x</math>
||<math>\exists z</math>
||
||
||<math>(</math>
||<math>\color{red}\exists y</math>
||
||
||
||
||<math>Animal(</math>
||<math>y</math>
||<math>)</math>
||<math>\land</math>
||<math>\lnot</math>
||<math>Loves(x,</math>
||<math>y</math>
||<math>)</math>
||
||<math>)</math>
||<math>\color{red}\lor</math>
||
||
||
||<math>Loves(</math>
||<math>z</math>
||<math>,x)</math>
||
||
||
||
||
||
||
||
||
||by 3.1
 
|-
||<math>\forall x</math>
||<math>\color{red}\exists z</math>
||
||
||
||<math>\exists y</math>
||
||<math>(</math>
||
||
||<math>Animal(</math>
||<math>y</math>
||<math>)</math>
||<math>\land</math>
||<math>\lnot</math>
||<math>Loves(x,</math>
||<math>y</math>
||<math>)</math>
||<math>)</math>
||
||<math>\lor</math>
||
||
||
||<math>Loves(</math>
||<math>z</math>
||<math>,x)</math>
||
||
||
||
||
||
||
||
||
||by 3.1
 
|-
||<math>\forall x</math>
||
||
||
||
||<math>\color{red}\exists y</math>
||
||<math>(</math>
||
||
||<math>Animal(</math>
||<math>y</math>
||<math>)</math>
||<math>\land</math>
||<math>\lnot</math>
||<math>Loves(x,</math>
||<math>y</math>
||<math>)</math>
||<math>)</math>
||
||<math>\lor</math>
||
||
||
||<math>Loves(</math>
||<math>g(x)</math>
||<math>,x)</math>
||
||
||
||
||
||
||
||
||
||by 3.2
 
|-
||
||
||
||
||
||
||
||<math>(</math>
||
||
||<math>Animal(</math>
||<math>f(x)</math>
||<math>)</math>
||<math>\color{red}\land</math>
||<math>\lnot</math>
||<math>Loves(x,</math>
||<math>f(x)</math>
||<math>)</math>
||<math>)</math>
||
||<math>\color{red}\lor</math>
||
||
||
||<math>Loves(</math>
||<math>g(x)</math>
||<math>,x)</math>
||
||
||
||
||
||
||
||
||
||by 4
 
|-
||
||
||
||<math>(</math>
||
||
||
||
||
||
||<math>Animal(</math>
||<math>f(x)</math>
||<math>)</math>
||
||
||
||
||
||
||
||<math>\color{red}\lor</math>
||
||
||
||<math>Loves(</math>
||<math>g(x)</math>
||<math>,x)</math>
||
||<math>)</math>
||<math>\color{red}\land</math>
||<math>(</math>
||<math>\lnot Loves(x,f(x))</math>
||<math>\color{red}\lor</math>
||<math>Loves(g(x),x)</math>
||<math>)</math>
||
||by 5
 
|-
||
||
||<math>\{</math>
||<math>\{</math>
||
||
||
||
||
||
||<math>Animal(</math>
||<math>f(x)</math>
||<math>)</math>
||
||
||
||
||
||
||
||<math>,</math>
||
||
||
||<math>Loves(</math>
||<math>g(x)</math>
||<math>,x)</math>
||
||<math>\}</math>
||<math>,</math>
||<math>\{</math>
||<math>\lnot Loves(x,f(x))</math>
||<math>,</math>
||<math>Loves(g(x),x)</math>
||<math>\}</math>
||<math>\}</math>
||([[clause (logic)|clause]] representation)
 
|}
 
Informally, the skolem function <math>g(x)</math> can be thought of as yielding the person by whom <math>x</math> is loved, while <math>f(x)</math> yields the animal (if any) that <math>x</math> doesn't love. The 3rd last line from below then reads as ''"<math>x</math> doesn't love the animal <math>f(x)</math>, or else <math>x</math> is loved by <math>g(x)</math>"''.
 
The 2nd last line from above, <math>(Animal(f(x)) \lor Loves(g(x), x)) \land (\lnot Loves(x, f(x)) \lor Loves(g(x), x))</math>, is the CNF.
 
==Notes==
<references/>
 
==See also==
* [[Algebraic normal form]]
* [[Disjunctive normal form]]
* [[Horn clause]]
* [[Quine&ndash;McCluskey algorithm]]
 
==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&ndash;13, 2004, Revised Selected Papers. Lecture Notes in Computer Science 3542, Springer 2005, pp.&nbsp;183&ndash;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.&nbsp;115&ndash;125. Steklov Mathematical Institute (1968)
 
==External links==
* {{springer|title=Conjunctive normal form|id=p/c025090}}
* [http://www.izyt.com/BooleanLogic/applet.php Java applet for converting to CNF and DNF, showing laws used]
* [http://fuzziness.org/fuzzynorms 3D application showing the difference between CNF and DNF for different De Morgan Triples]
 
{{DEFAULTSORT:Conjunctive Normal Form}}
[[Category:Normal forms (logic)]]

Revision as of 12:32, 24 February 2014

My name: Duane Lawrenson
Age: 22
Country: Switzerland
Town: Courchapoix
Post code: 2825
Address: Bosch 35

Check out my webpage: hemorrhoids symptoms