TactivergeLite

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?

About 30 min · 3 goals · Reviewed by the founders' mentors · Full interactive version

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.

Predict

Rule: drive IF path clear AND battery OK. The path is clear but the battery is low. Does it drive?

  1. Yes
  2. 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.

You can also open the interactive on the full site when you have a faster connection.

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?

Only one row moves. With OR by mistake, the lift would move in three rows, including with the doors open.

Common mix-ups

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

Practice 1. A burglar alarm should sound if the door opens or a window breaks. Which word joins the two conditions?
Practice 2. A paper shredder should run only when the bin is in place and paper is detected. Which rule is right?

Practice 4. A rover's rule is 'drive IF NOT obstacle'. The obstacle sensor says true. Does it drive?

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.

← Choosing a good thresholdRepeat N times →