Lelifi·tools

Boolean Algebra Calculator

A Boolean expression returns only 0 or 1, so 2^n input rows cover every case for n variables. Type something like NOT (A AND B) OR C and the tool builds all 8 rows, reports the 7 minterms, and simplifies the function to A' + B' + C.

Operators: AND OR NOT XOR NAND NOR XNOR, symbols + * ! ~ ' and parentheses. Variables A, B, C, D. Writing AB means A AND B.

Evaluate one row

Simplified Result (sum of products)A' + B' + C
Expression TypeContingency
Variables FoundA, B, C
Truth Table Rows8
Minterms (output = 1)m(0), m(1), m(2), m(3), m(4), m(5), m(7)
Maxterms (output = 0)m(6)
Value for Selected InputsA=1, B=1, C=0 gives 1

All math happens in your browser. Nothing you type is uploaded or stored.

Type a Boolean expression with up to four variables, then get its truth table, minterm and maxterm lists, a simplified sum of products, and a tautology check.

By the Lelifi editors ·

Key takeaways

Truth Table Rows Double With Each Variable (2^n) 2 1 var 4 2 vars 8 3 vars 16 4 vars 32 5 vars Rows grow exponentially, not linearly
Each added variable doubles the row count, so one variable needs 2 rows, three variables need 8 rows, and five variables need 32 rows.
Karnaugh Map for NOT (A AND B) OR C Cell order along the top is BC = 00, 01, 11, 10 (only one bit changes per step) BC=00 BC=01 BC=11 BC=10 A=0 A=1 1 1 1 1 1 1 1 0 Groups: row A=0 gives A', columns 00 and 01 give B', columns 01 and 11 give C Simplified result: A' + B' + C
The same function drawn as a 2 by 4 grid. Grouping the A=0 row gives A prime, grouping the B=0 columns gives B prime, and grouping the C=1 columns gives C.
On this page
  1. What Boolean Algebra Is and Why Two Values Are Enough
  2. The Seven Operators and What Each One Does
  3. Truth Table Size: Why n Variables Need 2^n Rows
  4. Worked Example: Truth Table for NOT (A AND B) OR C
  5. De Morgan's Laws and the Duality Principle
  6. Minterms, Maxterms, and Sum of Products
  7. Karnaugh Maps and Prime Implicant Tabulation
  8. Tautologies, Contradictions, and Checking Your Work

What Boolean Algebra Is and Why Two Values Are Enough

Boolean algebra is the branch of mathematics that works with statements that are either true or false. George Boole published the idea in 1847 in a short book on logic, and the Stanford Encyclopedia of Philosophy entry on the mathematics of Boolean algebra describes the modern version as a set with two operations and a complement, closed under the rules of a distributive lattice.

Every variable in the system holds 0 or 1, and every operator returns 0 or 1. That restriction is what makes exhaustive checking possible: with a finite number of inputs there is a finite number of cases, so a truth table settles any question about an expression. No limits, no approximations, no special cases.

The practical payoff arrived in 1937, when Claude Shannon showed in his MIT master's thesis that relay circuits obey the same rules. A closed contact became 1, an open contact became 0, series wiring became AND, and parallel wiring became OR. MIT OpenCourseWare 6.042J still teaches the topic that way, because the circuit view makes the algebra easier to picture.

The Seven Operators and What Each One Does

Almost every homework problem and every datasheet uses the same small family of operations. The table below gives the rule for each one, along with the way this calculator accepts it.

Operator Reads As Output Is 1 When Accepted Input
AND Conjunction Both inputs are 1 AND, asterisk, or AB
OR Disjunction At least one input is 1 OR or the plus sign
NOT Negation The single input is 0 NOT, tilde, or trailing apostrophe
XOR Exclusive or Exactly one input is 1 XOR or the caret
NAND Not and At least one input is 0 NAND
NOR Not or Both inputs are 0 NOR
XNOR Equivalence The two inputs match XNOR

NAND and NOR earn their place because a single chip type can build every other operation. Wire both inputs of a NAND together and you get NOT. Use two NAND gates and you get AND. Three give OR. That property is why manufacturers can mass produce one gate and cover an entire design.

Truth Table Size: Why n Variables Need 2^n Rows

Each variable doubles the number of cases, because every existing combination splits into one branch where the new variable is 0 and one where it is 1. One variable has 2 rows, two variables have 4, three have 8, four have 16, and five have 32. A ten-variable problem needs 1,024 rows, which is why hand work stops at four or five.

Variables Rows (2^n) Minterm Range Typical Use
1 2 m(0) to m(1) Single switch check
2 4 m(0) to m(3) Half adder logic
3 8 m(0) to m(7) Classroom problems, seven segment drivers
4 16 m(0) to m(15) Karnaugh map limits, multiplexer logic
5 32 m(0) to m(31) Beyond comfortable hand work

