DNF and CNF: build a rule from rows
A table records when the result is 1 or 0. Turn these cases into a formula, then turn the formula into a circuit.
Prerequisite: formulas and assignmentsTheory
Literal → part → full form
A literal is a variable such as A or its negation ¬A. DNF joins literals with AND and joins those terms with OR. CNF does the reverse: OR inside each clause, AND between clauses.
Choose a table row. DNF uses rows with 1: a zero for A becomes ¬A. CNF uses rows with 0 and reverses the signs so that the clause is false on exactly that row.
| A | B | F | Row |
|---|---|---|---|
| 0 | 0 | 0 | |
| 0 | 1 | 1 | |
| 1 | 0 | 1 | |
| 1 | 1 | 0 |
Selected row · F = 1
AND joins the literals: this term is 1 only on the selected row.
This row contributes to the full form below.
(¬A ∧ B) ∨ (A ∧ ¬B)
The whole formula as a circuit. Toggle inputs: its output matches F in the table.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | B | F |
|---|---|---|---|
| 0 | 0 | 0 | |
| 0 | 1 | 1 | |
| 1 | 0 | 1 | |
| 1 | 1 | 0 |
Ordinary and canonical forms
A alone is already both DNF and CNF. For variables A and B, canonical DNF records every relevant assignment in full: (A ∧ ¬B) ∨ (A ∧ B). B disappears only after simplification.
In canonical form, every part contains each selected variable exactly once. Part order does not matter. We allow 0 and 1 as compact constant forms: empty OR gives 0 and empty AND gives 1. All 0 and All 1 show both extreme cases.
If the full canonical formula exceeds the bounded circuit editor, the diagram shows the selected row’s part only. Its caption says so; the full formula and table remain available.
Practice
Build your own truth table
Click F to change 0 and 1. Compare DNF and CNF for the same function, try 2–4 variables and trace a row into the circuit.
| A | B | F | Row |
|---|---|---|---|
| 0 | 0 | ||
| 0 | 1 | ||
| 1 | 0 | ||
| 1 | 1 |
Selected row · F = 1
AND joins the literals: this term is 1 only on the selected row.
This row contributes to the full form below.
(¬A ∧ B) ∨ (A ∧ ¬B)
The whole formula as a circuit. Toggle inputs: its output matches F in the table.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | B | F |
|---|---|---|---|
| 0 | 0 | 0 | |
| 0 | 1 | 1 | |
| 1 | 0 | 1 | |
| 1 | 1 | 0 |
Games
Table → formula
Write DNF for the given table. Literal and term order may differ.
AND: & or ∧ · OR: | or ∨ · NOT: ! or ¬. Parentheses set the order.
Tap a component to add it, or drag it onto the board. Connect a right-hand dot to another component’s left-hand dot: drag a wire or tap both dots in turn. Tap an input to toggle 0/1.
Truth table
↗ “Show case” sets this row’s inputs on the circuit. The highlighted row matches the current inputs. This explores a case; it does not submit an answer. ? means an unknown signal.
| Show case | A | B | F |
|---|---|---|---|
| 0 | 0 | ? | |
| 0 | 1 | ? | |
| 1 | 0 | ? | |
| 1 | 1 | ? |