Boolean Algebra Simplification Calculator

Enter a Boolean expression and this calculator returns its minimal two-level form — not a form that happens to be shorter, but the provably smallest sum-of-products (or product-of-sums) for that function. It builds the truth table, extracts the minterms, runs the Quine–McCluskey algorithm to find every prime implicant, and then picks a cheapest cover. You get the literal count before and after, the full prime-implicant list, and which of those implicants are essential.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Boolean expressionSingle letters are variables; juxtaposition means AND, + means OR and a trailing apostrophe means NOT.AB + AB'C + A'BC
Target formSOP gives an OR of AND terms; POS gives an AND of OR terms. Both describe the same function.Minimal sum of products (AND-OR)
Variable orderLeave blank to use the letters in your expression, alphabetically; otherwise list them with the most significant bit first.

It returns

  • Minimal expression — An apostrophe means complement. A constant result of 0 or 1 has no product terms at all.
  • Literals in the minimal form
  • Literals as you entered it
  • Terms in the minimal form
  • Minterms where F = 1
  • Prime implicants

The formula

XY+XY=X
(AB)=A+B

In plain text: F = Σ m(i) → merge implicants that differ in one bit → minimal cover of the minterms

  • FThe Boolean function being minimised (0 or 1)
  • m(i)Minterm i — the row of the truth table with binary index i where F = 1 (row index)
  • XAny product of literals common to two terms (product term)
  • YThe single variable in which the two terms differ (literal)

The adjacency identity XY + XY′ = X is the only merging rule the algorithm uses. Applying it until nothing more merges yields the prime implicants.

Updated Category Discrete Math, Logic & Graph Theory Verified against published test cases Reading time 12 min

What "minimal" means, and why it is not the same as "shorter"

Simplifying a Boolean expression by hand gives you a shorter expression. It does not tell you whether a shorter one exists. Two students can apply the identities in different orders, reach different answers, and both be correct — and neither knows which is cheapest. Minimisation as an algorithm answers the question that hand algebra cannot: among all two-level sum-of-products expressions for this function, which uses the fewest terms and the fewest literals?

The cost model matters. A literal is one appearance of a variable or its complement, so AB'C has three literals. A term is one product in a sum-of-products expression. In a two-level AND-OR circuit those map directly onto hardware: each term is one AND gate, each literal is one input to that gate, and the whole sum is one OR gate. Minimising literals minimises gate inputs, which in classical gate-array design is what you pay for.

Everything here is about two-level form. That restriction is deliberate: two-level circuits have a uniform, predictable propagation delay, and the minimisation problem is exactly solvable. Allow more levels and you can often do better on literal count — AB + AC factors to A(B + C), three literals instead of four — but the delay grows and the problem stops being tractable. If the calculator tells you the minimal form has more literals than the expression you typed, that is almost always what happened: you typed a factored form.

How the Quine–McCluskey algorithm finds the answer

The algorithm rests on a single identity: XY + XY′ = X. If two product terms agree in every variable except one, and disagree in that one, the differing variable drops out. Written on minterm indices, two minterms merge exactly when their binary codes differ in one bit position, and the merged implicant carries a dash in that position.

The procedure has two halves. First, find every prime implicant. List the minterms as binary codes. Compare every pair; where they differ in exactly one bit, record the merged term and mark both parents as used. Repeat on the merged terms, and again, until no more merges are possible. Anything never used in a merge is a prime implicant — an implicant that cannot be enlarged. This half is purely mechanical and always terminates.

icSecond, choose a minimal cover. Build a chart of prime implicants against minterms. Any minterm covered by exactly one prime implicant forces that implicant into the answer; it is an essential prime implicant, and every minimal solution contains it. Remove the essentials and the minterms they cover, then find the cheapest set of the remaining prime implicants that covers what is left. This calculator searches that remainder exhaustively when the number of candidates is small, so the reported cover really is minimal in literals, with ties broken by term count and then alphabetically so the answer is reproducible.

Karnaugh maps do exactly the same two steps graphically: adjacent cells on the map are minterms differing in one bit, a rectangular group of 2k cells is an implicant, and the largest groups are the prime implicants. The map is faster for a human up to four variables; the algorithm is what you use beyond that. The Karnaugh map solver shows the same function laid out on the grid.

Worked example: simplifying AB + AB′C + A′BC

Take the default expression with variables A, B, C, where A is the most significant bit.

  1. Find the minterms. AB is true whenever A = 1 and B = 1, giving rows 110 and 111, that is m6 and m7. AB′C is row 101, m5. A′BC is row 011, m3. So F = Σm(3, 5, 6, 7).
  2. Write the codes and merge in pairs. m3 = 011, m5 = 101, m6 = 110, m7 = 111. Compare each pair: 011 and 111 differ only in the first bit, giving -11. 101 and 111 differ only in the second, giving 1-1. 110 and 111 differ only in the third, giving 11-. The pair 011 and 101 differs in two bits, so it does not merge; nor do 011 and 110, nor 101 and 110.
  3. Try a second round. -11, 1-1 and 11- all have their dashes in different positions, so none of them can merge with another. All three are prime implicants: -11 = BC, 1-1 = AC, 11- = AB.
  4. Build the cover chart. m3 is covered only by BC. m5 is covered only by AC. m6 is covered only by AB. m7 is covered by all three. So BC, AC and AB are all essential.
  5. Read off the answer. F = BC + AC + AB — three terms, six literals, down from three terms and eight literals as written.

