Truth Table Generator
Generate a complete truth table for propositional logic formulas with 2-4 variables and common logical operations.
About this calculator
This calculator builds the complete truth table for a chosen logical operation applied across 2 to 4 propositional variables, evaluating every one of the 2ⁿ possible true/false rows and counting how many come out true. Four of the five operations — AND, OR, XOR, and NAND — are evaluated left to right across the variables. For AND, OR, and XOR that grouping choice is immaterial, since all three are associative and the final answer comes out the same either way. NAND is different: it's commutative (A NAND B = B NAND A) but not associative — (A NAND B) NAND C and A NAND (B NAND C) can disagree on the same inputs — so like IMPLIES, the calculator has to commit to one grouping for NAND, and it uses the same left-to-right convention as AND, OR, and XOR.
IMPLIES is the one operation evaluated in the opposite direction, right to left instead (A implies (B implies C), not (A implies B) implies C), because material implication is not associative, and grouping it the other way would silently produce a different truth table for the same variables. Neither Number of Variables nor the Operation selector visibly moves the true/false counts when nudged by a small percentage from their defaults — but that's purely because both are small whole numbers (2 and 1) that a ten percent wiggle rounds straight back to their starting value, not because either input is actually unimportant; changing Number of Variables from 2 to 3 doubles the row count outright, and switching the Operation changes which rows come out true entirely. This page checks Tautology and Contradiction by counting outcomes, not by symbolic proof, so a formula that is always true for a structural reason a symbolic solver would catch is detected here only because every one of its rows happens to evaluate to true.
Inputs
Results
Total Rows
4
True Outcomes
1
How to Use This Calculator
- Enter the Number of Variables (2 to 4) to set how many propositional variables (A, B, C, D) the table covers.
- Select the Operation from the dropdown (AND, OR, XOR, IMPLIES, or NAND) to choose the logical connective applied across all variables.
- The calculator evaluates all 2^n rows, applying the operation left-to-right (or right-to-left for IMPLIES) across the variables.
- Review the Total Rows, True Outcomes, False Outcomes, and True Percentage to see how often the operation holds.
- Check the Tautology and Contradiction outputs to see if the operation is always true or always false across every row.
What each input means
- Number of Variables
- Number of propositional variables (A, B, C, D)
- Operation
- The logical connective applied between variables. IMPLIES is right-associative: A → B → C means A → (B → C). All other operations evaluate left-to-right.
How this is calculated
Worked example, using the default values
- Identify Input ParametersNumber of Variables = 2, Operation = AND (left-to-right) = 2 variables, AND operation
- Calculate Total RowsTotal Rows4 = 4
- Calculate True OutcomesTrue Outcomes1 = 1
- Calculate False OutcomesFalse Outcomes3 = 3
- Calculate True PercentageTrue Percentage25 = 25
Engine last updated . Checked against 9 independently-derived tests — how we verify calculators. Built by Paul Gunder, a software engineer, not a licensed financial, medical, or legal professional.
Frequently Asked Questions
Why is IMPLIES evaluated right to left while every other operation goes left to right?
AND, OR, and XOR are all associative operations, meaning it makes no difference to the final truth value whether you group the variables from the left or the right — the answer comes out the same either way. NAND is commutative but not associative: (A NAND B) NAND C and A NAND (B NAND C) can disagree on the same inputs, so like IMPLIES it needs a fixed grouping — the calculator just happens to evaluate it left-to-right, the same direction as AND, OR, and XOR. Material implication is the operation evaluated in the opposite direction: A implies (B implies C) and (A implies B) implies C can also disagree on the same inputs, so the calculator has to commit to one grouping there too, and it follows the standard mathematical convention of evaluating IMPLIES from the right.
Why doesn't nudging Number of Variables from 2 to 2.2 change the row count?
Number of Variables is rounded to the nearest whole number before the calculator builds any rows, and a small percentage nudge on a value as low as 2 isn't large enough to round up to 3. The variable count absolutely does matter — moving it from 2 to 3 doubles the total number of rows outright — it just isn't visible to a wiggle this small.
How does the calculator decide whether a formula is a Tautology or a Contradiction?
It counts outcomes rather than reasoning symbolically: Tautology is reported when every single one of the 2ⁿ evaluated rows comes out true, and Contradiction is reported when every row comes out false. Anything in between — some rows true, some false — is neither, even if the formula has some deeper structural property a symbolic proof method might flag.
What does the True Percentage actually measure?
It's simply the count of rows that evaluated to true, divided by the total row count (2ⁿ for n variables), expressed as a percentage. For iterated XOR (parity), that percentage lands at exactly 50% for any number of variables in the 2 to 4 range this calculator supports, not just an even count, while AND across several variables produces a much smaller share of true rows, since every single variable has to be true simultaneously.
Related Calculators
The questions that sit next to this one — chosen by subject, including calculators filed under a different category.
Logical Equivalence Checker
Test whether two propositional logic expressions produce identical truth values across all variable assignments.
Logic & Formal ReasoningBoolean Algebra Simplifier
Estimate Boolean expression simplification from sum-of-products form. Calculates term and literal reduction using grouping heuristics.
Logic & Formal ReasoningSyllogism Validator
Check the validity of categorical syllogisms by figure and mood. Identifies all 19 traditionally valid syllogistic forms.
Tabletop RPGTreasure Hoard Generator
Generate appropriate treasure hoard value from CR tier and party composition following D&D 5e guidelines.
More in Math & Statistics.