maths.free › Discrete Math & Logic › Boolean algebra and logic circuits
Boolean algebra and logic circuits
The laws of Boolean algebra, sum-of-products form, simplification, and building adders from gates.
Boolean algebra is the algebra of two values, 0 and 1, with the operations AND (written \( xy \) or \( x \land y \)), OR (\( x + y \) or \( x \lor y \)) and NOT (\( \bar x \)). Its laws look like ordinary algebra with a few surprises. Both operations are commutative and associative, each distributes over the other, \( x + 0 = x \) and \( x \cdot 1 = x \), and \( x + \bar x = 1 \), \( x\bar x = 0 \). The surprises are idempotence \( x + x = x \), absorption \( x + xy = x \), and distributivity of OR over AND, \( x + yz = (x + y)(x + z) \), which fails for numbers. De Morgan's laws \( \overline{x + y} = \bar x\,\bar y \) and \( \overline{xy} = \bar x + \bar y \) complete the list.
Every Boolean function can be written in sum-of-products (disjunctive normal) form: for each row of the truth table where the function is 1, write the product (the minterm) that is 1 only in that row, and OR them together. So a function of \( n \) variables is determined by its truth table, and there are \( 2^{2^n} \) of them: \( 2^n \) rows, each with an output of 0 or 1. The example is the multiplexer \( pq + \bar p r \): it outputs \( q \) when \( p = 1 \) and \( r \) when \( p = 0 \).
Simplifying an expression means fewer gates. Minterms that differ in one variable merge: \( xy + x\bar y = x(y + \bar y) = x \). The consensus law \( xy + \bar x z + yz = xy + \bar x z \) removes a redundant term. For a handful of variables, a Karnaugh map arranges the truth table so that mergeable minterms sit next to each other; for more, algorithms such as Quine-McCluskey do the same systematically.
A logic circuit wires gates together, and arithmetic is built this way. A half adder adds two bits: the sum bit is \( x \oplus y \) (exclusive or) and the carry is \( xy \). A full adder also takes an incoming carry \( c \): sum \( x \oplus y \oplus c \) and carry \( xy + c(x \oplus y) \). Chaining \( n \) full adders adds two \( n \)-bit numbers, and NAND gates alone can build every one of these, because NOT, AND and OR can all be made from NAND.
Picture it: a truth table is a column of switches, one row per input combination. A sum-of-products circuit has one AND gate per lit row, each recognising its row, feeding a single OR gate that lights the output whenever any row matches.
Think it: to prove a Boolean identity you may either use the laws or check all \( 2^n \) rows; both are complete methods. Every law has a dual, obtained by swapping AND with OR and 0 with 1, and the dual of a true identity is true. That halves the list of laws to remember.
Worked example · truth table of (p and q) or (not p and r)
Truth table of (p and q) or (not p and r)
Step by step
- \left(p \wedge q\right) \vee \left(r \wedge \neg p\right)
3 variable(s) → 8 rows. Fill in every combination.
- \
Contingent: true for some inputs, false for others.
Reveal the answer
Now you Pick a problem, or type or draw your own. Every step, a picture, the answer hidden until you ask.
Symbols used here
Tap any symbol for the full definition, a picture, and what every letter in it means.
How to: Boolean algebra and logic circuits
- Write the truth table of the function you need.
- Write one minterm for each row with output 1 and OR them together.
- Merge minterms that differ in one variable, and apply absorption and consensus.
- Check the simplified expression against the truth table.
- Translate the expression into gates: one AND per product term, one OR to combine them.
Questions people ask
Is Boolean algebra the same as propositional logic?
The algebra of truth values with and, or and not is exactly propositional logic written algebraically. Boolean algebra is more general: the subsets of a set under union, intersection and complement obey the same laws.
Why is NAND called universal?
NOT x is x NAND x, AND is the NOT of a NAND, and OR is (NOT x) NAND (NOT y). Since NOT, AND and OR express every Boolean function, NAND alone does too.
What makes mathematics "discrete"?
It deals with separate, countable objects (integers, graphs, statements) rather than continuous quantities. No limits, no infinitesimals; instead induction, counting and logic.
How does a proof by induction work?
Show the statement for the first case, then show that whenever it holds for n it holds for n + 1. Like dominoes: the first falls, and each knocks over the next.
What order should I take these lessons in?
Logic and proof first, because every later lesson proves things. Then induction, sets, relations and functions, counting, recurrences, graphs, Boolean algebra and automata, and finally algorithms and complexity, which use nearly everything before them.
Is discrete mathematics the same as the maths of computer science?
Largely. Data structures are graphs and trees, correctness arguments are induction, running times are recurrences and sums, circuits are Boolean algebra, and what a computer can do efficiently is the subject of the last lessons. It is also ordinary mathematics in its own right.
Do I need calculus for this course?
No. School algebra is enough. A little familiarity with limits helps when comparing growth rates, and the lesson on asymptotic analysis explains the one limit fact it uses.
More in Discrete Math & Logic
Truth tablesSums and inductionProof by inductionAlgorithms and growth of functionsPredicate logic and quantifiersDirect proof, contrapositive and contradictionStrong induction and the well-ordering principleRelations: equivalence relations and partial ordersFunctions and cardinalityCounting: rules, choices and bijectionsThe pigeonhole principleSolving linear recurrence relationsGraphs: degrees, paths and connectivityTrees and spanning trees