๐ง๐พโ๐ป Logic
Mental models for logical reasoning
Logic block viewer
This block viewer lets you flick through all the existing blocks in the Logic folder so you can choose what parts to add to your pages and what parts you might want to create, revise, or leave out.
It's literally just an alphabetical list of whatever is in this folder.
1000 Bottles of Wine
Now we’re going to solve a puzzle together. We’re going to think through a few different ways to approach it. This is a well-known puzzle and it’s certainly possible to google the answer. However, we’d suggest: don’t do that - you would steal from yourself the opportunity of learning this important idea.
๐น๏ธA long awaited party
Conditions:
๐พ You have 1000 wine bottles, one of which is poisoned.
๐ You have 500 rats you can use to test the wine.
โ The poison is lethal and will kill within 1 hour.
In your notebook, write down your solution to this problem. Here are the constraints again:
๐พ You have 1000 wine bottles, one of which is poisoned.
๐ You have 500 rats you can use to test the wine.
โณ The poison is lethal and will kill within 1 hour.
๐พ ๐พ ๐
One way to think of this is to reduce this problem to its simplest case. If you have 2 bottles and 1 rat, you can test the wine by giving the rat a sip from one bottle. Wait one hour. If the rat is alive, the bottle is safe. If the rat is dead, the bottle is poisoned.
With 500 rats, it’s similar, but not the same. Divide the 1000 bottles into 500 groups of 2. In round 1, give each rat a sip from one bottle in each group. Wait one hour. If the rat is alive, the bottle is safe. If the rat is dead, you found the poisoned bottle. If all rats are alive, the poisoned bottle is in the 500 bottles that were not tested. You still have 500 rats, so you can have each rat test the other bottle in their group.
This solution will take a maximum of 2 hours.
New condition
You now have just 10 rats to test the wine.
In your notebook, write down your solution to this problem. Here are the constraints again:
๐พ You have 1000 wine bottles, one of which is poisoned.
๐ You have 10 rats you can use to test the wine.
โณ The poison is lethal and will kill within 1 hour.
With just 10 rats, we need a way to make our solution more efficient. We can break our problem into 10 smaller problems. Think of it as a search pattern, narrowing down our suspects with each round of testing.
Round 1: Let’s divide our 1000 bottles into 10 groups of 100. Each rat tests one group : a sip from every bottle in its group of 100. An hour later, with one dead rat, we have narrowed our search to 100 bottles. We’ve saved 900 bottles of wine and we still have 9 rats to help us.
Round 2 Let’s do it again: take our suspicious 100 bottles and create ten groups of ten. Our nine rats each drink from one whole group (and one group goes un-drunk). Our doomed rat perishes again, and after another hour, we’ve found the right group of ten. We now have 8 rats.
Round 3 Now we’re down to just 10 bottles. Eight rats test a bottle each, leaving two untested. If a rat dies, we’ve found the poisoned bottle. If not, we have two bottles left for the last round.
Round 4: Base case We can use just one rat to test one bottle. If we have a dead rat, it’s the poisoned bottle. If not, the last untasted bottle is the culprit.
Through careful division and patience, we’ve turned an overwhelming search into a manageable investigation. Four hours, and we’ll have our answer.
New condition
The birthday party is now in 1 hour, so you only have time for one test!
Think about how you can use some of the thinking tools you just learned to solve this problem.
You will need boolean logic, deduction, and binary at least. Here are the constraints again:
๐พ You have 1000 wine bottles, one of which is poisoned.
๐ You have 10 rats you can use to test the wine.
โณ The poison is lethal and will kill within 1 hour.
โ You only have 1 hour so can only do 1 round of testing.
If we only have one hour, we can only do a single round of testing! Our strategy of narrowing down can’t work. We’re going to have to think about what we have learned about binary to solve this problem.
I really advise that you write this out yourself in binary as you follow the solution through.
Let’s reduce our case. Let’s say we have 3 bottles and 2 rats.
We’re going to number the bottles in binary. Each rat will test a different bit of the binary number. Rat 1 will test the 1s place, Rat 2 the 2s place.
Decimal | Binary | Rat 1 | Rat 2 |
---|---|---|---|
1 | 001 | x | |
2 | 010 | x | |
3 | 011 | x | x |
If only rat 1 dies, we know the poison is in the 1s place. It’s bottle 1. If only rat 2 dies, the poison is in the 2s place: bottle 2 is poisoned. If both die, bottle 3 is our culprit.
To be clear: instead of testing bottles one by one, we will have the rats sip from multiple bottles at once, just as with our progressive elimination search. But in this test, each rat’s survival or death becomes a piece of information that we can combine to locate the poisoned bottle.
Take a moment to check this out for yourself with 8 bottles and 3 rats.
Decimal | Binary | Rat 1 | Rat 2 | Rat 3 |
---|---|---|---|---|
1 | 001 | |||
2 | 010 | |||
3 | 011 | |||
4 | 100 | |||
5 | 101 | |||
6 | 110 | |||
7 | 111 | |||
8 | 100 |
Now, what about 16 bottles? How many rats do you need?
We can also frame this as: how many rats do we need for n
bottles? With 1000 bottles, do you definitely need 10 rats? How would you prove that?
Abduction
Learning Objectives
Abduction is reasoning to the best explanation for all the evidence we observe
Unlike deduction which proves only what must be true, or induction which only finds patterns that are probably true, abduction seeks the most complete explanation.
Given we guessed STARE
And we got ๐จโฌ๐จโฌ๐ฉ
Then LAPSE might be the answer (but we can’t be certain)
In Wordle, we think like word detectives. We have an initial constraint: it must be an English word of five letters.
We have five attempts. Each guess we make gives us some feedback and allows us to eliminate some hypotheses, or guesses. A yellow square might support our theory about which letters are in the word, contradict it, or suggest a completely different explanation. We must:
- Keep track of all feedback squares
- Form multiple possible word theories
- Test each word against all the evidence
- Choose the word that best fits everything we know
- Make a guess even though we can’t know for sure whether we’re right
- Revise our guess when new evidence appears
It’s quite a lot like problem solving we’ve done before, isn’t it? This process of seeking the best explanation mirrors how we approach complex problems in many fields:
๐ง๐ฝโโ๏ธ Doctors diagnosing illnesses from symptoms
๐ต๐ฟ Detectives solving cases from clues
๐ง๐ฟโ๐ฌ Scientists developing theories from observations
๐ง๐ปโ๐ง Engineers troubleshooting system failures
We need a strategy, but experience also matters. In Wordle, the more English words we know, and the more we know about words, the better our guesses. In engineering, the more we know about building software, the faster we can find our problems.
Now go solve today’s puzzle:

