OCR H446, section 1.4.3 (a)
Boolean logic works with values that are only true (1) or false (0). Many problems can be described as conditions built from true or false facts, such as "the alarm sounds if the door is open and the system is armed". You need to be able to express such problems as Boolean expressions, and work out when they are true.
OCR's Boolean notation
OCR exams use these symbols. The alternatives in the right-hand column are also accepted in your answers.
| Operation | Symbol used | Example | Alternatives accepted |
|---|---|---|---|
| AND (conjunction) | A AND B, |
||
| OR (disjunction) | A OR B, |
||
| NOT (negation) | NOT A, , |
||
| XOR (exclusive disjunction) | A XOR B, |
||
| Equivalence (if and only if) | (or ) |
Order of precedence: NOT first, then AND, then OR. Use brackets to avoid doubt.
The truth tables
| A | B | |||
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 |
| A | |
|---|---|
| 0 | 1 |
| 1 | 0 |
- AND: true only when both are true.
- OR: true when at least one is true.
- XOR: true when exactly one is true (they differ).
- NOT: reverses the value.
From a problem to an expression
- Identify the simple conditions (the inputs) and give each a letter.
- Decide which are true when something happens.
- Link them with the words in the problem: "and" gives , "or" gives , "not" or "isn't" gives , "either, but not both" gives .
- Write the expression, using brackets for groups.
- Build a truth table to check it, or to find when the outcome is true.
Example 1: an alarm
"The alarm sounds if the door is open and the system is armed."
- = the door is open. = the system is armed. = the alarm sounds.
| D | S | Q |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Example 2: a drone
"A drone can fly if the battery is charged and it is not raining, or if the pilot has an override."
- = battery charged. = it is raining. = override. = it can fly.
| B | R | O | F | ||
|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 | 0 | 1 |
| 1 | 0 | 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 1 | 1 | 1 |
| 1 | 1 | 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 0 | 0 | 1 |
With 3 inputs there are rows. The drone flies in 5 of them.
Example 3: "either but not both"
"A student gets a discount if they are a member or a pupil, but not both."
- = member, = pupil: .
- The same as .
In programs
The same expressions are used in conditions in selection and iteration:
In OCR pseudocode: while x <= 5 AND flag == false.
Worked example
Task: write a Boolean expression for a lift: it moves if the door is closed, and either the "up" or "down" button was pressed, and the weight limit is not exceeded.
- = door closed, = up pressed, = down pressed, = weight limit exceeded, = lift moves.
Check one case: door closed (), up pressed (), no one pressed down (), weight fine (): . The lift moves. ✓
The brackets matter: without them, would mean something different (since AND binds tighter than OR).
Exam tip: define each letter, write the expression with brackets, and check it against one or two cases from the question. Use the OCR symbols (, , , ), or the accepted alternatives.
Check yourself
Write an expression for "the heater is on if it is cold and the timer is on"
With = cold, = timer on and = heater on: .
What is ?
0, because XOR is only true when exactly one input is true.
How many rows does the truth table for 4 inputs have?
.
Which has higher precedence: AND or OR?
AND. So means .