Boolean Logic, Truth Tables and Circuit Simplification
IB Computer Science · Computer Organization
Three representations of one thing. A logic circuit can be described as a diagram of gates, as a truth table listing the output for every combination of inputs, or as a Boolean expression. Exam questions move between the three, and the skill is to convert reliably. From a diagram to a table: label every intermediate wire, then evaluate row by row, working from inputs to output. From a table to an expression: take each row whose output is 1, write it as an AND of the inputs (using NOT for inputs that are 0 in that row), and join the rows with OR. From an expression to a diagram: draw one gate per operator, innermost first. A table for n inputs has 2n rows; write the inputs in binary counting order so that no row is missed.
The half adder as the standard example. Adding two one-bit numbers needs two outputs: the sum bit S = A XOR B and the carry bit C = A AND B. The row 1 + 1 gives S = 0, C = 1, because 1 + 1 = 10 in binary. Two half adders and an OR gate make a full adder that also accepts a carry in, and chaining full adders builds the circuit that adds whole binary numbers inside the processor. This is why gates matter: every arithmetic operation the CPU performs is ultimately a network of these circuits.
Simplification and why it is worth doing. Two expressions with identical truth tables are equivalent, and the simpler one needs fewer gates. Fewer gates means lower cost, faster operation (fewer gate delays between input and output), less heat and fewer components to fail. The laws used most: X OR NOT X = 1; X AND NOT X = 0; X OR (X AND Y) = X (absorption); distribution, so that (A AND B) OR (A AND NOT B) = A AND (B OR NOT B) = A; and De Morgan's laws, NOT (A AND B) = NOT A OR NOT B, and NOT (A OR B) = NOT A AND NOT B. After simplifying, always rebuild the truth table of the new expression and check it matches the original — a simplification that changes the table is a mistake, not a simplification.
NAND is enough. Every gate can be built from NAND gates alone: NOT A = A NAND A; A AND B = NOT (A NAND B); A OR B = (NOT A) NAND (NOT B) by De Morgan. This is called functional completeness (NOR has the same property), and it is why manufacturers can mass-produce a single gate type and wire it into anything. The exam version of this idea is a question that gives you a circuit and asks you to rebuild it with NAND only, or asks why a designer might prefer to.
Worked example: Example 1 — from a description in words to a truth table to a simplified circuit
A cash machine allows a transaction (T = 1) when the card is valid (V = 1) and the PIN is correct (P = 1), or when the card is valid and a staff member confirms (S = 1). Write the expression, draw up the truth table, simplify, and state the number of gates before and after.
Solution
Step 1 — translate the words into an expression. "The card is valid and the PIN is correct" is V AND P. "The card is valid and a staff member confirms" is V AND S. "Or" joins the two parts: T = (V AND P) OR (V AND S). This expression needs three gates: two ANDs and one OR.
Step 2 — truth table. Three inputs so 8 rows, written in binary counting order V P S: 000 → 0; 001 → 0; 010 → 0; 011 → 0; 100 → 0; 101 → 1; 110 → 1; 111 → 1. An observation straight from the table: T is 1 only when V is 1 and at least one of P, S is 1. The first four rows (V = 0) all give 0 regardless of P, S.
Step 3 — simplify using the distributive law. (V AND P) OR (V AND S) = V AND (P OR S). Two gates: one OR and one AND. From three gates down to two, and more importantly, the signal path goes through two stages as before but with fewer components.
Step 4 — mandatory check. Redraw the table for V AND (P OR S): P OR S is 0 only at P = S = 0; so T is 1 at 101, 110, 111 and 0 in the remaining rows — identical to the table in step 2. The simplification is valid.
What the examiner looks for. A table with all 8 rows in order; an expression read directly from the words; the name of the law used; and the check after simplifying. Candidates often skip the last step, and lose marks when they simplify wrongly without knowing it.
Worked example: Example 2 — building a circuit using only NAND and explaining why
Build an OR gate using only NAND gates, prove it with a truth table, and explain why a chip manufacturer can accept using three NAND gates in place of one OR gate.
Solution
Construction. By De Morgan, A OR B = NOT (NOT A AND NOT B) = (NOT A) NAND (NOT B). And NOT A = A NAND A. So: gate 1: X = A NAND A (that is NOT A); gate 2: Y = B NAND B (that is NOT B); gate 3: Z = X NAND Y. Three NAND gates give one OR gate.
Proof by table. A B → X Y → Z: 00 → 11 → 0; 01 → 10 → 1; 10 → 01 → 1; 11 → 00 → 1. The Z column is 0, 1, 1, 1 — exactly the table of OR. Listing the intermediate columns X, Y is what makes the proof complete rather than a bare assertion.
Why accept three in place of one. On paper, three gates are more than one. But in chip manufacturing, the deciding cost is the number of types of component that must be designed, verified and optimized, not the number of gates. A production line making only NAND can optimize that gate to the limit in size and speed, then use it for everything; NAND is also the simplest gate to build from transistors. In addition, when all gates are the same, layout and testing of the circuit are easier to automate. So functional completeness is not only a mathematical property but the economic reason for how chips are made. A good answer distinguishes the number of gates on the diagram from the real cost.
Common mistake
Trap 1 — writing a truth table with missing rows or in the wrong order. n inputs give 2 to the power of n rows, written in binary counting order; three inputs give 8 rows, not 6.Trap 2 — not re-checking after simplifying. The new expression must give an identical table; changing the table is an error, not a simplification.
Trap 3 — confusing XOR with OR in the 1 1 row. XOR gives 0 when both are 1; that is exactly why the half adder uses XOR for the sum bit.