Math calculator

Truth Table Generator

A column per sub-expression, so the table shows the working — not only the answer.

Build a truth table

One column per sub-expression, in the order they are evaluated.

AND OR NOT XOR IMPLIES IFF all work, as do & | ~ ^ → ↔ and their ASCII forms. Up to six variables.

p ∧ (q ∨ ¬r)

contingency

True in some rows and false in others — a contingency. Its truth depends on the variables, which is the ordinary case.

Variables

p, q, r

8 rows — 2^3

True in

3 of 8

38% of assignments

Columns

3

one per distinct sub-expression

The table

Truth table with a column for every sub-expression
pqr¬rq ∨ ¬rp ∧ (q ∨ ¬r)
TTTFTT
TTFTTT
TFTFFF
TFFTTT
FTTFTF
FTFTTF
FFTFFF
FFFTTF

Rows run TRUE first, which is the convention in logic textbooks. Electronics tables usually count up from all-false, so a table copied from a datasheet will have its rows in the opposite order — the content is identical either way.

Normal forms, read off the table

DNF (one conjunction per true row): (p ∧ q ∧ r) ∨ (p ∧ q ∧ ¬r) ∨ (p ∧ ¬q ∧ ¬r)

CNF (one disjunction per false row): (¬p ∨ q ∨ ¬r) ∧ (p ∨ ¬q ∨ ¬r) ∧ (p ∨ ¬q ∨ r) ∧ (p ∨ q ∨ ¬r) ∧ (p ∨ q ∨ r)

Each of the 3 true rows gives one conjunction that is true on exactly that row and nowhere else; ORing them together reproduces the column. That construction works for any column of Ts and Fs at all, which is why every truth function has a formula.

T and F are read as VARIABLES here, not as constants — they are two of the commonest variable letters in logic exercises. Write TRUE, FALSE, 1 or 0 for the constants.

Both normal forms reproduce the main column exactly — which is a constructive proof that every truth function has a formula.

What this tool shows

One column per sub-expression, so the table reads as the working — plus classification, equivalence with a counterexample, and both normal forms.

  • A column for every distinct sub-expression, in evaluation order
  • Tautology, contradiction or contingency, classified
  • Two expressions compared row by row, with the first disagreement named
  • Disjunctive and conjunctive normal forms read off the table itself
A column per sub-expression Equivalence with a counterexample DNF and CNF from the table Free, no signup

Free, no signup — normal forms verified against the table.

Updated 6 September 2026 · Works in any browser, no installation

A truth table is a proof by exhaustion — every assignment tried, none skipped. p ∧ (q ∨ ¬r) takes 8 rows for its 3 variables, is true in 3 of them, and is therefore a contingency.

At a glance

Formula shown
n variables give 2\u207f rows. The expression is a tautology if every row is true, a contradiction if none is, and a contingency otherwise.
Scenario support
Propositional expressions in up to six variables.
Educational estimate
Planning support from the values you enter — not professional advice.

The intermediate columns are the working

A table with only the final column tells you the answer and hides how it was reached. This one builds a column for every distinct sub-expression, innermost first, so the table reads left to right as the evaluation actually happens.

p ∧ (q ∨ ¬r) produces the columns ¬r, q ∨ ¬r, p ∧ (q ∨ ¬r)3 of them, ending at the whole expression. Each depends only on columns to its left, which is what makes the ordering meaningful rather than arbitrary.

This matters when a table disagrees with your hand working: the first column where they differ localises the mistake. A single-column table can only tell you that something went wrong somewhere.

Three classifications, and the one that is usually the question

Every propositional expression falls into exactly one of three categories:

  • Tautology — true on every row. p ∨ ¬p is one: True in every row — a tautology. The expression is true no matter what the variables are, so it carries no information about them.
  • Contradiction — false on every row. p ∧ ¬p is one.
  • Contingency — true on some rows and false on others, which is what most expressions are. p ∧ (q ∨ ¬r) is true on 3 of 8.

“Is this a tautology” is the question most exercises are really asking, because a tautology is a statement that holds regardless of the facts — which is what a logical law is. Every valid rule of inference is one.

Equivalence needs a counterexample, not a verdict

Two expressions are logically equivalent when their columns match on every row. When they do not, one row is enough to prove it — and that row is the useful output.

They disagree when p = T, q = F: the first is false and the second is true. One row is enough to settle it — equivalence has to hold everywhere.

That is the difference between “p → q and q → p are not equivalent” and something you can actually check by hand. The first is a claim; the second is a specific assignment you can substitute into both and see them differ.

¬(A ∧ B) and ¬A ∨ ¬B go the other way: they agree on every row, so De Morgan holds — verified here rather than quoted.

Implication is the one that looks wrong

p → q is FALSE only when p is true and q is false. In particular it is TRUE whenever p is false, whatever q does — which strikes almost everyone as wrong the first time.

