Boolean Algebra Calculator
Simplify any Boolean expression to its smallest sum of products and product of sums. See the Karnaugh map, the minterms, the canonical forms and the prime implicants used, and check whether two expressions are equivalent. Free, in your browser.
Write AND as AND, &, *, ∧ or letters side by side (AB); OR as OR, |, +, ∨; NOT as NOT, !, ~, ¬ or A'.
- A'B'C + A'BC + AB'C + ABC
- AB + A'C + BC
- (A + B)(A + C)
- NOT (A AND B) OR A
- A XOR B XOR C
- p -> (q -> p)
- AB'C + ABC' + ABC + A'BC
Are two expressions equivalent?
Compare the expression above with another one. They are equivalent when they give the same result for every row of the truth table.
How to simplify a Boolean expression
There are two common ways, and this calculator shows both.
- With the laws of Boolean algebra. Rewrite step by step with the laws below until nothing can be removed. Example:
A + A'B=(A + A')(A + B)(distributive) =1 · (A + B)(complement) =A + B. - With a Karnaugh map. Put the 1s of the truth table in a grid ordered in Gray code, so neighbouring cells differ in one variable. Circle groups of 1, 2, 4 or 8 neighbouring 1s, as large as possible (groups may wrap around the edges). Each group becomes one product term; the variables that change inside a group drop out.
- The calculator uses the Quine-McCluskey method, the table version of a Karnaugh map that also works for more than 4 variables: it finds every prime implicant, keeps the essential ones and picks the fewest others that cover all the 1s.
Laws of Boolean algebra
| Law | AND form | OR form |
|---|---|---|
| Identity | A ∧ 1 = A | A ∨ 0 = A |
| Null (domination) | A ∧ 0 = 0 | A ∨ 1 = 1 |
| Idempotent | A ∧ A = A | A ∨ A = A |
| Complement | A ∧ ¬A = 0 | A ∨ ¬A = 1 |
| Double negation | ¬¬A = A | |
| Commutative | A ∧ B = B ∧ A | A ∨ B = B ∨ A |
| Associative | (A ∧ B) ∧ C = A ∧ (B ∧ C) | (A ∨ B) ∨ C = A ∨ (B ∨ C) |
| Distributive | A ∧ (B ∨ C) = (A ∧ B) ∨ (A ∧ C) | A ∨ (B ∧ C) = (A ∨ B) ∧ (A ∨ C) |
| Absorption | A ∧ (A ∨ B) = A | A ∨ (A ∧ B) = A |
| De Morgan | ¬(A ∧ B) = ¬A ∨ ¬B | ¬(A ∨ B) = ¬A ∧ ¬B |
| Consensus | AB + A'C + BC = AB + A'C | (A + B)(A' + C)(B + C) = (A + B)(A' + C) |
Every law has a dual: swap AND with OR and 0 with 1 and it stays true. In engineering notation, AND is written as letters side by side (AB), OR as + and NOT as a prime (A'). To see each step as a column, put the expression in the truth table generator.
Simplify Boolean expressions in Python
SymPy's simplify_logic does the same job in code: form="dnf" gives a sum of products and form="cnf" a product of sums. Press Run this code to try it in the online Python editor.
from sympy import symbols
from sympy.logic import simplify_logic
from sympy.logic.boolalg import truth_table
A, B, C = symbols("A B C")
expr = (A & B) | (A & ~B & C) | (~A & B & C)
print("Simplified:", simplify_logic(expr, form="dnf")) # sum of products
print("As POS: ", simplify_logic(expr, form="cnf")) # product of sums
for inputs, value in truth_table(expr, [A, B, C]):
print(inputs, "->", value)
Frequently asked questions
How does the calculator simplify an expression?
It finds every row where the expression is true, merges them into prime implicants with the Quine-McCluskey method and picks the fewest that cover all true rows. The result is a minimal sum of products; it does the same with the false rows for the product of sums.
What is the difference between SOP and POS?
A sum of products (SOP) is an OR of AND terms, like AB + A'C. A product of sums (POS) is an AND of OR terms, like (A + C)(A' + B). Both describe the same function.
Does it draw a Karnaugh map?
Yes, for expressions with 2, 3 or 4 variables. Each cell shows its minterm number, and coloured dots show which group of the simplified answer covers it.
Can it check if two expressions are equal?
Yes. Type a second expression under "Are two expressions equivalent?". If they differ, it shows an input where one is true and the other is false.
How many variables can it handle?
Up to 8 variables. The Karnaugh map is drawn for 2 to 4.
Is it free?
Yes. It runs in your browser, is free and needs no account.
Related tools
- Truth Table Generator - Step by Step, Free OnlineMake a truth table for any Boolean expression, with a column for every step. AND, OR, NOT, XOR, NAND, NOR, implies and iff; minterms, SOP and POS. Free.
- Binary to Decimal Converter with Steps - Free OnlineConvert binary to decimal instantly with step-by-step working: each bit, its place value and the sum. Also shows hex and octal, works for long numbers. Free.
- Decimal to Binary Converter with Steps - Free OnlineConvert decimal to binary instantly and see the working: divide by 2 and read the remainders. Hex, octal, two's complement and code examples. Free.