CS24: Boolean Logic
Logic gates (NOT, AND, OR, XOR), truth tables, Boolean expressions, and combining gates into logic circuits.
Logic gates (NOT, AND, OR, XOR), truth tables, Boolean expressions, and combining gates into logic circuits.
Computers process all data as binary (0s and 1s). Boolean logic allows computers to make decisions based on these binary values. Logic gates are the physical electronic circuits that implement Boolean logic operations. Each gate takes one or more binary inputs and produces a single binary output.
Boolean expression: Q = A (spoken as "NOT A" or "A bar")
| Input A | Output Q |
|---|---|
| 0 | 1 |
| 1 | 0 |
If A = 1 (TRUE), then NOT A = 0 (FALSE). If a sensor detects that a door is open (1), the NOT gate would output that the door is NOT closed (0 is false - it's not closed).
Boolean expression: Q = A . B (spoken as "A AND B" - the dot represents AND)
| Input A | Input B | Output Q |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
A car engine should only start if the key is turned (A = 1) AND the brake is pressed (B = 1). If either condition is not met, the engine will not start (Q = 0).
Boolean expression: Q = A + B (spoken as "A OR B" - the plus represents OR)
| Input A | Input B | Output Q |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
An alarm should sound if the front door is open (A = 1) OR the back door is open (B = 1). If either door is open, the alarm triggers.
Boolean expression: Q = A ⊕ B (spoken as "A XOR B")
| Input A | Input B | Output Q |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
A light with two switches (like a staircase light) uses XOR logic. When the switches are in different positions, the light is on. When both are in the same position, the light is off.
This circuit has an AND gate followed by a NOT gate (also called a NAND gate).
| A | B | A . B | NOT (A . B) |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 0 |
| A | B | C | A + B | (A + B) . C |
|---|---|---|---|---|
| 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 |
Expression: Q = A . B
This means: NOT A is ANDed with B. The circuit has: A goes into a NOT gate, the output of NOT A goes into an AND gate along with B.
Expression: Q = (A + B) . C
This means: (A OR B) is ANDed with NOT C. The circuit has: A and B go into an OR gate, C goes into a NOT gate, then both outputs go into an AND gate.
Expression: Q = A . B + C
This means: (A AND B) OR C. The circuit has: A and B go into an AND gate, the result is ORed with C. (AND is evaluated before OR.)
| Gate | Inputs | Output is 1 when... | Expression |
|---|---|---|---|
| NOT | 1 | Input is 0 | A |
| AND | 2 | Both inputs are 1 | A . B |
| OR | 2 | Either or both inputs are 1 | A + B |
| XOR | 2 | Inputs are different | A ⊕ B |
| NAND | 2 | NOT both inputs are 1 | A . B |
| NOR | 2 | Both inputs are 0 | A + B |
| Mistake | Why It's Wrong | How to Fix It |
|---|---|---|
| Confusing OR and XOR | OR gives 1 when both are 1; XOR gives 0 | Remember: XOR = "exclusive" = one OR the other, not both |
| Wrong order of operations | NOT, AND, OR - not left to right | Apply NOT first, then AND, then OR; use brackets to clarify |
| Missing rows in truth tables | 2 inputs = 4 rows; 3 inputs = 8 rows | Count in binary: 00, 01, 10, 11 for 2 inputs |
| Forgetting intermediate columns | Working out the final column in your head leads to errors | Always show intermediate steps as separate columns |
Q1: Draw the truth table for Q = A . B
Q2: A circuit has the expression Q = (A OR B) AND NOT C. Draw the full truth table.
Q3: What is the difference between OR and XOR? Give a real-world example of each.
Q4: Write the Boolean expression for a circuit where A and B go into an OR gate, and the output is fed into a NOT gate.
Q5: How many rows does a truth table need for a circuit with 3 inputs?
✗ Confusing AND, OR, NOT gates with their truth table outputs ✓ AND: output 1 only when ALL inputs are 1. OR: output 1 when ANY input is 1. NOT: output is the opposite of the input. Memorise the truth tables.
✗ Drawing logic gate symbols incorrectly in exams ✓ AND gate: D-shape. OR gate: curved D with curved input side. NOT gate: triangle with circle. Each symbol is distinct — practice drawing them.
✗ Forgetting that a NOT gate can only have ONE input ✓ NOT (inverter) takes exactly one input and produces the opposite. It cannot have two inputs. AND and OR gates can have two or more inputs.
✗ Not recognising that NAND and NOR are the negated versions of AND and OR ✓ NAND = NOT AND (output is opposite of AND). NOR = NOT OR (output is opposite of OR). Adding the circle (bubble) on the output inverts the gate's normal result.
Draw and complete the truth table for the following logic circuit: A AND B is fed into a NOT gate. Then explain what type of gate this combination produces. [4 marks]
The circuit is: A AND B → NOT = NAND gate A | B | A AND B | NOT (A AND B) 0 | 0 | 0 | 1 0 | 1 | 0 | 1 1 | 0 | 0 | 1 1 | 1 | 1 | 0 This combination produces a NAND gate. The output is 0 only when both inputs are 1, and 1 in all other cases. The NAND gate is the negation of the AND gate — adding a NOT gate to the output of an AND gate produces the NAND truth table.
AO1 (Computational Thinking — 40%): Demonstrate knowledge and understanding of the principles and concepts of computer science, including Boolean logic and logic gates: AND, OR and NOT for AQA 8525, OCR J277 & Edexcel 1CP2.
AO2 (Application — 40%): Apply knowledge and understanding of computer science, including Boolean logic and logic gates: AND, OR and NOT to analyse problems in computational terms and to design, write and evaluate solutions.
AO3 (Evaluation — 20%): Evaluate the effectiveness, correctness and efficiency of computational solutions, including Boolean logic and logic gates: AND, OR and NOT, and make reasoned judgements about trade-offs.
Get the best revision books and guides to boost your grades.