Boolean Logic
Logic gates, truth tables, logic expressions, circuits, interconversion and an interactive gate simulator.
1 Introduction to Boolean Logic
Boolean logic is a system of logic where every value is either TRUE (1) or FALSE (0). Logic gates are electronic components that take binary inputs and produce a binary output according to a specific rule.
In truth tables: 1 = TRUE and 0 = FALSE. These two notations are fully interchangeable — you will see both in Cambridge exams.
2 The Six Logic Gates
| Gate | Rule (plain English) | Output = 1 when… | |||
|---|---|---|---|---|---|
| NOT | Inverts the single input | AND | Output 1 only if BOTH inputs are 1 | OR | Output 1 if AT LEAST ONE input is 1 |
| NAND | Opposite of AND | NOR | Opposite of OR | XOR / EOR | Output 1 only if inputs are DIFFERENT |
3 Truth Tables
NOT Gate (1 input)
| A | NOT A |
|---|
AND Gate
| A | B | A AND B | |
|---|---|---|---|
| 0 | 0 | 1 | 1 |
OR Gate
| A | B | A OR B | |
|---|---|---|---|
| 0 | 0 | 1 | 1 |
NAND Gate
| A | B | A NAND B | |
|---|---|---|---|
| 0 | 0 | 1 | 1 |
NOR Gate
| A | B | A NOR B | |
|---|---|---|---|
| 0 | 0 | 1 | 1 |
XOR / EOR Gate
| A | B | A XOR B | |
|---|---|---|---|
| 0 | 0 | 1 | 1 |
Memory trick for XOR: "Exclusively different" — output is 1 only when the two inputs are NOT equal to each other.
4 Logic Expressions
A logic expression combines inputs using gate names to describe a circuit in text form. Example: X = (A AND B) OR (NOT C)
Evaluating an Expression — Worked Example
Evaluate X = (A AND B) OR (NOT C) for A=1, B=0, C=1:
- Evaluate innermost brackets first:
A AND B = 1 AND 0 = 0 - Evaluate NOT:
NOT C = NOT 1 = 0 - Combine with OR:
0 OR 0 = 0 - Therefore X = 0
5 Logic Circuits
A logic circuit is a diagram of interconnected gate symbols. For this syllabus, circuits have a maximum of three inputs and one output. No simplification is required.
Drawing a Circuit from an Expression
Expression: Z = (A OR B) AND (NOT A)
- Identify gates needed: 1× OR, 1× NOT, 1× AND
- Input A feeds into both the OR gate and the NOT gate
- Input B feeds into the OR gate
- Output of OR gate and output of NOT gate both feed into the AND gate
- AND gate output is labelled Z
Always label your inputs (A, B, C) and your final output clearly. Unlabelled inputs or outputs will lose marks in the exam.
6 Three-Input Circuits
With three inputs A, B, C there are 2³ = 8 rows in the truth table. Use this template — the bit pattern is systematic:
| A | B | C | Output | ||||
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
Pattern: column A alternates every 4 rows, column B every 2 rows, column C every row. This guarantees all 8 combinations are covered systematically.
Worked Three-Input Example
Expression: W = (A AND B) OR (NOT C)
| A | B | C | A AND B | NOT C | W | ||
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
7 Interconversion — the 3-Way Skill
The exam can ask you to convert between any combination of these four forms:
- Written formula using AND, OR, NOT, NAND, NOR, XOR
- e.g.
X = (A AND B) OR C - Use brackets to show order clearly
- Lists all possible input combinations
- 2 inputs → 4 rows; 3 inputs → 8 rows
- One output column filled for every row
- Diagram using standard gate symbols
- Inputs labelled A, B, C; output labelled
- Wires connect gate outputs to next gate inputs
- Written English description of the logic
- "Output is 1 when A is 1 and B is 0"
- Convert words → logic expression → circuit
Practise all directions: expression→circuit, circuit→truth table, truth table→expression, statement→all three. Any direction can appear in the exam — they carry equal weight.
8 Interactive Gate Simulator
Toggle inputs A and B to see all gate outputs update in real time.
🔌 Two-Input Gate Simulator
🔌 NOT Gate Simulator
Stop wrestling with confusion.
Join thousands of students mastering Computer Science without the academic jargon.
From syntax to systems. We break down the hardest ideas in computer science so you can actually build things.