The reason is that → makes a promise rather than a claim of connection. “If it rains, I will bring an umbrella” is broken only by rain and no umbrella. On a dry day the promise is not broken, regardless of the umbrella, so the statement stands.

That is why p → q and ¬p ∨ q are equivalent — the tool confirms they agree on all 4 rows. Implication is not a primitive: it is a not-or in disguise, and that identity is the cleanest way to see why the false-premise rows come out true.

Reading DNF and CNF straight off the table

Every true row can be described by one conjunction that is true on exactly that row and nowhere else. OR those conjunctions together and you have reproduced the column.

For p ∧ (q ∨ ¬r) that gives DNF = (p ∧ q ∧ r) ∨ (p ∧ q ∧ ¬r) ∨ (p ∧ ¬q ∧ ¬r). Each of the 3 true rows gives one conjunction that is true on exactly that row and nowhere else; ORing them together reproduces the column. That construction works for any column of Ts and Fs at all, which is why every truth function has a formula.

The conjunctive form comes from the false rows instead, with every literal negated: CNF = (¬p ∨ q ∨ ¬r) ∧ (p ∨ ¬q ∨ ¬r) ∧ (p ∨ ¬q ∨ r) ∧ (p ∨ q ∨ ¬r) ∧ (p ∨ q ∨ r). Both are generated here and checked back against the original column — a normal form that does not reproduce the table is not one.

The consequence is worth stating: since ANY column of Ts and Fs can be built this way, every possible truth function has a formula, and ∧, ∨ and ¬ alone are enough to write all of them. That is a completeness theorem, and the construction above is its proof.

Notation, and the T and F trap

The tool accepts every common spelling: ∧ && & · * for and, ∨ || | + for or, ¬ ~ ! and a postfix prime for not, plus → -> => and ↔ <-> <=>, and the words AND OR NOT XOR NAND NOR IMPLIES IFF.

Two symbols are deliberately NOT read as constants: T and F. They are among the commonest variable letters in logic exercises, and silently turning “A ∧ F” into “A ∧ false” would answer a different question. Write TRUE, FALSE, 1 or 0 when you mean the constants.

Variable case is preserved for the same reason — a and A are different variables, and folding them together would silently merge two columns into one. Row order runs true-first, which is the logic-textbook convention; electronics tables usually count up from all-false, so a table copied from a datasheet will look reversed while saying exactly the same thing.

Sources and methodology

Propositional logic and the normal-form results are standard; the reference below covers the notation used here.

Method. Every figure on this page comes from src/lib/truth-table-generator.ts over the parser in src/lib/algebra/boolean.ts. Sub-expression columns come from a traversal of the parsed tree rather than from string matching, so a repeated sub-expression gets one column rather than two. DNF and CNF are generated from the table and then re-parsed and compared against the original. That engine is verified on every change against 57 hand-written assertions, including that both normal forms reproduce the original column exactly on every tested expression. The count and the per-case breakdown are published on the formula verification page.

Related calculators

Where this goes next:

Union and IntersectionSix set operations on two or three sets at once, with the Venn regions, inclusion-exclusion checked against the real counts, and De Morgan verified on your own sets.
Power SetList all 2^n subsets with the binary word that generates each one, grouped by size and checked against the binomial coefficients, with the element-versus-subset distinction spelled out.
SubsetTest whether one set is a subset, a proper subset, equal or disjoint — and when the answer is no, name the exact element that breaks it.
Binomial Coefficientn choose k exactly on big integers, by the multiplicative formula that never builds a number bigger than the answer — with Pascal's rule, the row it sits in, and permutations beside it.
Interval NotationConvert between inequality, interval notation, set-builder form and a number-line graph in every direction, including absolute values, unions and the empty set.
Descartes' Rule of SignsCount the sign variations in f(x) and f(-x), list every combination of positive, negative and complex roots the rule permits, and see which one is actually true.

More in Math, or browse all calculators.

Read the guide

Propositional logic and set algebra are the same structure under different symbols, De Morgan included. The Union and Intersection Calculator verifies the set version of the same laws, and the Power Set Calculator covers the 2ⁿ counting that gives a truth table its row count.

Educational use disclaimer

This generator handles propositional logic with up to six variables (64 rows). Variables are single letters and their case is preserved, so a and A are different variables. T and F are read as variables rather than constants, because they are among the commonest variable letters in logic exercises — write TRUE, FALSE, 1 or 0 for the constants.

How we calculate · Found an error? email us

Authorship & verification

Written and maintained by , a business operator who builds spreadsheet-based calculators.

What's changed (3 updates)

Published 6 September 2026

  1. Published the truth table generator: a column for every distinct sub-expression, in evaluation order, so the table reads as the working rather than only the answer.
  2. Compares two expressions row by row and names the first assignment where they differ, which is what settles an equivalence question.
  3. Reads DNF and CNF off the table itself, which is a constructive proof that every truth function has a formula.

Add this calculator to your site

Responsive embed — and private: nothing your visitors type leaves their browser.