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
De Morgan's Laws
Key Identities
Operator Precedence (low → high)
| Precedence | Operation | Symbols | Example |
|---|---|---|---|
| 1 (lowest) | Biconditional | ↔ / XNOR | A ↔ B |
| 2 | Implication | → / IMPLIES | A → B |
| 3 | Disjunction | ∨ / OR, NOR | A ∨ B |
| 4 | Exclusive OR | ⊕ / XOR | A ⊕ B |
| 5 | Conjunction | ∧ / AND, NAND | A ∧ B |
| 6 (highest) | Negation | ¬ / NOT | ¬A |
All Two-Variable Operator Outputs
| A | B | AND | OR | NAND | NOR | XOR | XNOR |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 |
How to Use
- 1Enter an expression: Type directly or use the operator buttons to insert symbols. Variables A, B, C, D are detected automatically.
- 2Evaluate: Press Enter or click "Evaluate Expression". The truth table, type badge, SOP, and POS appear instantly.
- 3Read the truth table: Each row shows one combination of variable values and the resulting output. Row numbers are decimal equivalents (minterm indices).
- 4Inspect canonical forms: SOP lists all input combinations that produce 1; POS lists those that produce 0. Σm() and ΠM() give shorthand notation.
- 5Check equivalence: Open the equivalence panel, enter a second expression, and verify that both produce the same truth table.
- 6Try 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)
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# | A | B | f(A,B) | Minterm (SOP) | Maxterm (POS) |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | — | (A∨B) |
| 1 | 0 | 1 | 0 | — | (A∨¬B) |
| 2 | 1 | 0 | 1 | (¬A∧B) | — |
| 3 | 1 | 1 | 1 | (A∧B) | — |
Why canonical forms matter
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:
- ›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
| Domain | How Boolean Algebra Is Used | Typical Syntax |
|---|---|---|
| Digital Logic Design | Gate-level circuit design, minimization with Karnaugh maps | AND/OR/NOT/NAND gates |
| Programming | Conditional branching, bit masking, access control checks | if (a && !b || c) |
| Database Queries | SQL WHERE clause filtering with AND/OR/NOT operators | WHERE active AND NOT deleted |
| Search Engines | Boolean search operators for combining query terms | "cat" AND "dog" NOT "fish" |
| Cryptography | XOR as core primitive in stream ciphers and hash functions | AES, SHA, one-time pad |
| Formal Verification | Proving circuit correctness; SAT solvers find satisfying assignments | Hardware 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).