Truth Table Generator

Enter a logical expression using variables like p, q, r and operators such as AND (&&), OR (||), NOT (!), XOR (^), and implication (->) to generate a complete truth table. You can also control variable ordering and choose whether to show false values first. The table output shows every possible combination of truth values and the resulting evaluation of your formula.

Use variables p, q, r, s. Operators: && (AND), || (OR), ! (NOT), ^ (XOR), -> (implies), <-> (biconditional). T = tautology, F = contradiction.

Comma-separated list of variables in desired column order. Leave blank for auto-detection.

Results

Formula Classification

--

Number of Variables

--

Total Rows

--

Rows Evaluating TRUE

--

Rows Evaluating FALSE

--

TRUE vs FALSE Outcomes

Results Table

Frequently Asked Questions

What operators can I use in the truth table generator?

You can use a wide range of logical operators: && or 'and' for conjunction (AND), || or 'or' for disjunction (OR), ! or '~' or 'not' for negation (NOT), ^ or 'xor' for exclusive OR, -> or '=>' for implication, and <-> for biconditional (XNOR). The constants T and F represent tautology (always true) and contradiction (always false).

How many variables can I use in a single expression?

You can use up to 4 variables (p, q, r, s) for a manageable table size. With 4 variables, the truth table has 16 rows (2^4). Using 5 or more variables is not recommended as it produces 32+ rows and becomes difficult to read.

What is a tautology and how can I tell if my formula is one?

A tautology is a formula that evaluates to TRUE for every possible combination of input values. If all rows in the result column show TRUE, the formula is a tautology. This calculator labels the formula as 'Tautology', 'Contradiction', or 'Contingency' based on the output.

What does 'false values first' mean?

By default, truth tables list TRUE before FALSE (T, F) for each variable. Selecting 'False values first' reverses this order so FALSE appears at the top (F, T). Both orderings cover the same combinations; it is a matter of convention and personal preference.

What is the difference between XOR and OR?

OR (||) is TRUE when at least one operand is TRUE, including when both are TRUE. XOR (^) is TRUE only when exactly one operand is TRUE — it returns FALSE when both operands are TRUE or both are FALSE. XOR is called 'exclusive or' because it excludes the case where both are true.

How does logical implication (p -> q) work?

The implication p -> q is FALSE only when p is TRUE and q is FALSE. In all other cases — when p is FALSE, or when both are TRUE — the implication evaluates to TRUE. This mirrors the logical rule that a false hypothesis makes any conditional statement vacuously true.

Can I use parentheses to group sub-expressions?

Yes, parentheses are fully supported and recommended for complex expressions. For example, write (p && q) -> (!p || r) to ensure the AND is evaluated before the implication. Without parentheses, the calculator applies standard operator precedence: NOT > AND > XOR > OR > implication > biconditional.

What is a contradiction?

A contradiction is the opposite of a tautology — it is a formula that evaluates to FALSE for every possible input combination. For example, p && !p is always false because a variable and its negation cannot both be true simultaneously. Contradictions appear when a formula is logically impossible.

More Math Tools