Disjunctive normal form: Difference between revisions

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
imported>Marc Schroeder
 
imported>Jochen Burghardt
Definition: cf. Talk:Disjunctive_normal_form#Meaning_of_"Conjunct"; also reuire parentheses around each Disjunct
 
Line 1: Line 1:
{{Short description|Standard form of a boolean function}}
{{Short description|Standard form of a boolean function}}
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 {{mdash}} in [[philosophical logic]] {{mdash}} a ''cluster concept''.{{sfn|Post|1921}} As a [[Normal form (abstract rewriting)|normal form]], it is useful in [[automated theorem proving]].
In [[boolean logic]], a '''disjunctive normal form''' ('''DNF''') is a [[normal form (abstract rewriting)|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 {{mdash}} in [[philosophical logic]] {{mdash}} a ''cluster concept''.{{sfn|Post|1921}} The disjunctive normal form and its counterpart, the [[conjunctive normal form]], are the most common standardized ways of representing [[boolean expressions]]. They are widely used in various applications such as [[circuit design]] or [[automated theorem proving]].


==Definition==
==Definition==
Line 6: Line 6:


The following is a [[context-free grammar]] for DNF:
The following is a [[context-free grammar]] for DNF:
: ''DNF'' <math>\, \to \,</math> ''Conjunct'' <math>\, \mid \, </math> ''Conjunct'' <math>\, \lor \,</math> ''DNF''
: ''DNF'' <math>\, \to \,</math> (''Disjunct'') <math>\, \mid \, </math> (''Disjunct'') <math>\, \lor \,</math> ''DNF''
: ''Conjunct'' <math>\, \to \,</math> ''Literal'' <math>\, \mid\, </math> ''Literal'' <math>\, \land \,</math> ''Conjunct''
: ''Disjunct'' <math>\, \to \,</math> ''Literal'' <math>\, \mid\, </math> ''Literal'' <math>\, \land \,</math> ''Disjunct''
: ''Literal'' <math>\, \to \,</math> ''Variable'' <math>\, \mid \,</math> <math>\, \neg \,</math> ''Variable''
: ''Literal'' <math>\, \to \,</math> ''Variable'' <math>\, \mid \,</math> <math>\, \neg \,</math> ''Variable''
Where ''Variable'' is any variable.
Where ''Variable'' is any variable.
Line 161: Line 161:
==References==
==References==
{{sfn whitelist |CITEREFSobolev2020}}
{{sfn whitelist |CITEREFSobolev2020}}
*{{cite book|last1=Arora | first1=Sanjeev |author1-link=Sanjeev Arora|last2=Barak|first2= Boaz |author2-link=Boaz Barak| title=Computational Complexity: A Modern Approach | publisher=[[Cambridge University Press]]|date=20 April 2009|pages=579|isbn=9780521424264|doi=10.1017/CBO9780511804090}}
*{{cite book|last1=Arora | first1=Sanjeev |author1-link=Sanjeev Arora (computer scientist)|last2=Barak|first2= Boaz |author2-link=Boaz Barak| title=Computational Complexity: A Modern Approach | publisher=[[Cambridge University Press]]|date=20 April 2009|pages=579|isbn=9780521424264|doi=10.1017/CBO9780511804090}}
*{{cite book|last1=Davey | first1=B.A.|last2=Priestley |first2= H.A. | title=Introduction to Lattices and Order |title-link= Introduction to Lattices and Order | publisher=Cambridge University Press | series=Cambridge Mathematical Textbooks | year=1990 }}
*{{cite book|last1=Davey | first1=B.A.|last2=Priestley |first2= H.A. | title=Introduction to Lattices and Order |title-link= Introduction to Lattices and Order | publisher=Cambridge University Press | series=Cambridge Mathematical Textbooks | year=1990 }}
*{{cite book | isbn=0-444-88074-7 | editor-first=Jan |editor-last= Van Leeuwen | editor-link=Jan van Leeuwen | title=Formal Models and Semantics | publisher=[[Elsevier]] | series=Handbook of Theoretical Computer Science | volume=B | year=1990 | first1=Nachum |last1=Dershowitz |author1-link=Nachum Dershowitz |first2= Jean-Pierre |last2=Jouannaud |author2-link= Jean-Pierre Jouannaud | contribution=Rewrite Systems | pages=243&ndash;320 }}
*{{cite book | isbn=0-444-88074-7 | editor-first=Jan |editor-last= Van Leeuwen | editor-link=Jan van Leeuwen | title=Formal Models and Semantics | publisher=[[Elsevier]] | series=Handbook of Theoretical Computer Science | volume=B | year=1990 | first1=Nachum |last1=Dershowitz |author1-link=Nachum Dershowitz |first2= Jean-Pierre |last2=Jouannaud |author2-link= Jean-Pierre Jouannaud | contribution=Rewrite Systems | pages=243&ndash;320 }}

Latest revision as of 15:10, 23 October 2025

Template:Short description In boolean logic, a disjunctive normal form (DNF) is a 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 Template:Mdash in philosophical logic Template:Mdash a cluster concept.Template:Sfn The disjunctive normal form and its counterpart, the conjunctive normal form, are the most common standardized ways of representing boolean expressions. They are widely used in various applications such as circuit design or automated theorem proving.

Definition

A logical formula is considered to be in DNF if it is a disjunction of one or more conjunctions of one or more literals.Template:SfnTemplate:SfnTemplate:Sfn A DNF formula is in full disjunctive normal form if each of its variables appears exactly once in every conjunction and each conjunction appears at most once (up to the order of variables). As in conjunctive normal form (CNF), the only propositional operators in DNF are and (), 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.

The following is a context-free grammar for DNF:

DNF (Disjunct) (Disjunct) DNF
Disjunct Literal Literal Disjunct
Literal Variable ¬ Variable

Where Variable is any variable.

For example, all of the following formulas are in DNF:

  • (A¬B¬C)(¬DEFDF)
  • (AB)(C)
  • (AB)
  • (A)

The formula AB is in DNF, but not in full DNF; an equivalent full-DNF version is (AB)(A¬B)(¬AB).

The following formulas are not in DNF:

  • ¬(AB), since an OR is nested within a NOT
  • ¬(AB)C, since an AND is nested within a NOT
  • A(B(CD)), since an OR is nested within an AND[1]

Conversion to DNF

In classical logic each propositional formula can be converted to DNFTemplate:Sfn ...

File:Karnaugh map KV 4mal4 18.svg
Karnaugh map of the disjunctive normal form <templatestyles src="Template:Color/styles.css" />A∧¬B∧¬D) ∨ <templatestyles src="Template:Color/styles.css" />ABC) ∨ <templatestyles src="Template:Color/styles.css" />(ABD) ∨ <templatestyles src="Template:Color/styles.css" />(A∧¬B∧¬C)
File:Karnaugh map KV 4mal4 19.svg
Karnaugh map of the disjunctive normal form <templatestyles src="Template:Color/styles.css" />AC∧¬D) ∨ <templatestyles src="Template:Color/styles.css" />(BCD) ∨ <templatestyles src="Template:Color/styles.css" />(A∧¬CD) ∨ <templatestyles src="Template:Color/styles.css" />B∧¬C∧¬D). Despite the different grouping, the same fields contain a "1" as in the previous map.

