Truth Table Generator (Free Logic Calculator)

Fractions & numbersFreeNo sign-up

A truth table generator lists every combination of true (T) and false (F) values for the variables in a logical statement and works out the statement in each row. With n variables there are 2ⁿ rows. For example, (A ∧ B) ∨ ¬C has 3 variables, so 2³ = 8 rows, and it is true in 5 of them, which makes it a contingency.

Truth table generator
Try:
You can also type: NOT ~ ! · AND & && * · OR | || + · XOR ^ · IMPLIES -> => · IFF <-> <=> = · NAND · NOR. Variables are letters or words (p, q, A, rain); A′B or A B means A ∧ B; T and F (or 1 and 0) are the constants true and false. Up to 8 variables.
Truth table
Tautology4 of 4 rows true

((p → q) ∧ ¬q) → ¬p is a tautology: it is true in every row.

ClassificationTautology
True rows4 of 4
p q p → q ¬q (p → q) ∧ ¬q ¬p ((p → q) ∧ ¬q) → ¬p
T T T F F F T
T F F T F F T
F T T F F T T
F F T T T T T
Copy table as:

Normal forms

Simplified DNFT (always true)
Simplified CNFT (always true)
Sum of products1
Product of sums1
Minterms (true rows)Σm(0, 1, 2, 3)
Maxterms (false rows)none
Final column, top to bottomTTTT
Satisfiableyes
Show steps
  1. Read the expression with the usual precedence (¬ first, then ∧, ⊕, ∨, →, ↔; → groups from the right). With full parentheses it is (((p → q) ∧ ¬q) → ¬p).
  2. There are 2 variables (p, q), so the table has 2² = 4 rows. The first variable alternates slowest, starting with T; the last alternates every row.
  3. Work from the inside out, one column per sub-expression: p → q; then ¬q; then (p → q) ∧ ¬q; then ¬p; then ((p → q) ∧ ¬q) → ¬p.
  4. Rules for the operators used: p → q is F only when p is T and q is F; in every other row it is T. p ∧ q is T only when both parts are T. ¬p flips the value: T becomes F and F becomes T.
  5. The last column is the whole expression. It is T in 4 rows and F in 0, so it is a tautology.

Two expressions are logically equivalent when their final columns match in every row. Use the Equivalence tab to check.

Truth Table Generator (Free Logic Calculator)
Embed this calculator on your site

Free to use on class pages, blogs and course pages. Copy the code below and paste it into your page:

How to use the truth table generator

  1. Type a logical expression, such as (p → q) ∧ ¬q → ¬p. Use the symbol buttons or type words and keyboard symbols (AND, &, OR, |, NOT, ~, ->, <->).
  2. Read the table: one column per variable, one column per sub-expression, and the full expression in the green column on the right.
  3. See whether the statement is a tautology, a contradiction or a contingency, plus its simplified DNF and CNF, Boolean sum of products, minterms and maxterms.
  4. Switch to Equivalence to compare two expressions, or to Argument check to test whether premises lead to a conclusion.
  5. Change T/F to 1/0 or flip the row order to match your textbook, and copy the table as a spreadsheet, Markdown or LaTeX.

Logical operators you can use

Operator Symbol You can also type True when
NOT (negation) ¬p ~p, !p, NOT p, p′ p is false
AND (conjunction) p ∧ q &, &&, *, AND both are true
OR (disjunction) p ∨ q |, ||, +, OR at least one is true
XOR (exclusive or) p ⊕ q ^, XOR exactly one is true
IMPLIES (conditional) p → q ->, =>, IMPLIES p is false or q is true
IFF (biconditional) p ↔ q <->, <=>, =, IFF both have the same value
NAND p ↑ q NAND not both are true
NOR p ↓ q NOR both are false

Without parentheses, the generator follows the usual order: ¬ first, then ∧, ⊕, ∨, → and finally ↔. A chain of arrows groups from the right, so p → q → r means p → (q → r). When in doubt, add parentheses.

Truth tables of the basic connectives

p q ¬p p ∧ q p ∨ q p ⊕ q p → q p ↔ q
T T F T T F T T
T F F F T T F F
F T T F T T T F
F F T F F F T T

The row that surprises most students is p → q with p false: a conditional with a false “if” part counts as true. The only way to break “if p, then q” is p true and q false.

How to make a truth table by hand

  1. List the variables and count the rows: 2ⁿ for n variables (2 → 4 rows, 3 → 8, 4 → 16).
  2. Fill the first variable column with T for the top half and F for the bottom half. Halve the block size for each next column, so the last column alternates T, F, T, F.
  3. Add a column for each sub-expression, working from the inside of the parentheses outward.
  4. Finish with the full expression and read its column.

Worked examples

(A AND B) OR NOT C

There are 8 rows. A ∧ B is true only in the 2 rows where A and B are both true, and ¬C is true in the 4 rows where C is false. Their OR is true in 2 + 4 − 1 = 5 rows, because the row A = T, B = T, C = F is counted in both. So the expression is a contingency, true in 5 of 8 rows.

Modus ponens: ((p → q) ∧ p) → q

p → q and p are both true only in the row p = T, q = T, and there q is true. In every other row the “if” part is false, so the whole conditional is true. The expression is true in all 4 rows, so it is a tautology, which is why modus ponens is a valid rule of inference.

(A XOR B) AND C

