Solver · Live
Truth table generator,
any boolean expression, instantly.
Type any boolean logic expression using AND, OR, NOT, XOR, NAND, NOR, implication (→), or biconditional (↔). The generator parses it, identifies your variables, and produces a complete truth table showing every T/F combination, with intermediate sub-expression columns for step-by-step clarity.
2 variables (A, B) · 4 rows · 22 combinations
Insert symbol
Examples
Classification
Contingent
Neither always true nor always false.
True rows
1 / 4
25% of all input combinations evaluate to TRUE.
Variables
A, B
2^2 = 4 distinct input rows.
Truth table(4 rows × 3 cols)
| A | B | A ∧ B | |
|---|---|---|---|
| F | F | F | |
| F | T | F | |
| T | F | F | |
| T | T | T |
Logic guide
Boolean algebra, logic gates, and truth tables: a complete guide.
A truth table is a mathematical table that lists all possible combinations of input values for a boolean expression and the corresponding output value for each combination. They are the fundamental tool for analyzing digital circuits, verifying logical arguments, and proving mathematical theorems.
Boolean algebra basics
Boolean algebra operates on values that are either TRUE (T, 1) or FALSE (F, 0). Every boolean expression is built from variables and the fundamental operations:
| Operation | Symbol(s) | Meaning | True when… |
|---|---|---|---|
| NOT (negation) | ¬A, !A, ~A | Inverts the value | A is FALSE |
| AND (conjunction) | A ∧ B, A && B | Both must be true | A and B are both TRUE |
| OR (disjunction) | A ∨ B, A || B | At least one must be true | A is TRUE or B is TRUE (or both) |
| XOR (exclusive OR) | A ⊕ B, A XOR B | Exactly one must be true | A and B have different values |
| NAND | A ↑ B, A NAND B | NOT (A AND B) | A and B are not both TRUE |
| NOR | A ↓ B, A NOR B | NOT (A OR B) | A and B are both FALSE |
| IMPLIES (→) | A → B, A -> B | If A then B | A is FALSE, or B is TRUE |
| IFF (↔) | A ↔ B, A IFF B | A if and only if B | A and B have the same value |
How to read a truth table
A truth table has one column per input variable (shown left of the dividing line) and one or more output columns. Each row represents one specific assignment of TRUE/FALSE to each variable. With n variables, there are exactly 2n rows: one for every possible combination. The variables are iterated in binary counting order: for two variables A, B, the rows are FF, FT, TF, TT.
Standard logic gate truth tables
NOT gate (inverter)
| A | ¬A |
|---|---|
| F | T |
| T | F |
AND gate
| A | B | A ∧ B |
|---|---|---|
| F | F | F |
| F | T | F |
| T | F | F |
| T | T | T |
OR gate
| A | B | A ∨ B |
|---|---|---|
| F | F | F |
| F | T | T |
| T | F | T |
| T | T | T |
XOR (exclusive-OR)
| A | B | A ⊕ B |
|---|---|---|
| F | F | F |
| F | T | T |
| T | F | T |
| T | T | F |
Tautologies, contradictions, and contingencies
Boolean expressions fall into three categories:
- Tautology: the expression is TRUE for every possible input combination. Example:
A ∨ ¬A(the Law of Excluded Middle: a variable is either true or its negation is true). Every column in the output is T. - Contradiction: the expression is FALSE for every possible input. Example:
A ∧ ¬A: a variable cannot be both true and false simultaneously. Every output column is F. - Contingent: the expression is true for some inputs and false for others, the most common case. The expression's truth value depends on the specific values of its variables.
De Morgan's Laws
One of the most important identities in boolean algebra, De Morgan's Laws relate AND and OR through negation:
- ¬(A ∧ B) ≡ (¬A) ∨ (¬B): "NOT (A AND B)" equals "(NOT A) OR (NOT B)"
- ¬(A ∨ B) ≡ (¬A) ∧ (¬B): "NOT (A OR B)" equals "(NOT A) AND (NOT B)"
You can verify these with the generator above: enter NOT (A AND B) IFF (NOT A OR NOT B); you'll get all T's in the output (a tautology), proving they're equivalent.
Logical implication (if…then)
The implication A → B (read "if A then B") is one of the trickiest connectives. It evaluates to FALSE only when A is TRUE and B is FALSE, because if the premise holds, the conclusion must hold. In all other cases it's TRUE:
- F → F = T: if the premise is false, the implication is vacuously true (a promise about a situation that never arises cannot be broken).
- F → T = T: vacuously true.
- T → F = F: the premise held but the conclusion failed: the implication is false.
- T → T = T: premise and conclusion both hold.
The biconditional A ↔ B (IFF, "if and only if") is TRUE when A and B have the same truth value, it is equivalent to (A → B) ∧ (B → A). Try verifying this: enter(p IFF q) IFF ((p -> q) AND (q -> p)).
Operator precedence
When parentheses are omitted, operators bind in this order (highest first, tightest binding):
- NOT (¬): prefix, unary
- AND (∧): binary
- XOR (⊕): binary
- OR (∨), NOR (↓): binary
- IMPLIES (→): binary, right-associative
- IFF (↔): binary, lowest precedence
So A ∧ B ∨ C parses as (A ∧ B) ∨ C (AND binds tighter than OR), and A → B → C parses as A → (B → C) (IMPLIES is right-associative). Always use parentheses when in doubt; the generator shows how it parsed your expression via the intermediate columns.
Applications of truth tables
- Digital circuit design: logic gates (AND, OR, NOT, NAND, NOR, XOR) are the building blocks of all digital hardware. Every CPU instruction, memory cell, and arithmetic operation ultimately reduces to combinations of these gates. Truth tables are used to verify gate designs before fabrication.
- Propositional logic / discrete math: truth tables are used to prove logical equivalences, check the validity of arguments, and simplify boolean expressions (Karnaugh maps, Boolean minimisation).
- Programming: conditional logic in any language is boolean algebra. Understanding truth tables helps write correct conditions, avoid off-by-one errors in compound conditions, and understand short-circuit evaluation (
&&,||). - Database queries: SQL WHERE clauses use boolean logic.
WHERE active = 1 AND (role = 'admin' OR role = 'mod')is a boolean expression over three predicates.
NAND and NOR: universal gates
NAND and NOR are called universal gates because any boolean function can be implemented using only NAND gates (or only NOR gates). This makes them valuable in chip manufacturing; a fab can produce just one gate type and build arbitrarily complex circuits:
- NOT A = A NAND A
- A AND B = (A NAND B) NAND (A NAND B)
- A OR B = (A NAND A) NAND (B NAND B)
Try these in the generator to verify; they should all produce tautologies when compared (using IFF) to their standard forms.