Logic

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'.

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.

  1. 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.
  2. 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.
  3. 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

LawAND formOR form
IdentityA ∧ 1 = AA ∨ 0 = A
Null (domination)A ∧ 0 = 0A ∨ 1 = 1
IdempotentA ∧ A = AA ∨ A = A
ComplementA ∧ ¬A = 0A ∨ ¬A = 1
Double negation¬¬A = A
CommutativeA ∧ B = B ∧ AA ∨ B = B ∨ A
Associative(A ∧ B) ∧ C = A ∧ (B ∧ C)(A ∨ B) ∨ C = A ∨ (B ∨ C)
DistributiveA ∧ (B ∨ C) = (A ∧ B) ∨ (A ∧ C)A ∨ (B ∧ C) = (A ∨ B) ∧ (A ∨ C)
AbsorptionA ∧ (A ∨ B) = AA ∨ (A ∧ B) = A
De Morgan¬(A ∧ B) = ¬A ∨ ¬B¬(A ∨ B) = ¬A ∧ ¬B
ConsensusAB + 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.

simplify_logic.py Run this code
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.