Conjunctive normal form

Last updated

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. As a canonical normal form, it is useful in automated theorem proving and circuit theory.

Contents

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 (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:

  1. CNF → (Disjunction) CNF
  2. CNF → (Disjunction)
  3. DisjunctionLiteralDisjunction
  4. DisjunctionLiteral
  5. LiteralVariable
  6. LiteralVariable

Where Variable is any variable.

All of the following formulas in the variables , and 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. [1] 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. [2]
Then is converted to by swapping ANDs with ORs and vice versa while negating all the literals. Remove all . [1]

Conversion by syntactic means

Convert to CNF the propositional formula .

Step 1: Convert its negation to disjunctive normal form. [2]

, [lower-alpha 1]

where each is a conjunction of literals . [lower-alpha 2]

Step 2: Negate . Then shift 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 . [lower-alpha 3]

The (full) DNF equivalent of its negation is [2]

Conversion by semantic means

A CNF equivalent of a formula can be derived from its truth table. Again, consider the formula

. [lower-alpha 3]

The corresponding truth table is

TTTFTFFTF
TTFFTFTTF
TFTTFTFTT
TFFTFFTFT
FTTTFTFTT
FTFTFFTFT
FFTTFTFTF
FFFTFTTTF

A CNF equivalent of is

Each disjunction reflects an assignment of variables for which evaluates to F(alse).
If in such an assignment a variable

  • is T(rue), then the literal is set to in the disjunction,
  • is F(alse), then the literal is set to 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

into CNF produces a formula with clauses:

Each clause contains either or for each .

There exist transformations into CNF that avoid an exponential increase in size by preserving satisfiability rather than equivalence. [3] [4] 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 , then both and 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 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" to be a name for .

Maximum number of disjunctions

Consider a propositional formula with variables, .

There are possible literals: .

has non-empty subsets. [lower-alpha 4]

This is the maximum number of disjunctions a CNF can have. [lower-alpha 5]

All truth-functional combinations can be expressed with disjunctions, one for each row of the truth table.
In the example below they are underlined.

Example

Consider a formula with two variables and .

The longest possible CNF has disjunctions: [lower-alpha 5]

This formula is a 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, [lower-alpha 6] 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 k3) 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

, [lower-alpha 7] is commonly represented as a set of sets
.

See below for an example.

Converting from first-order logic

To convert first-order logic to CNF: [5]

  1. Convert to negation normal form.
    1. Eliminate implications and equivalences: repeatedly replace with ; replace with . Eventually, this will eliminate all occurrences of and .
    2. Move NOTs inwards by repeatedly applying De Morgan's law. Specifically, replace with ; replace with ; and replace with ; replace with ; with . After that, a may occur only immediately before a predicate symbol.
  2. Standardize variables
    1. For sentences like which use the same variable name twice, change the name of one of the variables. This avoids confusion later when dropping quantifiers. For example, is renamed to .
  3. Skolemize the statement
    1. Move quantifiers outwards: repeatedly replace with ; replace with ; replace with ; replace with . These replacements preserve equivalence, since the previous variable standardization step ensured that doesn't occur in . After these replacements, a quantifier may occur only in the initial prefix of the formula, but never inside a , , or .
    2. Repeatedly replace with , where is a new -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.
  4. Drop all universal quantifiers.
  5. Distribute ORs inwards over ANDs: repeatedly replace with .

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 ):

by 1.1
by 1.1
by 1.2
by 1.2
by 1.2
by 2
by 3.1
by 3.1
by 3.2
by 4
by 5
(clause representation)

Informally, the Skolem function can be thought of as yielding the person by whom is loved, while yields the animal (if any) that doesn't love. The 3rd last line from below then reads as " doesn't love the animal , or else is loved by ".

The 2nd last line from above, , is the CNF.

See also

Notes

  1. maximum number of conjunctions for
  2. maximum number of literals for
  3. 1 2 = (( NOT (p AND q)) IFF (( NOT r) NAND (p XOR q)))
  4. 1 2 It is assumed that repetitions and variations (like ) based on the commutativity and associativity of and do not occur.
  5. 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
  6. maximum number of disjunctions
    maximum number of literals

Related Research Articles

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 quantified variables over non-logical objects, and allows the use of sentences that contain variables, so that rather than propositions such as "Socrates is a man", one can have expressions in the form "there exists x such that x is Socrates and x is a man", where "there exists" is a quantifier, while x is a variable. This distinguishes it from propositional logic, which does not use quantifiers or relations; in this sense, propositional logic is the foundation of first-order logic.

<span class="mw-page-title-main">Original proof of Gödel's completeness theorem</span>

The proof of Gödel's completeness theorem given by Kurt Gödel in his doctoral dissertation of 1929 is not easy to read today; it uses concepts and formalisms that are no longer used and terminology that is often obscure. The version given below attempts to represent all the steps in the proof and all the important ideas faithfully, while restating the proof in the modern language of mathematical logic. This outline should not be considered a rigorous proof of the theorem.

<span class="mw-page-title-main">Logical connective</span> Symbol connecting sentential formulas in logic

In logic, a logical connective is a logical constant. Connectives can be used to connect logical formulas. For instance in the syntax of propositional logic, the binary connective can be used to join the two atomic formulas and , rendering the complex formula .