... by syntactic means

The conversion involves using logical equivalences, such as double negation elimination, De Morgan's laws, and the distributive law. Formulas built from the primitive connectives {,,¬}[2] can be converted to DNF by the following canonical term rewriting system:Template:Sfn

(¬¬x)x(¬(xy))((¬x)(¬y))(¬(xy))((¬x)(¬y))(x(yz))((xy)(xz))((xy)z)((xz)(yz))

... by semantic means

The full DNF of a formula can be read off its truth table.[3]Template:Sfn For example, consider the formula

ϕ=((¬(pq))(¬r(pq))).[4]

The corresponding truth table is

p q r ( ¬ (pq) ) ( ¬r (pq) )
T T T F T F F T F
T T F F T F T T F
T F T T F T F T T
T F F T F F T F T
F T T T F T F T T
F T F T F F T F T
F F T T F T F T F
F F F T F T T T F
  • The full DNF equivalent of ϕ is
(p¬qr)(¬pqr)(¬p¬qr)(¬p¬q¬r)
  • The full DNF equivalent of ¬ϕ is
(pqr)(pq¬r)(p¬q¬r)(¬pq¬r)

Remark

A propositional formula can be represented by one and only one full DNF.Template:Refn In contrast, several plain DNFs may be possible. For example, by applying the rule ((ab)(¬ab))b three times, the full DNF of the above ϕ can be simplified to (¬p¬q)(¬pr)(¬qr). However, there are also equivalent DNF formulas that cannot be transformed one into another by this rule, see the pictures for an example.

Disjunctive Normal Form Theorem

