Truth Table Generator
Enter any propositional logic expression and get the complete truth table instantly. Supports AND, OR, NOT, implication, biconditional, and XOR with up to 5 variables. Detects tautologies and contradictions. No signup, runs entirely in your browser.
⏱ 7 min read · Complete guide below
| p | q | p AND q |
|---|---|---|
| F | F | F |
| F | T | F |
| T | F | F |
| T | T | T |
How to Use the Truth Table Generator
- 1Type a logic expression using symbols (∧, ∨, ¬, →, ↔) or words (AND, OR, NOT, IMPLIES, IFF, XOR).
- 2Use up to 5 variables (p, q, r, s, t) and parentheses to group sub-expressions.
- 3Read the complete truth table — every combination of inputs and the resulting value.
- 4Check the verdict: an all-true column is a tautology, an all-false column a contradiction.
Worked Example: Proving De Morgan's Law
Enter NOT (p AND q). With two variables the table has 2² = 4 rows. The expression is false only in the single row where both p and q are true; in the other three rows it is true. Now enter (NOT p) OR (NOT q) in a fresh table and compare: the two output columns are identical, row for row. That equivalence is De Morgan's first law — negating an AND turns it into an OR of the negations.
Truth tables turn “is this always true?” into something you can just look at. Try (p IMPLIES q) IFF (NOT p OR q): every row comes out true, so the generator flags it as a tautology — a formal proof that “if p then q” is the same as “not-p or q”, which is exactly the rewrite compilers and circuit designers use to simplify conditionals. Because the table exhausts every input combination, a matching pair of columns is a complete proof, not just evidence.
What a Truth Table Actually Shows
A truth table is an exhaustive list of every possible combination of true/false values for the variables in a logical expression, together with the result the expression produces for each. Because it covers allpossibilities, it is a complete description of what a formula does — nothing is left to argument. With nvariables there are 2ⁿ rows: two variables give four rows, three give eight, and five give thirty-two, which is why the tool caps at five. Reading a truth table is simply a matter of scanning down the final column: it tells you exactly when the whole expression is true and when it is false, turning an abstract logical statement into something concrete you can inspect at a glance.
The Logical Operators, Briefly
Each connective has a precise definition that the table makes visible. AND (∧) is true only when both operands are true; OR (∨), the inclusive or, is true when at least one is true; NOT (¬) simply flips a value. XOR (exclusive or) is the one that trips people up — it is true only when the operands differ, false when they are the same, which is the crucial contrast with inclusive OR. Implication (→) is subtler still: “p implies q” is false in exactly one case, when p is true but q is false, and true everywhere else — including, perhaps surprisingly, whenever p is false. The biconditional (↔) is true when both sides share the same value. Building tables for small expressions is the fastest way to make these definitions second nature.
Tautologies, Contradictions, and Proving Equivalence
Truth tables shine at answering “is this always true?” A tautology is a formula whose final column is true in every row (like p OR NOT p), while a contradiction is false in every row (like p AND NOT p); the generator flags both automatically. The most powerful use, though, is proving logical equivalence: two expressions are equivalent precisely when their output columns match row for row. Because the table exhausts every input, a matching pair of columns is a complete proof, not mere evidence. This is exactly how De Morgan's laws and the rewrite of “if p then q” into “not-p or q” are established — results that compilers and digital-circuit designers rely on to simplify logic.
Logic Tips
Verify De Morgan's laws
Enter NOT (p AND q) and compare it with (NOT p) OR (NOT q). Both should produce identical truth tables — that is De Morgan's first law. Try NOT (p OR q) vs (NOT p) AND (NOT q) for the second law.
Prove logical equivalence
Two expressions are logically equivalent if their truth tables are identical. Use the generator to verify that p → q is equivalent to NOT p OR q — a key simplification in circuit design.
Check tautologies
Tautologies are logically always-true statements. Enter (p → q) IFF (NOT p OR q) to verify this is a tautology. The generator will confirm it is true for all rows.
Operator precedence
The precedence order (highest to lowest) is: NOT, AND, OR, XOR, → (implies), ↔ (iff). Use parentheses to override precedence. (p AND q) OR r is different from p AND (q OR r).
Frequently Asked Questions
What operators are supported?
AND, OR, NOT, → (implies), ↔ or IFF (biconditional), and XOR. You can use symbols (∧, ∨, ¬, →, ↔) or words (AND, OR, NOT, IMPLIES, IFF, XOR). Parentheses are supported for grouping.
How many variables can I use?
Up to 5 variables (p, q, r, s, t). With 5 variables, the truth table has 32 rows (2⁵). More than 5 variables would produce tables too large to display usefully.
What is a tautology?
A tautology is a formula that is true for every possible combination of variable values. Example: p OR NOT p is always true. A contradiction is always false — p AND NOT p is never true.
How does implication (→) work?
p → q (p implies q) is false only when p is true and q is false. In all other cases it is true. This matches the logical definition of "if p then q" — the statement is only violated when the premise is true but the conclusion is false.
What is the difference between XOR and OR?
OR (inclusive or) is true when at least one operand is true, including when both are true. XOR (exclusive or) is true only when exactly one operand is true. XOR is false when both operands have the same value.
Is my data stored?
No. The parser and evaluator run entirely in your browser. No expressions or results are sent to any server.
How many rows will my truth table have?
A truth table has 2 raised to the power of the number of variables. So one variable gives 2 rows, two variables give 4, three give 8, four give 16, and five give 32. Each row represents one unique combination of true/false values for the variables, and together they cover every possibility. This exponential growth is why the tool limits expressions to five variables — beyond that the table becomes too large to read usefully.
How do I prove two logical expressions are equivalent?
Generate a truth table for each expression and compare their final output columns. If the two columns are identical for every single row, the expressions are logically equivalent — they always produce the same result no matter the inputs. Because the table checks every possible combination, matching columns constitute a complete proof, not just supporting evidence. This is the standard way to verify identities like De Morgan's laws.
Why is "p implies q" true when p is false?
Implication (p → q) is defined to be false only in the single case where the premise p is true but the conclusion q is false; in every other case it is true. When p is false, the statement "if p then q" makes no claim that can be violated, so by convention it is treated as true (this is sometimes called being "vacuously true"). It can feel counterintuitive at first, but building the truth table makes the pattern clear and consistent.
What is the difference between XOR and OR?
OR is the inclusive or: it is true when at least one operand is true, including when both are true. XOR is the exclusive or: it is true only when exactly one operand is true, and false when both operands are the same (both true or both false). In short, "A or B or both" is OR, while "A or B but not both" is XOR. The truth tables differ only in the row where both inputs are true.
What order do the logical operators evaluate in?
The standard precedence, from highest to lowest, is NOT, then AND, then OR, then XOR, then implication (→), then the biconditional (↔). Higher-precedence operators bind more tightly, so NOT p AND q means (NOT p) AND q rather than NOT (p AND q). When in doubt, add parentheses to make the grouping explicit — (p AND q) OR r evaluates differently from p AND (q OR r), and being explicit avoids mistakes.