The propositional calculus is a branch of logic. It is also called propositional logic, statement logic, sentential calculus, sentential logic, or sometimes zeroth-order logic. It deals with propositions and relations between propositions, including the construction of arguments based on them. Compound propositions are formed by connecting propositions by logical connectives representing the truth functions of conjunction, disjunction, implication, equivalence, and negation. Some sources include other connectives, as in the table below.

<span class="mw-page-title-main">De Morgan's laws</span> Pair of logical equivalences

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 mathematician. The rules allow the expression of conjunctions and disjunctions purely in terms of each other via negation.

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 concept. As a normal form, it is useful in automated theorem proving.

Intuitionistic logic, sometimes more generally called constructive logic, refers to systems of symbolic logic that differ from the systems used for classical logic by more closely mirroring the notion of constructive proof. In particular, systems of intuitionistic logic do not assume the law of the excluded middle and double negation elimination, which are fundamental inference rules in classical logic.

A formula of the predicate calculus is in prenex normal form (PNF) if it is written as a string of quantifiers and bound variables, called the prefix, followed by a quantifier-free part, called the matrix. Together with the normal forms in propositional logic, it provides a canonical normal form useful in automated theorem proving.

In logic, a truth function is a function that accepts truth values as input and produces a unique truth value as output. In other words: the input and output of a truth function are all truth values; a truth function will always output exactly one truth value, and inputting the same truth value(s) will always output the same truth value. The typical example is in propositional logic, wherein a compound statement is constructed using individual statements connected by logical connectives; if the truth value of the compound statement is entirely determined by the truth value(s) of the constituent statement(s), the compound statement is called a truth function, and any logical connectives used are said to be truth functional.

In mathematical logic, positive set theory is the name for a class of alternative set theories in which the axiom of comprehension holds for at least the positive formulas.

<span class="mw-page-title-main">Method of analytic tableaux</span>

In proof theory, the semantic tableau (; plural: tableaux, also called an analytic tableau, truth tree, or simply tree, is a decision procedure for sentential and related logics, and a proof procedure for formulae of first-order logic. An analytic tableau is a tree structure computed for a logical formula, having at each node a subformula of the original formula to be proved or refuted. Computation constructs this tree and uses it to prove or refute the whole formula. The tableau method can also determine the satisfiability of finite sets of formulas of various logics. It is the most popular proof procedure for modal logics.

The Kripke–Platek set theory with urelements (KPU) is an axiom system for set theory with urelements, based on the traditional (urelement-free) Kripke–Platek set theory. It is considerably weaker than the (relatively) familiar system ZFU. The purpose of allowing urelements is to allow large or high-complexity objects to be included in the theory's transitive models without disrupting the usual well-ordering and recursion-theoretic properties of the constructible universe; KP is so weak that this is hard to do by traditional means.

Independence-friendly logic is an extension of classical first-order logic (FOL) by means of slashed quantifiers of the form and , where is a finite set of variables. The intended reading of is "there is a which is functionally independent from the variables in ". IF logic allows one to express more general patterns of dependence between variables than those which are implicit in first-order logic. This greater level of generality leads to an actual increase in expressive power; the set of IF sentences can characterize the same classes of structures as existential second-order logic.

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 applying the resolution rule acts as a decision procedure for formula unsatisfiability, solving the Boolean satisfiability problem. For first-order logic, resolution can be used as the basis for a semi-algorithm for the unsatisfiability problem of first-order logic, providing a more practical method than one following from Gödel's completeness theorem.

In logic, a functionally complete set of logical connectives or Boolean operators is one that can be used to express all possible truth tables by combining members of the set into a Boolean expression. A well-known complete set of connectives is { AND, NOT }. Each of the singleton sets { NAND } and { NOR } is functionally complete. However, the set { AND, OR } is incomplete, due to its inability to express NOT.

In mathematics, a set is inhabited if there exists an element .

In logic, especially mathematical logic, a Hilbert system, sometimes called Hilbert calculus, Hilbert-style deductive system or Hilbert–Ackermann system, is a type of system of formal deduction attributed to Gottlob Frege and David Hilbert. These deductive systems are most often studied for first-order logic, but are of interest for other logics as well.

Dependence logic is a logical formalism, created by Jouko Väänänen, which adds dependence atoms to the language of first-order logic. A dependence atom is an expression of the form , where are terms, and corresponds to the statement that the value of is functionally dependent on the values of .

The Tseytin transformation, alternatively written Tseitin transformation, takes as input an arbitrary combinatorial logic circuit and produces an equisatisfiable boolean formula in conjunctive normal form (CNF). The length of the formula is linear in the size of the circuit. Input vectors that make the circuit output "true" are in 1-to-1 correspondence with assignments that satisfy the formula. This reduces the problem of circuit satisfiability on any circuit to the satisfiability problem on 3-CNF formulas. It was discovered by the Russian scientist Grigori Tseitin.

References

  1. 1 2 Howson 2005, p. 46.
  2. 1 2 3 see Disjunctive normal form § Conversion to DNF
  3. Tseitin 1968.
  4. Jackson & Sheridan 2004.
  5. Russel & Norvig 2010, pp. 345–347, 9.5.1 Conjunctive normal form for first-order logic.