The same result falls out of hand algebra if you happen to pick the right moves: AB + AB′C = A(B + B′C) = A(B + C) = AB + AC, using X + X′Y = X + Y. That leaves AB + AC + A′BC, and AC + A′BC = C(A + A′B) = C(A + B) = AC + BC, giving AB + AC + BC. Two applications of the same identity — but you had to spot them. The algorithm never has to spot anything.

This function has a name: it is the majority function on three inputs, true whenever at least two of A, B and C are true. Its minimal form is symmetric in the three variables, which is a good sanity check on any answer you get.

How to read the output

Start with the literal count. Six literals in three terms means a two-level AND-OR circuit with three AND gates of two inputs each and one three-input OR gate — before you add inverters for the complemented literals. Compare that with the literal count for your input to see what the minimisation bought you, and remember the comparison is only meaningful when your input was already in two-level form.

The prime implicant list is longer than the answer whenever some implicants were not needed. That gap is informative: a function with many redundant prime implicants has multiple minimal covers of equal cost, and a synthesis tool may pick a different one than this calculator does. Both are correct. When every prime implicant is marked essential, the minimal cover is unique.

A result of 1 means the function is true in every row — a tautology — and a result of 0 means it is never true. Both are reported with zero terms and zero literals, because a constant needs no gates at all. If you expected a real expression and got a constant, check the parse: an unbalanced bracket or a misplaced apostrophe usually shows up this way. The truth table calculator is the quickest way to confirm what your expression actually evaluates to.

Choosing POS rather than SOP does not change the function, only its shape. The calculator minimises the complement as a sum of products and then applies De Morgan to every term, which is the standard construction. Whether SOP or POS is cheaper depends entirely on the function: a function true in only two of sixteen rows has a compact SOP, and its complement — true in fourteen rows — usually has a compact POS instead.

The Boolean identities this calculator is equivalent to applying

Every identity holds for all values of the variables and can be verified by a two-row or four-row truth table.
NameOR formAND form
IdentityA + 0 = AA · 1 = A
Null (dominance)A + 1 = 1A · 0 = 0
IdempotentA + A = AA · A = A
ComplementA + A′ = 1A · A′ = 0
Involution(A′)′ = A
CommutativeA + B = B + AAB = BA
Associative(A + B) + C = A + (B + C)(AB)C = A(BC)
DistributiveA + BC = (A + B)(A + C)A(B + C) = AB + AC
AbsorptionA + AB = AA(A + B) = A
AdjacencyAB + AB′ = A(A + B)(A + B′) = A
SimplificationA + A′B = A + BA(A′ + B) = AB
De Morgan(A + B)′ = A′B′(AB)′ = A′ + B′
ConsensusAB + A′C + BC = AB + A′C

Adjacency is the one the algorithm uses directly; every other row can be derived from the first four plus distribution. Note that A + BC = (A + B)(A + C) has no counterpart in ordinary arithmetic — Boolean addition distributes over multiplication as well as the reverse.

Notation this calculator accepts

Variables are single letters, and case is ignored, so a and A are the same variable. Writing letters next to each other means AND: ABC is A·B·C. A trailing apostrophe or prime complements the term before it, so A', (A+B)' and AB' all work. You can also use + or | for OR, *, . or & for AND, ! or ~ for a prefix NOT, and ^ for exclusive-or. Word operators AND, OR, NOT, XOR, NAND, NOR and XNOR work too, but put spaces around them — AANDB reads as five separate variables.

Pitfalls and limits

  • Minimal literal count is not minimal delay or minimal transistor count. Real synthesis tools optimise against a technology library, where a 3-input NAND may be cheaper than a 2-input AND plus an inverter. Use this result as the algebraic baseline, not as a layout.
  • Inverters are not counted. The literal count ignores the cost of producing A′ from A. If complemented inputs are not already available, add one inverter per distinct complemented variable.
  • Ties are real. When several covers have the same literal count, the calculator picks one deterministically. A textbook answer key may show a different but equally minimal expression — compare literal counts, not strings.
  • Two-level only. Factored and multi-level forms are excluded by construction, so the reported minimum can exceed the literal count of a factored expression you already had.
  • Hazards are not modelled. A minimal cover can contain a static hazard: a glitch when two inputs change and no product term covers the transition. Hazard-free design deliberately adds redundant prime implicants, which costs literals.
  • Six variables is the ceiling here. The truth table is enumerated in full, so cost doubles per variable. Beyond that, use Espresso-style heuristic minimisation, which trades guaranteed optimality for speed.

