Truth Table
generator.
Type a logic statement to see every row of its truth table and test if two agree.
- Variables
- 3
- Rows
- 8
- False rows
- 5
A ∧ (B ∨ ¬C) is true on 3 of the 8 rows, so it is a contingency: its value depends on the inputs.
Truth table, 8 rows (up to 8 variables)
| Row | A B C | ¬C | B ∨ ¬C | A ∧ (B ∨ ¬C) |
|---|---|---|---|---|
| 0 | 0 0 0 | 1 | 1 | 0¬C: 1B ∨ ¬C: 1 |
| 1 | 0 0 1 | 0 | 0 | 0¬C: 0B ∨ ¬C: 0 |
| 2 | 0 1 0 | 1 | 1 | 0¬C: 1B ∨ ¬C: 1 |
| 3 | 0 1 1 | 0 | 1 | 0¬C: 0B ∨ ¬C: 1 |
| 4 | 1 0 0 | 1 | 1 | 1¬C: 1B ∨ ¬C: 1 |
| 5 | 1 0 1 | 0 | 0 | 0¬C: 0B ∨ ¬C: 0 |
| 6 | 1 1 0 | 1 | 1 | 1¬C: 1B ∨ ¬C: 1 |
| 7 | 1 1 1 | 0 | 1 | 1¬C: 0B ∨ ¬C: 1 |
Karnaugh map
Karnaugh map of A ∧ (B ∨ ¬C), rows and columns in Gray-code order. 3 of 8 are true: rows 4, 6, 7.
Canonical forms
Start from the true rows
(¬A ∧ B ∧ C) ∨ (A ∧ ¬B ∧ C) ∨ (A ∧ B ∧ ¬C) ∨ (A ∧ B ∧ C)
Check several at once
Each expression
| Expression | Result | True rows |
|---|---|---|
| P ∨ ¬P | Tautology | 2 of 2 |
| P ∧ ¬P | Contradiction | 0 of 2 |
| P → Q | Contingency | 3 of 4 |
| P ∧ (P → Q) → Q | Tautology | 4 of 4 |
Working
- 1Each variable is true or false, so the rows double with each one3 variables (A, B, C): 2³ = 8 rows
- 2Work the inner parts first, then the whole¬C, then B ∨ ¬C, then A ∧ (B ∨ ¬C)
- 3Read off the true rows (minterms)Σm(4, 6, 7)
- 4True on 3 of 8 rowsA ∧ (B ∨ ¬C): contingency
- 5Check: put row 4 back into the expressionA = 1, B = 0, C = 0 gives ¬C = 1, B ∨ ¬C = 1, A ∧ (B ∨ ¬C) = 1The canonical DNF has the same true rows
How it's worked out
A truth table lists every way to set the variables to true or false, then works out the statement on each row. Each variable has two possible values, so each new one doubles the rows. Two variables give 4 rows, three give 8, and the 8 variables this tool takes give 256.
Rows are numbered from 0 by reading the inputs as a binary number, with the first variable in alphabetical order as the leading digit. So for A, B and C, row 6 is A = 1, B = 1, C = 0. The tool works the inner parts of the statement first, the way a textbook table adds a column for each piece, and shows those columns too.
Each connective has a fixed rule. AND is true only when both parts are; OR is false only when both are. The conditional P → Q is false only when P is true and Q is false, and the biconditional is true when the two sides match. The table gives each output for the rows P, Q = 00, 01, 10, 11, worked out by the same parser the tool uses.
| Operator | Type it as | Rows 0 to 3 |
|---|---|---|
| NOT | NOT, !, ~, ¬, or a trailing ' | 1 0 |
| AND | AND, &, &&, *, ∧, or two letters side by side | 0 0 0 1 |
| OR | OR, |, ||, +, ∨ | 0 1 1 1 |
| XOR | XOR, ^, ⊕ | 0 1 1 0 |
| NAND | NAND, ↑ | 1 1 1 0 |
| NOR | NOR, ↓ | 1 0 0 0 |
| Implies | IMPLIES, ->, =>, → | 1 1 0 1 |
| If and only if | IFF, <->, <=>, ==, XNOR | 1 0 0 1 |
Without brackets, NOT binds tightest, then AND and NAND, then XOR, then OR and NOR, then implies, then if and only if. So A OR B AND C is read as and is true on rows 3, 4, 5, 6 and 7. Implies groups to the right, so P → Q → R means P → (Q → R). Books do not all agree on where XOR sits, so add brackets when in doubt.
Results. A statement true on every row is a tautology, one false on every row is a contradiction, and anything in between is a contingency. Two statements are logically equivalent when they agree on every row. A minterm is an AND of every variable that is true on one row only. The canonical DNF joins the minterms of the true rows with OR, and the canonical CNF joins the maxterms of the false rows with AND.
Worked examples
Nora checks the rule for a door alarm
The alarm should sound when the system is armed (A) and either a door opens (B) or the code has not been entered (C is false). Nora types A AND (B OR NOT C).
The tool builds the columns ¬C, B ∨ ¬C and A ∧ (B ∨ ¬C). The alarm sounds on rows 4, 6 and 7, 3 of 8, so the rule is a contingency. Row 5 is the one to look at: armed, no door open and the code entered, so it stays quiet, as it should.
For a circuit, the canonical DNF is (A ∧ ¬B ∧ ¬C) ∨ (A ∧ B ∧ ¬C) ∨ (A ∧ B ∧ C). The Karnaugh map puts rows 6 and 7 side by side, which is the A AND B part of the rule.
Omar tests a step in a proof
Omar has shown "if P then Q" and wants to use "if Q then P". He compares P → Q with its converse Q → P, and the tool says they are not equivalent: they differ on rows 1 and 2. Proving a statement does not prove its converse.
Two rewrites do hold. P → Q against ¬P ∨ Q is equivalent on every row, and so is the contrapositive ¬Q → ¬P, which is equivalent as well. Swap the boxes to try each one.
Kim designs a light for three judges
A light should come on when at least two of three judges press yes. With judges A, B and C, those are the rows with two or more 1s: rows 3, 5, 6 and 7. Kim enters them as true rows, and the tool writes one AND-term per row, then joins the four terms with OR.
She then compares it with the shorter AB + BC + AC, and the tool reports them as equivalent. That shorter form is the majority function, the same as the carry output of a full adder.
Reading your result
Read the comparison row by row. "Not equivalent" names the rows where the two outputs differ. The common De Morgan slip, ¬(A ∧ B) written as ¬A ∧ ¬B, differs on rows 1 and 2, where A and B have different values. The correct law turns AND into OR, and the tool reports it as equivalent.
A tautology tells you an argument form is valid. Modus ponens, written as one statement, is (P ∧ (P → Q)) → Q, and it is a tautology. Affirming the consequent, (Q ∧ (P → Q)) → P, is a contingency, so that argument can fail.
Canonical forms are correct but not short. The DNF has one term for every true row, so it grows with the table. To find a shorter form, group the 1s on the Karnaugh map in blocks of 1, 2, 4 or 8, including blocks that wrap around the edges, or use the Boolean algebra calculator.
Check how your input was read. The label above the answer shows the statement as the parser understood it, with the usual symbols. If a bracket is missing, that is where it shows.
Common mistakes
- Typing a word as a variable. Letters next to each other are ANDed, so CAT is C ∧ A ∧ T. Use single letters such as P and Q, or a letter with a number such as X1.
- Treating OR as "one or the other but not both". OR is true when both parts are true. The exclusive version is XOR, which is false on that row.
- Expecting P → Q to need a link between P and Q. The conditional only fails when P is true and Q is false. "If 2 is odd, then the Moon is cheese" is true, because its first part is false.
- Comparing statements with different variables. The tool builds one table over every variable in either box. A statement that does not use a variable simply ignores it, so the rows still line up.
Questions people ask
Sources
- OpenStax, Contemporary Mathematics, section 2.3, Constructing Truth Tables
- OpenStax, Contemporary Mathematics, section 2.4, Truth Tables for the Conditional and Biconditional
- OpenStax, Contemporary Mathematics, section 2.5, Equivalent Statements
- OpenStax, Contemporary Mathematics, section 2.6, De Morgan's Laws
- Levin, Discrete Mathematics: An Open Introduction, 3rd ed., section 3.1, Propositional Logic
- Kuphaldt, Lessons in Electric Circuits, volume IV, chapter 8, Karnaugh Mapping