Truth Table Generator

Generate truth tables for logical expressions with up to 4 variables — AND, OR, NOT, XOR, NAND, NOR, IMPLIES, and XNOR — with tautology/contradiction detection and a visual result grid.

Total Rows
4
2 variable(s) → 2^2 rows
True Outcomes
1
25.00% of rows
False Outcomes
3
75.00% of rows
Tautology?
No
True for every possible input
Contradiction?
No
False for every possible input
Contingent?
Yes
True for some inputs, false for others

True / False Ratio

T: 1
F: 3

Truth Table

#ABResult
1000 (F)
2010 (F)
3100 (F)
4111 (T)

Operator Reference

OperatorSyntaxDescription
ANDA AND BTrue when both operands are true
ORA OR BTrue when at least one operand is true
NOTNOT ANegation — flips true/false
XORA XOR BExclusive OR — true when operands differ
NANDA NAND BNOT AND — false only when both are true
NORA NOR BNOT OR — true only when both are false
IMPLIESA IMPLIES BConditional — false only when A is true and B is false
XNORA XNOR BBiconditional — true when operands are equal

Input Pattern Visualization

F
F
F
T
Planning notes, formulas, and examples

About the Truth Table Generator

A truth table lists every possible combination of truth values for the variables in a logical expression and shows whether the expression evaluates to true or false in each case. Truth tables are the cornerstone of propositional logic, digital circuit design, and Boolean algebra.

This generator supports up to four variables (A, B, C, D) and eight logical operators: AND, OR, NOT, XOR, NAND, NOR, IMPLIES (→), and XNOR (↔). Type any well-formed expression — from a simple "A AND B" to a nested formula like "(A OR B) AND (NOT C IMPLIES D)" — and the page produces a complete truth table with color-coded results. It classifies the expression as a tautology (always true), a contradiction (always false), or contingent, and shows the true/false ratio in a visual bar.

Preset buttons load common expressions so you can explore operator behaviour without typing. The operator reference table at the bottom summarises every supported connective. An input-pattern grid provides a minimap of which combinations are true or false. Whether you are studying for a discrete-maths exam, designing a combinational logic circuit, or debugging a Boolean filter in code, this truth-table generator is the quickest way to check your reasoning.

When This Page Helps

Writing out every row of a truth table by hand is mechanical but easy to mishandle, especially for 3- or 4-variable expressions where the table has 8 or 16 rows. This calculator parses any combination of AND, OR, NOT, XOR, NAND, NOR, IMPLIES, and XNOR with up to 4 variables, generates the complete table, and classifies the expression as a tautology, contradiction, or contingent formula. It highlights true rows in green so patterns jump out, and is invaluable for verifying logical equivalences and De Morgan transformations.

How to Use the Inputs

  1. Type a logical expression using variables A, B, C, D and operators like AND, OR, NOT, XOR.
  2. Select the number of variables your expression uses.
  3. Click a preset button to load a common expression.
  4. Review the truth table to see every input combination and its result.
  5. Check the output cards for tautology, contradiction, and ratio analysis.
  6. Use the operator reference table to look up any connective you are unsure about.
Formula used
AND: T iff both T | OR: T iff at least one T | NOT: flips | XOR: T iff different | IMPLIES: F only when T→F | XNOR: T iff same

Example Calculation

Result: 1 true row out of 4

A AND B is true only when both A and B are true (row 4). It is contingent — neither a tautology nor a contradiction.

Tips & Best Practices

  • Use parentheses to control precedence: (A OR B) AND C ≠ A OR (B AND C).
  • NAND and NOR are functionally complete — any logic function can be built with either alone.
  • IMPLIES is only false when the antecedent is true and consequent is false.
  • A tautology remains true regardless of input — useful for validating proofs.

From Expression to Table

The calculator assigns all possible combinations of true/false to the variables (2ⁿ rows for n variables), evaluates the expression for each combination, and displays the result in a standard truth-table format. Operator precedence follows conventions: NOT binds tightest, then AND, then OR/XOR, then IMPLIES, then XNOR. Use parentheses to override precedence whenever the default order doesn't match your intent.

Tautologies, Contradictions, and Contingencies

If every row evaluates to true, the expression is a tautology — a logical law (e.g., A OR NOT A). If every row is false, it's a contradiction (e.g., A AND NOT A). Otherwise, it's contingent. Recognising tautologies is essential for validating proof steps, and contradictions signal inconsistent assumptions. The calculator's classification saves you from scanning every row manually.

Functional Completeness and Gate Design

A set of operators is functionally complete if any Boolean function can be expressed using only those operators. {AND, NOT} is complete, as is {NAND} alone or {NOR} alone. Entering expressions built from a single gate type and checking their truth tables against the target function is a practical way to verify functional-completeness constructions, a key exercise in digital-logic and discrete-math courses.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • AND, OR, NOT, XOR, NAND, NOR, IMPLIES (→), and XNOR (↔). You can also use &&, ||, !, and -> as shorthand.