Truth-Table Generator

Type a propositional-logic formula and get its full truth table, with intermediate columns and a tautology check — instantly, in your browser.

Syntax: ! or ~ not · && and · || or · ^ or xor exclusive-or · -> if–then · <-> if-and-only-if. Unicode (¬ ∧ ∨ ⊕ → ↔) works too. Use single-letter variables (not T/F) and parentheses.

How it works

Every formula is parsed by a small recursive-descent parser (no eval) and evaluated for all 2n truth assignments of its variables — up to 6 variables (64 rows). Operator precedence, from tightest: negation (!), then &&, xor, ||, ->, and finally <->. Implication p -> q is right-associative, so p -> q -> r means p -> (q -> r). Rows are ordered with the first variable changing slowest, like a binary counter. After the table is built, the tool classifies the formula: a tautology (true in every row — a logical law), a contradiction (false in every row), or a contingency (true in some rows). Everything is computed locally — no data leaves your device.

Frequently asked questions

Why is p -> q true when p is false?

That is the classical definition of material implication: p -> q is only false in the one case where p is true and q is false. Think of it as "p promises q": a false premise can't break the promise. Equivalently, p -> q is exactly !p || q — check both tables and compare.

What is the difference between a tautology and a contingency?

A tautology is true under every assignment (e.g. p || !p), so it carries no information about the world. A contingency is true in some rows and false in others (e.g. p -> q). A contradiction is false everywhere (e.g. p && !p).

Can I test whether two formulas are equivalent?

Yes: build a biconditional between them, like (p -> q) <-> (!p || q). If the result is a tautology, the two formulas agree on every assignment — that is what logical equivalence means.

Why are T and F not allowed as variable names?

T and F are reserved for the truth constants true and false, so they can't double as variable names. Any other single letter works, uppercase or lowercase.