Computing & tech · Course · Binary series

Boolean algebra: learning to calculate with true and false

Reading a truth table is not enough: to design a circuit, you must be able to write, transform and simplify an expression without changing its meaning. The rules, the method and the logic gates, with examples checked step by step.

Quick facts

Values
0 and 1false and true, nothing else
Basic operations
NOT, AND, ORevaluated in this order of precedence
Rules of calculation
About teneach one checkable with a truth table
De Morgan's laws
1847published in Augustus De Morgan's “Formal Logic”
Adding two bits
2 gatesan XOR for the sum, an AND for the carry
Universal gate
NAND (or NOR)enough to build every other gate

Prerequisites

Having read Binary: how 0 and 1 carry all information (parts 1 and 3), or at least knowing what a bit and a truth table are.

Reading a truth table is not enough. To design a circuit, you need to calculate with these expressions: write them, transform them, simplify them and, above all, check that their meaning has not changed.

The stakes are concrete: in a circuit, a shorter expression needs fewer gates, so the component is smaller, cheaper and uses less power.

The article follows three steps. First we learn to calculate (parts 1 to 5: read, evaluate, prove, simplify). Then we learn to negate an expression (part 6: De Morgan's laws). Finally we build the component that carries out an expression, the logic gate, with its standard symbols (part 7). Parts 8 and 9 open further leads and set out the limits.

It is written for two audiences: beginners, who follow the main thread with worked numbers, and specialists, who will find deeper material in the “Going further” boxes. Every term is defined when it first appears and listed in the glossary.

Key takeaway

Boolean algebra is an algebra in which everything can be checked. Since there are only two values, a rule is proven as soon as it has been tested on every possible case.

01Quick reminder: variables, operations, truth tables

A Boolean variable is a quantity that can only be 0 (false) or 1 (true). It stands for a yes-or-no question: A = “the door is open”, B = “it is raining”.

Three basic operations, familiar from everyday language:

  • NOT (negation, written ¬A): flips the value.
  • AND (conjunction, written A·B): is 1 only if both are 1.
  • OR (disjunction, written A+B): is 1 if at least one of the two is 1.

A truth table lists every combination of inputs and the matching output:

AB¬AA·B (AND)A+B (OR)
00100
01101
10001
11011

These operations can be built with switches: in series for AND, in parallel for OR (see the article on binary).

A fourth operation is widely used: exclusive OR (XOR, written A⊕B). It is 1 when the two inputs are different: one or the other, but not both. We will see that it can be built from the first three.

02Reading an expression: order of precedence

When you write an expression such as A + B·C, you need to know where to start. As in arithmetic, where multiplication comes before addition, the order is: NOT, then AND, then OR. So A + B·C means A + (B·C).

Worked check: with A = 1, B = 0, C = 0. First B·C = 0·0 = 0, then A + 0 = 1. Had we wrongly read (A + B)·C, we would have found (1 + 0)·0 = 0. The two readings give different results, hence the importance of precedence, and of brackets when in doubt.

Method for evaluating an expression: replace the variables with their values, work out the NOTs first, then brackets and ANDs, then ORs. With a little practice, you can do it in your head.

03Careful: this is not school algebra

Bridge to understanding

The “+” and “·” symbols look like addition and multiplication, but the rules are not the same. Three differences that surprise people:

  • 1 + 1 = 1 (“true OR true” is still “true”). There is no 2 in Boolean algebra: only 0 and 1 exist.
  • A·A = A and A + A = A: repeating a condition changes nothing. “It is raining AND it is raining” just means “it is raining”.
  • A + B·C = (A + B)·(A + C): distribution works “both ways”, which is not true for ordinary numbers. Let us check with A = 1, B = 0, C = 0: left side 1 + 0·0 = 1; right side (1+0)·(1+0) = 1·1 = 1. With A = 0, B = 1, C = 1: left side 0 + 1 = 1; right side (0+1)·(0+1) = 1. And a case that gives 0, with A = 0, B = 1, C = 0: left side 0 + 1·0 = 0; right side (0+1)·(0+0) = 1·0 = 0.

Three cases do not prove a rule. The full table of 8 combinations does: the “A + B·C” and “(A + B)·(A + C)” columns are identical on every row.

ABCB·CA + B·CA + BA + C(A + B)·(A + C)
00000000
00100010
01000100
01111111
10001111
10101111
11001111
11111111

04The rules of calculation, explained

These rules are called laws. They appear, sometimes under slightly different names, in every Boolean algebra course.

RuleFormulaIn plain words
IdentityA·1 = A ; A + 0 = AAND with “true” changes nothing; OR with “false” changes nothing
Annulment (null element)A·0 = 0 ; A + 1 = 1AND with “false” is always false; OR with “true” is always true
IdempotenceA·A = A ; A + A = ARepeating is pointless
ComplementA·¬A = 0 ; A + ¬A = 1A thing and its opposite are never both true; one of the two always is
Double negation¬(¬A) = ADenying twice is affirming
CommutativityA·B = B·A ; A+B = B+AOrder does not matter
Associativity(A·B)·C = A·(B·C) ; (A+B)+C = A+(B+C)Group however you like
DistributivityA·(B+C) = A·B + A·C ; A+(B·C) = (A+B)·(A+C)Expansion works both ways
AbsorptionA + A·B = A ; A·(A+B) = AIf A is true, the rest is unnecessary

Two ways to prove a rule

1. With a truth table: test every case. Take absorption, A + A·B = A:

ABA·BA + A·BEqual to A?
0000yes
0100yes
1001yes
1111yes

With n variables there are 2 to the power n rows: 4 rows for 2 variables, 8 for 3, 16 for 4. It is the safest method, but it gets long as n grows.

2. By calculation: apply the rules from the table, step by step:

A + A·B = A·1 + A·B (identity) = A·(1 + B) (distributivity) = A·1 (1 + B = 1, annulment) = A (identity).

Calculation is shorter, but you need to know which rule to apply. That is what the following examples are for.

05Three guided examples and a method

Example 1: simplifying an expression

We want to simplify A·B + A·¬B.

  1. Factor out A (distributivity in reverse): A·(B + ¬B).
  2. Now B + ¬B = 1 (complement: one of the two is necessarily 1).
  3. So A·1 = A (identity).

The expression reduces to A: B had no influence. In practice: “the door is open and it is raining, or the door is open and it is not raining” just means “the door is open”.

Example 2: a house alarm

An alarm must ring if it is armed (E) AND a door is open (P) OR a window is broken (V). It can be written in two equivalent ways:

  • Factored form: S = E·(P + V). It needs 2 gates (an OR, then an AND).
  • Expanded form: S = E·P + E·V. It needs 3 gates (two ANDs, then an OR).

Worked check: E = 1, P = 0, V = 1. Factored form: 1·(0+1) = 1·1 = 1. Expanded form: 1·0 + 1·1 = 0 + 1 = 1. Same result, but the first costs one gate less. Multiplied across millions of circuits, the saving matters: it is exactly what Shannon was after with relays.

Example 3: from truth table to expression (majority vote)

A circuit must output 1 when at least two of its three inputs A, B, C are 1. Its truth table:

ABCOutput M
0000
0010
0100
0111
1000
1011
1101
1111

Step 1: write one term per row where the output is 1. Each term is an AND that is true only for that combination (variables equal to 0 are negated):

M = ¬A·B·C + A·¬B·C + A·B·¬C + A·B·C

Step 2: simplify. Use idempotence to write the last term A·B·C three times (the result does not change), then group in pairs:

  • ¬A·B·C + A·B·C = B·C·(¬A + A) = B·C
  • A·¬B·C + A·B·C = A·C·(¬B + B) = A·C
  • A·B·¬C + A·B·C = A·B·(¬C + C) = A·B

Result: M = A·B + A·C + B·C. Three ANDs and two ORs instead of four three-variable terms. This “majority” function is no toy: it is the carry of a full adder (part 7).

Method: simplify in 5 steps

  1. Look. Spot the terms (separated by +) and the factors they share.
  2. Reorder. Use commutativity and associativity to place similar terms side by side.
  3. Find a pair. Two terms that differ by only one variable (A·B + A·¬B): factor, apply the complement (B + ¬B = 1), then identity.
  4. Look for a special case. Absorption (A + A·B), idempotence (A + A), null element (A·0, A + 1), double negation, and De Morgan's laws for any negation sitting over a bracket. These laws say how to negate a compound expression: negating an AND gives the OR of the negations, negating an OR gives the AND of the negations, i.e. ¬(A·B) = ¬A + ¬B and ¬(A + B) = ¬A·¬B. They are explained and checked in part 6.
  5. Check. Test the result on at least two sets of values, or with a full truth table. An unchecked simplification is not a simplification.

Example. Simplify B·A + A·¬B. (2) Commutativity: B·A = A·B, so A·B + A·¬B. (3) Pair: A·(B + ¬B) = A·1 = A. (5) Check: A = 1, B = 0 → 0 + 1 = 1 = A; A = 0, B = 1 → 0 + 0 = 0 = A. Answer: A.

Key takeaway

Simplifying means spotting pairs of terms that differ by a single variable (A·B + A·¬B), then applying the complement (B + ¬B = 1) to make it disappear.

Practice

A set of worked exercises will accompany this article (coming soon): 54 exercises in 18 levels of increasing difficulty, over four pages, from evaluating a single operation up to Karnaugh maps.

06De Morgan's laws: negating a compound statement

Who was De Morgan?

Augustus De Morgan (1806-1871) was a British mathematician and logician. In 1847 he published “Formal Logic”, which contains the two laws that bear his name. In the same year, almost at the same moment, George Boole published “The Mathematical Analysis of Logic”. The two men corresponded and renewed logic in parallel, by different routes: Boole through algebra, De Morgan by extending classical logic.

These two laws say how to negate an AND or an OR:

  • ¬(A·B) = ¬A + ¬B
  • ¬(A+B) = ¬A · ¬B

A mnemonic sums up the method: “break the line, change the sign”. You “break” the negation bar, put it on each variable, and swap AND and OR.

In plain English: negating “it is raining AND it is windy” gives “it is not raining OR it is not windy” (one of the two missing is enough). And negating “I'll have tea OR coffee” gives “I'll have no tea AND no coffee” (neither one).

Worked check for the first law: with A = 1 and B = 0, the left side is ¬(1·0) = ¬0 = 1; the right side ¬1 + ¬0 = 0 + 1 = 1. With A = 1 and B = 1: ¬(1·1) = 0 and ¬1 + ¬1 = 0 + 0 = 0.

Where is it used? In circuit design (to turn an AND into an OR and cut down the number of gate types), but also in search engines and programs: looking for documents that do not contain both “cats” AND “dogs” is the same as looking for those that lack “cats” OR lack “dogs”.

07From rules to logic gates

A logic gate is an electronic circuit that carries out a Boolean operation: it takes one or more bits as input and outputs one bit. Boolean algebra provides the rules; gates implement them in hardware.

The common gates

ABANDORNANDNORXOR
0000110
0101101
1001101
1111000
  • NOT (inverter): one input, inverted output.
  • NAND = “NOT-AND”: the inverse of AND. NOR = “NOT-OR”: the inverse of OR.
  • XOR: is 1 if the two inputs are different. It is built from the three basic operations: A⊕B = A·¬B + ¬A·B. Check: A = 1, B = 0 → 1·1 + 0·0 = 1; A = 1, B = 1 → 1·0 + 0·1 = 0.

Gate symbols

On a circuit diagram, each gate has a symbol. Those below are the “distinctive-shape” symbols of the ANSI/IEEE 91-1984 standard. The international standard IEC 60617-12 also offers rectangular symbols, and both families are in use. Three reading rules: the shape gives the basic function (flat back for AND, curved back for OR, triangle for NOT); a small circle, the bubble, on an output means “inverted”; XOR is recognised by the extra curved line at the input of the OR symbol.

Symbols of the six common logic gates Six distinctive-shape symbols: NOT (triangle and bubble), AND (flat back, rounded nose), OR (curved back, pointed tip), NAND (AND with a bubble), NOR (OR with a bubble), XOR (OR with an extra curved line on the input side). AYNOT (NON) ABYAND (ET) ABYOR (OU) ABYNAND (NON-ET) ABYNOR (NON-OU) ABYXOR (OU exclusif)
Figure 1 — The six common gates, distinctive-shape symbols (ANSI/IEEE 91). The bubble at the output means “inverted”.
GateHow to recognise itExpressionY for A, B = 00, 01, 10, 11
NOTTriangle with a bubble at the outputY = ¬AA = 0 → 1; A = 1 → 0
ANDFlat back, rounded noseY = A·B0, 0, 0, 1
ORCurved back, pointed noseY = A + B0, 1, 1, 1
NANDAND symbol with a bubbleY = ¬(A·B)1, 1, 1, 0
NOROR symbol with a bubbleY = ¬(A + B)1, 0, 0, 0
XOR (exclusive OR)OR symbol with an extra curved line at the inputY = A·¬B + ¬A·B0, 1, 1, 0

Bridge to understanding

The bubble is De Morgan's law drawn. A NAND can also be drawn as an OR symbol with a bubble on each input: ¬(A·B) = ¬A + ¬B. Both drawings show the same circuit. Reading a bubble means reading a negation.

What are they for? Adding two bits

ABA + B (in binary)CarrySum
000000
010101
100101
111010

The “Sum” column is exactly the XOR table, and the “Carry” column is the AND table. Two gates are therefore enough to build a half adder. It is “half” because it cannot take in a carry from the previous column.

A full adder takes three bits: A, B and the incoming carry. Its sum is an XOR of all three, and its outgoing carry is 1 if at least two of the three inputs are 1: the “majority” function from example 3. By chaining full adders, numbers of several bits can be added. Claude Shannon already presented a base-two adder at the end of his 1937 thesis.

Worked example: 5 + 3 on 4 bits. 0101 + 0011: rightmost column 1+1 = 0, carry 1; second column 0+1+1 = 0, carry 1; third column 1+0+1 = 0, carry 1; fourth column 0+0+1 = 1. Result: 1000, i.e. 8. The calculation is correct.

Beyond addition

Combined, gates also make comparators (is A equal to B?), multiplexers (choosing one input among several, like a railway switch) and decoders (activating one line according to a code). A processor's arithmetic unit is an assembly of these building blocks.

Going further: the NAND gate is universal

With NAND gates alone, you can build all the others:

  • NOT A = A NAND A. Check: A = 0 → 0 NAND 0 = 1; A = 1 → 1 NAND 1 = 0. That is indeed the inverse. Cost: 1 gate.
  • A AND B = NOT(A NAND B). Cost: 2 NAND gates (one for the NAND, one wired as an inverter).
  • A OR B = (NOT A) NAND (NOT B), by De Morgan: ¬(¬A·¬B) = A + B. Cost: 3 NAND gates (two inverters, one NAND).

That is an industrial advantage: a single basic gate to produce and optimise. The same holds for the NOR gate. NAND, like NOR, is called a universal gate.

08Going further

Normal forms: sum of products and product of sums

The method of example 3 produces a disjunctive normal form (a sum of products): any Boolean function can be written this way, with one term per truth-table row where the output is 1. Conversely, the conjunctive normal form writes a product of sums, with one factor per row where the output is 0. These forms are not the shortest, but they always exist: they are a starting point for simplification.

Duality

Every rule of Boolean algebra remains true if AND and OR are swapped, along with 0 and 1. Example: A + 0 = A becomes A·1 = A; A + A·B = A becomes A·(A + B) = A. That is why the rules come in pairs in the table of part 4.

Karnaugh maps and Quine-McCluskey

Who was Karnaugh? Maurice Karnaugh (1924-2022) was an American physicist and mathematician, born in New York. A researcher at Bell Labs, he published “The Map Method for Synthesis of Combinational Logic Circuits” in 1953, refining the chart proposed in 1952 by the American computer scientist Edward W. Veitch.

To simplify functions of a few variables by hand, there is a visual tool: the Karnaugh map. It lays out the truth table on a grid where neighbouring 1s, which differ by only one variable, can be grouped at a glance: it is exactly the simplification A·B + A·¬B = A done graphically. Beyond a few variables, algorithms such as the Quine-McCluskey method, developed in the 1950s, take over, and today automatic synthesis tools do.

The same rules in other fields

De Morgan's laws and the other rules also apply to set theory: “union” plays the role of OR, “intersection” that of AND, “complement” that of NOT. They also apply to search queries with the AND, OR and NOT operators.

Today's Boolean algebra is not quite Boole's

In Boole's system (1847 and 1854), the “+” sign acts as an exclusive OR: it joins classes that do not overlap. In 1864, in “Pure Logic”, the British logician and economist William Stanley Jevons (1835-1882) redefined “+” as an inclusive OR, the one used in this article, which makes the rule A + A = A possible (idempotence, part 4). He had suggested it to Boole in an 1863 letter; Boole refused, because the rule would have undermined his reliance on the ordinary algebra of numbers. Charles Sanders Peirce made the same choice independently in 1867. It is this version, extended by Peirce and Ernst Schröder, that became the Boolean algebra taught today. Jevons also built, in 1869, a “logic piano”, one of the first reasoning machines.

09Limits and misconceptions

  • The “+” is not addition. This is the most common confusion: 1 + 1 = 1 in Boolean algebra.
  • A truth table describes a single instant. It says nothing about time: a Boolean expression has no memory. The flip-flop, subject of the next article in the series, is what brings memory.
  • Rule names are not universal. Some rules (such as A·B + A·¬B = A) have different names depending on the course, or no name at all. What matters is being able to check them, not recite them.
  • Boole was not thinking of computers. He wanted to describe the laws of thought; it was Shannon, Nakashima and others who showed, in the 1930s, that the same algebra describes circuits.

10Conclusion

Boolean algebra is a surprisingly simple algebra: two values, three operations, about ten rules, and the ability to check everything with a truth table. It lets you simplify an expression without changing its meaning, and so build smaller circuits and write clearer conditions. The worked exercises (coming soon) will let you check, step by step, that the rules have sunk in.

But a Boolean expression remembers nothing: it computes a result from the inputs present now. For a circuit to remember, a different kind of component is needed. That is the subject of the next article in the series: the flip-flop, or how data becomes memory.

11Glossary

  • Absorption: the rule A + A·B = A (and its dual A·(A + B) = A).
  • Annulment (null element): A·0 = 0 and A + 1 = 1.
  • Associativity: (A·B)·C = A·(B·C) and (A + B) + C = A + (B + C); brackets in a chain of ANDs or ORs do not matter.
  • Boolean algebra: an algebra whose variables are only 0 or 1, with the operations AND, OR, NOT.
  • Boolean variable: a quantity that can only be 0 or 1.
  • Commutativity: A·B = B·A and A + B = B + A; order does not matter.
  • Complement: the rules A·¬A = 0 and A + ¬A = 1.
  • De Morgan's laws: rules for negating an AND or an OR: ¬(A·B) = ¬A + ¬B and ¬(A+B) = ¬A·¬B.
  • Disjunctive normal form: an expression written as a sum (OR) of products (AND), one term per row equal to 1 in the truth table.
  • Distributivity: A·(B + C) = A·B + A·C, and also A + B·C = (A + B)·(A + C).
  • Double negation: ¬(¬A) = A.
  • Duality: the principle that a rule remains true when AND and OR, and 0 and 1, are swapped.
  • Full adder: a circuit that adds three bits (A, B and the incoming carry).
  • Half adder: a circuit that adds two bits; sum = XOR, carry = AND.
  • Idempotence: the rules A·A = A and A + A = A.
  • Identity: A·1 = A and A + 0 = A.
  • Karnaugh map: a grid that lays out a truth table so that simplifications can be spotted at a glance.
  • Logic gate: a circuit that carries out a Boolean operation.
  • Multiplexer: a circuit that selects one input among several, like a railway switch.
  • NAND, NOR: “NOT-AND” and “NOT-OR” gates, the inverses of AND and OR.
  • Truth table: a table of outputs for every possible input.
  • XOR (exclusive OR): is 1 if the two inputs differ; A⊕B = A·¬B + ¬A·B.

Sources

Reference textbooks

  1. Kuphaldt (Tony R.), Lessons In Electric Circuits, vol. IV, chapter 7 — Boolean Algebra — accessed November 2026
  2. Kuphaldt (Tony R.) — Boolean Rules for Simplification — accessed November 2026

Boole (original text)

  1. Project Gutenberg — Boole (George), An Investigation of the Laws of Thought, 1854 — accessed November 2026

Boolean algebra: laws and method

  1. University of Washington (CSE 370) — Lecture 3: Boolean Algebra — accessed October 2026
  2. University of Toronto (CSC 258) — Some Boolean algebra identities — accessed October 2026
  3. Brooklyn College (CUNY) — Laws of Boolean algebra — accessed October 2026
  4. University College Cork — Biographical history: George Boole — accessed October 2026

Gate symbols

  1. Texas Instruments (F. A. Mann) — Overview of IEEE Standard 91-1984: Explanation of Logic Symbols — accessed November 2026
  2. IEEE Standards Association — IEEE/ANSI 91/91a-1991, Graphic Symbols for Logic Functions — accessed November 2026
  3. Spinning Numbers (Willy McAllister) — Digital logic gates — accessed November 2026
  4. Wikipedia — Logic gate — accessed November 2026

De Morgan

  1. Wikipedia — De Morgan's laws — accessed October 2026
  2. ProofWiki — De Morgan's Laws — accessed October 2026
  3. Encyclopædia Britannica — History of logic: Boole and De Morgan — accessed November 2026
  4. New Mexico State University (J. H. Barnett) — Origins of Boolean Algebra in the Logic of Classes — accessed November 2026
  5. University of Waterloo (S. Burris) — Notes on De Morgan, Boole and Jevons — accessed November 2026

Jevons and modern Boolean algebra

  1. Stanford Encyclopedia of Philosophy (S. Burris, J. Legris) — The Algebra of Logic Tradition — accessed November 2026
  2. Stanford Encyclopedia of Philosophy (S. Burris) — George Boole — accessed November 2026
  3. IEEE Computer Society — W. Stanley Jevons — accessed November 2026
  4. Internet Archive — Peirce (Charles S., dir.), Studies in Logic, 1883 — accessed November 2026

Shannon and the adder

  1. Encyclopedia.com — Shannon, Claude Elwood — accessed October 2026

Karnaugh, Veitch, Quine-McCluskey

  1. Transactions of the AIEE (M. Karnaugh, 1953) — The Map Method for Synthesis of Combinational Logic Circuits — accessed November 2026
  2. Wikipedia — Karnaugh map — accessed October 2026
  3. Wikipedia — Edward W. Veitch — accessed October 2026
  4. Wikipedia — Maurice Karnaugh — accessed October 2026
  5. Technische Hochschule Köln — Zwei Verfahren zur Minimierung von logischen Schaltungen — accessed October 2026