It is a theorem that all consistent formulas in propositional logic can be converted to disjunctive normal form.[5][6][7][8] This is called the Disjunctive Normal Form Theorem.[5][6][7][8] The formal statement is as follows:

Disjunctive Normal Form Theorem: Suppose

X

is a sentence in a propositional language

with

n

sentence letters, which we shall denote by

A1,...,An

. If

X

is not a contradiction, then it is truth-functionally equivalent to a disjunction of conjunctions of the form

±A1...±An

, where

+Ai=Ai

, and

Ai=¬Ai

.[6]

The proof follows from the procedure given above for generating DNFs from truth tables. Formally, the proof is as follows:

Suppose

X

is a sentence in a propositional language whose sentence letters are

A,B,C,

. For each row of

X

's truth table, write out a corresponding conjunction

±A±B±C

, where

±A

is defined to be

A

if

A

takes the value

T

at that row, and is

¬A

if

A

takes the value

F

at that row; similarly for

±B

,

±C

, etc. (the alphabetical ordering of

A,B,C,

in the conjunctions is quite arbitrary; any other could be chosen instead). Now form the disjunction of all these conjunctions which correspond to

T

rows of

X

's truth table. This disjunction is a sentence in

[A,B,C,;,,¬]

,[9] which by the reasoning above is truth-functionally equivalent to

X

. This construction obviously presupposes that

X

takes the value

T

on at least one row of its truth table; if

X

doesn’t, i.e., if

X

is a contradiction, then

X

is equivalent to

A¬A

, which is, of course, also a sentence in

[A,B,C,;,,¬]

.[6]

This theorem is a convenient way to derive many useful metalogical results in propositional logic, such as, trivially, the result that the set of connectives

{,,¬}

is functionally complete.[6]

Maximum number of conjunctions

Any propositional formula is built from n variables, where n1.

There are 2n possible literals: L={p1,¬p1,p2,¬p2,,pn,¬pn}.

L has (22n1) non-empty subsets.[10]

This is the maximum number of conjunctions a DNF can have.[11]

A full DNF can have up to 2n conjunctions, one for each row of the truth table.

Example 1

Consider a formula with two variables p and q.

The longest possible DNF has 2(2×2)1=15 conjunctions:[11]

(¬p)(p)(¬q)(q)(¬pp)(¬p¬q)_(¬pq)_(p¬q)_(pq)_(¬qq)(¬pp¬q)(¬ppq)(¬p¬qq)(p¬qq)(¬pp¬qq)

The longest possible full DNF has 4 conjunctions: they are underlined.

This formula is a tautology. It can be simplified to (¬pp) or to (¬qq), which are also tautologies, as well as valid DNFs.

Example 2

Each DNF of the e.g. formula (X1Y1)(X2Y2)(XnYn) has 2n conjunctions.

Computational complexity

The Boolean satisfiability problem on conjunctive normal form formulas is NP-complete. By the duality principle, so is the falsifiability problem on DNF formulas. Therefore, it is co-NP-hard to decide if a DNF formula is a tautology.

Conversely, a DNF formula is satisfiable if, and only if, one of its conjunctions is satisfiable. This can be decided in polynomial time simply by checking that at least one conjunction does not contain conflicting literals.

Variants

An important variation used in the study of computational complexity is k-DNF. A formula is in k-DNF if it is in DNF and each conjunction contains at most k literals.Template:Sfn

See also

Notes

<templatestyles src="Reflist/styles.css" />

  1. However, this one is in negation normal form.
  2. Formulas with other connectives can be brought into negation normal form first.
  3. Script error: No such module "Footnotes".: "Make a truth-table for the formula. Each line of the table which comes out "T" will yield one of the basic conjunctions of the disjunctive normal form."
  4. ϕ = ((NOT (p AND q)) IFF ((NOT r) NAND (p XOR q)))
  5. a b Script error: No such module "citation/CS1".
  6. a b c d e Script error: No such module "citation/CS1".
  7. a b Script error: No such module "citation/CS1".
  8. a b Script error: No such module "citation/CS1".
  9. That is, the language with the propositional variables A,B,C, and the connectives {,,¬}.
  10. |𝒫(L)|=22n
  11. a b Cite error: Script error: No such module "Namespace detect".Script error: No such module "Namespace detect".

Script error: No such module "Check for unknown parameters".

References

Template:Sfn whitelist

  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "Citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "Template wrapper".
  • Script error: No such module "citation/CS1".

Template:Normal forms in logic