Truth Table Generator
Type an expression and every row appears: (p OR q) AND NOT r gives three variables, eight rows and three of them true, with satisfiability and tautology named under the table. The reading the parser used is printed in full brackets before the first row, because precedence is where these tools quietly disagree: p OR q AND NOT r is a different question, it reads as (p OR (q AND (NOT r))) and five of its eight rows are true. Implication is the operator most often argued about, and here p -> q is false only when p is true and q is false, while a chain such as p -> q -> r groups to the right. Switch Columns to Every step and each sub-expression gets a column of its own, so p OR q and NOT r are worked out before they meet. Up to twelve variables, which is 4,096 rows: the panel draws the first 256 and scrolls, and Copy and the CSV carry all of them.
reads as ((p OR q) AND (NOT r))
-> is false only when the left side is true and the right side is false. NOT binds tightest, then AND and NAND, then XOR and XNOR, then OR and NOR, then ->, then <->. A chain of -> groups to the right, every other chain groups to the left.
| p | q | r | (p OR q) AND NOT r |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 1 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 0 | 1 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 0 |
satisfiableyes, 3 of 8 rowstautologyno
- Variables
- 3
- Rows
- 8
- True rows
- 3
- Tautology
- No
(p OR q) AND NOT r: 3 variables, 8 rows, 3 true. Satisfiable on 3 of 8 rows, and not a tautology.
Your expression
How the table reads
- Values
- First row
- Columns
Type the expression and the table follows. AND, OR, NOT, XOR, NAND, NOR, -> for implies and <-> for if and only if all read the way the table further down lists them, so &&, |, ~, ^, => and <=> arrive at the same place. NOT binds tightest, then AND, then XOR, then OR, then ->, then <->, and the line above the table prints the reading in full brackets so you can see exactly how your expression grouped. Up to twelve variables, which is 4,096 rows: the panel draws the first 256 rows and scrolls, while Copy and the CSV carry every one of them. Variable names are case sensitive, so P and p are two columns, and T and F are ordinary variables: write 1, 0, true or false when you mean a constant. Your expression is kept in this browser so the page opens where you left it, and the Start over button at the top of the page forgets it.
What you can type
| Operator | Binds | Also written | True when |
|---|---|---|---|
| NOT | 1 | NOT ! ~ ¬ p' | true when the one side is false |
| AND | 2 | AND && & ∧ * . · | true only when both sides are true |
| NAND | 2 | NAND ↑ | false only when both sides are true |
| XOR | 3 | XOR ^ ⊕ != ≠ | true when the two sides differ |
| XNOR | 3 | XNOR | true when the two sides match |
| OR | 4 | OR || | ∨ + | true when either side is true, or both |
| NOR | 4 | NOR ↓ | true only when both sides are false |
| -> | 5 | -> => → ⇒ ⊃ > IMPLIES | false only when the left side is true and the right side is false |
| <-> | 6 | <-> <=> ↔ ⇔ ≡ = == IFF EQUIV | true when the two sides match |
Common questions
- When is p implies q false?
- Only when p is true and q is false. Every other row is true, including the two where p is false, which is the part that feels wrong the first time: a conditional with a false left side makes no claim, so it is counted true. That is the material conditional every logic course uses, and the table on this page follows it: p -> q has four rows and three of them are true. A chain groups to the right, so p -> q -> r reads as p -> (q -> r) and seven of its eight rows are true, while (p -> q) -> r has five. The page prints which of the two it used in brackets above the table, so you never have to guess.
- Which operator binds tightest?
- NOT binds tightest, then AND and NAND, then XOR and XNOR, then OR and NOR, then implies, and the biconditional is loosest. A chain of implications groups to the right; every other chain groups to the left. It matters: (p OR q) AND NOT r is true on three of its eight rows, while the same characters without the brackets, p OR q AND NOT r, read as (p OR (q AND (NOT r))) and come out true on five. Rather than ask you to trust the convention, the page prints the fully bracketed reading above the table, so you can see exactly how your expression was grouped and add brackets if that is not what you meant.
- Which symbols can it read?
- The words AND, OR, NOT, XOR, NAND, NOR, XNOR, IMPLIES and IFF in any case, and the symbols beside them in the table under the tool: &&, &, *, . for AND, ||, |, + for OR, !, ~ for NOT, ^ and != for XOR, ->, =>, > for implies, and <->, <=>, ==, = for if and only if. The logic symbols are read too, and a prime after a variable negates it the way a Karnaugh map writes it, so p' is NOT p. Operator words ignore case, but variable names do not: P and p are two different columns. T and F are ordinary variables, so write 1, 0, true or false when you mean a constant.
- How many variables can it handle?
- Twelve, which is 4,096 rows. A thirteenth would be 8,192 rows and is refused with that number in the message rather than left to lock up the page, and nothing is quietly cut short instead. The panel draws the first 256 rows, which is every row up to eight variables, and scrolls; Copy puts the whole table on the clipboard and the CSV file carries all 4,096 rows, with one column per variable and one for the result, and a column for each sub-expression in between when Columns is set to Every step.
- How do I tell a tautology from a contradiction?
- The four figures under the panel answer it directly: Rows, True rows and Tautology, with the satisfiable line inside the panel. A tautology is true on every row, so p OR NOT p reads tautology yes. A contradiction is true on none, so p AND NOT p has two rows, no true row at all, and the page says it is a contradiction and not satisfiable. Anything in between is satisfiable but not a tautology, and the line names how many rows make it true.
- Can I check whether two expressions are equivalent?
- Yes, by joining them with <-> and looking at the Tautology figure. Two expressions are equivalent exactly when their biconditional is true on every row. NOT (p AND q) <-> (NOT p OR NOT q) is true on all four of its rows, which is De Morgan's law; (p -> q) <-> (NOT q -> NOT p) is true on all four as well, which is contraposition. If the answer comes back as anything short of a tautology, the rows that are false are the cases where the two expressions part company.
- Can I see the working rather than just the answer?
- Set Columns to Every step. Each sub-expression then gets a column of its own, children before parents, so (p OR q) AND NOT r is drawn as p OR q, then NOT r, then the whole thing, and a sub-expression that appears twice gets one column rather than two. The CSV keeps those columns too. An expression with more working columns than the panel draws is shown with the result column alone and a line that says how many steps it had, rather than a table cut off without saying so.
- Is my expression sent anywhere?
- No. The parsing and the evaluation happen in your browser, there is no account and nothing is uploaded, and the CSV file is built in the page rather than fetched from a server. Your expression and your display settings are kept in this browser's own storage so the page opens where you left it, and the Start over button at the top of the page forgets them. If your browser blocks storage the tool still works: it opens on the example every time.
The expression is parsed into a tree and every row is evaluated from that tree, so nothing you type is ever run as code. Up to twelve variables, which is 4,096 rows; past that it refuses rather than freezing the page. Implication is false only when the left side is true and the right side is false, and that convention is printed above the table.