Math
Boolean algebra calculator
Type a logic expression in whatever notation you use. The calculator builds the truth table, writes the canonical sum-of-products and product-of-sums forms, and minimises the expression with the Quine–McCluskey method, showing the prime implicant chart.
NOT: A', ¬A, !A or NOT A. AND: A·B, AB, A*B, A&B, A∧B or A AND B. OR: A+B, A|B, A∨B or A OR B. XOR: A⊕B, A^B or A XOR B. Also NAND, NOR, → and ↔. 0 and 1 are constants.
Canonical SOP (sum of minterms):
F = Σm(1, 3, 6, 7) = A′B′C + A′BC + ABC′ + ABC
Canonical POS (product of maxterms):
F = ΠM(0, 2, 4, 5) = (A + B + C)(A + B′ + C)(A′ + B + C)(A′ + B + C′)
| # | A | B | C | F | G |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 |
| 2 | 0 | 1 | 0 | 0 | 0 |
| 3 | 0 | 1 | 1 | 1 | 1 |
| 4 | 1 | 0 | 0 | 0 | 0 |
| 5 | 1 | 0 | 1 | 0 | 0 |
| 6 | 1 | 1 | 0 | 1 | 1 |
| 7 | 1 | 1 | 1 | 1 | 1 |
| Prime implicant | Covers | m1 | m3 | m6 | m7 |
|---|---|---|---|---|---|
| A′C (essential) | 1, 3 | × | × | ||
| BC | 3, 7 | × | × | ||
| AB (essential) | 6, 7 | × | × |
Show the working, step by step
Read the expression (NOT binds tightest, then AND, XOR, OR). Fully bracketed it is:
F = ((A·B) + (A′·C)) + (B·C)
Evaluate F for all 2^3 = 8 combinations of A, B, C. The rows where F = 1 are the minterms.
F = Σm(1, 3, 6, 7) F = ΠM(0, 2, 4, 5)
Quine–McCluskey: write each minterm in binary and group by the number of 1s. Two terms in neighbouring groups that differ in exactly one bit combine, with a dash in that bit (XY + XY′ = X). Repeat until nothing combines. Terms that never combine are the prime implicants.
Prime implicants (3):
0-1 = A′C covers m1, m3 -11 = BC covers m3, m7 11- = AB covers m6, m7
A prime implicant is essential if it is the only one covering some minterm. Here the essential prime implicants cover every minterm.
essential: A′C, AB F = AB + A′C
Compare with G = (A·B) + (A′·C) row by row.
Every row matches, so F ≡ G.
| 1s | Pattern | Minterms | |
|---|---|---|---|
| 1 | 001 | 1 | ✓ combined |
| 2 | 011 | 3 | ✓ combined |
| 2 | 110 | 6 | ✓ combined |
| 3 | 111 | 7 | ✓ combined |
| 1s | Pattern | Minterms | |
|---|---|---|---|
| 1 | 0-1 | 1, 3 | prime |
| 2 | -11 | 3, 7 | prime |
| 2 | 11- | 6, 7 | prime |
Notation the calculator accepts
| Operation | You can type | Precedence |
|---|---|---|
| NOT | A' ¬A !A ~A NOT A | Highest |
| AND | AB A·B A*B A&B A∧B A AND B | Next |
| XOR | A⊕B A^B A XOR B | Next |
| OR | A+B A|B A∨B A OR B | Next |
| Implies, iff | A→B A->B, A↔B A<->B | Lowest |
Variables are single letters, optionally followed by digits (x1, x2). A run of letters such as
ABC means A·B·C, the usual textbook shorthand, and the words AND, OR, NOT, XOR,
NAND, NOR and XNOR are read as operators. 0 and 1 are the constants. Use brackets whenever the
precedence is not what you want: (A + B)' is NOR, A + B' is not.
A worked example
The default expression is F = AB + A′C + BC.
- Truth table. F is 1 on rows 1 (001), 3 (011), 6 (110) and 7 (111), so F = Σm(1, 3, 6, 7) and F = ΠM(0, 2, 4, 5).
- Canonical forms. SOP: A′B′C + A′BC + ABC′ + ABC. POS: (A + B + C)(A + B′ + C)(A′ + B + C)(A′ + B + C′).
- Combine. 001 and 011 differ only in B, giving 0-1 = A′C. 011 and 111 give -11 = BC. 110 and 111 give 11- = AB. Nothing combines further, so these three are the prime implicants.
- Chart. m1 is covered only by A′C, and m6 only by AB, so both are essential. Together they cover m1, m3, m6 and m7, so BC is not needed.
- Result: F = AB + A′C, four literals instead of six. The comparison box holds AB + A′C, and the calculator confirms that the two are equivalent.
Laws worth knowing
| Law | AND form | OR form |
|---|---|---|
| Identity | A·1 = A | A + 0 = A |
| Complement | A·A′ = 0 | A + A′ = 1 |
| Idempotent | A·A = A | A + A = A |
| Absorption | A(A + B) = A | A + AB = A |
| De Morgan | (AB)′ = A′ + B′ | (A + B)′ = A′B′ |
| Distributive | A(B + C) = AB + AC | A + BC = (A + B)(A + C) |
| Consensus | (A + B)(A′ + C)(B + C) = (A + B)(A′ + C) | AB + A′C + BC = AB + A′C |
The second distributive law, A + BC = (A + B)(A + C), has no counterpart in ordinary arithmetic and is a common source of slips. Type both sides into the calculator to see that they agree on all eight rows.
About the minimisation
Quine–McCluskey finds every prime implicant, takes the essential ones, and then chooses the fewest extra implicants that cover the remaining minterms (fewest literals on a tie). The result is a minimal sum of products. There can be more than one minimal answer; the calculator shows one. A product-of-sums minimum, or a form using XOR, can sometimes be shorter still: A ⊕ B needs four literals as a sum of products, A′B + AB′.
Common mistakes
- Reading AB + C as A(B + C). AND binds more tightly than OR, so it is (AB) + C.
- Misapplying De Morgan. (AB)′ is A′ + B′, not A′B′.
- Writing a prime on a bracket but meaning one letter. (A + B)′ = A′B′, while A + B′ keeps A as it is.
- Mixing up the variable order in minterm numbers. Here the first variable alphabetically is the most significant bit: with A, B, C, m6 is 110, that is ABC′.
Common questions
How do I simplify a Boolean expression?
Either apply the laws of Boolean algebra by hand (absorption, De Morgan, consensus and so on) or do it systematically: list the minterms from the truth table, combine minterms that differ in one variable, and pick the fewest prime implicants that cover them all. That is the Quine–McCluskey method, which this calculator uses. A Karnaugh map does the same combining visually, for up to four or five variables.
What is the difference between SOP and POS?
Sum of products (SOP) is an OR of AND terms, such as AB + A′C; it lists the input rows where the output is 1. Product of sums (POS) is an AND of OR terms, such as (A + B)(A′ + C); it rules out the rows where the output is 0. The canonical forms use full-length terms, one per row: minterms for SOP and maxterms for POS.
What are minterms and maxterms?
A minterm is an AND of every variable, each plain or complemented, that is 1 on exactly one row of the truth table. For variables A, B, C, row 3 (011) has minterm A′BC, written m3. A maxterm is an OR of every variable that is 0 on exactly one row: row 3 has maxterm (A + B′ + C′), written M3. A function is the sum of its minterms, Σm, and the product of its maxterms, ΠM, and the two index lists are complementary.
What is the consensus theorem?
AB + A′C + BC = AB + A′C. The term BC is redundant: whenever B and C are both 1, either A is 1 and AB covers it, or A is 0 and A′C covers it. It is the default example here, and the prime implicant chart shows why: BC is a prime implicant, but its minterms m3 and m7 are already covered by the essential implicants A′C and AB.
How do I check whether two Boolean expressions are equivalent?
Two expressions are equivalent when they give the same output for every combination of inputs, so compare their truth tables row by row. Type the second expression in the comparison box. If they differ, the calculator names an input where they do; for A ⊕ B and A + B that is A = 1, B = 1, where XOR gives 0 and OR gives 1.
Related calculators
-
Set calculator
Union, intersection and complement: the set version of OR, AND and NOT.
-
Number system converter
Binary, octal, decimal and hexadecimal conversions.
-
Relation calculator
Boolean matrices and Warshall’s algorithm.
-
Discrete math calculator
Recurrences, inclusion–exclusion and the pigeonhole principle.