A1.2.5 · Data representation and computer logic
Logic diagrams
By the end you can
Draw a logic diagram from an expression or a problem, read an expression back from a diagram, and simplify a circuit using the laws of Boolean algebra.
A is the picture version of a Boolean expression: each operator becomes a gate symbol, and wires carry each result to the next gate. Inputs go on the left and the output, usually called Q, on the right. Being able to move between the three forms (expression, truth table, diagram) in any direction is what this section is about.
From an expression to a diagram#
Find the innermost parts
Brackets first. Without brackets, NOT binds tightest, then AND, then OR, so A OR B AND C means A OR (B AND C).Draw those gates first
Their inputs come straight from A, B, C. A NOT that applies to a single input goes right next to it.Feed outputs onwards
Each gate’s output becomes an input of the gate that uses it, until one gate is left: its output is Q.
Build your own
Inputs are single letters. Gates: AND, OR, NOT, NAND, NOR, XOR, XNOR (or · + ¬). Use brackets to make the order clear.
Logic diagram
The small numbers show what each wire carries right now. Thick red wires are 1.
From a diagram to an expression#
Work from left to right. Write the expression for each gate's output on its output wire, using the labels already on its input wires. When you reach Q, the label on its wire is the whole expression. Try it on this one before reading the answer:
Show the answer
- The top gate: A OR B.
- The middle gate: B AND C, then the NOT gate makes NOT (B AND C).
- The last gate ANDs those two: Q = (A OR B) AND NOT (B AND C).
Exam questions often ask you to construct the truth table for a circuit. Give every gate's output its own column and fill the columns from left to right: each one only needs the columns before it, so a slip shows up in one column instead of spoiling Q.
From a problem to a circuit#
Exam questions often describe a situation in words. Give each condition a letter, look for the words and, or and not (and phrases like “unless” or “either ... but not both”), and build the expression piece by piece. Then check it against a couple of cases from the description.
A car alarm
The alarm should sound when the system is armed and either a door or the boot is opened. Armed = A, door = D, boot = B. “Either a door or the boot” is D OR B, and both that and A must be true: Q = A AND (D OR B).
Q = 0
Siren: silent
A greenhouse fan
A fan should run when it is too hot and the window is not already open, or whenever the gardener presses the override. Hot = T, window open = W, override = S: Q = (T AND NOT W) OR S.
Q = 0
Fan: off
Simplifying a circuit with Boolean algebra#
A circuit drawn straight from a description is often bigger than it needs to be. The rewrite an expression into an equivalent one (the same truth table) with fewer gates. Most come in pairs, one for AND and one for OR; swap AND with OR and 0 with 1 to get from one to the other.
| Law | AND form | OR form |
|---|---|---|
| Identity | A AND 1 = A | A OR 0 = A |
| Null (annulment) | A AND 0 = 0 | A OR 1 = 1 |
| Idempotent | A AND A = A | A OR A = A |
| Complement | A AND NOT A = 0 | A OR NOT A = 1 |
| Double negation | NOT NOT A = A | |
| Commutative | A AND B = B AND A | A OR B = B OR A |
| Associative | (A AND B) AND C = A AND (B AND C) | (A OR B) OR C = A OR (B OR C) |
| Distributive | A AND (B OR C) = (A AND B) OR (A AND C) | A OR (B AND C) = (A OR B) AND (A OR C) |
| Absorption | A AND (A OR B) = A | A OR (A AND B) = A |
| De Morgan | NOT (A AND B) = NOT A OR NOT B | NOT (A OR B) = NOT A AND NOT B |
Worked example
Here is a circuit with three two-input gates and four NOT gates. Simplify it one law at a time, writing which law each step uses:
| NOT (NOT A OR NOT B) OR (A AND NOT B) | The circuit as drawn | |
| = | (NOT NOT A AND NOT NOT B) OR (A AND NOT B) | De Morgan: NOT (X OR Y) = NOT X AND NOT Y |
| = | (A AND B) OR (A AND NOT B) | Double negation: NOT NOT X = X |
| = | A AND (B OR NOT B) | Distributive: take out the common A |
| = | A AND 1 | Complement: X OR NOT X = 1 |
| = | A | Identity: X AND 1 = X |
The whole circuit is just A: a single wire, no gates at all. B makes no difference to the output, which you can confirm by typing the original expression into Figure 1 and switching B on and off. Simplifying first means a cheaper, smaller and faster circuit.
Combining gates: an adder#
Bigger circuits are built by feeding gates into gates. The half adder in A1.2.3 is two gates with shared inputs; a full adder joins two half adders and an OR gate so that it can also take in a carry; eight full adders in a chain add two bytes. Every circuit in a CPU is built this way, from the same few gates.
Check yourself
Logic diagrams and Boolean algebra
Quick questions, made fresh every time and marked here. Do a few until they feel easy.
Exam practice
Paper 1-style questions
6 questions · 15 marks
Write your answer as you would in the exam, then show the mark points and tick each one your answer made. These are our own questions in the style of the exam, not past-paper questions.
1.Construct a logic diagram for Q = NOT (A AND B) OR C.
[3]Construct: Draw or write it out (a table, a diagram, a program).
2.Write the Boolean expression for the logic diagram shown.
[2]Identify: Pick out the answer from the options or the context.
3.A security light must switch on (Q = 1) when it is dark (D = 1) and movement is detected (M = 1), or whenever the manual switch is on (S = 1). Construct a Boolean expression for Q.
[2]Construct: Draw or write it out (a table, a diagram, a program).
4.Explain why a designer simplifies a Boolean expression before building its circuit.
[2]Explain: Give reasons: say what happens AND why, or how one thing causes another.
5.Name the Boolean algebra law used in each step: (a) NOT (A AND B) = NOT A OR NOT B; (b) A OR (A AND B) = A.
[2]Identify: Pick out the answer from the options or the context.
6.Construct a simplified expression for Q = (A OR B) AND (A OR NOT B) using Boolean algebra, naming the law used at each step.
[4]Construct: Draw or write it out (a table, a diagram, a program).
Past papers
Old exam questions on this topic
From HL Paper 1, May 2014 to November 2025. These papers were set on the previous syllabus, so the wording may differ from today's exam, but the topic is the same. Find the questions and markschemes in your school's past-paper pack.
| Paper | Question | Marks | About |
|---|---|---|---|
| May 2024 TZ1 | 13(b) | 4 | Logic diagram from a description (car rules) |
| May 2022 | 6 | 4 | Truth table from a circuit |
| May 2021 | 3 | 2 | Circuit from a truth table |
| May 2019 | 7 | 3 | Truth table from a circuit |
| May 2018 | 5 | 3 | Diagram from an expression |
| November 2018 | 3 | 3 | Diagram from an expression |
| May 2017 | 12(c) | 4 | Truth table from a diagram; the single equivalent gate |
| May 2017 | 12(d) | 2 | Using truth tables to test equivalence |
| November 2017 | 5 | 3 | Diagram from an expression |
In a nutshell
- A logic diagram draws an expression with standard gate symbols: inputs on the left, output (Q) on the right.
- To draw one, work from the inside of the brackets out: each bracketed part becomes a gate whose output feeds the next.
- Without brackets, NOT is done first, then AND, then OR, just as × comes before + in arithmetic.
- To read one, label each gate’s output with its sub-expression, from left to right, until you reach Q.
- For a problem in words: name each input, turn "and"/"or"/"not" into gates, then check with a truth table.
- Simplify first: fewer gates are cheaper, faster and use less power. Use a Karnaugh map (A1.2.4) or the laws of Boolean algebra, naming each law.
- Key laws: identity, null, idempotent, complement, double negation, commutative, associative, distributive, absorption and De Morgan.
