Digital Logic Toolkit — Truth table generator
Truth Table Generator
Turn an expression into a full truth table, with a column for every sub-expression.
Accepts + · ' ¬ ∧ ∨ ⊕ ~ ! & | and the words AND, OR, NOT, XOR.
Check how this was read
- Read "AB" as A · B — 2 variables ANDed together. Declare "AB" as a variable name if you meant one variable.
read as ((A · B) + (¬A · C))
Notation ▾
+ is OR, juxtaposition is AND, a trailing ' is NOT, -> is implication and <-> is the biconditional. The fully parenthesised reading is always echoed back. The full notation and precedence table is below.
Start from a worked example
Contingent — true in 4 of 8 rows
| # | A | B | C | A′ | A · B | A′ · C | F |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 1 |
| 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 |
| 3 | 0 | 1 | 1 | 1 | 0 | 1 | 1 |
| 4 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| 5 | 1 | 0 | 1 | 0 | 0 | 0 | 0 |
| 6 | 1 | 1 | 0 | 0 | 1 | 0 | 1 |
| 7 | 1 | 1 | 1 | 0 | 1 | 0 | 1 |
Minterms and maxterms
- Σm(1, 3, 6, 7)
- ΠM(0, 2, 4, 5)
The maxterm indices are exactly the indices the minterm list does not contain. Both lists, written out term by term.
The expression back out
Canonical SOP — one product term per 1-row
A′ · B′ · C + A′ · B · C + A · B · C′ + A · B · C
Minimal SOP — the cheapest cover of the same rows, computed by Quine–McCluskey
Minimal forms
Minimal SOP
A′ · C + A · B
Minimal POS
(A + C) · (A′ + B)
They cost the same here — 2 terms · 4 literals as a sum of products, 2 terms · 4 literals as a product of sums.
Why you can trust the count
Two pipelines run over the same prime-implicant chart. The walkthrough uses essential primes, then minterm (“row”) dominance, then implicant (“column”) dominance, then Petrick’s method — the sequence a textbook shows, which reaches one correct answer.
The list of every minimum cover is produced by a second pipeline that uses essentials and minterm dominance only. Essential-prime extraction is safe for enumeration and minterm dominance is safe; implicant dominance is not — striking out a dominated prime discards every cover that used it, and some of those cost exactly the minimum.
So the walkthrough answers “what is an optimum?” and the list answers “what are all the optima?”. Both are shown because the textbook shows the first and the truth is the second.
Notation and operator precedence used here
Engineers write A · B + A′ · C; logicians write (p ∧ q) ∨ (¬p ∧ r). This page accepts both and renders whichever you typed. Every spelling below is equivalent, and input is NFKC-normalised before parsing.
| Operation | Accepted input | Rendered as |
|---|---|---|
| NOT | A', !A, ~A, ¬A, NOT A | A′ |
| AND | A·B, A*B, A&B, A∧B, A AND B, AB | A · B |
| OR | A+B, A|B, A∨B, A OR B | A + B |
| XOR | A^B, A⊕B, A XOR B | A ⊕ B |
| XNOR | A@B, A⊙B, A XNOR B | A ⊙ B |
| NAND | A↑B, A NAND B | A ↑ B |
| NOR | A↓B, A NOR B | A ↓ B |
| IMPLIES | A->B, A=>B, A→B | A → B |
| IFF | A<->B, A<=>B, A↔B, A≡B | A ↔ B |
| Constants | 0, 1, F, T, FALSE, TRUE | 0, 1 |
Precedence, highest to lowest. ( ) → postfix ′ and prefix NOT → AND (including juxtaposition) → XOR / XNOR → NAND / NOR → OR → IMPLIES (right-associative) → IFF. Textbooks genuinely disagree about where XOR sits and VHDL refuses to guess at all, so the fully parenthesised reading of whatever you type is echoed under the field, and an unbracketed mix of XOR, XNOR, NAND or NOR with AND or OR raises a non-blocking warning.
Row order.Rows count 000 → 111 with the first variable as the most significant bit, and the index in the first column is the minterm number. A textbook that counts the other way produces the same function with the indices reversed, which is a real source of lost marks — so the convention is printed in the table's caption rather than assumed.
How to read this table
One row per input combination, counted 000 → 111 with the first variable as the most significant bit. The number in the first column is that row's minterm index, which is what connects this table to the Karnaugh map, to the Σm list and to the Quine–McCluskey tabulation.
The columns in the middle are the point. A column for every sub-expression is the column a marker wants, because it shows where an answer went wrong rather than only that it did. Complements of single variables are hoisted to the front, in variable order, because those are the columns you fill in first.
Tautology, contradiction, contingency
A tautology is true in every row; a contradiction is false in every row; anything else is contingent. Equivalently: a tautology is a function whose ΠM list is empty and a contradiction is one whose Σm list is empty, which is exactly how this page decides it — by comparing the truth mask against the full mask, not by reading the rows back.
The page opens on AB + A'C: Contingent — true in 4 of 8 rows, Σm(1, 3, 6, 7) · ΠM(0, 2, 4, 5), minimal SOP A′ · C + A · B. Every one of those numbers is computed at build time by the same engine the browser runs.
Implication and the biconditional
The two rows students refuse to believe: 0 → 0 = 1 and 0 → 1 = 1. A conditional only claims something when its antecedent holds, so a false antecedent makes the whole statement vacuously true.
A → B is A′ + B, which is why its single false row is the one where both A′ and B are 0. A ↔ B is (A → B)·(B → A), true on Σm(0, 3) — the same function hardware calls XNOR and a comparator calls match. The XNOR gate page draws it.
Checking two statements for equivalence
Compare two builds s₁ ↔ s₂ and asks whether it is a tautology. That is why the useful output is not a bare yes or no but the first disagreeing row: it is the counter-example you write down. The canonical example is the contrapositive — A → B against B′ → A′, which agree in all four rows.
Testing an argument
An argument is valid when no row makes every premise true and the conclusion false. That single sentence is the whole method, and this page implements it exactly: it builds (P₁ · P₂ · …) → C and checks whether that is a tautology. When it is not, the row where it is 0 is the counter-model, and that row is the answer.
Modus ponens — premises A → B and A, conclusion B — is valid. Affirming the consequent — premises A → B and B, conclusion A — is not, and its counter-model is A = 0, B = 1. The two arguments differ by one letter and one of them is a fallacy.
Getting an expression back out of a table
Canonical SOP is one product term per 1-row; canonical POS is one sum term per 0-row; the minimal form is neither, and is computed by Quine–McCluskey exactly as on the Quine–McCluskey page. Both are shown above, labelled, one under the other, so the difference between canonical and minimal is visible rather than asserted. The output column is editable, so a table you were given is also an input.
Limits, stated plainly
Full tables to ten variables in the page and six in the initial HTML; from seven to ten variables the first 64 rows ship and the rest expand on request, with the complete Σm and ΠM lists either way. At eleven variables and above the row table is replaced by a notice giving the row count, and the minterm list and minimal form stand in for it — the table is never truncated without saying so, and the tool never stops working. No sequential logic.
Worked examples
Worked examples
- A·B + Cintro8 rows over A, B, C
- A → Bintroonly row A=1, B=0 is false
- A ↔ Bcoretrue on the two agreeing rows
- (A + B) → Ccore8 rows, 5 true
- A ⊕ B ⊕ Ccoretrue on the 4 odd-parity rows
- (A·B)′ + Ccore8 rows, 7 true
- ((A → B)·(B → C)) → (A → C)coretautology: all 8 rows true
- P·P̄examcontradiction: 0 on every row
- A·B + C·Dexam16 rows, 7 true
- A ↑ Bedge casefalse only when both inputs are 1
Related
- Boolean algebra simplifier — simplify the expression this table describes
- Karnaugh map solver — the same rows, arranged so adjacent ones touch
- SOP and POS canonical forms — canonical forms and the minterm/maxterm lists
- Quine–McCluskey solver — minimise past the row count a table can show
- Logic gate diagram builder — draw the circuit this table specifies
- Logic gate symbols — the truth table of every gate on one chart
- XNOR gate — the biconditional, as hardware calls it
- De Morgan's laws — check a De Morgan rewrite row by row
Sources
- Boole, George. An Investigation of the Laws of Thought, on Which are Founded the Mathematical Theories of Logic and Probabilities. London: Walton and Maberly, 1854.
- Shannon, Claude E. “A Symbolic Analysis of Relay and Switching Circuits.” Transactions of the American Institute of Electrical Engineers 57, no. 12 (December 1938): 713–723. doi:10.1109/T-AIEE.1938.5057767.
- Post, Emil L. “Introduction to a General Theory of Elementary Propositions.” American Journal of Mathematics 43, no. 3 (July 1921): 163–185. doi:10.2307/2370324 — the truth-table method as a decision procedure.
- Wittgenstein, Ludwig. Tractatus Logico-Philosophicus. London: Kegan Paul, 1922, §§4.31, 4.442 — the truth-table schema in the form still taught.
- Huntington, Edward V. “Sets of Independent Postulates for the Algebra of Logic.” Transactions of the American Mathematical Society 5, no. 3 (1904): 288–309. doi:10.2307/1986459.