Truth Table Generator for Propositional Logic

Enter a logical formula to generate every truth-value assignment, see each intermediate subexpression, and identify whether the formula is a tautology, contradiction, or contingency. Everything runs privately in your browser.

Enter a proposition

Use letters or names such as P, Q, rain, and wet. Parentheses are supported. Maximum: 10 variables and 500 characters.

Private by design: the formula is parsed and evaluated on this device. It is not uploaded or saved by the tool.

Truth table

The example formula is ready to evaluate.

Your complete truth table will appear here.
Press Generate truth table or use Ctrl/⌘ + Enter.

Advertisement

Supported logical operators

OperationAccepted inputWhen it is truePrecedence
NOT!P, ~P, ¬P, not PWhen P is false1 (highest)
ANDP & Q, P && Q, P ∧ Q, P and QWhen both operands are true2
XORP ^ Q, P ⊕ Q, P xor QWhen exactly one operand is true3
ORP | Q, P || Q, P ∨ Q, P or QWhen at least one operand is true4
ImplicationP -> Q, P => Q, P → Q, P implies QExcept when P is true and Q is false5
BiconditionalP <-> Q, P <=> Q, P ↔ Q, P iff QWhen both operands match6 (lowest)

Constants true, false, 1, and 0 are also accepted. Implication groups from right to left; use parentheses whenever you want to make a grouping explicit.

How the generator builds a truth table

1. Parse the formula

The generator turns variables, constants, parentheses, and connectives into a syntax tree. Clear position-aware messages identify missing operands, unmatched parentheses, and unsupported characters.

2. Enumerate assignments

With n distinct variables there are 2n assignments. Each variable alternates at half the frequency of the variable to its right, producing every combination exactly once.

3. Evaluate subexpressions

Each connective is evaluated from its operands. The table includes connective nodes in inside-out order, so you can follow the same intermediate steps used to reach the final column.

4. Classify the result

All true means tautology; all false means contradiction; a mixture means contingency. True and false row counts are shown above the table.

Limits and assumptions: variable names begin with a letter and may contain letters, digits, or underscores. Keywords are case-insensitive. The 10-variable limit caps output at 1,024 rows, keeping table generation and export practical on phones. This is classical two-valued propositional logic; predicates, quantifiers, and three-valued logics are outside the tool’s scope.

Definitions and truth functions follow OpenStax’s standard treatments of constructing truth tables and conditional and biconditional truth tables.

Editorial review: Parser precedence, connective definitions, classifications, and example outputs checked by the Starlight Tools editorial team. Last reviewed: .

Worked propositional logic examples

Implication: P → Q

An implication is false only for P = true and Q = false. A false antecedent makes the implication true, so both rows beginning with P = false evaluate to true.

De Morgan’s law

¬(P ∧ Q) ↔ (¬P ∨ ¬Q) is true on all four assignments. The generator therefore classifies the biconditional as a tautology. Its intermediate columns also show that the left and right sides always match.

Exclusive OR

P ⊕ Q is true when exactly one of P and Q is true. It differs from inclusive OR, which is also true when both operands are true.

Why parentheses help

P ∨ Q ∧ R is interpreted as P ∨ (Q ∧ R) because AND has higher precedence than OR. Write (P ∨ Q) ∧ R when the OR should be evaluated first.

Truth table generator FAQ

What is a truth table?

A truth table lists every possible truth-value assignment for a formula’s variables and shows the formula’s value for each assignment. Intermediate columns reveal how compound propositions are evaluated.

How many rows does a truth table have?

A formula with n distinct propositional variables has 2n assignments. Two variables produce 4 rows, three produce 8, and ten produce 1,024.

What is the truth value of P implies Q?

P → Q is false only when P is true and Q is false. It is equivalent to ¬P ∨ Q.

What is the difference between a tautology and a contradiction?

A tautology is true under every assignment. A contradiction is false under every assignment. A contingency has at least one true row and at least one false row.

Can I use words as variable names?

Yes. Names such as rain, road_wet, and alarm2 work. The reserved words not, and, xor, or, implies, iff, true, and false act as operators or constants.

Does operator precedence matter?

Yes. The order is NOT, AND, XOR, OR, implication, then biconditional. Parentheses override precedence. Chained implication groups from right to left, so P → Q → R means P → (Q → R).

Can I copy or download the table?

Yes. Copy table produces tab-separated text suitable for spreadsheets and notes. Download CSV creates a UTF-8 CSV file containing the variables and every intermediate column.

Does the generator store my formulas?

No. Formula parsing, evaluation, copying, and CSV creation happen locally in your browser. The tool does not transmit or save your entered formula.

Explore more tools