Row numbers follow a fixed convention: read the variables left to right as a binary number. With three variables, the row A=1, B=0, C=1 is 101, which is decimal 5, so it is called m(5). Keeping the same order everywhere is what lets two people compare answers without confusion.

Worked Example: Truth Table for NOT (A AND B) OR C

Take the expression NOT (A AND B) OR C with three variables. There are 2^3 = 8 rows. For each row, compute A AND B, flip that result, and then OR it with C.

Row A B C A AND B Output
m(0)00001
m(1)00101
m(2)01001
m(3)01101
m(4)10001
m(5)10101
m(6)11010
m(7)11111

Seven of the 8 rows output 1, so the minterm list is m(0), m(1), m(2), m(3), m(4), m(5), and m(7). Only m(6) outputs 0, which makes the maxterm list a single entry. Because some rows give 1 and one row gives 0, the expression is a contingency rather than a tautology or a contradiction.

Writing the raw sum of products from those 7 minterms takes seven three-literal products. That form is correct but wasteful, and the next two sections show how to cut it down to three terms.

De Morgan's Laws and the Duality Principle

Two identities do most of the heavy lifting in Boolean simplification. Augustus De Morgan stated them in the 1800s, and they still start every logic course:

In words: to negate a product, negate each factor and switch to sum. To negate a sum, negate each term and switch to product. The same move works at any depth, so a whole parenthesized block can be inverted one operator at a time.

Check the first law against the table above. NOT (A AND B) alone outputs 1 whenever A and B are not both 1, which covers m(0), m(1), and m(2) out of 4 rows. The right side, A' OR B', is 1 on exactly the same rows. Identical columns mean the two expressions are the same function, not merely similar ones.

Duality extends the idea to the whole algebra. Swap AND with OR, swap 0 with 1, and leave the variables alone, and any true statement stays true. That is why the distributive law comes in pairs, A(B + C) = AB + AC and A + BC = (A + B)(A + C), and why a proof of one form usually hands you the other for free.

Minterms, Maxterms, and Sum of Products

A minterm is a product that is 1 on one row and 0 everywhere else. For three variables, m(6) corresponds to A=1, B=1, C=0, so the minterm is A B C' with every variable present exactly once, complemented where the row has a 0. Summing the minterms where a function outputs 1 always reproduces it, which is called the canonical sum of products.

Minterm A B C Product Term
m(0)000A'B'C'
m(1)001A'B'C
m(2)010A'BC'
m(5)101AB'C
m(6)110ABC'
m(7)111ABC

Maxterms work the mirror image. M(6) is the sum that is 0 only on row 6, written A' + B' + C, with each variable complemented where the row has a 1. Multiplying the maxterms of the zero rows gives the canonical product of sums.

Both forms describe the same function, so pick the shorter one. A function that is 1 on 7 of 8 rows needs 7 minterms in sum of products but only 1 maxterm in product of sums, which is why the maxterm side is usually the better starting point for sparse zero rows.

Karnaugh Maps and Prime Implicant Tabulation

A Karnaugh map arranges the truth table in a grid so that neighbors differ by one variable. Cells are ordered 00, 01, 11, 10 along each axis, never 00, 01, 10, 11, because that order keeps the wrap-around adjacency intact. Any group of 1s whose size is a power of two, drawn as a rectangle or square and allowed to wrap past the edges, becomes one product term.

For NOT (A AND B) OR C, the 2 by 4 map has a full row of 1s at A=0, a pair of columns at B=0, and a pair of columns at C=1. Reading those groups gives A', B', and C, so the function simplifies to A' + B' + C. The figure on this page draws those three groups on the same grid.

Group size maps directly to term size: 8 cells drop 3 variables and collapse to 1, 4 cells leave one variable, 2 cells leave two variables, and a single isolated cell keeps all three. Bigger groups mean shorter terms, so the goal is always to cover every 1 with as few large groups as possible.

Software uses the same reasoning in tabular form. The Quine-McCluskey method combines rows that differ in one bit, records which combinations cannot be combined further, and then picks a cover from those prime implicants. This calculator runs that tabulation for up to four variables, so a 16-row problem is solved without any grid drawing.

Tautologies, Contradictions, and Checking Your Work

Three labels cover every possible expression. A tautology outputs 1 on every row, like A OR NOT A, and its simplified form prints as 1. A contradiction outputs 0 on every row, like A AND NOT A, and prints as 0. Everything else is a contingency, meaning the output depends on the inputs, which is the normal case for real circuits.

