Skip to main content

CNF/DNF Converter

Our free logic & computer science calculator solves cnfdnfconverter problems. Get worked examples, visual aids, and downloadable results.

Reviewed by Manoj Kumar, Mathematics Educator

Reviewed by Manoj Kumar, Mathematics Educator

Formula

DNF = OR(minterms) | CNF = AND(maxterms)

DNF (Disjunctive Normal Form) represents a function as an OR of AND terms (minterms), each corresponding to a truth table row with output 1. CNF (Conjunctive Normal Form) represents a function as an AND of OR terms (maxterms), each corresponding to a row with output 0. Together they are dual canonical representations.

Worked Examples

Example 1: CNF/DNF for F(A,B,C) = Sum(1,3,5,7)

Problem:Express the function with minterms 1,3,5,7 in both CNF and DNF form.

Solution:All minterms have C=1: m1=001, m3=011, m5=101, m7=111\nDNF: A'B'C + A'BC + AB'C + ABC\nMaxterms (0-rows): 0,2,4,6 (all have C=0)\nCNF: (A+B+C)(A+B'+C)(A'+B+C)(A'+B'+C)\nNote: Both forms simplify to F = C

Result:DNF: A'B'C + A'BC + AB'C + ABC | CNF: (A+B+C)(A+B'+C)(A'+B+C)(A'+B'+C)

Example 2: Complement Function

Problem:Find F and F' for F(A,B) = Sum(0,3).

Solution:F minterms: 0(A'B'), 3(AB)\nF DNF: A'B' + AB\nF maxterms: 1,2\nF CNF: (A+B')(A'+B)\n\nF' minterms: 1(A'B), 2(AB')\nF' DNF: A'B + AB'\nF' CNF: (A+B)(A'+B')\nNote: F = XNOR, F' = XOR

Result:F = A'B' + AB (XNOR) | F' = A'B + AB' (XOR)

Frequently Asked Questions

What is CNF (Conjunctive Normal Form)?

CNF (Conjunctive Normal Form) is a standardized way to write a Boolean expression as an AND (conjunction) of OR (disjunction) clauses. Each clause contains one or more literals (variables or their negations) connected by OR. For example, (A OR B) AND (A' OR C) AND (B OR C') is in CNF. In the context of truth tables, CNF is equivalent to the Product of Sums (POS) canonical form, where each clause (maxterm) corresponds to a truth table row with output 0. CNF is the standard form used in SAT solvers, automated theorem provers, and formal verification tools because many efficient algorithms are specifically designed to operate on CNF formulas.

What is DNF (Disjunctive Normal Form)?

DNF (Disjunctive Normal Form) is a standardized way to write a Boolean expression as an OR (disjunction) of AND (conjunction) terms. Each term contains one or more literals connected by AND. For example, (A AND B) OR (A' AND C) OR (B AND C') is in DNF. In truth table terms, DNF is equivalent to the Sum of Products (SOP) canonical form, where each product term (minterm) corresponds to a row with output 1. DNF is particularly useful for understanding when a function evaluates to true: the function is true whenever any single term is satisfied. While DNF is natural for human understanding, many computational problems are harder in DNF than CNF form.

How do you convert between CNF and DNF?

Converting between CNF and DNF requires expanding one form into the other using the distributive law. To convert CNF to DNF, distribute AND over OR by multiplying out all the clauses. For example, (A+B)(C+D) becomes AC + AD + BC + BD. This expansion can cause an exponential blowup: a CNF with k clauses of m literals each can produce up to m^k terms in DNF. The reverse direction (DNF to CNF) also uses distribution but distributes OR over AND. Because direct conversion can be exponential, the practical approach is often to go through the truth table: enumerate all rows, identify minterms for DNF and maxterms for CNF, and then apply minimization algorithms.

What is the relationship between CNF/DNF and minterms/maxterms?

DNF and CNF are directly related to minterms and maxterms respectively. A canonical DNF lists all minterms (product terms where the function equals 1), connected by OR. Each minterm includes every variable exactly once, either normal or complemented. A canonical CNF lists all maxterms (sum terms where the function equals 0), connected by AND. Each maxterm includes every variable once, but with opposite complementation compared to the minterm of the same index. Minterm m_i and maxterm M_i are complements: m_i corresponds to the binary encoding of i with 1 meaning normal and 0 meaning complemented, while M_i uses the opposite convention. Together they completely describe a Boolean function.

References

Reviewed by Manoj Kumar, Mathematics Educator ยท Editorial policy