Why This Matters
A one-bit full adder has three inputs and two outputs. Its carry output is . Written without Boolean algebra, the same circuit might be drawn from a full truth table with four separate product terms, wasting gates and wire delay.
Chip design tools still start from this algebra. A compiler, hardware description language, or hand schematic turns predicates into Boolean functions , rewrites them using identities, then maps the result to NAND, NOR, multiplexers, lookup tables, or standard cells.
Core Definitions
Boolean value
A Boolean value is one of two symbols, usually written and . In circuits, and denote voltage ranges, not exact voltages. In logic, they denote false and true.
Boolean function
An -input Boolean function is a map . The function is completely specified by its truth table with rows.
Literal, minterm, maxterm
A literal is a variable or its complement . A minterm is an AND of one literal for each variable. A maxterm is an OR of one literal for each variable.
Canonical normal form
Canonical sum-of-products lists every input row where the function is . Canonical product-of-sums lists every input row where the function is .
Operators and Truth Tables
The four operators used constantly are AND, OR, NOT, and XOR. We write AND by juxtaposition or , OR by , NOT by a bar, and XOR by .
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 |
XOR differs from OR in exactly one row. For , OR returns while XOR returns . This is the source of many bugs when a bit mask operation is mistaken for a logical condition.
A truth table for three inputs has eight rows. The majority-of-three function returns when at least two inputs are .
| majority | |||
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 |
The canonical SOP is . Boolean algebra reduces it to , the carry output of a full adder.
The same operators act on all bits of a machine word in C. This example uses one byte so the layout fits on one line.
#include <stdint.h>
#include <stdio.h>
int main(void) {
uint8_t x = 0b10110100;
uint8_t mask = 0b00001111;
uint8_t low = x & mask; // 00000100
uint8_t set = x | mask; // 10111111
uint8_t flip = x ^ mask; // 10111011
uint8_t inv = (uint8_t)~x; // 01001011
printf("%02x %02x %02x %02x\n", low, set, flip, inv);
}
Byte layout for the first operation:
x 10110100
mask 00001111
x&mask 00000100
Each output bit is computed independently. Bit 2 survives because both inputs have a there; bit 7 becomes because the mask has a .
Algebraic Identities
Boolean algebra has identities similar to ordinary algebra, plus identities that depend on two-valued logic.
| Name | Identity |
|---|---|
| Idempotence | and |
| Commutativity | and |
| Associativity | and |
| Distributivity | and |
| Complement | and |
| Identity | and |
| Domination | and |
| Absorption | and |
The second distributive law, , is valid in Boolean algebra but has no direct analogue in ordinary arithmetic. Verify it by cases. If , both sides equal . If , both sides equal .
Absorption is the standard cleanup after expanding a circuit expression. Starting from , factor . Since , the expression is . In a circuit this removes the AND gate and the OR gate; the output wire is just .
A small instruction-selection example shows the same algebra in software. Suppose an execution unit should start when valid is true and either is_add or is_sub is true.
uint8_t issue(uint8_t valid, uint8_t is_add, uint8_t is_sub) {
return valid & (is_add | is_sub);
}
If the decoder guarantees is_add | is_sub only when valid is already true, then valid & (is_add | is_sub) absorbs to is_add | is_sub. That rewrite is legal only with the stated invariant.
De Morgan's Laws and Gate Rewrites
De Morgan's laws move negation across AND and OR.
They matter because real gate libraries often prefer NAND and NOR gates. A NAND is . A NOR is . By pushing bubbles through a schematic, a designer can replace mixed NOT, AND, and OR gates with a small number of NAND or NOR gates.
Consider this expression:
Apply De Morgan twice.
The original circuit has an OR for , an AND with , and a final inverter. The rewritten form has three inverters, one AND, and one OR. That is not always fewer gates. But if the target library has cheap NAND gates, implement the original as one OR feeding one NAND, or rewrite the OR itself with NAND gates.
A NAND-only implementation of follows from De Morgan:
Using NAND, and . Then .
SOP, POS, and Karnaugh Maps
Canonical SOP is formed from rows where . For variables , row contributes . If is on rows , then
After simplification, this becomes .
Canonical POS is formed from rows where . A maxterm is false on exactly one row. For row , the maxterm is . The variable is complemented when the row value is , because the OR term must evaluate to on that row.
For majority-of-three, the zero rows are .
A Karnaugh map arranges truth-table cells so adjacent cells differ in one variable. For four variables, use Gray-code order on both axes. Let on minterms .
| 00 | 01 | 11 | 10 | |
|---|---|---|---|---|
| 00 | 1 | 0 | 0 | 1 |
| 01 | 0 | 1 | 1 | 0 |
| 11 | 0 | 1 | 1 | 0 |
| 10 | 1 | 0 | 0 | 1 |
The four corner cells form one wraparound group. They share and , so the term is . The central group shares and , so the term is . Thus , which is XNOR . Inputs and vanished.
Algorithmic Minimization
Karnaugh maps work well for three or four variables. Five variables are possible but error-prone. More inputs need algorithms.
Quine-McCluskey groups minterms by the number of bits, combines terms that differ in one position, and repeats until no more combinations exist. A dash means the variable disappeared.
m0 0000
m2 0010 combine with m0 00-0
m8 1000 combine with m0 -000
m10 1010 combine with m2 -010
00-0 and 10-0 combine to -0-0
The implicant -0-0 means , so it represents . Repeating the process for minterms gives -1-1, which represents .
Quine-McCluskey is exact, but the prime implicant chart can grow fast. Espresso, introduced by Brayton and coauthors, is a heuristic minimizer for two-level logic. It does not promise the smallest expression for every input, but it handles cases that are too large for hand maps. Binary decision diagrams are another representation of Boolean functions, but they are outside this page.
Main Theorem
Canonical Boolean Normal Forms
Statement
Every Boolean function has a canonical sum-of-products expression and a canonical product-of-sums expression.
Intuition
A truth table lists every input row. For each row where , build a minterm that fires only on that row. OR those minterms. For each row where , build a maxterm that fails only on that row. AND those maxterms.
Proof Sketch
For an input row , define a minterm by using when and when . This minterm evaluates to exactly on row . The OR of all with matches on every row. For POS, define a maxterm by using when and when . This maxterm evaluates to exactly on row . The AND of all with matches on every row.
Why It Matters
The theorem gives a mechanical path from specification to gates. It is not the final circuit. It is the starting expression that minimization rewrites.
Failure Mode
The canonical forms have up to terms. For , the truth table has rows, so direct canonical construction is often impossible in a real design flow.
Common Confusions
OR is not XOR
Inclusive OR returns on input . XOR returns on input . In an adder, the sum bit uses XOR, , while the carry bit uses majority logic.
A Karnaugh map wraps at the edges
The left and right columns are adjacent because Gray-code order makes and differ in one bit. The top and bottom rows are also adjacent. Missing wraparound groups is a common reason for a non-minimal expression.
Algebraic simplification needs the same domain
The identity is Boolean, not integer arithmetic. In C, x | x == x for bitwise OR, but x + x == x is false for most integers.
Exercises
Problem
For , write the canonical SOP and minimize it.
Problem
Use De Morgan's laws to rewrite as a sum of products.
Problem
Run one Quine-McCluskey combination pass for minterms of variables . Give the minimized expression.
References
Canonical:
- Charles Petzold, Code: The Hidden Language of Computer Hardware and Software, 2nd ed. (2022), ch. 10-14, relays, gates, binary addition, and feedback
- David A. Patterson and John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 5th ed. (2013), Appendix B, logic design basics and combinational circuits
- M. Morris Mano and Michael D. Ciletti, Digital Design, 5th ed. (2013), ch. 2-3, Boolean algebra, gates, minimization, and combinational logic
- Stephen Brown and Zvonko Vranesic, Fundamentals of Digital Logic with VHDL Design, 3rd ed. (2009), ch. 2-4, Boolean functions, Karnaugh maps, and circuit implementation
- J. Clark Scott, But How Do It Know? The Basic Principles of Computers for Everyone (2009), ch. 1-6, gates, memory, and the path from switches to a computer
Accessible:
- Randy H. Katz and Gaetano Borriello, Contemporary Logic Design, 2nd ed., ch. 2, Boolean algebra and two-level logic
- R. K. Brayton, G. D. Hachtel, C. T. McMullen, and A. L. Sangiovanni-Vincentelli, Logic Minimization Algorithms for VLSI Synthesis (1984), ch. 2-4, exact and heuristic two-level minimization
- UC Berkeley CS61C notes on synchronous digital systems and combinational logic
Next Topics
/computationpath/logic-gates/computationpath/nand-universality/computationpath/combinational-circuits/topics/propositional-logic/topics/sat