What Boolean logic is and why it matters
Every decision a computer makes reduces to a question with two possible answers: true or false, 1 or 0. Boolean logic is the formal system that governs how these binary values combine. In the Cambridge IGCSE Computer Science syllabus (0478), Boolean logic appears in the section on logic gates and logic circuits. You need to know six gates, read and construct truth tables, write and interpret logic expressions, and trace signals through multi-gate circuits. This topic is one of the most predictable on the exam: the question formats repeat, the gate set is fixed, and accuracy is rewarded over speed.
The six logic gates
The IGCSE syllabus requires you to know six logic gates. Each gate takes one or two binary inputs and produces a single binary output according to a fixed rule. The table below gives the gate name, its logic rule, the written expression, and the full truth table.
AND gate
The AND gate outputs 1 only when all inputs are 1. If either input is 0, the output is 0. Think of it as both conditions must be true.
Expression: X = A AND B (also written as X = A . B)
| A | B | X = A AND B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
OR gate
The OR gate outputs 1 when any input is 1. The output is 0 only when both inputs are 0. Think of it as at least one condition must be true.
Expression: X = A OR B (also written as X = A + B)
| A | B | X = A OR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
NOT gate
The NOT gate has a single input and inverts it. A 1 becomes 0, and a 0 becomes 1. It is the simplest gate.
Expression: X = NOT A
| A | X = NOT A |
|---|---|
| 0 | 1 |
| 1 | 0 |
NAND gate
NAND stands for NOT AND. It produces the exact opposite output of an AND gate. The output is 0 only when both inputs are 1. In every other case, the output is 1.
Expression: X = NOT (A AND B)
| A | B | X = NOT (A AND B) |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
NOR gate
NOR stands for NOT OR. It produces the exact opposite output of an OR gate. The output is 1 only when both inputs are 0.
Expression: X = NOT (A OR B)
| A | B | X = NOT (A OR B) |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
XOR gate (Exclusive OR)
The XOR gate outputs 1 when the inputs are different. If both inputs are the same (both 0 or both 1), the output is 0. The name "exclusive" is the clue: it excludes the case where both inputs match.
Expression: X = A XOR B
| A | B | X = A XOR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Quick-reference comparison
The following table puts all six gates side by side. The output column shows the result for each of the four standard two-input combinations (00, 01, 10, 11). NOT is listed with its two single-input results.
| Gate | Rule | Outputs (00, 01, 10, 11) |
|---|---|---|
| AND | Both inputs must be 1 | 0, 0, 0, 1 |
| OR | At least one input must be 1 | 0, 1, 1, 1 |
| NOT | Inverts the input | 1, 0 |
| NAND | Opposite of AND | 1, 1, 1, 0 |
| NOR | Opposite of OR | 1, 0, 0, 0 |
| XOR | Inputs must be different | 0, 1, 1, 0 |
Building truth tables
A truth table lists every possible combination of inputs and the resulting output. The method is systematic.
Step 1: Count the inputs. With n inputs, the table has 2^n rows. Two inputs give 4 rows. Three inputs give 8 rows.
Step 2: List all input combinations. Use binary counting. For two inputs A and B: 00, 01, 10, 11. For three inputs A, B, C: 000, 001, 010, 011, 100, 101, 110, 111. A useful pattern: the rightmost column alternates 0, 1, 0, 1. The next column alternates in pairs: 0, 0, 1, 1. The next alternates in fours: 0, 0, 0, 0, 1, 1, 1, 1.
Step 3: Evaluate the expression column by column. If the expression has intermediate steps (for example, NOT A fed into an AND gate with B), add intermediate columns. Work left to right through the expression, filling each column before moving to the next.
Step 1: Two inputs (A, B), so 4 rows.
Step 2: List combinations: 00, 01, 10, 11.
Step 3: Add an intermediate column for NOT A, then evaluate (NOT A) AND B.
| A | B | NOT A | X = (NOT A) AND B |
|---|---|---|---|
| 0 | 0 | 1 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 |
| 1 | 1 | 0 | 0 |
The output is 1 only when A is 0 and B is 1. That result makes sense: NOT A requires A to be 0, and the AND gate then requires B to be 1.
Logic expressions and notation
Cambridge uses a specific notation for logic expressions in the IGCSE 0478 paper.
| Operation | Written form | Symbol form |
|---|---|---|
| AND | A AND B | A . B |
| OR | A OR B | A + B |
| NOT | NOT A | A with overline (or NOT A) |
Be careful with the dot and plus symbols. In Boolean logic, the dot (.) means AND and the plus (+) means OR. These are not multiplication and addition in the arithmetic sense, even though the symbols look identical.
Writing an expression from a circuit: Start at the inputs and follow the signal through each gate. Label the output of each intermediate gate, then combine the labels into the final expression. Brackets show which operation happens first.
Writing an expression from a truth table: Look at every row where the output is 1. For each such row, write a term that describes the input combination (using AND for the inputs that are 1 and NOT for inputs that are 0). Connect the terms with OR. This produces a sum-of-products expression.
Combining gates into circuits
Real logic problems use multiple gates connected in sequence. To trace through a multi-gate circuit, work from the inputs toward the output, evaluating one gate at a time.
Worked example: alarm system
A building has an alarm system with three binary inputs:
- D = door sensor (1 = door open, 0 = door closed)
- W = window sensor (1 = window open, 0 = window closed)
- A = alarm armed (1 = armed, 0 = disarmed)
The alarm should sound (output X = 1) when the alarm is armed AND either the door or the window is open.
Expression: X = (D OR W) AND A
The circuit uses two gates. First, an OR gate takes D and W as inputs. Its output feeds into an AND gate alongside A. Trace the truth table for all eight input combinations:
| D | W | A | D OR W | X = (D OR W) AND A |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 1 |
The alarm sounds in exactly three situations: door open with alarm armed, window open with alarm armed, or both open with alarm armed. The circuit behaves exactly as intended.
Worked exam-style questions
Question 1: Complete the truth table
A logic circuit has two inputs, P and Q, and one output, X. The expression for the circuit is:
X = (P AND Q) OR (NOT P)
Complete the truth table for this circuit. [4 marks]
When P=0, Q=0: P AND Q = 0, NOT P = 1, so X = 0 OR 1 = 1
When P=0, Q=1: P AND Q = 0, NOT P = 1, so X = 0 OR 1 = 1
When P=1, Q=0: P AND Q = 0, NOT P = 0, so X = 0 OR 0 = 0
When P=1, Q=1: P AND Q = 1, NOT P = 0, so X = 1 OR 0 = 1
| P | Q | P AND Q | NOT P | X |
|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 0 | 1 |
Question 2: Write the expression from a circuit description
A logic circuit has three inputs: A, B, and C. The circuit works as follows:
- Gate 1 is a NAND gate with inputs A and B. Its output is called T.
- Gate 2 is an OR gate with inputs T and C. Its output is X.
Write the Boolean expression for X. [2 marks]
Gate 1: T = NOT (A AND B)
Gate 2: X = T OR C
Substitute T into the second expression:
X = NOT (A AND B) OR C
The key technique is labelling each gate's output, then substituting back to get the final expression. This same method works for circuits with any number of gates.
Common mistakes
- Confusing OR with XOR. Standard OR outputs 1 when both inputs are 1. XOR outputs 0 in that case. If you find yourself writing "one or the other but not both," that is XOR, not OR.
- Forgetting NOT inverts only one input. In a circuit, NOT applies to whichever signal it is connected to. If NOT sits before an AND gate on only the A input, it inverts A but leaves B unchanged.
- Missing rows in truth tables. Two inputs require exactly 4 rows. Three inputs require exactly 8 rows. Missing even one row loses marks.
- Dropping brackets in expressions. X = NOT A AND B is ambiguous. X = (NOT A) AND B is clear: NOT applies to A only. X = NOT (A AND B) is also clear: the AND is evaluated first, then the result is inverted. Missing brackets is one of the most frequent sources of lost marks on this topic.
- Confusing the dot and plus notation. The dot (.) means AND. The plus (+) means OR. Students who mix these up produce entirely wrong truth tables.
Translating real-world problems into logic
The IGCSE exam often frames Boolean logic in a real-world context. A question might describe a car that starts only when the seatbelt is fastened AND the key is turned, or a vending machine that dispenses only when the correct amount is inserted OR a token is used.
The approach is consistent:
- Identify the binary inputs (what conditions are being checked).
- Identify the output (what happens when the conditions are met).
- Determine the relationship: does every condition need to be true (AND), or just one (OR)? Is any condition inverted (NOT)?
- Write the expression, then draw the truth table to verify it matches the described behaviour.
Practise this translation skill. The gates themselves are simple. The challenge in exam questions is mapping the English description to the correct combination of gates.
Self-check questions
- A NAND gate has inputs A = 1 and B = 0. What is the output? Explain your reasoning.
- Write the Boolean expression and complete the truth table for a circuit where input A goes through a NOT gate, and the result is fed into an OR gate alongside input B.
- A safe opens when a PIN is correct (P = 1) AND a fingerprint matches (F = 1) AND the time lock has expired (NOT T, where T = 1 means the time lock is still active). Write the expression for the output X and list the input combination(s) that open the safe.
- How many rows does a truth table need if there are four inputs? Show how you calculated this.
- Explain the difference between OR and XOR using the input combination A = 1, B = 1.
A thorough guide to Boolean logic for Cambridge IGCSE Computer Science (0478), covering all six logic gates, truth table construction, logic expressions, multi-gate circuits, and worked exam-style questions with common mistakes to avoid.
Comment(s)