United Kingdom ยท Maths & Statistics

Boolean Algebra Calculator

Use . or AND, + or OR, ! or NOT, # or XOR. Brackets work. Up to four variables.
Classification—

Type an expression in whichever notation you use โ€” A.B, AB, AโˆงB or A AND B all work. The calculator evaluates every input combination, builds the truth table, and derives the sum-of-products and product-of-sums forms directly from it.

How do you build a truth table?

List every combination of input values โ€” 2โฟ rows for n variables โ€” then evaluate the expression for each. With three variables that is eight rows. The rows where the output is 1 give the minterms, and ORing those together produces the canonical sum-of-products form.

How to use this calculator

  1. Use whichever notation you were taughtA.B, AB, AโˆงB and A AND B are all accepted. So are +, โˆจ and OR for disjunction, and !, ยฌ, ~ or a trailing apostrophe for negation.
  2. Brackets change the orderAND binds tighter than OR by convention, so A + B.C means A OR (B AND C). Add brackets if you mean something else.
  3. Read the classification firstA tautology is always true, a contradiction always false. Either usually means the expression can be replaced by a constant.
  4. Take the canonical forms as a starting pointThey are correct but not minimal. A Karnaugh map or the identities below will usually reduce them further.

Two values, and everything follows

Boolean algebra works with exactly two values โ€” true and false, 1 and 0 โ€” and three basic operations. From that austere starting point comes every digital circuit ever built.

The operations are AND, which is true only when both inputs are true; OR, which is true when at least one is; and NOT, which flips a value. XOR โ€” true when exactly one input is true โ€” is a useful fourth that can be built from the first three.

What makes the algebra useful is that expressions can be manipulated the way ordinary algebra is manipulated, with their own set of identities. Two expressions that produce identical truth tables are equivalent, and can be swapped freely.

That matters commercially. Every AND gate and every OR gate costs silicon area, power and propagation delay. An expression that reduces from six gates to three halves the cost and roughly halves the delay, and does so millions of times over across a chip.

De Morgan's laws are the two identities worth memorising above all others. The negation of an AND is the OR of the negations, and the negation of an OR is the AND of the negations. Almost every simplification that looks intractable yields to one of them.

Absorption is the other high-value pair: A + A.B = A, and A.(A + B) = A. Spotting one of those removes an entire term at a stroke, and they appear far more often than students expect.

The distributive laws work in both directions in Boolean algebra, unlike ordinary arithmetic. A.(B + C) = A.B + A.C is familiar, but A + B.C = (A + B).(A + C) has no arithmetic analogue and catches people out.

The canonical forms are the bridge between a truth table and an expression. Any function, however it was originally written, can be reconstructed from its truth table as a sum of products โ€” one product term for each row where the output is 1.

That guarantees a solution exists for any specification you can write down as a table, which is why digital design starts with a truth table rather than an expression.

Formula!(A.B) = !A + !B ยท !(A + B) = !A.!B

Worked example: A.B + !C

Three variables means 2ยณ = 8 rows.

With A, B and C running from 000 through 111, the expression A.B + !C evaluates as follows. It is true whenever C is false, regardless of A and B, because !C alone satisfies the OR. It is also true when both A and B are true, whatever C is.

So rows 000, 010, 100, 110 are all true because C = 0. Row 111 is true because A.B = 1. Rows 001, 011 and 101 are false โ€” C is true and A.B is false.

That gives five true rows out of eight, so the expression is contingent rather than a tautology or a contradiction.

The minterms are the indices of the true rows: 0, 2, 4, 6 and 7.

Writing each as a product gives the canonical sum of products: !A.!B.!C + !A.B.!C + A.!B.!C + A.B.!C + A.B.C.

That is correct but obviously wasteful โ€” five product terms to express something we originally wrote in two. The first four all share !C, and !C alone covers all of them regardless of A and B. Factoring gives !C + A.B.C, and since A.B.C only adds a case where C is true, absorption reduces it to !C + A.B โ€” back where we started.

That round trip demonstrates why the canonical form is a starting point rather than an answer. It is a guaranteed-correct expression derived mechanically from the table; making it minimal is a separate step.

The maxterms are the false rows: 1, 3 and 5. The product of sums form takes each of those, inverts every variable, and ANDs the brackets together: (A + B + !C).(A + !B + !C).(!A + B + !C).

With three terms rather than five, the product of sums is actually the more compact canonical form here. That happens whenever the function is true more often than false, and checking both is worth the few seconds it takes.

A quick sanity check on the count: five true rows and three false rows sum to eight, which is 2ยณ. If they do not sum correctly, a row has been missed.

The identities worth knowing