Today's Wordle
๐ Use abductive reasoning to best explain the evidence
Binary Information Theory
At its heart, our rat puzzle demonstrates how binary data encoding works. Each rat represents one binary digit (a bit). They either live (1) or die (0). With 10 rats, we have 10 bits of information.
๐งฎ The Power of Binary
- 1 bit can represent 2^1 = 2 possibilities (0 or 1)
- 2 bits can represent 2^2 = 4 possibilities (00, 01, 10, 11)
- 3 bits โ 2^3 = 8 possibilities
- 10 bits โ 2^10 = 1024 possibilities!
๐ฏ Key Insight
This is why 10 rats are enough for 1000 bottles. Each possible combination of rat survival/death can uniquely identify one bottle number. We’re seeing the same principle that allows computers to encode vast amounts of information using just 1s and 0s.
๐ Memory Locations
Just like how computers use binary addressing to locate specific memory locations, we’re using our “rat bits” to encode the location (bottle number) of our poison. Each bit helps narrow down the possibilities until we have a unique address.
Binary Logic recap
Learning Objectives
Read the learning objectives listed on this page: Bear in mind what you’re trying to achieve while reading this text. If a topic isn’t making much sense, and isn’t in the objectives, you can probably skip over it. If a topic is listed in the objectives, you should keep studying it until you are confident you’ve met the objective.
Reading
Review chapters 1, 2, and the “Binary Addition”, “Signed Numbers” and “Unsigned Numbers” sections of chapter 5 of How Computers Really Work. This time focus on the Binary Logic section that you might have skipped before.
Do every exercise listed in the chapters that you haven’t done before. You can skip the projects.
Check you have achieved each learning objective listed on this page.
Bisection
Learning Objectives
In bisection, we start with a large problem space and cut it in half with each guess.
In software development, bisection helps us find exactly when a change occurred. For example:
Given our code worked last week but not today
When we test the middle version and it works
Then the problem must be in the newer half
With each test, we:
- Select the middle version
- Test if it works
- Eliminate half the versions
- Repeat until we find the exact change
This binary search technique is remarkably efficient. Even with thousands of versions, we’ll find the problematic change in just a few tests. Git and other version control systems include built-in bisect tools for this purpose.

