Logical Expression Parser Calculator

Analyze propositions, operators, precedence, nesting, truth values, equivalence, implication, contradictions, and validity with clear outputs. Students compare statements, verify logic, and learn faster today.

Expression A status

Classification: Contingency

True rows: 7

False rows: 1

Manual assignment

P=1, Q=0, R=1

Expression A: True

Expression B: True

Comparison summary

Expression B status: Contingency

Equivalent: No, at least one row differs.

Calculator

Supported operators: !, &, |, ^, ->, <->, parentheses.
Optional comparison expression for equivalence testing.
Example: P=1,Q=0,R=1

Parsed analysis

Variables: P, Q, R

Canonical DNF A:
(!P & !Q & !R) | (!P & !Q & R) | (!P & Q & !R) | (!P & Q & R) | (P & !Q & R) | (P & Q & !R) | (P & Q & R)

Canonical CNF A:
(!P | Q | R)

Canonical DNF B:
(!P & !Q & !R) | (!P & !Q & R) | (!P & Q & !R) | (!P & Q & R) | (P & !Q & !R) | (P & !Q & R) | (P & Q & R)

Canonical CNF B:
(!P | !Q | R)

Truth table

P Q R Expr A Expr B Equivalent row
0 0 0 1 1 1
0 0 1 1 1 1
0 1 0 1 1 1
0 1 1 1 1 1
1 0 0 0 1 0
1 0 1 1 1 1
1 1 0 1 0 0
1 1 1 1 1 1

Accepted syntax

  • NOT !P
  • AND P & Q
  • OR P | Q
  • XOR P ^ Q
  • IMPLIES P -> Q
  • IFF P <-> Q

What this tool returns

  • Syntax validation
  • Variable extraction
  • Truth table generation
  • Tautology detection
  • Equivalence testing
  • Canonical DNF and CNF

Example data table

Scenario Expression A Expression B Manual assignment Purpose
Implication rewrite (P -> Q) (!P | Q) P=1,Q=0 Check equivalence
Distribution study P & (Q | R) (P & Q) | (P & R) P=1,Q=0,R=1 Verify boolean law
Contradiction test P & !P P=1 Detect impossible statement
Tautology test P | !P P=0 Detect always true statement

Formula used

This calculator applies propositional logic rules through operator precedence and postfix evaluation. Negation is processed first, then conjunction, exclusive disjunction, inclusive disjunction, implication, and biconditional.

Implication: P -> Q is evaluated as !P | Q.

Biconditional: P <-> Q is true when both sides match.

Classification: if every result is 1, the expression is a tautology. If every result is 0, it is a contradiction. Otherwise, it is a contingency.

Canonical DNF and CNF: DNF is built from rows where the result equals 1. CNF is built from rows where the result equals 0.

How to use this calculator

  1. Enter a logical statement in Expression A.
  2. Optionally add Expression B for equivalence comparison.
  3. Use operators !, &, |, ^, ->, and <->.
  4. Optionally provide variable values like P=1,Q=0.
  5. Press Parse and calculate to show the results above the form.
  6. Use Download CSV for truth table export.
  7. Use Download PDF to save the printed report as a PDF.

FAQs

1. What does this parser calculate?

It validates propositional expressions, builds a full truth table, evaluates sample assignments, classifies the statement, and compares two expressions for logical equivalence.

2. Which operators are supported?

You can use negation, conjunction, disjunction, exclusive OR, implication, biconditional, and parentheses. Text forms like AND, OR, XOR, and IFF are normalized automatically.

3. Why is my expression rejected?

The tool checks misplaced operators, missing operators between variables, empty parentheses flow, unsupported characters, and unmatched parentheses before evaluation starts.

4. What is a tautology?

A tautology returns true for every possible variable assignment. The truth table contains only ones in the result column for that expression.

5. How does equivalence testing work?

The calculator evaluates both expressions across every row of the combined truth table. If all paired outputs match, the expressions are logically equivalent.

6. What are canonical DNF and CNF?

Canonical DNF joins all true-producing minterms. Canonical CNF joins all false-producing maxterms. They describe the same expression using standard normal forms.

7. Can I export results?

Yes. The CSV button downloads the truth table data. The PDF button opens the browser print workflow so you can save the report as a PDF.

Related Calculators

boolean expression calculatorboolean algebra simplifierlogic circuit minimizerlogic equation solvermodus tollens calculatorlogic gate simulatorexistential quantifier calculatorfirst order logic solverbitwise operation calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.