Simplification pays off in parts. The raw sum of products for NOT (A AND B) OR C uses 3 inverters, 7 three-input AND gates, and 1 seven-input OR gate, which is 11 gates. The simplified A' + B' + C needs 2 inverters and 1 three-input OR gate, which is 3 gates. Eight fewer parts on a function with 8 rows is the kind of saving that shows up on a circuit board.

Use the truth table as a cross-check whenever you simplify by hand. Enter the original expression, note the minterm list, then enter your simplified version and compare. If the minterm lists match exactly, the two expressions are equivalent, and if a single row differs, the algebra has a mistake somewhere.

Two more habits catch most errors. Keep variables in the same order every time, since swapping A and B changes the row numbering even when the function is unchanged. And test the extreme rows first, all zeros and all ones, because those two rows expose most inversion mistakes in a few seconds.

Frequently asked questions

How many rows does a truth table need for four variables?

A truth table needs 2^n rows for n variables, so four variables require 16 rows numbered m(0) through m(15). Each row is one unique combination of A, B, C, and D, and the output column shows whether the whole expression is 1 or 0 for that combination.

What is the difference between a minterm and a maxterm?

A minterm is a product term that is 1 on exactly one row, and minterm numbers are the rows where your function outputs 1. A maxterm is a sum term that is 0 on exactly one row, so maxterm numbers are the rows where the function outputs 0. Together they cover all 2^n rows.

How do I simplify NOT (A AND B) using De Morgan's law?

De Morgan's law says the negation of a product equals the sum of the negations, so NOT (A AND B) becomes A' OR B'. The tool confirms it on <strong>4</strong> rows: the minterms are m(0), m(1), and m(2), and the simplified sum of products is A' + B'.

What does the calculator report for A XOR B?

Exclusive OR outputs 1 only when the inputs differ, so A XOR B has minterms m(1) and m(2) out of 4 rows. The simplified sum of products is A'B + AB', which uses 4 literals and 5 basic gates if you build it from AND, OR, and NOT parts.

Is A OR NOT A a tautology?

Yes. A OR NOT A outputs 1 on both rows of a two-variable-free table, so the tool labels it a tautology and prints the simplified result 1. A contradiction works the same way in reverse: A AND NOT A prints 0 on every row and returns 0.

How many minterms does a three-input XOR have?

A three-input XOR has 4 minterms, m(1), m(2), m(4), and m(7), out of 8 rows. Those are the rows with an odd number of 1 inputs, which is why parity checking uses XOR chains. The expression cannot be reduced below 4 product terms.

Can I write AND as AB instead of A AND B?

Yes. The parser accepts AND, the asterisk, and plain adjacency, so AB, A*B, and A AND B are the same product. It also accepts OR as a plus sign, NOT as a tilde or a trailing apostrophe, and the operations XOR, NAND, NOR, and XNOR by name.

What does a Karnaugh map group of 4 cells mean?

A group of 4 adjacent 1 cells removes 2 variables from the term, leaving a single literal. A group of 8 cells removes 3 variables and collapses to the constant 1. Groups must be powers of two in size: 1, 2, 4, 8, or 16 cells, and they can wrap around the edges.

Why does Boolean algebra only use two values?

The two values 0 and 1 stand for false and true, and every operator is defined by a finite table, so any expression can be checked exhaustively. Claude Shannon showed in 1937 that the same rules model switching circuits, where 1 means a closed contact and 0 means an open one.

Does the order of operations matter in a Boolean expression?

Yes. NOT binds tightest, then AND and NAND, then XOR and XNOR, then OR and NOR, and parentheses override all of it. Without parentheses, A OR B AND C is read as A OR (B AND C), which is 1 on minterms m(3), m(4), m(5), m(6), and m(7).

How much does simplification shrink a circuit?

For the function NOT (A AND B) OR C, the raw sum of 7 minterms needs 3 inverters, 7 three-input AND gates, and 1 seven-input OR gate, or 11 gates. The simplified form A' + B' + C needs just 3 gates, a saving of 8 gates on one small function.

What is the maxterm number for the row A=1, B=1, C=0?

Read A, B, C as a binary number with A as the leftmost bit, so 110 equals decimal 6. That row is m(6). If the function outputs 0 there, then 6 also appears in the maxterm list, and the maxterm itself is written A' + B' + C.

Can the calculator handle four variables with a mix of operators?

Yes. Expressions up to four variables run as 16 rows, and mixed operators such as A NAND B OR C AND D are parsed by precedence. NAND and NOR bind where AND and OR bind, so write parentheses when you want a different grouping than the default left to right reading.

What does product of sums mean and when would I use it?

A product of sums multiplies sum clauses, and each clause is 0 on one row, so it is built from the maxterms where the function outputs 0. It is the natural form for a function that is mostly 1, while sum of products is shorter for a function that is mostly 0.

Spotted a wrong number or a broken result?

More Math tools

See all Math tools

Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.