NameIdentityDual
IdentityA + 0 = AA.1 = A
NullA + 1 = 1A.0 = 0
IdempotentA + A = AA.A = A
ComplementA + !A = 1A.!A = 0
De Morgan!(A + B) = !A.!B!(A.B) = !A + !B
AbsorptionA + A.B = AA.(A + B) = A
DistributiveA.(B + C) = A.B + A.CA + B.C = (A + B).(A + C)

Every identity comes in a dual pair: swap AND for OR and 0 for 1, and a true statement stays true. That is a genuine theorem, not a coincidence, and it halves the amount you need to memorise. The distributive dual in the last row is the one with no arithmetic equivalent โ€” A + B.C = (A + B).(A + C) is false for ordinary numbers and true for booleans.

From expression to circuit, and where it goes wrong

The sum-of-products form maps directly onto hardware: one AND gate per product term, feeding a single OR gate. That two-level structure has a predictable propagation delay, which is why it is the standard target for combinational logic.

The product-of-sums form maps to OR gates feeding an AND gate, and is preferred when the function is mostly true.

NAND and NOR gates are universal โ€” any function can be built from either alone โ€” and they are cheaper in CMOS than AND and OR, which are internally a NAND followed by an inverter. De Morgan's laws are what let a designer convert a sum-of-products expression into an all-NAND implementation without changing its behaviour.

Karnaugh maps are the practical minimisation tool up to about four variables. They rearrange the truth table so that adjacent cells differ in exactly one variable, which makes groups of terms that can be combined visually obvious. Beyond four or five variables they become unwieldy and the Quine-McCluskey algorithm or automated tools take over.

Don't-care conditions are worth mentioning. Where certain input combinations can never occur, the output for those rows can be treated as either 0 or 1 โ€” whichever gives a simpler result. Real designs often simplify dramatically once don't-cares are used, and a canonical form derived without them is unnecessarily large.

On common errors: operator precedence is the main one. AND binds tighter than OR, so A + B.C is A OR (B AND C), not (A OR B) AND C. When in doubt, bracket it.

Negation scope is the second. !A.B means (NOT A) AND B, while !(A.B) negates the whole product. Different textbooks use an overbar whose extent makes this unambiguous on paper and ambiguous when typed.

The third is assuming XOR distributes like OR. It does not, and expressions mixing XOR with AND and OR usually need converting to a truth table rather than manipulated directly.

A final note on why this matters beyond electronics. The same algebra underlies database query optimisation, search engine boolean queries, conditional logic in programming, and formal verification of software. A compiler simplifying an if condition is doing exactly what a Karnaugh map does, and the identities above are the rules it follows.

The canonical forms produced here are correct but not minimal. Use a Karnaugh map or the identities above to reduce them, and remember that don't-care conditions can simplify a real design considerably further.

Assumptions and limitations

  • Handles up to four variables โ€” 16 rows
  • Produces canonical forms, which are correct but not minimal
  • Does not perform Karnaugh map or Quine-McCluskey minimisation
  • Does not handle don't-care conditions
  • AND binds tighter than OR โ€” bracket anything ambiguous
  • Does not handle sequential logic, flip-flops or state machines
  • Variable names are single letters and are case-insensitive

Questions people ask about this in United Kingdom

How do you build a truth table?

List every combination of input values โ€” 2โฟ rows for n variables โ€” and evaluate the expression for each.

Three variables give eight rows; four give sixteen.

What are De Morgan's laws?

!(A.B) = !A + !B, and !(A + B) = !A.!B.

The negation of an AND is the OR of the negations, and vice versa. Almost every difficult simplification yields to one of them.

What is the sum of products form?

One product term for every row where the output is 1, ORed together.

It can always be read straight off a truth table, which guarantees a solution exists for any specification you can tabulate.

Is the canonical form the simplest?

No. It is correct but usually wasteful โ€” A.B + !C expands to five product terms and reduces back to two.

Minimising needs a Karnaugh map or the Boolean identities.

Does A + B.C mean A OR B, then AND C?

No. AND binds tighter than OR, so it means A OR (B AND C).

If you mean the other reading, write (A + B).C.

What is a tautology?

An expression that is true for every input combination, such as A + !A.

A contradiction is the opposite โ€” always false. Either means the expression can be replaced by a constant.

Why are NAND gates called universal?

Because any boolean function can be built from NAND gates alone, and the same is true of NOR.

They are also cheaper in CMOS than AND and OR, which is why De Morgan conversions matter in real design.

Method, source and review date

How it is worked out
Exhaustive evaluation with canonical form derivation
Formula used
2โฟ rows for n variables; SOP = OR of the minterms where output = 1
Checked against
Standard boolean algebra
Last reviewed
Confidence
High

Spotted a figure that has moved, or a formula you can show is wrong? Tell us โ€” send a correction. Fixes to rates and formulas are treated as urgent.

Disclaimer

This calculator gives an estimate for guidance only. Check the figures against your own measurements or paperwork before you commit money to them.