The result is 1 only when C = 1 and exactly one of A and B is 1: the rows A = 1, B = 0, C = 1 and A = 0, B = 1, C = 1. That is 2 of 8 rows, minterms Σm(3, 5).

Tautology, contradiction or contingency

  • Tautology: true in every row, such as p ∨ ¬p.
  • Contradiction: false in every row, such as p ∧ ¬p.
  • Contingency: true in some rows and false in others, such as p ∧ q.

A statement is satisfiable when at least one row makes it true, so every tautology and every contingency is satisfiable.

Logical equivalence and common laws

Two statements are logically equivalent (≡) when their final columns agree in every row. These standard equivalences all check out in the Equivalence tab:

Law Equivalence
De Morgan ¬(p ∧ q) ≡ ¬p ∨ ¬q and ¬(p ∨ q) ≡ ¬p ∧ ¬q
Implication p → q ≡ ¬p ∨ q
Contrapositive p → q ≡ ¬q → ¬p
Biconditional p ↔ q ≡ (p → q) ∧ (q → p)
Distributive p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)
Exportation (p ∧ q) → r ≡ p → (q → r)

The converse q → p is not equivalent to p → q: they differ when p = T, q = F and when p = F, q = T.

DNF and CNF from a truth table

To get the disjunctive normal form (DNF), write one AND-term for each true row and join the terms with ∨. For the conjunctive normal form (CNF), write one OR-clause for each false row that is false exactly in that row, and join the clauses with ∧. The generator then combines terms that differ in a single variable (the Quine–McCluskey method) to give the shortest forms. For (A ∧ B) ∨ ¬C the simplified CNF is (A ∨ ¬C) ∧ (B ∨ ¬C); in Boolean algebra notation the expression is AB + C′.

Checking an argument with a truth table

An argument is valid when every row that makes all premises true also makes the conclusion true. A row with true premises and a false conclusion is a counterexample. For example, p → q, q, therefore p (affirming the consequent) is invalid: p = F, q = T makes both premises true and the conclusion false. Modus tollens, p → q, ¬q, therefore ¬p, is valid.

Common mistakes

  • Wrong number of rows. Three variables need 8 rows, not 6. Count 2ⁿ.
  • Treating p → q as false when p is false. It is true in that case.
  • Reading ∨ as “one or the other but not both”. That is XOR; ∨ is also true when both parts are true.
  • Missing parentheses. ¬p ∧ q is (¬p) ∧ q, not ¬(p ∧ q).
  • Confusing a statement with its converse. p → q and q → p have different columns.

Truth tables practice quiz: 10 questions

Test yourself with 10 multiple-choice questions. Choose an answer and press Submit to see if you are right and why. Your score appears at the end.

Question 1 of 10
1. How many rows does a truth table with 4 variables have?

Found a mistake? Let us know!

2. When is p → q false?

Found a mistake? Let us know!

3. In how many of its 4 rows is p ∨ q true?

Found a mistake? Let us know!

4. Which statement is a tautology?

Found a mistake? Let us know!

5. Which expression is equivalent to ¬(p ∧ q)?

Found a mistake? Let us know!

6. Which statement is equivalent to p → q?

Found a mistake? Let us know!

7. How many rows make (A ∧ B) ∨ C true?

Found a mistake? Let us know!

8. p ⊕ q (XOR) is true when …

Found a mistake? Let us know!

9. Is the argument p → q, q, therefore p valid?

Found a mistake? Let us know!

10. p ↔ q is true in which rows?

Found a mistake? Let us know!

Frequently asked questions

How do you use a truth table generator?

Type the statement with letters for the variables and symbols or words for the operators, for example (p -> q) & ~q. The generator builds every row, shows each sub-expression, and tells you whether the statement is a tautology, a contradiction or a contingency.

How do you learn truth tables?

Memorize the five basic tables above (¬, ∧, ∨, →, ↔), then practice building tables for two- and three-variable statements by hand. Check each one here, find the first column where your answer differs, and fix that rule. The practice quiz on this page is a good start.

How do you make a truth table from a Boolean expression?

Read AND as ∧ (or a product, AB), OR as ∨ (or a sum, A + B) and NOT as ¬ (or A′). List 2ⁿ rows of 0s and 1s, add a column for each part, and finish with the whole expression. In this generator you can type A′B + AB′ directly and choose 1/0 values.

How do you make a truth table for logic gates?

Write the circuit as an expression, one gate at a time: an AND gate feeding an OR gate with an inverted input C is (A AND B) OR NOT C. Each gate output becomes a sub-expression column, and the final column is the circuit output. NAND and NOR gates are available as operators.

How do you make truth tables in Excel?

Copy the table here with the Spreadsheet (TSV) button and paste it into Excel or Google Sheets. To build one with formulas instead, put TRUE/FALSE in the variable columns and use AND(), OR(), NOT() and XOR(). Excel has no IMPLIES function, so write p → q as =OR(NOT(A2),B2), which is false only when p is true and q is false.

How do you use a truth table to check an argument's conclusion?

Make a column for each premise and one for the conclusion. Look only at the rows where every premise is true. If the conclusion is true in all of them, the argument is valid; if any of those rows has a false conclusion, that row is a counterexample. The Argument check tab does this for you.

Related calculators

More fractions & numbers calculators

Browse all 541 calculators

Related to This Article

What people say about "Truth Table Generator: Steps, DNF/CNF & Equivalence"?

No one replied yet.

Leave a Reply