CNF/DNF Converter
Our free logic & computer science calculator solves cnfdnfconverter problems. Get worked examples, visual aids, and downloadable results.
Reviewed for accuracy by Manoj Kumar, Mathematics Educator
CNF/DNF Converter
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser โ no data is sent to any server.
Formula: DNF = OR(minterms) | CNF = AND(maxterms)
Worked example โ DNF: A'B'C + A'BC + AB'C + ABC | CNF: (A+B+C)(A+B'+C)(A'+B+C)(A'+B'+C)
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 DNF: A'B'C + A'BC + AB'C + ABC Maxterms (0-rows): 0,2,4,6 (all have C=0) CNF: (A+B+C)(A+B'+C)(A'+B+C)(A'+B'+C) Note: 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) F DNF: A'B' + AB F maxterms: 1,2 F CNF: (A+B')(A'+B) F' minterms: 1(A'B), 2(AB') F' DNF: A'B + AB' F' CNF: (A+B)(A'+B') Note: 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.
What is the difference between canonical and minimized normal forms?
Canonical normal forms (canonical DNF/CNF) include every variable in every term, making them unique representations of a function but often verbose. Each minterm and maxterm contains exactly n literals for n variables. Minimized normal forms eliminate redundant variables and combine terms to produce the simplest equivalent expression. For example, the canonical DNF A'B + AB simplifies to the minimized form B (variable A is redundant). Canonical forms are useful for comparing functions (two functions are equal iff they have the same canonical form) and for automated processing. Minimized forms are preferred for circuit implementation because they use fewer gates and literals, reducing hardware cost and improving performance.
How do you determine if a Boolean function is a tautology or contradiction?
A tautology is a Boolean function that evaluates to 1 (true) for every possible input combination. In DNF form, a tautology has all possible minterms present. In CNF form, a tautology has no maxterms (an empty conjunction is trivially true). Checking if a DNF is a tautology is co-NP-complete in general. A contradiction evaluates to 0 for all inputs: the DNF has no minterms, and the CNF contains all maxterms. A contingency is neither a tautology nor a contradiction, meaning the function is true for some inputs and false for others. CNF/DNF Converter displays whether the entered function is a tautology, contradiction, or contingency, along with the percentage of satisfying assignments.
What is the significance of literal count in CNF and DNF?
The literal count measures the complexity of a Boolean expression and directly relates to circuit implementation cost. In canonical forms, the literal count equals the number of terms multiplied by the number of variables. For a function with 5 minterms over 4 variables, the canonical DNF has 20 literals. When deciding between CNF and DNF representation, choose the one with fewer terms (and thus fewer literals): if a function has 3 minterms and 5 maxterms, DNF is more compact. The literal count after minimization indicates how much simplification was achieved. In circuit design, each literal corresponds to a gate input, so fewer literals mean fewer connections, lower power consumption, and reduced propagation delay.
How are CNF and DNF used in database query optimization?
Database query optimizers use CNF and DNF concepts when processing WHERE clauses. A WHERE clause like (A=1 AND B=2) OR (C=3 AND D=4) is in DNF form. Converting to CNF can help identify common conditions across branches that can be evaluated first. Index selection benefits from analyzing which form allows more efficient access paths. SQL query planners often convert complex predicates to CNF because conjunctive conditions (AND) allow independent filtering on each clause, enabling the use of multiple indexes. Conversely, DNF is useful when evaluating OR conditions requires union of result sets. Understanding these normal forms helps database administrators write queries that align with the optimizer preferred evaluation strategy.
References
Reviewed for accuracy by Manoj Kumar, Mathematics Educator ยท Editorial policy
Related Calculators
๐งฎDegrees to Radians Converter
Calculate degrees to radians converter with inputs, formulas, and instant results.
๐งฎRadians to Degrees Converter
Calculate radians to degrees converter with inputs, formulas, and instant results.
๐งฎPolish Notation Converter (Prefix, Infix, Postfix)
Calculate polish notation converter with inputs, formulas, and instant results.
๐งฎBinary Fraction Converter
Calculate binary fraction converter with inputs, formulas, and instant results.
๐งฎGray Code Converter
Calculate gray code converter with inputs, formulas, and instant results.
๐งฎIEEE 754 Floating-Point Converter
Calculate ieee754floating point converter with inputs, formulas, and instant results.
๐งฎAngle Converter
Calculate angle converter with inputs, formulas, and instant results.
๐งฎData Storage Converter
Calculate data storage converter with inputs, formulas, and instant results.