Write a logic expression from a problem statement, logic circuit or truth table
Boolean Logic – IGCSE Computer Science 0478
What You’ll Learn
By the end of this lesson you’ll be able to:
- Translate a real‑world problem into a Boolean expression.
- Read a logic circuit and write the corresponding expression.
- Read a truth table and write the simplest Boolean expression.
- Use De Morgan’s laws and other simplification techniques.
Key Concepts
Boolean logic uses only two values: TRUE (1) and FALSE (0). The main operators are:
- AND (∧) – true only if both operands are true.
- OR (∨) – true if at least one operand is true.
- NOT (¬) – flips the value.
Example: $A ∧ B$ is true only when both A and B are true.
Analogies
Think of Boolean logic like a traffic light:
- AND = “Both red lights must be on for the car to stop.”
- OR = “Either green light is on, the car can go.”
- NOT = “If the light is red, NOT red means it’s green.”
Writing Expressions from Problem Statements
Suppose the problem is: “A door opens if the alarm is off AND either the key is inserted OR the fingerprint is recognised.”
Let:
- $A$ = alarm is off
- $K$ = key inserted
- $F$ = fingerprint recognised
Expression: $A ∧ (K ∨ F)$
From Logic Circuits to Expressions
Look at the circuit below (described in words):
- Inputs: X, Y, Z
- First gate: AND of X and Y
- Second gate: OR of the AND result with Z
Expression: $(X ∧ Y) ∨ Z$
From Truth Tables to Expressions
Consider this truth table:
| A | B | Output |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
From the table we see the output is true when exactly one of A or B is true – that’s an XOR. Expression: $A ⊕ B$ (or equivalently $(A ∧ ¬B) ∨ (¬A ∧ B)$).
Simplification Techniques
- Use De Morgan’s laws: $¬(A ∧ B) = ¬A ∨ ¬B$
- Apply the Consensus theorem: $A ∧ B ∨ A ∧ ¬B = A$
- Combine like terms: $A ∨ A = A$
Exam Tips ??
- Read the problem carefully – identify all variables.
- Sketch a quick diagram or truth table to visualise the logic.
- Check your expression against the truth table or circuit.
- Use De Morgan’s laws to simplify before writing the final answer.
- Remember to use parentheses to show the correct order of operations.
Practice Problem
Write a Boolean expression for: “A light turns on if the power is on AND (the switch is up OR the motion sensor detects movement).”
Variables:
- $P$ = power is on
- $S$ = switch is up
- $M$ = motion sensor detects movement
Answer: $P ∧ (S ∨ M)$
Your Turn! 🧪
Try writing an expression for the following scenario:
“The alarm sounds if the door is open AND (the window is open OR the motion sensor is triggered).”
Revision
Log in to practice.