Math
Truth Table Generator
Build a truth table for any boolean expression with up to 6 variables. Supports AND, OR, NOT, XOR, IMPLIES, IFF in word, ASCII, and unicode forms. Flags tautologies, contradictions, and contingencies.
Truth Table Generator
Use AND, OR, NOT, XOR, IMPLIES, IFF (or the symbols ∧ ∨ ¬ ⊕ → ↔, or ASCII forms &&, ||, !, ^, ->, <->). Up to 6 variables.
Examples
Result
Contingency (sometimes true, sometimes false)
5 of 8 rows are true.
Variables
3
Rows (2^n)
8
True rows
5
Complexity
simple
| p | q | r | Result |
|---|---|---|---|
| T | T | T | T |
| T | T | F | T |
| T | F | T | F |
| T | F | F | T |
| F | T | T | F |
| F | T | F | T |
| F | F | T | F |
| F | F | F | T |
Frequently Asked Questions about the Truth Table Generator
Which logical operators does this calculator support?
All six standard propositional connectives, in three notations each so you can paste an expression from a textbook, a programming language, or a math paper without rewriting it. AND can be written AND, &&, *, or the unicode symbol for conjunction. OR can be written OR, ||, +, or the unicode symbol for disjunction. NOT can be written NOT, !, ~, or the unicode negation symbol. XOR (exclusive or) can be written XOR, ^, or the unicode XOR symbol. IMPLIES (material conditional) can be written IMPLIES, -> (ASCII arrow), or the unicode rightwards arrow. IFF (biconditional, if and only if) can be written IFF, <-> (ASCII double arrow), or the unicode left-right arrow. Parentheses ( ) group sub-expressions. Variable names are any letter sequence (case sensitive) that is not a reserved keyword, and the constants TRUE and FALSE are accepted too. Precedence follows the textbook convention: NOT binds tightest, then AND, then XOR, then OR, then IMPLIES, then IFF (loosest).
Why does a truth table always have 2^n rows?
Because each variable in a boolean expression has exactly two possible values, true or false, and the rows enumerate every combination. With one variable you have 2 rows (true, false). Adding a second variable doubles the count to 4, since each existing row now branches into two (the new variable is either true or false). A third variable doubles it again to 8, a fourth to 16, and so on. In general, n independent variables produce 2 to the power of n combinations, which is why this calculator caps the input at 6 variables (64 rows). At 6 variables a truth table is already at the edge of what is comfortable to read on screen; at 10 variables you would have 1024 rows, and at 20 over a million. For expressions that big you want a SAT solver or a model checker instead of a truth table.
What is the difference between a tautology, a contradiction, and a contingency?
A tautology is an expression that is true on every row of its truth table, no matter what values the variables take. The classic example is p OR NOT p, which is always true (either p is true, or its negation is). A contradiction is the opposite: false on every row regardless of the variables. p AND NOT p is the textbook example. A contingency is anything in between, an expression that is true on some rows and false on others. Most useful boolean expressions are contingencies; tautologies show up when you are proving a logical law (like De Morgan's), and contradictions show up when you are checking whether two conditions can both hold at once. This calculator labels the verdict at the top of the result panel, alongside how many of the 2^n rows came out true.
How do I check De Morgan's laws with this tool?
De Morgan's first law says NOT (p AND q) is logically equivalent to (NOT p) OR (NOT q); the second says NOT (p OR q) is equivalent to (NOT p) AND (NOT q). To verify either one, generate the truth table for both sides separately and compare them row by row. They should produce the same result column. For the first law, NOT (p AND q) is true on three out of four rows (every row except p = true, q = true), and (NOT p) OR (NOT q) gives exactly the same pattern. You can also check the equivalence in one shot by building the IFF of the two sides, like NOT (p AND q) IFF (NOT p) OR (NOT q). That whole expression is a tautology if the two sides are equivalent, so a green tautology verdict at the top of the result means the law holds for those variables.
How do I verify two expressions are logically equivalent?
Two boolean expressions are logically equivalent when they produce the same result on every row of the truth table over the union of their variables. The fastest way to check that here is to combine them into a single biconditional and look at the verdict. Build the expression LEFT IFF RIGHT and run it through the generator. If the verdict is Tautology (all rows true), the two expressions agree on every assignment, so they are logically equivalent. If the verdict is Contingency, they disagree on at least one row, and the rows where the Result column is false are exactly the assignments that prove they are not equivalent. This trick is how you can verify any logical law in a few seconds: implication elimination (p -> q IFF NOT p OR q), absorption (p AND (p OR q) IFF p), distributivity, double negation, and so on.