Lite / Discovering How the World Works / Week 22
AND, OR, NOT: combining conditions
A lift should move only if the doors are closed AND someone pressed a button. What happens if an engineer types OR by mistake?
Why should I care?
Real decisions rarely depend on one thing. A rover drives only if the path is clear AND the battery is fine. An alarm sounds if the door opens OR a window breaks. These three little words are also the building blocks of every computer chip.
- Combine two conditions using AND, OR and NOT.
- Fill in a truth table for a combined rule.
- Choose the right combination for a safety rule.
Predict
Rule: drive IF path clear AND battery OK. The path is clear but the battery is low. Does it drive?
- Yes
- No
Guess first, then reveal
No. AND needs both parts to be true. One false part is enough to make the whole thing false. That's exactly why engineers use AND for safety: every condition must be satisfied.
Discover
Try an AND gate, then an OR gate, then NOT. Flip the inputs through every combination (off-off, off-on, on-off, on-on) and write down when the output is on.
What the interactive shows (text version)
The logic lab can be replaced by these truth tables. AND: off+off → off, off+on → off, on+off → off, on+on → on. OR: off+off → off, off+on → on, on+off → on, on+on → on. NOT: off → on, on → off.
Watch (optional)
Watch for: Watch for the truth tables for AND and OR, and how NOT flips a value.
Introduces AND, OR, NOT and XOR, the building blocks behind every digital decision a computer makes.
“Boolean Logic & Logic Gates: Crash Course Computer Science #3” by CrashCourse (opens YouTube; streaming video uses a lot of data)
The video is optional. Everything you need is in this lesson's text.
Understand
AND: everything must be true
A AND B is true only when A is true and B is true. One false makes it false. Use AND when every condition is required: move IF doors closed AND button pressed.
OR: anything will do
A OR B is true when A is true, or B is true, or both. Only false when both are false. Use OR when any one reason is enough: alarm IF door opens OR window breaks.
NOT: flip it
NOT A is true when A is false. It lets you write rules like drive IF NOT obstacle. Combine them: drive IF path clear AND NOT battery low.
Truth tables
With two conditions there are only four possibilities: both false, first only, second only, both true. A truth table lists all four and the result. Checking all four rows is a quick way to make sure a rule does what you mean.
Explain it another way
Intuitive
A theme park ride: you can go on IF you're tall enough AND you have a ticket. You get free entry IF it's your birthday OR you're under 5.
Technical
AND, OR and NOT are Boolean operators. With two inputs, AND is true in 1 of 4 rows, OR in 3 of 4. Every digital circuit, from a calculator to a phone, is built from gates that compute these.
Applied
Factory machines use 'two-hand controls': the press only moves IF the left button AND the right button are both held. That guarantees both of the operator's hands are well away from the blade.
Worked example 1
Fill in the truth table for 'lift moves IF doors closed AND call pressed'.
Doors closed? / Call pressed? → Moves?
- No / No → No
- No / Yes → No
- Yes / No → No
- Yes / Yes → Yes
Only one row moves. With OR by mistake, the lift would move in three rows, including with the doors open.
Common mix-ups
OR means one or the other but not both.
✓ In logic, OR is also true when both are true. 'One but not both' is a different operator called XOR.AND and OR are interchangeable in everyday rules.
✓ They give very different behaviour. For safety, AND usually means 'every condition must be met'.
Practice
Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.
Apply it
Write a combined rule for a plant-watering helper: water IF the soil is dry AND it is NOT already raining. Draw its four-row truth table. Then add a third condition of your own and say whether it joins with AND or OR.
Reflect
Can you think of a rule at school or home that secretly uses AND or OR?
Write your answer on paper or in your own notes. Lite never stores what you write.