📢 Advertisement — 728×90
📢 Advertisement

This truth table generator is provided by Hesapstan to evaluate boolean logic expressions without running user input as code. It supports NOT, AND, OR, XOR, NAND, NOR, XNOR and IMPLIES, with full truth tables up to 6 variables and single-assignment evaluation up to 10 variables.

What does this truth table generator do?

This calculator parses a boolean expression, evaluates it for truth-value assignments, and shows the result as either a full truth table or a single selected assignment.

  • Full table mode generates every true/false combination for up to 6 variables.
  • Single-assignment mode evaluates one chosen set of truth values for up to 10 variables.
  • The final expression is classified as a tautology, contradiction, or contingency.
  • The expression is not executed as JavaScript code; it is parsed and evaluated through fixed logic rules.
Search intent

This page is focused on truth table generation and boolean expression evaluation. If you need prefix or postfix notation conversion, the Polish notation converter is the closer tool.

What is a truth table?

A truth table is a systematic table showing the result of a logical expression for every possible combination of truth values assigned to its variables.

For example, A OR NOT A is true when A is true and also true when A is false, so it is a tautology. A AND NOT A is false in every case, so it is a contradiction.

Truth tables are widely used in propositional logic, discrete mathematics, computer science, digital logic, and reasoning about conditions.

Supported operators and syntax

The calculator accepts both text operators and common symbolic aliases, so A AND B and A ∧ B represent the same logical operation.

  • NOT or ¬: reverses a truth value.
  • AND or ∧: true only when both sides are true.
  • OR or ∨: true when at least one side is true.
  • XOR or ⊕: true when exactly one side is true.
  • NAND or ↑: the negation of AND.
  • NOR or ↓: the negation of OR.
  • XNOR or ↔: true when both sides have the same truth value.
  • IMPLIES or →: false only when the left side is true and the right side is false.
Variable rule

Variables must be single letters. A joined expression such as AB is not silently interpreted as A AND B; it is rejected with a specific error message.

📢 Advertisement

How is operator precedence handled?

Operator precedence decides which part of a logic expression is evaluated first; parentheses can always be used to make the intended grouping explicit.

  1. NOT is evaluated first.
  2. AND and NAND are evaluated before lower-precedence binary operators.
  3. XOR and XNOR are evaluated before OR and NOR.
  4. OR and NOR are evaluated before IMPLIES.
  5. Parentheses override the normal order and should be used in mixed expressions.
Why parentheses matter

A AND B OR C is not the same expression as A AND (B OR C). Parentheses help both the calculator and the reader understand your intended logic.

How full table mode works

Full table mode lists every combination of truth values for the variables detected in the expression and evaluates the final result for each row.

One variable gives 2 rows, two variables give 4 rows, and six variables give 64 rows. For readability, full table mode is capped at 6 variables.

  • Each variable gets its own column.
  • The result column shows the truth value of the full expression.
  • The calculator then classifies the expression as tautology, contradiction, or contingency.

When to use single-assignment mode

Single-assignment mode is useful when you only need the value of the expression for one chosen set of truth values, especially when the expression has many variables.

For an expression with 8 or 10 variables, a full truth table would be too large for quick reading. In that case, choosing true or false for each variable and evaluating one assignment is more practical.

Full table limit

If your expression has more than 6 variables, use single-assignment mode. The limit is a readability limit, not a claim that the logic cannot be evaluated.

Tautology, contradiction, and contingency

The classification summarizes the whole expression: a tautology is always true, a contradiction is always false, and a contingency is true in some rows and false in others.

  • Tautology: A OR NOT A is true for every assignment.
  • Contradiction: A AND NOT A is false for every assignment.
  • Contingency: A AND B depends on the values of A and B.

This classification should not be confused with the result of a single row. A contingency can still be true for a particular assignment.

Example: A AND (B OR NOT C)

In A AND (B OR NOT C), the expression inside the parentheses is evaluated before the final AND with A.

  1. The variables A, B, and C are detected, so full table mode creates 8 rows.
  2. NOT C is evaluated inside each row.
  3. B OR NOT C is evaluated next.
  4. A AND (...) is evaluated last.
  5. Because the final expression is true in some rows and false in others, it is classified as a contingency.
Learning value

This example is useful because it shows why a truth table is more than a final answer: it reveals which assignments make the logic true or false.

Why the calculator does not use eval or Function

The calculator does not run the user expression as JavaScript code. It tokenizes the expression, converts it to a structured evaluation order, and applies a fixed set of boolean operators.

Safety note

No eval(), Function(), or dynamic code execution is used. Unsupported tokens are rejected instead of being executed or guessed.

This matters because truth table input is user-controlled text. A parser-and-evaluator approach keeps the behavior predictable and limited to the supported logic syntax.

Common mistakes

Most truth table mistakes come from ambiguous writing, missing operands, or misunderstanding precedence.

  • Writing AB when the intended expression is A AND B.
  • Forgetting parentheses in mixed AND, OR, XOR, and IMPLIES expressions.
  • Treating XOR as the same as OR.
  • Calling an expression a tautology because one row is true.
  • Expecting a very large full table instead of using single-assignment mode.

Limitations and related tools

This truth table generator is for propositional boolean expressions, not for predicate logic, quantified statements, set proofs, or arbitrary programming expressions.

  • Full table mode supports up to 6 variables.
  • Single-assignment mode supports up to 10 variables.
  • Variables must be single letters.
  • Invalid tokens, unmatched parentheses, missing operands, and trailing operators are rejected with explicit messages.
Related search paths

For notation conversion, use the Polish notation converter. For set-builder style notation, use the set-builder notation calculator instead of this truth table generator.

Frequently Asked Questions

What does a truth table generator calculate?

It evaluates a logic expression for every true/false combination of its variables and shows the result in a table. It also classifies the expression as a tautology, contradiction, or contingency.

Can I write AB instead of A AND B?

No. The operator must be explicit. AB is not silently treated as A AND B because that could hide input mistakes.

Why is full table mode limited to 6 variables?

A full truth table has 2^n rows. Six variables already produce 64 rows, so the limit keeps the table readable. More variables can be evaluated in single-assignment mode.

What is the difference between a tautology and a contingency?

A tautology is true in every row. A contingency is true in some rows and false in others.

Does this calculator execute my expression as code?

No. It parses supported logic tokens and evaluates them through fixed boolean rules; it does not use eval or Function.

📢 Advertisement

Related Calculators

🔀Polish Notation ConverterSet Builder Calculator