Where this sits among the alternatives

Hand algebra, Karnaugh maps and Quine–McCluskey all compute the same thing, and they differ only in who does the searching. Hand algebra needs you to spot the applicable identity, and gives no guarantee of optimality. A K-map turns spotting into seeing, and works comfortably to four variables and awkwardly to five or six. Quine–McCluskey is the mechanical form of the same search, correct at any size but exponential in cost — which is why industrial synthesis uses heuristic minimisers such as Espresso, which usually find the optimum and never promise it.

The algorithm is due to Willard Van Orman Quine, who described the prime-implicant idea in 1952, and Edward J. McCluskey, who turned it into a tabular procedure in 1956. Maurice Karnaugh's map had appeared in 1953. All three predate integrated circuits, and all three are still taught because the underlying question — what is the cheapest circuit that computes this table — never went away.

Two neighbouring tools finish the picture. To see whether an expression is a tautology or to compare two expressions row by row, use the truth table calculator. To work with collections rather than propositions — where the same De Morgan laws govern union, intersection and complement — use the set operations calculator. And when the structure you are minimising is a graph rather than a function, the Dijkstra shortest path calculator handles the corresponding optimisation.

Frequently asked questions

Is the answer really the minimal expression, or just a simplified one?

It is minimal in literals among all two-level sum-of-products expressions for that function, which is what Quine–McCluskey guarantees. The algorithm enumerates every prime implicant and then searches for a cheapest cover, so no shorter two-level expression exists. A factored, multi-level expression can still have fewer literals — A(B + C) beats AB + AC — but it is a different kind of circuit with a longer delay.

My textbook gives a different answer with the same number of terms. Which is right?

Both, most likely. When a function has several minimal covers of equal cost, any of them is a correct answer, and different sources break the tie differently. Compare the literal counts and the term counts: if they match, the two expressions are equivalent and equally cheap. You can confirm equivalence by entering yours <-> theirs in the truth table calculator and checking for a tautology.

What is a prime implicant, in plain terms?

An implicant is any product term that makes the function true wherever the term is true. A prime implicant is one you cannot make any shorter — delete any literal and it would start covering a row where the function is false. Prime implicants are the only terms worth using in a minimal expression, because a non-prime term can always be replaced by the prime one containing it, at fewer literals.

Why does SOP sometimes have more terms than POS for the same function?

Because the two forms cover opposite halves of the truth table. SOP builds the function from its true rows; POS builds it from its false rows. A function true in three of sixteen rows has at most three product terms in SOP but has to exclude thirteen rows in POS, so SOP is usually cheaper — and the reverse holds for a function true in thirteen rows. Try both and take whichever the calculator reports as smaller.

How do I enter a complement?

Put an apostrophe after the thing you are complementing: A' for a single variable, (A + B)' for a whole group, AB' for A AND not-B. A prefix ! or ~ works too, and so does the word NOT with spaces around it. The apostrophe binds tighter than anything else, so AB' is A·(B′) rather than (A·B)′.

What does a result of 1 or 0 mean?

That the function does not depend on its inputs. A result of 1 means every row of the truth table is true, so the expression is a tautology and the circuit is a constant high. A result of 0 means no row is true. Both are reported with zero terms and zero literals because a constant needs no gates. If that surprises you, check the parsed truth table — a stray complement is the usual cause.

Can I minimise a function with more than six variables?

Not here. This calculator enumerates the whole truth table, so the work doubles with each variable and both the table and the prime-implicant search become impractical. Above six variables, use a heuristic minimiser such as Espresso, or express the function structurally — as an adder, a comparator, a decoder — and reuse a known-good block instead of minimising from scratch.

Does the minimal expression give the fastest circuit?

Not necessarily. Two-level minimisation targets gate inputs, not propagation delay or area in a specific technology. A minimal SOP has a fixed two-gate delay plus inverters, which is often good, but a synthesis tool mapping onto real NAND and NOR cells may find a faster or smaller implementation of the same function. Treat the minimal form as the algebraic reference point that any implementation must match logically.

References

  • The Problem of Simplifying Truth Functions, American Mathematical Monthly 59(8), 1952 — Mathematical Association of America (W. V. Quine)
  • Minimization of Boolean Functions, Bell System Technical Journal 35(6), 1956 — Bell Telephone Laboratories (E. J. McCluskey)
  • Digital Design: With an Introduction to the Verilog HDL, VHDL and SystemVerilog, 6th ed. — Pearson (M. Morris Mano and Michael D. Ciletti)
  • Logic Minimization Algorithms for VLSI Synthesis (the Espresso minimiser) — Kluwer Academic Publishers (Brayton, Hachtel, McMullen, Sangiovanni-Vincentelli)