StringMash.com

Boolean algebra calculator

Simplify any expression to its shortest sum of products, and see why.

13 characters
Updates as you type
SimplifiedAB + A'C
MintermsΣm(1, 3, 6, 7)
MaxtermsΠM(0, 2, 4, 5)
Truth table column01010011
Product of sums(A + B + C)(A + B' + C)(A' + B + C)(A' + B + C')
The Karnaugh map is drawn below for two to four variables

Show the steps
A\BC00011110000111302104051716
  1. Variables: A, B, C. 8 rows, one for each way to set them.
  2. F is 1 on rows 1, 3, 6, 7. Those are the minterms; the rows where F is 0 are the maxterms.
  3. Quine–McCluskey: pair up minterms that differ in one variable, again and again, until nothing pairs. What's left are the prime implicants: A'C (1,3), BC (3,7), AB (6,7).
  4. Essential: A'C, AB, each the only one covering some minterm.
  5. Minimal sum of products: AB + A'C. Other answers of the same size can exist when a map has a choice of groups.

Using the calculator

Type an expression such as `AB + A'C + BC`. The first line is the simplest sum of products that gives the same truth table, here `AB + A'C`. Below it is the truth table, and the rows above the table give the minterms, the maxterms and the product of sums, each with its own copy button. For two to four variables the Karnaugh map is drawn with the chosen groups ringed.

Write the answer as switches the output between `AB + A'C`, words with AND, OR and NOT, and the `&&` and `||` of code, so you can paste it straight into an if statement.

Writing an expression

Type it the way your course writes it. AND can be `·`, `*`, `&`, `&&`, `∧` or the word AND, or nothing at all, so `AB` and `A(B + C)` are ANDs. OR is `+`, `|`, `||`, `∨` or OR. NOT is a `'` after a term, as in `A'` or `(A + B)'`, or `!`, `~`, `¬` or NOT before it. XOR is `^`, `⊕` or XOR, and NAND, NOR and XNOR work as words. `0` and `1` are constants.

Single letters are variables, so `abc` means a AND b AND c. A name with a digit, mixed case or more than four letters stays whole, so `x1`, `Rain` and `sprinkler` each count as one variable. Up to eight variables fit, a table of 256 rows.

How it simplifies

Rewriting by hand with the laws (absorption, De Morgan, consensus) works, but it's easy to stop before the shortest form. This calculator does it the systematic way instead, with the Quine–McCluskey method. It lists every row where the expression is true, then merges pairs of rows that differ in just one variable, since `ABC + ABC'` is just `AB`. Merging repeats until nothing more merges. What's left are the prime implicants, the largest groups possible.

Some prime implicants are essential: they're the only way to cover one of the true rows, so they must be in the answer. If they don't cover everything, the calculator tries every combination of the rest and keeps the one with the fewest terms, then the fewest letters. The working lists each stage, so you can check it against your own.

Which operator goes first

NOT binds tightest, then AND, then XOR, then OR. So `A + BC'` means A OR (B AND (NOT C)). Brackets override it as usual. NAND sits with AND and NOR with OR, and a chain of them is read left to right, which matters because NAND and NOR aren't associative: `(A NAND B) NAND C` isn't the same as `A NAND (B NAND C)`. Bracket chains of them to be sure.

From Boole to relays

George Boole set out an algebra of logic in 1854, in An Investigation of the Laws of Thought, with true and false treated as quantities that could be added and multiplied. For eighty years it stayed a branch of logic. Then in 1937 Claude Shannon, a master's student at MIT, showed in his thesis that circuits of relays and switches obey the same rules. Switches in series act as AND and switches in parallel as OR. Boolean algebra could simplify a telephone exchange, and relays could solve Boolean algebra. Every digital circuit since has been designed this way.

Questions

How do I simplify a Boolean expression?

Type it in. The answer is the minimal sum of products, found by the Quine–McCluskey method, with each stage in the working.

What is A + AB simplified?

A. If A is true the whole thing is true, and if A is false AB is false too, so B makes no difference. This is the absorption law.

Is the simplified answer the only one?

Not always. Some functions have two or more minimal forms of the same size, and the calculator shows one of them. Any of them is correct, and the truth tables match.

What do Σm and ΠM mean?

Σm lists the minterms, the row numbers where the output is 1. ΠM lists the maxterms, the rows where it's 0. Row numbers count from 0 with the variables read as a binary number, A first.

Sources

Added . What's new