A truth table calculator lists the value of a logic expression for every combination of its variables. Type an expression such as (A AND B) -> C, and it builds the full table with T and F, counts the rows and tells you whether the expression is a tautology, a contradiction or neither.
How to use the truth table calculator
- Type the expression.
- Use AND, OR, NOT, XOR, NAND, NOR, -> and iff, or the symbols.
- Press Make the table.
What a truth table shows
A truth table shows the value of an expression for each way of assigning true or false to its variables. The page notes that with n variables there are 2ⁿ possible combinations of truth values [1], so a table with three variables has 8 rows. For two variables there are 16 possible truth functions, which is 2 to the power 2 to the power 2 [1]. The calculator writes one row for each combination, starting with all variables true.
The connectives
The page gives the tables for the binary connectives. With p and q both true, AND is true and OR is true. With p true and q false, AND is false and OR is true. Exclusive or, XOR, is true when exactly one is true. NAND is the negation of AND, and NOR the negation of OR [1]. Implication, p → q, is false only when p is true and q is false, and the biconditional, p ↔ q, is true when both have the same value [1]. The calculator implements these as the page tabulates them.
Reading the table
Each row of the output lists the values of the variables in alphabetical order, then a bar, then the value of the expression. For A AND B the rows are T T | T, T F | F, F T | F and F F | F. For A → B they are T T | T, T F | F, F T | T and F F | T. The first line names the variables. The summary line gives the number of rows, 2 to the power of the number of variables, and how many are true.
Tautology, contradiction, contingency
The pages that we read do not define these words, so we give the usual meanings as our own. An expression is a tautology if it is true in every row, a contradiction if it is false in every row, and a contingency if it is true in some and false in others. A OR NOT A is a tautology, and A AND NOT A is a contradiction. The calculator names the kind in the summary line.
Order of the operators
To avoid doubt, use brackets. Without them, the calculator applies NOT first, then AND and NAND, then XOR, then OR and NOR, then implication, which groups to the right, and last the biconditional. So A OR B AND C means A OR (B AND C), as in ordinary arithmetic, where multiplication comes before addition. Use brackets for clarity whenever you can, since conventions differ between books.
Ways to write the operators
You can write words in any case: and, or, not, xor, nand, nor, implies, iff. You can also use symbols: & or ∧ for AND, | or ∨ or + for OR, ! or ~ or ¬ for NOT, ^ or ⊕ for XOR, arrow or → for implication and a two-way arrow or ↔ for the biconditional. Variables are single letters, which the calculator turns into capitals. Spaces are ignored.
Worked examples
The expression (p → q) AND (q → r) → (p → r), the chain of implications, is a tautology with 8 rows, all true. The expression A + B * C, which means A OR (B AND C), has 5 true rows out of 8. The expression A XOR B is the same as NOT (A ↔ B). You can test the equivalence of two expressions by making each table and comparing them, or by joining them with the biconditional and seeing whether the result is a tautology.
Using the calculator
Use it to check a logic homework answer, to design a simple circuit with gates or to test a condition in a program. A table with up to six variables has 64 rows, which is the limit of the calculator. If your expression has more variables, break it into parts. Copy the table with the copy button, and paste it into your notes.
Logic gates
The connectives correspond to the gates of digital circuits. AND, OR, NOT, XOR, NAND and NOR gates have exactly the truth tables of the same names. NAND and NOR are special because either one can build all of the others. A truth table is therefore the standard way to describe what a gate or a small circuit does, and the calculator can check a design before you build it.
Common mistakes
- Forgetting the brackets. They make the order clear.
- Using multi-letter variable names. Use single letters.
- Confusing XOR with OR. XOR is false when both are true.
- Reading implication as causation. It is false only when p is true and q is false.
What next
Use this often? Add Truth Table to your Home screen.
Frequently asked questions
What is a truth table calculator?
A tool that lists the value of a logic expression for every combination of its variables.
How many rows does a truth table have?
2ⁿ for n variables. Three variables give 8 rows.
What is a tautology?
An expression that is true in every row of its truth table.
When is an implication false?
Only when the first part is true and the second part is false.
What is XOR?
Exclusive or: true when exactly one of the two inputs is true.
Sources
Was this tool helpful?
What went wrong?
We only receive the reason you pick, never what you typed into the tool.
Thanks for your feedback.