Skip to main content

CNF/DNF Converter

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

Share this calculator

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.

Why is CNF important in computational logic and SAT solving?

CNF is the standard input format for SAT (Boolean Satisfiability) solvers, which determine whether a Boolean formula can be made true by some assignment of variables. Modern SAT solvers like MiniSat, CaDiCaL, and Kissat are among the most successful practical algorithms in computer science, solving problems with millions of variables and clauses. CNF is preferred because unit propagation (if a clause has only one unset literal, that literal must be true) and clause learning work naturally in CNF form. SAT solvers are used in hardware verification, software testing, AI planning, cryptanalysis, and combinatorial optimization. The Cook-Levin theorem proves that CNF-SAT is NP-complete, making it theoretically universal for NP problems.

What is the complement of a Boolean function in CNF/DNF?

The complement (negation) of a Boolean function swaps all 1-outputs with 0-outputs and vice versa. In terms of normal forms: the complement of F in DNF has its minterms become the maxterms of F (the original 0-rows become 1-rows). If F = Sum(1,3,5) for 3 variables, then F' = Sum(0,2,4,6,7). De Morgan laws provide the algebraic method: the complement of a DNF is obtained by replacing AND with OR, OR with AND, and complementing each literal. For example, (AB + CD)' = (A'+B')(C'+D'). Similarly, the complement of a CNF expression applies De Morgan laws to produce a DNF. This duality between CNF and DNF under complementation is a fundamental property of Boolean algebra.

References