Yes, no and the logic of every decision
Chiamaka is paying for groceries at a supermarket in Lekki. She slots her card into the POS machine, types her four-digit PIN, and waits. Two seconds later the little screen says APPROVED, the slip curls out, and she walks away with her bags.
In those two seconds, something made a decision. Somewhere, a machine asked a set of questions — Is this PIN right? Is there enough money in the account? Has this card been reported stolen? — and from the answers, it decided: approve.
That sounds like thinking. In this lesson you will see that it is not thinking at all, in the way you think. It is something simpler, and in a way more beautiful: every decision a computer has ever made is built from yes-or-no questions joined by just three small words — AND, OR and NOT. Those three words are where switches start to "think". And the idea behind them came, not from an engineer, but from a self-taught mathematician in the 1840s who wanted to write down the laws of human reasoning.
Words in this lesson
| Word | What it means |
|---|---|
| Condition | A statement that is either true or false — "the PIN is correct" |
| True / false | The only two answers a condition can have; computers write them as 1 and 0 |
| AND | True only when every condition joined by it is true |
| OR | True when at least one condition joined by it is true |
| NOT | Turns true into false, and false into true |
| Truth table | A table showing the answer for every possible combination of inputs |
| Logic | Rules for reaching correct answers from true-or-false statements |
| Boolean | Named after George Boole: anything to do with true-or-false logic |
Every decision is a set of yes-or-no questions
Look again at Chiamaka's payment. The decision "approve or refuse" feels like one big judgment, but it can be broken into small questions, each with only two possible answers:
- Is the PIN correct? Yes or no.
- Is there enough money in the account? Yes or no.
- Has the card been reported stolen? Yes or no.
Each of these is a condition: a statement that is either true or false, with nothing in between. "The PIN is correct" is true or it is false. It cannot be "a bit correct".
You already know from Module 2 that a computer is built from switches with two states. Here is the connection that changes everything: true and false are also two states. A switch that is on can stand for "true". A switch that is off can stand for "false". Computers write true as 1 and false as 0 — the very same 1 and 0 you have been using to count.
So a decision is a handful of switches, each set by one yes-or-no question, and a rule that joins them. The rule is built from three words.
AND: everything must be yes
The POS machine should approve only if the PIN is correct and there is enough money. Both must be true. If either is false — wrong PIN, or not enough money — the answer is no.
That is AND. It is true only when every condition it joins is true.
The clearest way to see what AND does is to list every possible situation. With two conditions, each true or false, there are exactly four possibilities. A table that lists them all, with the result for each, is called a truth table:
| PIN correct? | Enough money? | Approve? (AND) |
|---|---|---|
| 0 (no) | 0 (no) | 0 (no) |
| 0 (no) | 1 (yes) | 0 (no) |
| 1 (yes) | 0 (no) | 0 (no) |
| 1 (yes) | 1 (yes) | 1 (yes) |
Only one row in four says yes: the row where both inputs are 1. That is the whole personality of AND — strict, demanding, satisfied only when everything is right.
You meet AND all day without naming it. You can sit the exam if you have paid your fees and you have your exam card. You can board the danfo if there is space and you have the fare. Every "and" in a rule is a place where all the conditions must hold.
OR: at least one yes
Now think about the security man at the gate of an estate. His instructions are: let a visitor in if they live here or they are on today's visitor list. Either one is enough. Both is fine too.
That is OR. It is true when at least one of its conditions is true.
| Lives here? | On the list? | Let in? (OR) |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
Three rows in four say yes. Only when every condition is false does OR say no. Where AND is strict, OR is generous.
A word of warning about "or"
In everyday English, "or" sometimes means one or the other, but not both. "Will you have rice or yam?" usually means pick one. A computer's OR never means that. In logic, OR is true when one condition is true or when both are. A resident who also appears on the visitor list still gets in. (There is a separate rule for "one or the other but not both". It has its own name, and you will meet it in the next lesson.)
NOT: turning yes into no
The third word is the simplest. NOT takes one condition and turns it upside down. NOT true is false. NOT false is true.
| Card reported stolen? | NOT stolen? |
|---|---|
| 0 | 1 |
| 1 | 0 |
Why would anyone need this? Because the POS machine's rule is not "approve if the card is stolen" — it is "approve if the card is not stolen". The bank stores the fact "this card has been reported stolen" as a 1 or 0. To use it in an approval rule, the machine has to flip it.
You use NOT constantly too. "You may go out if it is not raining." "Charge the phone if it is not already full." Whenever a rule cares about something being absent, NOT is there.
Joining them: rules with many conditions
The real power appears when you combine the three words. Here is something close to the rule a card payment needs:
Approve if the PIN is correct AND there is enough money AND the card is NOT reported stolen.
Three conditions, joined with AND and NOT. Here is what happens in four real situations:
| PIN correct | Enough money | Stolen | NOT stolen | Approve? |
|---|---|---|---|---|
| 1 | 1 | 0 | 1 | 1 — approved |
| 0 | 1 | 0 | 1 | 0 — wrong PIN |
| 1 | 0 | 0 | 1 | 0 — not enough money |
| 1 | 1 | 1 | 0 | 0 — stolen card |
With three yes-or-no inputs there are 2 × 2 × 2 = 8 possible combinations (the same doubling you learnt in Module 2). This table shows four of them; the other four all give 0, because each has at least one problem.
Worked example: a rule with OR inside it
Some banks let a customer go slightly overdrawn. Then the rule might become:
Approve if the PIN is correct AND (there is enough money OR an overdraft is allowed) AND the card is NOT stolen.
The brackets matter, exactly as in arithmetic: work out the part inside them first. Take a customer with the right PIN, not enough money, an overdraft allowed, and a card that is not stolen:
- Inside the brackets: enough money (0) OR overdraft allowed (1) → 1.
- NOT stolen: NOT 0 → 1.
- Now join everything with AND: PIN (1) AND brackets (1) AND not-stolen (1) → 1. Approved.
Now suppose a careless programmer groups it differently: (PIN correct AND enough money) OR (overdraft allowed AND card NOT stolen). Run the same customer through it: (1 AND 0) OR (1 AND 1) → 0 OR 1 → 1. Approved again, so the mistake hides. But run a customer with the wrong PIN and an overdraft: (0 AND 0) OR (1 AND 1) → 1. Approved! With one change of grouping, anyone with an overdraft could pay without knowing the PIN. Logic mistakes like this happen in real software, and they can be very costly. Getting the logic right is not a detail; it is the job.
From a philosopher's question to your phone
Where did this way of thinking come from? Not from computers. It is far older.
George Boole was an English mathematician, born in 1815. According to University College Cork, where he later taught, he had little formal education and was largely self-taught, and at sixteen he became the breadwinner for his parents and three younger brothers and sisters, working as a junior teacher. In his spare hours he chased a question that went back to the philosophers of ancient Greece: can the rules of correct reasoning be written down as precisely as the rules of arithmetic? In 1847 he published a short work called The Mathematical Analysis of Logic, arguing that just three operations — AND, OR and NOT — can perform all logic, according to the Computer History Museum in California. In 1854, by then a professor at Queen's College in Cork, Ireland, he expanded the idea in a book called An Investigation of the Laws of Thought.
Boole treated true and false like numbers, and AND, OR and NOT like arithmetic on them. That is why true-or-false logic is still called Boolean logic today, and why programmers talk about "Booleans" every day.
And then, for decades, almost nobody used it. The Computer History Museum says Boole's ideas were largely ignored until the 1930s.
The person who woke them up was Claude Shannon, an American student who first met Boole's ideas in a college philosophy class. In 1937, in his master's thesis at the Massachusetts Institute of Technology, he showed that Boole's algebra could be used to design circuits built from relays — electrical switches then used in telephone exchanges. MIT later described this work as the beginning of modern switching theory, and a Harvard professor, Howard Gardner, called it possibly the most important master's thesis of the century.
Put the two together and you get the idea at the heart of every computer:
- Boole showed that reasoning can be done with 1s and 0s.
- Shannon showed that switches can do Boole's reasoning.
A switch that is on is "true". Two switches arranged one way give AND; arranged another way, OR. In the next lesson you will build those arrangements yourself, and see how the transistors from Module 1 do the same thing billions of times over.
Common mistakes
| The mistake | Why it is wrong | What to do instead |
|---|---|---|
| "AND means add" | AND is about conditions all being true, not adding numbers | Read AND as "every one of these must be yes" |
| Thinking OR means "one but not both" | A computer's OR is true when both conditions are true as well | Read OR as "at least one" |
| "A condition can be partly true" | In Boolean logic, every condition is exactly true (1) or false (0) | Break vague questions into sharp yes-or-no ones |
| Ignoring brackets in a rule | The same words in a different grouping can give a different answer | Work out the brackets first, as in arithmetic |
| "The computer understands the decision" | It combines 1s and 0s by fixed rules; it does not know what a PIN is | Think "following rules", not "understanding" |
The short version
- Every computer decision is built from conditions: statements that are exactly true (1) or false (0).
- AND is true only when every condition is true. OR is true when at least one is. NOT flips true and false.
- A truth table lists every possible combination of inputs with its answer. Two inputs give 4 rows; three give 8.
- Combining AND, OR and NOT, with brackets, can express real rules — like approving a card payment. A misplaced bracket can make a rule dangerously wrong.
- George Boole (1847, 1854) showed reasoning could be done with true and false like arithmetic. Claude Shannon (1937) showed switching circuits could do Boole's logic.
Try it yourself
Write the logic of real life.
- Pick a rule from your own life that has at least two conditions — a school rule, a rule at work, how you decide whether to go out. Write it as one sentence using AND, OR or NOT.
- Draw its full truth table: every combination of 0s and 1s for the conditions, and the answer in the last column. Check you have 4 rows for two conditions or 8 for three.
- Write the estate gate rule from this lesson as a truth table, then change it to: "let in if they are on the visitor list AND NOT banned". How many rows say yes now?
- Take the overdraft rule from the worked example. Run three different customers through it, one row at a time, showing each step as the worked example did. Then run the same three through the wrongly bracketed version. Which customer gets a different answer?
- Explain to someone at home, without the words "Boolean" or "logic", why a computer that only knows on and off can still decide whether to approve a payment.
You'll know you've got it when you can take any everyday rule, rewrite it with AND, OR and NOT, and draw a truth table that shows exactly when it says yes — and when you can tell the story of how a nineteenth-century mathematician's idea ended up inside a POS machine.
More free previews
- ▶What a computer actually is15 min
- ▶Counting in twos15 min
- ▶Opening the box20 min
- ▶From numbers to words: how people talk to processors25 min
- ▶What a file really is20 min
- ▶How bits travel: wires, light and radio20 min
- ▶What really happens when you open a web page20 min
- ▶How passwords are stored, and cracked25 min
- ▶From rules to learning20 min
- ▶The whole journey: from a tap in Lagos to a screen in London25 min