DigitHelm

Boolean Algebra Calculator

Evaluate Boolean expressions with AND, OR, NOT, XOR, NAND, NOR, XNOR, implication, and biconditional. Generates truth tables for up to 4 variables with SOP, POS canonical forms, Σm/ΠM notation, and equivalence checking.

Variables: A B C D · Operators: AND OR NOT XOR NAND NOR XNOR → ↔ · Symbols: && || ! ^ ¬ ∧ ∨ ⊕

What Is the Boolean Algebra Calculator?

Boolean algebra is a mathematical system where every variable has exactly two possible values: true (1) or false (0). Operations on these values, AND, OR, NOT, and their derived forms, form the logical foundation of every digital system in existence.

This calculator evaluates any Boolean expression involving up to four variables (A, B, C, D), generating the complete truth table, classifying the expression as a tautology (always true), contradiction (always false), or contingency (sometimes true), and deriving the canonical Sum of Products (SOP) and Product of Sums (POS) normal forms.

The equivalence checker lets you verify that two different-looking expressions compute identical results for every possible input, a task that is tedious by hand for four variables (16 rows) but instant here.

Formula

Core Operators

NOT A (¬A, !A) → flips truth value: 0→1, 1→0
A AND B (A∧B, A&&B) → 1 only when both are 1
A OR B (A∨B, A||B) → 1 when at least one is 1
A XOR B (A⊕B) → 1 when exactly one is 1
A NAND B → NOT (A AND B) , universal gate
A NOR B → NOT (A OR B) , universal gate
A XNOR B (A↔B) → 1 when both are equal
A → B (A IMPLIES B) → 0 only when A=1 and B=0

De Morgan's Laws

¬(A ∧ B) = ¬A ∨ ¬B (NOT of AND equals OR of NOTs)
¬(A ∨ B) = ¬A ∧ ¬B (NOT of OR equals AND of NOTs)

Key Identities

Double Negation: ¬¬A = A
Idempotent: A ∧ A = A A ∨ A = A
Absorption: A ∧ (A ∨ B) = A A ∨ (A ∧ B) = A
Complement: A ∧ ¬A = 0 A ∨ ¬A = 1
Distributive: A ∧ (B ∨ C) = (A∧B) ∨ (A∧C)

Operator Precedence (low → high)

PrecedenceOperationSymbolsExample
1 (lowest)Biconditional↔ / XNORA ↔ B
2Implication→ / IMPLIESA → B
3Disjunction∨ / OR, NORA ∨ B
4Exclusive OR⊕ / XORA ⊕ B
5Conjunction∧ / AND, NANDA ∧ B
6 (highest)Negation¬ / NOT¬A

All Two-Variable Operator Outputs

ABANDORNANDNORXORXNOR
00001101
01011010
10011010
11110001

How to Use

  1. 1
    Enter an expression: Type directly or use the operator buttons to insert symbols. Variables A, B, C, D are detected automatically.
  2. 2
    Evaluate: Press Enter or click "Evaluate Expression". The truth table, type badge, SOP, and POS appear instantly.
  3. 3
    Read the truth table: Each row shows one combination of variable values and the resulting output. Row numbers are decimal equivalents (minterm indices).
  4. 4
    Inspect canonical forms: SOP lists all input combinations that produce 1; POS lists those that produce 0. Σm() and ΠM() give shorthand notation.
  5. 5
    Check equivalence: Open the equivalence panel, enter a second expression, and verify that both produce the same truth table.
  6. 6
    Try examples: Open the Examples panel for 16 pre-built expressions including De Morgan's laws, implication, tautologies, and more.

Example Calculation

Expression: (A AND B) OR (NOT A AND C)

Truth Table (3 variables, 8 rows)
# A B C | Result
0 0 0 0 | 0
1 0 0 1 | 1 ← ¬A∧C fires
2 0 1 0 | 0
3 0 1 1 | 1 ← ¬A∧C fires
4 1 0 0 | 0
5 1 0 1 | 0
6 1 1 0 | 1 ← A∧B fires
7 1 1 1 | 1 ← A∧B fires
Type: Contingency (true for 4 of 8 rows)
SOP: (¬A∧C) ∨ (A∧B∧¬C) ∨ (A∧B∧C)
Σm: Σm(1, 3, 6, 7)
ΠM: ΠM(0, 2, 4, 5)

