Skip to content

Truth Table Generator

Type a formula with ¬, ∧, ∨, →, ↔ or ⊕ — or words, ASCII, or Boolean algebra such as AB + A′C — and get its full truth table with a column for each sub-formula, in the order the operators are applied. The tool says whether the formula is a tautology, a contradiction or contingent, lists the minterms and maxterms, writes the canonical DNF and CNF, and can test whether two formulas are equivalent. Free, no sign-up.

Use ¬ ∧ ∨ → ↔ ⊕, or words (not, and, or, xor, nand, nor, implies, iff), or & | ! -> <->, or Boolean algebra (AB + A′C). Brackets are always allowed.

Try an example

A second formula: the tool says whether the two are logically equivalent.

Values shown as
Row order
Notation in headings
Operators and precedence
LevelOperationWritten as
1NOT¬ ~ ! not or a trailing ′
2AND, NAND∧ & · * and nand ↑ (or two operands side by side)
3XOR⊕ xor
4OR, NOR∨ | + or nor ↓
5Implication→ -> => implies
6Biconditional↔ <-> <=> iff ≡

Tightest first. Same-level operators are read left to right, except → which is read right to left: p → q → r means p → (q → r). NAND and NOR cannot be chained without brackets.

Truth table

Tautology

Verdict

4 of 4

True rows

p, q

Variables

True in every row: the formula is always true, whatever the variables are.

Read as: (p → q) ↔ (¬q → ¬p)

Truth table for (p → q) ↔ (¬q → ¬p)
pqp → q¬q¬p¬q → ¬p(p → q) ↔ (¬q → ¬p)
TTTFFTT
TFFTFFT
FTTFTTT
FFTTTTT

Normal forms

True rows (minterms), Σm

0, 1, 2, 3

False rows (maxterms), ΠM

none

Row numbers count the variables as a binary number, with the first variable as the leading digit and true as 1.

Canonical disjunctive normal form (sum of minterms)

(¬p ∧ ¬q) ∨ (¬p ∧ q) ∨ (p ∧ ¬q) ∨ (p ∧ q)

Canonical conjunctive normal form (product of maxterms)

1

How to Use the Truth Table Generator

  1. 1. Type the formula. Each variable is one letter, optionally followed by digits (p, q, x1). Connect them with ¬ ∧ ∨ → ↔ ⊕, or with words (not, and, or, implies, iff, xor), or with & | ! -> <->. Two letters side by side mean AND, as in Boolean algebra.
  2. 2. Read the table. The input columns come first, then one column for every sub-formula, and the final column — the whole formula — is highlighted. Rows start with all variables true, or all false if you choose.
  3. 3. Check the verdict. The formula is a tautology if every row is true, a contradiction if every row is false, and contingent otherwise.
  4. 4. Use the normal forms. The true rows give the canonical DNF, the false rows the canonical CNF. Add a second formula to test whether the two are equivalent.

Operator Precedence

Without brackets, the operators bind in a fixed order. The usual order in logic texts is ¬ first, then ∧, then ∨, then →, then ↔. This calculator follows it, and places exclusive-or between ∧ and ∨, the way programming languages order &, ^ and |. NAND (↑) binds like AND and NOR (↓) like OR.

Tightest firstOperationReads as
1¬pNegation applies to the nearest operand: ¬p ∧ q is (¬p) ∧ q
2p ∧ qp ∧ q ∨ r is (p ∧ q) ∨ r
3p ⊕ qp ∨ q ⊕ r is p ∨ (q ⊕ r)
4p ∨ qp ∨ q → r is (p ∨ q) → r
5p → qRight to left: p → q → r is p → (q → r)
6p ↔ qp → q ↔ r is (p → q) ↔ r

When in doubt, bracket

Books differ on chains of implications — most read p → q → r as p → (q → r), but some read it the other way. The tool shows exactly how it read your formula, with every bracket, above the table. Adding your own brackets removes any doubt.

Worked Example: p → q

pqp → q
TTT
TFF
FTT
FFT

An implication is false in exactly one case: the premise is true and the conclusion is false. The true rows are numbered 0, 1 and 3, so the canonical DNF is (¬p ∧ ¬q) ∨ (¬p ∧ q) ∨ (p ∧ q). The false row is number 2, so the canonical CNF is ¬p ∨ q — which is why p → q is equivalent to ¬p ∨ q.

Tautology, Contradiction or Contingent

KindFinal columnExample
TautologyTrue in every row(p → q) ↔ (¬q → ¬p), the contrapositive law
ContradictionFalse in every rowp ∧ ¬p
ContingentBoth true and false rowsp → q

Two formulas are logically equivalent when they have the same final column. De Morgan's law is the classic case: ¬(p ∧ q) and ¬p ∨ ¬q agree in all four rows. Put one formula in the main field and the other in “Compare with”, and the tool reports the first row where they differ, if there is one.

Minterms, Maxterms and Normal Forms

Number the rows by reading the variables as a binary number, with the first variable as the leading digit and true as 1. A minterm is a true row, and the canonical DNF (disjunctive normal form) is an OR of one full AND-term per true row. A maxterm is a false row, and the canonical CNF (conjunctive normal form) is an AND of one full OR-clause per false row, with each variable negated if it was true in that row. These forms are complete but rarely the shortest. To reduce them, a Karnaugh map or the Quine–McCluskey method finds a minimal sum of products.

Common Mistakes

  • Reading → as if it were symmetric. p → q and q → p are different formulas; the first row where they differ is p false, q true.
  • Treating a false premise as a false implication. If p is false, p → q is true whatever q is.
  • Dropping brackets around a negation. ¬(p ∧ q) is not ¬p ∧ ¬q; De Morgan turns the AND into an OR.
  • Leaving out a row. n variables need 2ⁿ rows; the generator produces them all, up to 8 variables (256 rows).
  • Mixing up CNF and DNF. DNF is an OR of ANDs and comes from the true rows; CNF is an AND of ORs and comes from the false rows.

Frequently Asked Questions

How do you make a truth table?
List every combination of true and false for the variables — 2ⁿ rows for n variables — then add a column for each sub-formula, working from the innermost operators outward, and finish with the whole formula. This generator does all of that and highlights the final column.
What is a tautology?
A formula that is true under every assignment of its variables, so its final column is all true. Examples are p ∨ ¬p and (p → q) ↔ (¬q → ¬p). The opposite is a contradiction, which is false in every row.
What is the order of precedence for logical operators?
The usual order is ¬, then ∧, then ∨, then →, then ↔. Exclusive-or is placed between ∧ and ∨ here, as in most programming languages. Same-level operators are read left to right, except that → is read right to left. Add brackets whenever the grouping matters.
How do I check whether two statements are logically equivalent?
Build the truth table for both over the same variables and compare the final columns. If they match in every row, they are equivalent. Enter one formula in the main field and the other in “Compare with” to do this automatically.
What are CNF and DNF?
DNF, disjunctive normal form, is an OR of AND-terms; CNF, conjunctive normal form, is an AND of OR-clauses. The canonical forms are read straight off the truth table: DNF from the true rows and CNF from the false rows.
Why is a false premise enough to make an implication true?
The statement p → q only makes a promise when p is true; if p is false, nothing has been broken, so the implication counts as true. It is false only when p is true and q is false, and this is why p → q is equivalent to ¬p ∨ q.
How many variables can the generator handle?
Up to eight, which gives 256 rows. Beyond that the table is too long to read, so the tool asks you to reduce the number of variables.

Related Tools

More in Math Calculators

See all Math Calculators