Boolean Algebra and Logic Circuits
Boolean algebra is the algebra of two values, and . It is equivalent in structure to propositional logic and to set algebra, and it is the mathematical foundation for digital circuit design. Boolean expressions describe Boolean functions; gates implement those expressions physically.
The value of Boolean algebra is that symbolic laws can simplify hardware. Equivalent expressions compute the same function, but one may use fewer gates, fewer inputs, or a more convenient universal gate type. This makes the topic a meeting point for logic, algebra, and computer engineering.
Definitions
The basic Boolean operations on are:
- Complement: , with and .
- Boolean sum: , corresponding to OR.
- Boolean product: , corresponding to AND.
A Boolean variable takes values in . A Boolean function of degree is a function
Boolean expressions are built recursively from variables, , , complement, Boolean sum, and Boolean product.
A literal is a variable or its complement. A minterm is a product containing one literal for each variable. A sum-of-products expression is a Boolean sum of product terms. A maxterm is a sum containing one literal for each variable, and a product-of-sums expression is a product of sum terms.
Logic gates implement Boolean operations: NOT, AND, OR, NAND, NOR, XOR, and XNOR. A set of gates is functionally complete if every Boolean function can be implemented using only gates from that set.
Key results
There are
Boolean functions of degree . Reason: there are input tuples, and each input can be assigned output or independently.
Every Boolean function can be represented by a sum of minterms. For each input tuple on which , build a minterm that is exactly on that tuple: use if the tuple has in coordinate , and if it has . The OR of all such minterms matches on every input.
Important identities:
These parallel logical and set identities. De Morgan's laws are especially important because they let circuits move between AND/OR designs and NAND/NOR designs.
NAND and NOR gates are functionally complete. For NAND:
Once NOT is available,
and OR follows from De Morgan's law:
Thus NAND can build NOT, AND, OR, and therefore every Boolean expression.
Visual
| Logic | Boolean algebra | Set algebra | Circuit gate |
|---|---|---|---|
| complement | NOT | ||
| union | OR | ||
| intersection | AND | ||
| De Morgan | complement of union | NOR plus NOT | |
| exclusive or | symmetric difference | XOR |
Worked example 1: Build a sum-of-products expression
Problem. A Boolean function is exactly on input tuples , , and . Write a sum-of-products expression.
Method.
- For tuple , use complemented literals for coordinates and an uncomplemented literal for the coordinate:
- For tuple :
- For tuple :
- OR the minterms:
Checked answer. Each minterm is on exactly one of the listed tuples and elsewhere. Their Boolean sum is exactly on the union of those three input cases.
Worked example 2: Simplify a Boolean expression
Problem. Simplify
Method.
- Group the first two terms:
- Use complementarity:
- Therefore
- Substitute:
- Use absorption:
Checked answer. The simplified expression is . A truth table confirms that the original output depends only on .
Code
from itertools import product
def F_original(x, y, z):
return (x and y) or (x and (not y)) or (x and z)
def F_simplified(x, y, z):
return x
def full_adder(x, y, c):
s = x ^ y ^ c
carry = (x and y) or (x and c) or (y and c)
return int(s), int(carry)
for bits in product([0, 1], repeat=3):
print(bits, int(F_original(*bits)), int(F_simplified(*bits)), full_adder(*bits))
The first two output columns match for every input tuple, verifying the simplification by exhaustive truth table.
Common pitfalls
- Treating Boolean sum as ordinary integer addition. In Boolean algebra, for OR.
- Forgetting that means AND, not multiplication over ordinary integers.
- Dropping complements when translating minterms from a truth table.
- Assuming a shorter-looking expression always uses fewer gates after implementation details are considered.
- Confusing XOR with OR. XOR is true only when exactly one input is true.
- Using De Morgan's laws in the wrong direction: becomes , not .
Truth tables are the safest correctness check for small Boolean functions. With variables there are only rows, so for it is realistic to compare an original expression, a simplified expression, and a proposed circuit directly. A simplification is valid only if every row matches. Matching on the rows where the function is is not enough unless the rows where it is have also been accounted for by the construction.
For circuit design, cost depends on the gate library. An expression with fewer algebraic symbols may not be cheaper if it requires gates that are unavailable or expensive. A NAND-only implementation, for example, may intentionally introduce double negations because NAND is the available universal gate. This is why algebraic simplification and technology mapping are related but distinct steps.
Minterm expansions are canonical but not necessarily minimal. They are excellent for constructing a function from a truth table because each row contributes exactly one product term. However, adjacent minterms often combine. For instance, eliminates a variable. Karnaugh maps visualize this combining process for small numbers of variables by placing adjacent input tuples next to each other.
The duality principle is another useful check. Many Boolean identities have a dual obtained by swapping with multiplication and swapping with . For example, has dual . If an alleged pair of identities is not dual in this sense, inspect it carefully before using it.
When translating from propositional logic, keep notation consistent. Logical corresponds to Boolean , and logical corresponds to Boolean product. Ordinary arithmetic precedence can mislead readers, so use parentheses in mixed expressions such as or .
A useful simplification strategy is to look first for complements, duplicates, and absorption. Complements create constants: and . Duplicates collapse: and . Absorption removes redundant detail: and . These small moves often simplify a circuit more reliably than expanding everything into minterms.
When drawing circuits from expressions, preserve the parse tree. The expression means first OR and , then negate the result, then AND with . It is not the same as or . Parentheses and overbar length carry structure. In handwritten work, a long overbar must visibly cover exactly the intended subexpression.
For multi-output circuits, shared subexpressions matter. A full adder has both a sum output and a carry output; computing once and reusing it can reduce hardware. Boolean algebra at the expression level should therefore be combined with a circuit-level view of which intermediate signals are worth sharing.
A final circuit check is to compare levels of logic as well as expression value. Two expressions can be equivalent but have different propagation delay because one requires more gate layers. In theoretical Boolean algebra the expressions are the same function; in hardware, the implementation cost may depend on fan-in, fan-out, delay, and available gates.
For small designs, keep both a truth table and an algebraic simplification. The truth table verifies behavior, while algebra explains why the simplification works and can generalize to larger inputs. Relying only on a table becomes impractical as variables grow, but relying only on algebra makes it easier to miss a translation error.
When converting a truth table to a circuit, decide whether to use rows where the output is or rows where the output is . Sum-of-products uses the rows. Product-of-sums uses the rows. Choosing the shorter side can lead to a simpler expression before any further minimization.
For sequential circuits, Boolean logic describes the combinational part, while stored state supplies memory. This page focuses on combinational logic; finite-state machines add feedback through state registers and transition functions.
Connections
- Propositional logic gives the logical connectives mirrored by Boolean operations.
- Sets and set operations mirrors Boolean identities with set identities.
- Functions, sequences, and sums frames Boolean functions as maps from to .
- Finite-state machines and computation uses Boolean logic in digital state machines.