Understanding Boolean Algebra

What Is Boolean Algebra?

Boolean algebra, invented by George Boole in 1847, is a branch of algebra where variables can take only two values, true or false. Nearly a century later, Claude Shannon's 1937 master's thesis showed that Boolean algebra is the perfect mathematical language for describing electrical switching circuits. That insight launched the digital revolution.

Every logic gate on a microchip, every if statement in code, every SQL WHERE clause, and every database index lookup ultimately reduces to Boolean operations evaluated billions of times per second.

Truth Tables, The Complete Picture

A truth table systematically lists every possible combination of input values and the corresponding output. For n variables there are 2n rows:

  • 1 variable → 2 rows
  • 2 variables → 4 rows
  • 3 variables → 8 rows
  • 4 variables → 16 rows (maximum supported by this calculator)

Row numbers in the truth table correspond to the minterm index, the decimal value of the binary string formed by the variable values (A is the most-significant bit). These indices appear in Σm and ΠM shorthand notation.

Canonical Forms, SOP and POS

Any Boolean function can be written in two standardised "canonical" forms:

  • Sum of Products (SOP) / Disjunctive Normal Form: OR of all minterms (rows where output = 1). Each minterm is an AND term that uses every variable (complemented if the variable is 0 in that row).
  • Product of Sums (POS) / Conjunctive Normal Form: AND of all maxterms (rows where output = 0). Each maxterm is an OR term that uses every variable (complemented if the variable is 1 in that row).

Example, f(A,B) with rows 2 and 3 producing 1:

Row#ABf(A,B)Minterm (SOP)Maxterm (POS)
0000(A∨B)
1010(A∨¬B)
2101(¬A∧B)
3111(A∧B)
SOP: (¬A∧B) ∨ (A∧B) → simplifies to B
POS: (A∨B) ∧ (A∨¬B) → also simplifies to B
Σm: Σm(2, 3)
ΠM: ΠM(0, 1)

Why canonical forms matter

SOP and POS are the starting point for logic minimization tools like Karnaugh maps and the Quine–McCluskey algorithm. Minimizing the canonical form yields a simpler circuit with fewer gates, lower power consumption, and faster propagation delay.

De Morgan's Laws in Practice

De Morgan's laws let you push a negation inside a compound expression by flipping the operator and complementing each operand:

¬(A ∧ B) = ¬A ∨ ¬B
¬(A ∨ B) = ¬A ∧ ¬B
  • NAND is De Morgan dual of OR: A NAND B = ¬A ∨ ¬B
  • NOR is De Morgan dual of AND: A NOR B = ¬A ∧ ¬B
  • Use them to convert between SOP and POS forms without building a new truth table
  • Essential when targeting NAND-only or NOR-only implementations (universal gate families)

Tautology, Contradiction, and Contingency

  • Tautology: true for every row in the truth table. Example: A OR NOT A. In propositional logic, tautologies are used to represent logical laws.
  • Contradiction (unsatisfiable): false for every row. Example: A AND NOT A. SAT solvers confirm unsatisfiability when no assignment makes the formula true.
  • Contingency: true for some rows and false for others. All non-trivial real-world Boolean conditions are contingencies.

Implication and Biconditional

Two operators often overlooked in digital logic but central to propositional logic:

  • Implication (A → B): reads "if A then B". False only when A is true and B is false. Equivalent to ¬A ∨ B. Used in formal proofs and conditional reasoning.
  • Biconditional / XNOR (A ↔ B): reads "A if and only if B". True when A and B have the same value. Equivalent to (A∧B) ∨ (¬A∧¬B). Used in equality checks and parity circuits.

Real-World Applications

