Library Computer Science 0478 Boolean Logic
O Level · Computer Science 0478

Boolean Logic

Revise Boolean Logic for Computer Science 0478 (O Level) — revision notes and instant AI marking. Free to start.

📖 Revision notes · preview
  Cambridge IGCSE Computer Science (0478)

Boolean Logic

Computers only understand two states — TRUE and FALSE (1 and 0) — and Boolean logic is simply the set of rules for combining those states to make decisions, using six gates: AND, OR, NOT, XOR, NAND, and NOR.

Summary — What This Chapter Covers

  • Boolean logic works with only two values — TRUE/FALSE, represented as 1/0 — and lets computers make decisions.
  • Six logic gates exist: AND, OR, NOT, XOR, NAND, NOR — each has its own symbol, rule, and truth table.
  • A logic circuit is what you get when you wire multiple gates together, following an order of operations (brackets first).
  • A truth table lists every possible combination of inputs and shows the output for each — with n inputs you need 2ⁿ rows.
  • A logic expression is the equation form of a circuit, e.g. Q = NOT(A OR B).
  • You can convert between all three representations: circuit → truth table → expression, and back again, in any direction.
  • Cambridge IGCSE limits circuits to a maximum of three inputs and one output.

1. Logic Gates

What is Boolean logic, really? Think of a light switch. It's either on or off — there's no "sort of on." Boolean logic is that same idea applied to reasoning: every statement is either completely TRUE or completely FALSE, nothing in between. Computers represent TRUE as 1 and FALSE as 0, and logic gates are the tiny electronic components that take these 1s and 0s as inputs and produce a 1 or 0 as output, based on a fixed rule.

Inputs and outputs are given single letters (A, B, C for inputs; often P, Q, X, Z for outputs) so we can write compact expressions instead of long sentences. A logic gate is just a visual symbol representing one rule — a picture standing in for a mini decision.

AND Gate

Imagine a car that will only start (output = 1) if both the key is turned and the seatbelt is on. Miss either one, and nothing happens. That's exactly how AND behaves — it's strict. It only outputs TRUE when every single input is TRUE.

Rule A AND B is TRUE only if A = TRUE and B = TRUE. Any FALSE input drags the whole output to FALSE.
ABA AND B
000
010
100
111

OR Gate

Now imagine a doorbell that rings if you press the front button or the back button. You don't need both — just one is enough. OR is generous: it's TRUE as soon as at least one input is TRUE.

Rule A OR B is TRUE if A = TRUE or B = TRUE (or both). It's only FALSE when both inputs are FALSE.
ABA OR B
000
011
101
111

NOT Gate

NOT is the simplest gate of all — it only has one input, and it just flips it. TRUE becomes FALSE, FALSE becomes TRUE. Think of it as a mirror.

Rule NOT A reverses the input: NOT TRUE = FALSE, NOT FALSE = TRUE.
ANOT A
01
10

XOR (Exclusive OR) Gate

This is the gate students mix up most often, so slow down here. XOR looks like OR but has one crucial difference: it is exclusive — meaning it wants exactly one input to be TRUE, not both. Picture two people trying to turn on a single hallway light using two separate switches at either end of the hallway — flipping just one switch turns the light on, but if both switches get flipped, the light effectively cancels out and turns off again.

Rule A XOR B is TRUE if exactly one input is TRUE — never both, never neither.
ABA XOR B
000
011
101
110
Watch Out OR and XOR only differ on one row: when both inputs are 1. OR says 1, XOR says 0. That's the entire difference — memorise that single row and you'll never confuse them again.

NAND (NOT AND) Gate

NAND is simply AND with the output flipped — take whatever AND would output, then invert it. In the circuit symbol, this "invert" is drawn as a small bubble on the output of the AND shape.

Rule A NAND B = NOT(A AND B). It's TRUE for every combination except when both inputs are TRUE.
ABNOT(A AND B)
001
011
101
110

NOR (NOT OR) Gate

Same idea again — NOR is OR with the result flipped. It's the "grumpiest" gate: the only way to get a TRUE output is if both inputs are FALSE.

Rule A NOR B = NOT(A OR B). TRUE only when both inputs are FALSE.
ABNOT(A OR B)
001
010
100
110
Practice Question 1.1

If A = 1 and B = 0, what is the output of: (a) A AND B, (b) A OR B, (c) A XOR B, (d) A NAND B, (e) A NOR B?

Practice Question 1.2

A student says "OR and XOR always give the same answer." Explain why this is wrong, using a specific example.

2. Logic Circuits