Higher or Lower
๐ Guess the number efficiently
Boolean Logic
Learning Objectives
Boolean logic uses only true or false to reason about the world.
In the real world, we use logic to make decisions all the time. For example: if it’s raining and you don’t have an umbrella, you will get wet. This can be represented as a truth table:
Is Raining | Has Umbrella | Is Wet |
---|---|---|
F | F | F |
F | T | F |
T | F | T |
T | T | F |
Truth tables show all possible combinations and all possible outcomes.
Given A is true (1)
And B is true (1)
Then A AND B is true (1)
In computers, we use binary logic to derive conclusions from data. Each bit can represent a logical state:
Raining | Umbrella | Wet |
---|---|---|
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 1 |
1 | 1 | 0 |
This is fundamental to how computers work. Every operation a computer performs, from simple addition to complex decision-making, ultimately comes down to chains of basic logical operations on 1s and 0s.
Try building some truth tables yourself in your notebook. Here are some examples to get you started:
- “You can get a loyalty reward if you have the app AND have made 10 purchases”
- “The alarm will sound if the door is open OR motion is detected, UNLESS the system is disabled”
- “Trainees pass the course if they complete coursework AND attend class AND complete their steps”
Deduction
Learning Objectives
Deduction is reasoning from general rules to a specific conclusion that is definitely true
In Murdle, we use deduction to solve murders. Given general rules about the crime scene and specific clues, we can
Given the body was found in the kitchen
And only Miss Saffron had been in the kitchen
Then Miss Saffron must be the murderer
This is deduction: starting with general rules and arriving at a specific conclusion that must be true. Unlike guessing or inferring patterns, deduction gives us certainty. If our premises are true, our conclusion must be true.
In Murdle, every puzzle can be solved through pure deduction. There’s no need to guess. The clues and rules will lead you to a single possible murderer.
Go play Murdle.

Murdle
๐ A deductive logic puzzle game
Falsification
Learning Objectives
Falsification is an efficient reduction strategy. It means making predictions that eliminate possibilities, rather than gathering evidence that supports them
Given many possible rules
Make a prediction that could eliminate some
When the prediction fails
Then we can discard those possibilities
This is a subtle distinction: dis confirmation is the mental model we must build here. In 20 Questions we discovered our problem space by confirming and disconfirming our guesses. In Zendo, we will try to discover the rule governing pyramid patterns not by confirming our guesses, but by eliminating what’s impossible
Here’s a classic example:
Popper explains that each additional white swan appears to confirm our wrong idea that all swans are white. A single black swan disproves it, and ends the loop. This strategy shows us that:
- Only gathering confirming evidence leaves too many possibilities, or too large a problem domain
- However, each failed prediction narrows our search space by discarding possibilities
- We learn more from being wrong than being right
It is more efficient to find a way to disprove your hypothesis or falsify your proposition, if you can. This is because you only need to disprove something once to discard it, but you may apparently verify a hypothesis many times in many different ways and still be wrong.
Now, practice eliminating possibilities in Zendo. For this game you need a group, so post in Slack to find others to play with.