DomainHow Boolean Algebra Is UsedTypical Syntax
Digital Logic DesignGate-level circuit design, minimization with Karnaugh mapsAND/OR/NOT/NAND gates
ProgrammingConditional branching, bit masking, access control checksif (a && !b || c)
Database QueriesSQL WHERE clause filtering with AND/OR/NOT operatorsWHERE active AND NOT deleted
Search EnginesBoolean search operators for combining query terms"cat" AND "dog" NOT "fish"
CryptographyXOR as core primitive in stream ciphers and hash functionsAES, SHA, one-time pad
Formal VerificationProving circuit correctness; SAT solvers find satisfying assignmentsHardware validation

Frequently Asked Questions

What is a Boolean expression?

  • A Boolean expression is a formula built from Boolean variables (A, B, C…) and logical operators.
  • Each variable holds exactly one of two values: true (1) or false (0).
  • The expression evaluates to a single Boolean value for each assignment of its variables.
  • Examples: A AND B, NOT (A OR C), (A XOR B) IMPLIES C.

How do I read a truth table?

  • Each row represents one combination of input variable values.
  • Variables on the left cycle through all 2ⁿ binary combinations (0…0 to 1…1).
  • The rightmost column shows the expression's output for that row.
  • A 1 in the output means the expression is true; a 0 means it is false.
  • Row numbers (minterm indices) are the decimal values of each binary input string.

What is the difference between SOP and POS?

  • SOP (Sum of Products): OR all minterms, rows where the output is 1.
  • POS (Product of Sums): AND all maxterms, rows where the output is 0.
  • Both are canonical forms: every Boolean function has exactly one SOP and one POS representation.
  • SOP maps directly to AND-OR gate structures; POS maps to OR-AND gate structures.
  • Both can be simplified with Karnaugh maps or the Quine–McCluskey algorithm.

What is the difference between NAND and NOR gates?

  • NAND: output is 0 only when all inputs are 1; otherwise 1. Equivalent to NOT(AND).
  • NOR: output is 1 only when all inputs are 0; otherwise 0. Equivalent to NOT(OR).
  • Both are "universal gates", any Boolean function can be built using only NAND gates, or only NOR gates.
  • NAND is the dominant gate in CMOS technology because of its low transistor count and power efficiency.
  • NOR-only logic was common in early bipolar transistor circuits.

How do De Morgan's laws help simplify circuits?

  • They let you move a NOT inside a compound expression by flipping AND↔OR.
  • NOT(A AND B) = (NOT A) OR (NOT B), convert NAND to OR-of-NOTs.
  • NOT(A OR B) = (NOT A) AND (NOT B), convert NOR to AND-of-NOTs.
  • You can eliminate double negations (¬¬A = A) after applying the law.
  • Useful when only NAND or NOR gates are available in a target technology.
  • Also used to convert between SOP and POS forms algebraically.

What does it mean when an expression is a tautology?

  • The expression evaluates to 1 (true) for every row in the truth table.
  • Common examples: A OR NOT A, A IMPLIES A, (A AND B) IMPLIES A.
  • Tautologies represent logical laws, they are true regardless of what the variables mean.
  • In SAT solving, a tautology is trivially satisfiable (every assignment satisfies it).
  • If your constraint is a tautology, it adds no filtering power, useful to know in query optimization.

How does XOR differ from OR?

  • OR outputs 1 when at least one input is 1 (inclusive, 1 OR 1 = 1).
  • XOR outputs 1 when exactly one input is 1 (exclusive, 1 XOR 1 = 0).
  • XOR is the difference: A XOR B = (A OR B) AND NOT (A AND B).
  • XOR is its own inverse: A XOR B XOR B = A, used in cryptographic stream ciphers and data recovery.
  • XOR detects parity: an n-bit XOR is 1 when an odd number of inputs are 1.

What does the equivalence checker do?

  • It evaluates two separate Boolean expressions over all possible input combinations.
  • It takes the union of variables from both expressions to build a shared truth table.
  • If both expressions produce the same output for every row, they are logically equivalent.
  • Equivalence checks are useful for verifying circuit simplifications, e.g. confirming that a minimized SOP equals the original expression.
  • Example: NOT(A AND B) is equivalent to NOT A OR NOT B (De Morgan's law).

Related Calculators