A single gate is only useful for simple decisions. Real problems need multiple conditions chained together — that's a logic circuit: several gates wired up so the output of one gate becomes the input of the next. This is exactly like how in maths, you combine +, , and × into one longer expression.

Brackets matter enormously. Just like (2 + 3) × 4 is different from 2 + (3 × 4), the expression (A AND B) OR C is a completely different circuit from A AND (B OR C). Always build the bracketed part first.

Reading a Circuit Diagram

Take the expression Q = NOT(A OR B). Here's how you'd read the circuit left to right:

A ──┐ ├──[ OR ]── P ──[ NOT ]── Q B ──┘ Step 1: A and B feed into the OR gate → produces P Step 2: P feeds into the NOT gate → produces Q (final output)

Notice how P is just a label for the "in-between" wire — the output of the first gate and the input to the second. Only Q is the final output of the whole circuit. IGCSE circuits are capped at 3 inputs and 1 output, so you'll never have to track more wires than that.

Worked Example — Sprinkler System

"A sprinkler system switches on if it is not daytime (input A) and the temperature is greater than 40°C (input B)."

Step 1 — Translate the sentence into logic. "Not daytime" → NOT A. "and the temperature is greater than 40" → combine with AND. So: Q = (NOT A) AND B.

Step 2 — Build it gate by gate. A goes through a NOT gate first (because it needs inverting before use). That output, plus B untouched, both feed into an AND gate to produce Q.

A ──[ NOT ]──┐ ├──[ AND ]── Q B ───────────┘

This is a great example of the general method: read the sentence for connecting words ("and", "or", "not") — they tell you exactly which gates to use and in what order.

Practice Question 2.1

Write the logic expression for a burglar alarm that sounds if the door sensor is triggered (D) OR (the window sensor is triggered (W) AND the system is armed (S)).

3. Truth Tables

A truth table is the ultimate "show every possibility" tool. Instead of describing a rule in words, you just list every combination of inputs and write down what the output is for each one. It removes all ambiguity — nothing is left to interpretation.

Formula — Number of Rows Rows needed = 2ⁿ, where n is the number of inputs.
1 input → 2 rows  |  2 inputs → 4 rows  |  3 inputs → 8 rows

Why 2ⁿ? Each input can independently be 0 or 1 — 2 choices. With 3 inputs, you're choosing a value for A (2 ways) AND B (2 ways) AND C (2 ways), so 2 × 2 × 2 = 8 total combinations. To make sure you don't accidentally skip a combination, count up in binary starting from all-zeros: 000, 001, 010, 011, 100, 101, 110, 111.

Worked Example — Building a Table for P = (A AND B) AND NOT C

The examiner-friendly method: build one column at a time, left to right, exactly following the brackets — never try to jump straight to the final answer.

Step 1: List all 8 rows for A, B, C.
Step 2: Add a column for the bracketed part first: A AND B.
Step 3: Add a column for NOT C.
Step 4: Combine those two new columns with AND to get the final answer, P.

ABCA AND BNOT CP
000010
001000
010010
011000
100010
101000
110111
111100
Time-Saver These "helper columns" (like A AND B and NOT C) aren't compulsory in your final answer — examiners often only want the input columns plus the final output column. But keep them while you're working it out; skipping straight to the answer is where careless mistakes creep in.

Going Backwards — Circuit from a Truth Table

This is a favourite exam trick: they give you a completed truth table and ask you to build the circuit that produces it. Here's the reliable method, using this table for output X:

ABCX
0000
0010
0100
0110
1001
1010
1100
1111

Step 1 — Find every row where the output is 1. Here, that's row (A=1, B=0, C=0) and row (A=1, B=1, C=1).

Step 2 — Build one "AND branch" per winning row. For each row, AND together the inputs exactly as they appear — using NOT on any input that's a 0 in that row.
• Row 1: A=1, B=0, C=0 → A AND (NOT B) AND (NOT C)
• Row 2: A=1, B=1, C=1 → A AND B AND C

Step 3 — OR the branches together. The final output is TRUE if either branch is true, so combine them with OR:

Result X = (A AND NOT B AND NOT C) OR (A AND B AND C)

This method works every time, no matter how complicated the table looks — find the 1s, build an AND-branch for each, then OR them all together.

Practice Question 3.1

How many rows would a truth table need for a logic expression with 2 inputs? List all the input combinations in the correct binary-counting order.

Practice Question 3.2

A truth table for output Z has exactly one row where Z = 1: when A=0, B=1. Write the simplest logic expression for Z.

4. Logic Expressions