Zendo
๐ Eliminate to learn
Induction
Learning Objectives
Induction is reasoning from specific examples to form general patterns that are probably true
In Sushi Go, we use induction to build winning strategies. By observing specific outcomes across multiple hands, we form general theories about what works. For example:
Given collecting 3 tempura scored 10 points
And collecting 2 tempura scored 5 points
And collecting 1 tempura scored 0 points
Then tempura probably works best in pairs
Unlike deduction which gives certainty, induction helps us form educated guesses about patterns. The more examples we see, the more confident we can be in our general conclusions - but we can never be 100% certain.
In Sushi Go, every game teaches us something new about card combinations, timing, and player behavior. Through repeated play, we inductively learn strategies like:
- Watching what others collect helps predict what cards will come around
- Early puddings often pay off in the final round
- Chopsticks are most valuable when saved for high-scoring combinations
Play a few rounds of Sushi Go and practice inductive reasoning. Don’t spend a long time reading the rules, just play through a few rounds to get the idea. Try to:
- Notice specific scoring patterns
- Look for recurring situations
- Form general theories about good strategies

Sushi Go
๐ Pattern finding
Introduction
Welcome to Logic. For this module, we will get out of VSCode and build mental models we can use anywhere to reason more effectively.
You will need
๐ Notebook and pen
๐ง Your wonderful brain
๐ And you will still need the curriculum and Google, that’s not banned, don’t worry.
Learning by teaching
In this prep you will build a series of mental models necessary for logical reasoning. You likely already know some of these pieces. We will start to build each model by playing a game. Pay attention, because…
In class this week you will be teaching something. You will be explaining one of these mental models. You will not use a computer to explain this, but something else. This could be a drawing, a game, a conversation, or anything you like that will help you communicate the concept, except a computer!
You should make sure you understand all these models, but choose just one to teach in class.
Mental models
- Deduction: Reasoning from general rules to a specific conclusion that is definitely true
- Induction: Reasoning from specific examples to form general patterns that are probably true
- Abduction: Reasoning to the best explanation for all the evidence we observe
- Falsification: Testing a theory by trying to prove it wrong
- Problem Domain: Identifying the bounded space that contains all possible solutions to a problem
- Bisection: Reasoning by reducing a problem space to the smallest possible size
- Binary Logic: Reasoning with only two possible states (true or false)
Your task
Your core prep for this sprint is to learn about all of these mental models. You will do this by reading, and by playing games that use them.
You will need to prepare to teach other people about one of these mental models. Make sure to coordinate on Slack so that people are teaching different mental models.
Learn by Teaching
This sprint you should have prepared to teach one of the following topics:
Topics
- Deduction
- Induction
- Abduction
- Falsification
- The Problem Domain
- Bisection
- Binary Logic
โฐ Timekeeper
The timekeeper will keep the groups on track.
๐ Instructions
Split into pairs. Each person will have 3 minutes to present their topic. After the lesson, you and your student will discuss the topic for 3 minutes. Then the student will become the teacher and present their own topic.
๐ง๐พโ๐คโ๐ง๐ป Pairs
1. Model
You will explain your topic to your student. You will have 3 minutes to communicate, in whatever way you have prepared. You can use a drawing, a game, a conversation, or anything you like that will help you communicate the concept, except a computer!
2. Check understanding
After your lesson, you and your student check your understanding for another 3 minutes. Then you will switch roles.
3. Add yourself to another group
At the end of both lessons, join another pair. Pick one of your topics and explain it to the other pair. They will do the same for you. At the end of both lessons, join another group of four and repeat the process.
๐ก Tips:
- Practice your lesson before class.
- Keep it simple. Just choose one concept to explain.
- Keep it short. Three minutes is enough.
The Problem Domain
Learning Objectives
The problem domain is a bounded space that contains all possible solutions to a problem. Everything outside the problem domain is impossible or irrelevant.
Given no constraints
Then… the answer could be anything in the universe!
When we add “must be a number”
Then we constrain to the domain of numbers
Before we can solve a problem, we need to understand what’s possible. In Twenty Questions we start with everything in the universe, then ask questions to reduce our problem space. We might start with “Is it alive?” to constrain our domain to animals, then “Is it a mammal?” to reduce further.

Twenty Questions
๐ Ask questions to reduce possibilities