MODULE 01

Logic Calculator: Truth Tables & Propositional Logic

Enter expressions using AND, OR, NOT, XOR, IMPLIES (->), IFF (<->), or symbols & | ~ ^ -> <->. Example: (P AND Q) -> R

What is Propositional Logic?

Propositional logic is the branch of mathematical logic dealing with statements that are either true or false, combined using AND, OR, NOT, implication, and biconditional. It's the foundation for truth tables, digital circuits, and program logic.

How Does This Calculator Work?

Type a logical formula using AND, OR, NOT, XOR, IMPLIES (or symbols like ∧ ∨ ¬ →) into the expression box, then choose Truth Table, Classify, Equivalence, or Simplify. The truth table view shows every sub-expression evaluated column by column, not just the final answer, so you can see exactly how each row was built up.

Common Formulas & Rules

  • Negation (¬P): true when P is false, and vice versa.
  • Conjunction (P ∧ Q): true only when both P and Q are true.
  • Disjunction (P ∨ Q): true when at least one of P, Q is true.
  • Implication (P → Q): false only when P is true and Q is false; otherwise true.
  • Biconditional (P ↔ Q): true when P and Q have the same truth value.
  • Tautology: a formula that is true in every row of its truth table (e.g. P ∨ ¬P).
  • Contradiction: a formula that is false in every row (e.g. P ∧ ¬P).

Worked Example

Consider the formula (P → Q) ↔ (¬P ∨ Q). Building the truth table across all 4 combinations of P and Q shows both sides always match — this identity is exactly why implication can always be rewritten as a disjunction, a rule used constantly when simplifying logical circuits and program conditions.

Logic calculator or predicate logic calculator?

This page is a logic calculator for propositional logic: every variable is simply true or false, and formulas are built with AND, OR, NOT, implication and biconditional. With n variables there are 2ⁿ rows, so a truth table settles tautologies, contradictions and equivalence completely.

If a statement talks about “every” or “some” members of a set, you need quantifiers instead, which is the job of the predicate logic calculator. If you only want to minimise an expression for hardware, use the boolean algebra calculator.

Study guide: Propositional Logic

Written for students learning this topic for the first time. Last updated October 2026.

Overview

Propositional logic studies statements that are either true or false, and the ways they can be combined. “7 is prime” is a proposition; a question or a command is not. Everything else in the subject is built from a handful of connectives: not, and, or, implies, and if-and-only-if.

What makes it powerful is that questions about any formula can be settled mechanically. With n distinct variables there are exactly 2ⁿ possible assignments, so a truth table decides whether a formula is always true, never true, or sometimes true, and whether two formulas mean the same thing. The same ideas sit underneath program conditions, database filters, and digital hardware.

Key ideas explained

The connectives and when each is true

¬P flips a value. P ∧ Q is true only when both parts are true. P ∨ Q is true when at least one part is true (an inclusive or). P → Q is false in exactly one case: P true and Q false. P ↔ Q is true when both sides have the same value. XOR (P ⊕ Q) is true when exactly one side is true.

Why implication feels strange

In everyday speech “if P then Q” suggests a cause. In logic it only promises that you will never see P true while Q is false. When P is false the promise is never tested, so the implication counts as true (a vacuous truth). “If 2 > 3 then the moon is made of cheese” is a true statement for exactly this reason.

Equivalence laws you can use instead of a table

De Morgan: ¬(P ∧ Q) ≡ ¬P ∨ ¬Q and ¬(P ∨ Q) ≡ ¬P ∧ ¬Q. Implication: P → Q ≡ ¬P ∨ Q. Double negation: ¬¬P ≡ P. Absorption: P ∨ (P ∧ Q) ≡ P. Applying these step by step simplifies a formula, and each step is a justification you can write in a proof.

Converse, inverse, and contrapositive

For P → Q, the converse is Q → P, the inverse is ¬P → ¬Q, and the contrapositive is ¬Q → ¬P. Only the contrapositive is equivalent to the original statement. The converse and inverse are equivalent to each other, but not to the original.

Worked examples

Verify De Morgan's law with a truth table

Problem. Show that ¬(P ∧ Q) is equivalent to ¬P ∨ ¬Q.

  1. List the four rows for (P, Q): TT, TF, FT, FF.
  2. Compute P ∧ Q: T, F, F, F. Negate it: F, T, T, T.
  3. Compute ¬P: F, F, T, T and ¬Q: F, T, F, T. Then ¬P ∨ ¬Q: F, T, T, T.

Answer. Both columns read F, T, T, T, so the two formulas agree in every row and are equivalent.

Classify a three-variable formula without writing 8 rows

Problem. Is (P → Q) ∧ (Q → R) → (P → R) a tautology?

  1. For the whole implication to be false, the left side must be true and P → R must be false.
  2. P → R is false only when P is true and R is false.
  3. With P true, (P → Q) forces Q true. Then Q → R has Q true and R false, so it is false, which contradicts the left side being true.

Answer. No row can make the formula false, so it is a tautology. This is the rule called hypothetical syllogism.

Enter these same values in the calculator above and compare each step with the working shown here.

Common mistakes to avoid

  • Reading P → Q as “P causes Q”, or believing it is false whenever P is false.
  • Treating the converse as equivalent to the original statement.
  • Pushing a negation through without flipping the connective: ¬(P ∧ Q) is not ¬P ∧ ¬Q.
  • Forgetting that logical “or” is inclusive. Use XOR when exactly one must hold.
  • Dropping parentheses. ¬P ∨ Q and ¬(P ∨ Q) are different formulas; ¬ binds tightest, then ∧, ∨, →, ↔.

Where this shows up in computer science

  • Digital hardware: every gate implements a connective, and simplifying a formula means fewer gates.
  • Programming: rewriting !(a && b) as !a || !b is De Morgan's law, and short-circuit evaluation follows the truth conditions of ∧ and ∨.
  • Satisfiability (SAT) solvers decide whether some assignment makes a formula true; they are used in hardware verification, planning, and package dependency resolution.

Test yourself

Try each question before opening the answer.

How many rows does the truth table of a formula with 5 distinct variables have?

2⁵ = 32.

Write the contrapositive of “If a number is divisible by 6, then it is divisible by 3.”

If a number is not divisible by 3, then it is not divisible by 6.

Is ((P ∨ Q) ∧ ¬P) → Q a tautology?

Yes. If ¬P is true then P is false, so P ∨ Q can only be true because Q is true (disjunctive syllogism).

Frequently asked questions

What's the difference between a tautology and a contradiction?

A tautology is a formula that's true in every row of its truth table (e.g. P ∨ ¬P). A contradiction is false in every row (e.g. P ∧ ¬P). Everything in between, true in some rows and false in others, is called a contingency.

How many rows does a truth table have?

A truth table has 2ⁿ rows, where n is the number of distinct variables. Two variables give 4 rows, three variables give 8 rows, and so on.

Is P → Q the same as Q → P?

No. P → Q (if P then Q) is not logically equivalent to its converse Q → P. It IS equivalent to its contrapositive, ¬Q → ¬P, which always has the same truth value.

What is a logic calculator?

A logic calculator evaluates logical expressions built from AND, OR, NOT, implication and biconditional. This one builds a truth table for every combination of inputs, classifies a formula as a tautology, contradiction or contingency, checks whether two expressions are equivalent, and simplifies expressions.

What is the difference between propositional logic and predicate logic?

Propositional logic combines whole statements with connectives such as AND and OR. Predicate logic adds variables and the quantifiers ∀ (for all) and ∃ (there exists) so you can talk about members of a domain. Use this page for truth tables and the predicate logic calculator for quantified statements.