A logic expression is just the "equation" version of a circuit or truth table. The output goes on the left of the equals sign, and the inputs plus gates go on the right — exactly like how y = 2x + 3 describes a relationship using symbols instead of a graph.

GateExpression Form
NOTZ = NOT A
ANDZ = A AND B
ORZ = A OR B
XORZ = A XOR B
NANDZ = A NAND B
NORZ = A NOR B

For circuits with multiple gates, you build the expression by working through the diagram in the same order the signal flows — innermost brackets (the earliest gates) go inside the parentheses first.

Worked Example — Circuit to Expression

Consider a circuit where: A and B feed into a NAND gate, and separately B and C feed into a NOR gate; the NAND output goes through a NOT gate; then that inverted result and the NOR output both feed into a final OR gate producing X.

Build it piece by piece:

• NAND branch: A NAND B, then inverted → NOT(A NAND B)
• NOR branch: B NOR C
• Combine with the final OR gate:

Result X = NOT(A NAND B) OR (B NOR C)

The trick to these multi-gate questions is always the same: name each intermediate wire in your head (or on paper), work out its mini-expression, then plug that mini-expression into the next gate like a jigsaw piece.

Practice Question 4.1

A circuit has inputs A and B. A goes through a NOT gate. That result and B both feed into an AND gate to give the final output Q. Write the logic expression for Q.

Practice Question 4.2

Write out, step by step, how you would draw a circuit for: X = ((A AND B) OR (C AND NOT B)) XOR NOT C

What to Memorise

AND
TRUE only if ALL inputs are TRUE. Strict gate.
OR
TRUE if AT LEAST ONE input is TRUE. Generous gate.
NOT
Single input. Flips TRUE ↔ FALSE.
XOR
TRUE if EXACTLY ONE input is TRUE. FALSE if both same.
NAND
= NOT(AND). FALSE only when both inputs are TRUE.
NOR
= NOT(OR). TRUE only when both inputs are FALSE.
Rows in a Truth Table
Formula: 2ⁿ, where n = number of inputs. Count up in binary from 0.
Circuit → Table Method
Build a helper column for each bracketed part first, left to right, before combining.
Table → Circuit Method
Find rows where output = 1 → build an AND-branch per row (NOT any 0-inputs) → OR all branches together.
Expression Format
Output = Inputs combined with gate names, e.g. Z = A AND B. Brackets show order.
IGCSE Limit
Circuits capped at 3 inputs, 1 output.
Order of Operations
Always resolve innermost brackets first, just like in maths.

Concepts Checklist

Exam Tips & Common Mistakes

Confusing OR and XORThis is the #1 exam mistake. Before submitting an answer involving OR or XOR, always double check the row where both inputs are 1 — OR gives 1, XOR gives 0.
Missing or misplaced brackets(A AND B) OR C is not the same circuit as A AND (B OR C). Always double check which inputs are grouped together in the original statement before drawing.
Skipping binary counting order in truth tablesJumping around instead of counting 000, 001, 010, 011... in order is the easiest way to accidentally miss or duplicate a row. Always count up in strict binary.
Mislabelling inputs on a drawn circuitExaminers explicitly warn: label every input (A, B, C) clearly, and draw signal flow left to right. An unlabelled wire loses marks even if the gate logic is correct.
Forgetting NAND/NOR are just inverted AND/ORDon't try to memorise NAND and NOR truth tables from scratch — build the AND or OR table first, then flip every output. It's faster and less error-prone.
Overcomplicating circuit-from-table questionsStudents often try to simplify or guess. Stick to the reliable method: find every row where output = 1, build one AND-branch per row, then OR all branches together. It always works.
What Examiners Look For Cambridge 0478 questions typically ask you to: (1) identify a gate from its symbol or truth table, (2) draw a circuit from a written statement or expression, (3) complete a truth table for a given expression, or (4) write the expression for a given circuit. Practise moving fluently between all four — circuit, table, expression, and plain English — since exams test transitions between them, not just isolated facts.
🔓 Read the full Boolean Logic note — free You're seeing the preview · free account, no card needed
Also in the full note
  • Exam Tips & Common Mistakes
What's inside
📖 Revision notes 🎯 Learn mode ✦ AI flashcards ✓ Instant AI marking 🧊 3D explorers 🧪 Experiments & simulations 📈 Progress tracking
📄 Practise Boolean Logic with Computer Science 0478 past papers Every paper with its mark scheme — answer online, marked instantly. Open →

Read the full Boolean Logic notes free

That's the preview — create a free account to read the rest, plus flashcards and practice questions with instant AI marking. No credit card.

Unlock the full notes free →

More Computer Science topics