MathsDiscrete Math

Boolean Algebra
calculator.

Simplify a logic expression or a minterm list to its shortest AND, OR and NOT form.

How it's worked out

The tool first builds the truth table: it tries every mix of 0 and 1 for the variables and records the output. Rows with output 1 are the minterms. For A → B, the output is 0 only when A is 1 and B is 0, so the minterms are rows 0, 1, 3. Levin's open textbook gives that same rule for implication.

Each minterm becomes one AND term that names every variable. That sum is the canonical form, and it is always correct but often long. To shorten it, the Quine-McCluskey method merges two terms that differ in exactly one variable.

XY+XY′\displaystyle XY + XY'=X\displaystyle {}= X

Merging repeats until nothing more merges. The terms left over are the prime implicants: no letter can be dropped from them without covering a row where the output is 0. A prime implicant is essential when it is the only one covering some minterm, so every shortest answer must use it. The University of Maryland ENEE 244 lecture notes set this out as a table with one row per prime implicant and one column per minterm.

After the essential terms, the tool tries every set of the other prime implicants and keeps the one with the fewest terms, then the fewest letters. The product of sums comes from the same method run on the rows where the output is 0. The last step checks the result against the input on every row.

A Karnaugh map shows the same thing as a picture. Its rows and columns are in Gray-code order, so cells next to each other differ in one variable, and the map wraps around at its edges. Each term of the shortest answer is a block of 1, 2, 4 or 8 cells.

Worked examples

Amara designs a majority vote circuit

Three judges press a button, and the light turns on when at least two agree. The output is 1 on 4 of the 8 rows, minterms 3, 5, 6, 7.

There are 3 prime implicants and all 3 are essential, since each covers a minterm no other term covers. So nothing can be dropped, and the shortest form is AB + AC + BC. It is the carry output of a full adder.

Open this example in the tool

Jon checks a homework minterm list

His sheet gives F(A, B, C, D) as Σm(0, 1, 2, 3, 5, 7, 8, 10, 14, 15). Merging finds 6 prime implicants: A′B′, A′D, B′D′, ABC, ACD′, BCD.

Only 2 are essential: A′D and B′D′. The four corner cells of the map are one group through the wrap-around, which gives B′D′. Cells 14 and 15 are still open, and the single term ABC covers both, so the shortest form is ABC + A′D + B′D′.

Open this example in the tool

Ken tests whether a term can go

In AB + A′C + BC, when B and C are both 1, either A is 1 and AB is true, or A is 0 and A′C is true. So BC never changes the output. The tool finds 3 prime implicants, 2 of them essential, and gives AB + A′C.

Ken types his own answer as the second expression. The check says the two are equivalent on every row, which is the consensus theorem.

Open this example in the tool

Reading your result

One minimal answer, not the only one. Some functions have two shortest forms with the same count of terms and letters, where two groups could each cover a leftover cell. Both are right. Use the second expression to check yours.

Fewer terms means fewer gates. Each AND term is an AND gate and the sum is one OR gate. 4 canonical terms for A′B′C′ + A′BC′ + AB′C′ + ABC′ shrink to C′, a single inverter.

XOR stays as it is. A XOR B has no shorter two-level form than AB′ + A′B, though one XOR gate does the job. The tool only uses AND, OR and NOT.

The kind of function. A tautology is true on every row, a contradiction on none, and anything else is a contingency. Both De Morgan's law for (A + B)′ and the absorption law A + AB = A pass the equivalence check, as they should.

Common mistakes

  • Reading the map in plain binary order. The columns go 00, 01, 11, 10, so that neighbors differ in one bit. Writing them as 00, 01, 10, 11 joins cells that should not group.
  • Missing the wrap-around. The left and right edges touch, and so do the top and bottom. The four corners of a 4-variable map can form one group.
  • Groups that are not a power of two. A block of 3 or 6 cells is not one term. Split it into blocks of 2 or 4.
  • Mixing up the converse. A → B and B → A are not the same. They differ when A is 0 and B is 1.

Questions people ask

Often both are right: a function can have two shortest forms that group a leftover cell in different ways. Check that both have the same number of terms and letters, then test them against each other. If they differ on a row, look for a missed wrap-around group or a misread cell.

Sources