◈ quant roadmapPart 0 · Ch 01/45
Quantitative Finance — the Mathematics of Markets · chapter 01

01Sets, Logic & the Art of Counting

The roadmap left us with one sentence: put a number on an uncertain future, then size your bet against the risk of being wrong. Every chapter after this one is that sentence made rigorous. But read it again and you'll notice it quietly assumes two things we have not earned yet. Before you can put a number on something, you have to be able to say which things you're talking about. And you have to be able to say how many there are. That's this chapter, and I want to warn you up front that it is not the boring one. It contains the single move that regenerates every counting formula you'll ever need — and a much stranger idea underneath it: "how many?" is never answered by looking. It is answered by pairing. Here's the plan. We'll build a set as a door that only says yes or no. We'll build a function as a vending machine with no formula in it. Then we'll settle "are there more people or more seats?" in a packed theatre — with total certainty, without counting anything. From there, counting becomes a strategy instead of an act of perception, and the strategy is this: count the easy thing, ask how many times each answer got built, and correct for it. By the end, C(n,k) = n!/(k!(n−k)!) — five people, pick two, 120/(2 × 6) = 10 — won't be a formula you memorized. It'll be the first thing you compute with a tool you own.

There's one real prerequisite, and it isn't algebra. This chapter is going to ask you to accept that a definition is a choice we make to keep our reasoning honest. It is not a truth someone discovered. For about ten minutes you'll need to let go of "but everyone knows what counting is." That's the whole entry fee. Everything else you already have: you can multiply, you can divide, you trust that 6/2 = 3, and you have physically pointed at things and said "one, two, three."

Here's the whole course on one page: the four verbs, the foundations underneath them, and the craft on top. We are standing on the very first rung. Nothing sits behind it.

Fig 1 · The course as a tower — pull Chapter 1 out and watch it fall
MODEL ESTIMATE PRICE ACT COMPUTE PART 0 foundations ? ★ Ch 01 1 2 ··· THE CRAFT
click a pillar — trace its road down to Ch 01 ↓
the tower stands — click a pillar
now pull the keystone. predict first: with Ch 01 gone, the tower…
tap “why here?” for the one sentence Ch 01 makes true
Nothing above stands without Chapter 1.
Ch 01 — the keystone every road runs into
MODEL · ESTIMATE · PRICE · ACT — the four things a quant does
pull Ch 01 → all four have nothing to stand on
Fig. 1. Pull the Ch 01 keystone and watch the tower fall.

Notice what's underneath everything: sets and counting. That isn't because they're elementary, but because the word probability has no meaning until they exist, so let's build them.

01Which things? A set is a door test

Start with a word you already use: collection, which in everyday English is basically a list. It has an order — there's a first one and a last one. And it can repeat — you can have two of the same thing in it. Hold onto that, because a set has neither of those, and the difference is going to cost you real money later if we let it slide now.

Think about a queue versus a guest list. In a queue, position matters, because being third is different from being seventh, and you could even leave and rejoin in principle, so you'd be in it twice. Now the guest list. There's a bouncer at the door, and he has exactly one question: are you on it — yes or no? He doesn't care what order you arrived in, and he doesn't care that you RSVP'd three times. Yes, or no. That's it.

That bouncer is the set. Not a picture of a set, not a metaphor for a set — a set is precisely a rule that answers yes or no about any thing you hand it. Type whatever you like into the door below and watch what comes back.

The membership test — two sets are the same only if they never disagree
{1,2,3} set A ? · {1,2,2,3} set B ? each column = one question you asked A B
Comparing {1,2,3} & {1,2,2,3}. Try to make them disagree — one different answer proves they’re not the same set.
pick a pair, then hand it a question
A set is a rule, not a list: hand it anything and it answers YES or NO. Same answers to every question = the same set.
set A and its every answer, ticked  YES /  NO across the columns.
set B’s answers, row below. A  gold column = the two disagreed there — the weld snaps.
{1,2,3} & {1,2,2,3}: ask anything — they never disagree. A repeated 2 is invisible.
& {∅}: agree on everything… until you ask “∅” itself.
Fig. 2. A set isn’t a list — it’s a rule: hand it anything, it answers YES or NO. {1,2,3} and {1,2,2,3} answer every question exactly alike, forever, so they’re one set; ∅ and {∅} finally split on a single question — “is ∅ inside you?”

So {1, 2, 2, 3} and {1, 2, 3} are the same set. The door gives identical answers to every question you can ask it, and the door is all there is. Writing 2 twice doesn't create a second 2. It just wastes ink. In the same way {1, 2} and {2, 1} are the same set, because "which order did you write them in" is not a question the door can even hear.

Two more things fell out of that door. A door that says no to everyone is still a door, which is the empty set, written . It's a real object — a perfectly good bouncer who happens to have an empty list. And now the one that trips everyone: {∅} is not the same as , because a room containing an empty room is not an empty room. Ask {∅} whether is inside it and the door says yes, so it has exactly one thing in it. That thing just happens to be nothing-shaped.

Now the confusion I promised would cost you. Deal three cards and read them as a sequence of draws: A-then-K-then-Q is a different object from Q-then-K-then-A — different order, different thing. Read the same three cards as a poker hand and they are one object, full stop. A hand is a set, and a sequence of draws is not. Flip the switch below and watch six different sequences collapse into one hand.

Order counts, then it doesn’t — six deals of A·K·Q fall into one hand
your hand — drag to reorder deals 6 A K Q J 10 A K Q A Q K K A Q K Q A Q A K Q K A 24 orders {A,K,Q} 3! = 6 ordered deals
3 cards: 6 → 1
order matters — six deals here
What you’re looking at — every shuffle of the same cards is one hand
blue — an order: which card is 1st, 2nd, 3rd. Drag A K Q and the matching one of the deals lights up. Every order is a different sequence — there are 3! = 6.
gold — the hand to watch. Flip to SET and all six slide into one {A,K,Q} because a set can’t hear the order: 6 ÷ 3! = 1. Scale up — deals explode to n!, the hand stays one.
Fig. 3. Drag A, K, Q into any order and the matching one of the six deals lights up — a sequence cares which card comes first. Flip the switch to SET and all six slide into a single hand {A,K,Q} (6→1): the same three cards, but order stops counting, because 6 ÷ 3! = 1. Scale the hand up and the deals explode to n! while the hand stays exactly one.

Feel how many things vanished when you flipped that switch. Six went to one. That collapse is not a technicality — it is the source of roughly half of all wrong counts in this entire course, and we'll come back and stare straight at it in Section 4. For now just carry the flag: before you count anything, decide whether the object you're counting is a set or a sequence.

We have doors. Now wire two of them together. If a set is a yes/no test, two sets give you two tests, and there are only three interesting ways to combine two yes/no answers: and, or, not. Nothing new is entering the room. We are wiring switches.

"And" gives you the things that pass both doors, which is the intersection, A ∩ B. "Not" gives you everything that fails the door, the complement. And "or" gives you the union, A ∪ B — but here I have to stop you, because English is about to lie. When someone asks "coffee or tea?" they mean pick one, but in maths "or" is inclusive: A ∪ B means at least one, and both is completely fine. It's the door that opens for anyone holding at least one ticket.

Now the one that actually does damage, and I want you to commit to an answer before you read on. There's a sign on the wall, and it says: NOT (raining AND cold). Right now it is raining, and it is warm, so does the sign still hold? Decide, then press your answer.

De Morgan — is “NOT both” the same as “neither”? Walk the pin, then predict which law paints the sign.
the sign: ¬(A ∧ B) sky = every possible weather A raining B cold both neither
Drag the gold pin around the sky — the lamps read three claims at that weather. Then predict: which law floods exactly the sign?
predict which law equals the sign
sign ¬(A∧B)
¬A ∨ ¬B
¬A ∧ ¬B
pin sits in: only raining
“Not both” only needs one to fail — so it is an OR of failures, not an AND.
¬A ∨ ¬B floods the sky except the lens — exactly the sign.
¬A ∧ ¬B (the trap) paints only the far “neither” corner.
Fig. 4. Drag the pin, then predict which law paints the sign ¬(A∧B).

The sign holds. And if your gut said no, good — that's the exact wrong turn we needed to catch. "Not both" is not the same sentence as "neither", because "not both" only needs one of them to fail. It's raining but it isn't cold, so it isn't both, so the sign is fine. Now say that back slowly: "not both" means "at least one of them is false." That sentence, written in symbols, is ¬(A ∧ B) = ¬A ∨ ¬B. That's De Morgan's law, and it's not an identity to memorize. It's a transcript of a sentence you just said out loud, and the Venn shading in that figure is the same sentence drawn.

One more piece of grammar and we can leave. Suppose I chop a set into pieces: when am I allowed to just add up the piece-counts? This looks like bookkeeping, but it is actually the licence for the plus sign, and it fails silently, which is the worst way for anything to fail. So let's break it on purpose. Count a deck of cards by suit, then count it by red cards and face cards, and check both against the real deck.

The licence to add — when does |A|+|B|+… count all 52 cards, each exactly once?
0 Σ blocks · Σ = count? 0 cards lit · count = 52? 52 the deck
Pick a way to split the deck. Watch each block claim its cards.
partition holds: 52 = 52
A split earns the right to add only if it passes BOTH tests: every card lit once, none lit twice.
13+13+13+13 = 52 ✓ 52 = 52
disjoint — no card counted twice (red rings in the grid). This is what repair can’t fake.
covers all — no card left dark (dashed holes in the grid). Both lamps green = the “+” is licensed.
0 doubled · 0 missed
Fig. 5. A 52-card deck as a 13×4 grid, split five ways. Each block claims its cards: a clean split drops exactly one chip on every card, so Σ blocks = cards lit = 52 and both lamps glow. Suit, colour and rank pass. Red+face claims the 6 red face cards twice (red rings) — the sum 38 overshoots the 32 cards that exist. Aces+♠ leaves 36 cards dark — the sum never counted them. The two lamps are the licence a partition needs before + is legal: repair subtracts the 6 so the arithmetic reads 32 = 32, yet the disjoint lamp stays red — you patched the number, not the structure.

By suit: 13 + 13 + 13 + 13 = 52. Correct. By red-and-face: 26 + 12 = 38, but the real answer is 32. Six cards — the red face cards — got counted twice, once for being red and once for having a face. Notice that addition didn't go slightly wrong here: it was never legal in the first place, and nothing warned you.

So here's the repair, and the two conditions have earned their keep. A partition of a set is a collection of pieces that (1) don't overlap — every pair of pieces intersects in — and (2) cover everything — their union is the whole set. Suits are a partition of the deck. Red/face is not. When you have a partition, and only then, you get the addition rule: |A| + |B| = |A ∪ B| for disjoint pieces. Hearts and spades never overlap, so 13 + 13 = 26 cards, nothing to correct. Neither condition is new: an empty intersection, and a union that reaches everything, demanded at the same time.

02The pairing — and what "how many" really means

We can now say which things: sets, and the and/or/not grammar on top of them. The next step is small: two sets are sitting there, so connect them — reach into one and land on exactly one thing in the other. That's it. That's the whole idea, and it's called a function.

Now, I know what your mental image is, because it's everyone's: y = 2x + 1. A formula. Some algebra you feed a number and get a number out. Please put that down for a minute, because it's the single most expensive misconception in this chapter. It's why "probability is a function on sets" is going to sound like mysticism in Chapter 9 when it should sound like Tuesday.

Look at a vending machine instead. Press B4 and you get exactly one thing. A machine that gives you a Snickers on Tuesday and a Twix on Wednesday from the same button is broken — and you didn't need a definition to know that, you just know it. That feeling is "exactly one." Now notice what the machine does not have anywhere inside it: a formula. Its rule is a lookup table screwed to the inside of the door. Press the buttons.

The one-output machine — press a button and watch exactly one thing land. Flip the switch and watch that promise break.
the buttons — DOMAIN the shelf — CODOMAIN tray break-it switch — click to cycle normal random double
press any button — one press, one item, always.
mode: normal exactly ONE output, always
the same-input test
press a button twice
press a button
A function keeps one promise: one input, one output — every time.
a button = an input; all 12 = the domain
the lit slot = the output; green = the range
a red fork = one input, two outputs — not a function
Fig. 6. One button, one wire, one slot — break it and the wire forks.

So: a function is a rule pairing each element of a domain with exactly one element of a codomain. The domain is the buttons. The codomain is the shelf — everything the machine could conceivably dispense — and the range is what actually drops for some button. So why name a shelf that's bigger than what comes out? Because we want to describe the machine's type before we know its stock, and that is the entire reason a codomain exists.

And while we're here — y = ±√x is not a function. That isn't because a rule forbids it, but because it's a machine that drops two cans: 9 gives back both 3 and −3.

Now stare at a map's arrows for a second, because there are only two ways a bunch of arrows can be imperfect. Either two arrows crash into the same target, or some target is sitting there untouched, and that's the whole taxonomy, forced rather than invented. Drag the arrows and watch both alarms.

Send each input to an output — then throw the switch and run the map in reverse
inputs outputs ▶ forward A B C D 1 2 3 4 5
inputs
collision?no unreached?no
map: bijective · 1/4 found
tap an output to trace it back
A map is a promise — reverse is the test of it
blue inputs — each fires exactly one arrow.
gold heads — drag onto an output; two into one = collision, none hit = gap.
reverse — only no collisions, no gaps survives = bijective.
Fig. 7. Drag heads to re-route, then flip forward/reverse to test invertibility.

Now the names land on something you're already holding. No collisions means the map is injective, and nothing missed means it's surjective. Both at once and it's a bijection — a perfect pairing. Here's the way I've come to think about it: injective means nothing is lost (given the output, you can always recover the input), and surjective means nothing is wasted (every target earns its place).

And now the rung that almost every course on earth skips.

You're in a packed theatre: ten thousand seats, no seat numbers, people everywhere. Question: are there more seats or more people? You cannot count either one, because you'd lose your place by row forty and there's no way to check yourself. So do this instead: ask everyone to sit down, one person per seat, and look at what happens.

Fig. 8 — pair, don't count: settle "more people or more seats?" with zero numbers
THE LOBBY THE HOUSE
◂ PAIR THEM ▸ 0% seated
anyone standing?
any seat empty?
predict, then drag to pair
"Same number" is a perfect pairing — one person, one seat, nobody left over.
nobody standing = injective.
no seat empty = surjective. Both = bijection.
Fig. 8. Counting loses its place — pairing settles "more people or more seats?" with zero numbers.

Nobody is left standing — so no two people crashed into one seat, and nobody missed out. That's injective. No seat is empty, because every seat got reached, and that's surjective. So the answer is: exactly the same number. And I want you to sit with how strange that is, because you now know it, with total certainty, and you never counted a thing.

So here's the move, and it's a promotion rather than a discovery. A bijection between two sets is precisely what "they have the same number of things" has always meant, and we just never said it out loud. "Same size" was never about numbers at all. It was about pairing, and numbers were the middleman all along, so we've just fired them.

Which sounds like philosophy until you notice what it does to counting. Go count three coffee cups on your desk — actually do it, out loud, finger moving. Now: what was your finger doing? It touched a cup and said "one," then touched another and said "two," and nothing was missed and nothing was touched twice. You were building a bijection between the cups and the ruler {1, 2, 3}, and you've been doing this since you were three years old without anybody ever naming it. Step through it, then break it.

Counting is pairing · hang a trusted ruler on the unknown — one number per cup
the cups — how many? (unknown) the ruler — a fixed, trusted strip of numbers injective surjective |A| = ? the count
tags 0/3 · pairing
tap a cup to hang ruler number 1 on it
the ruler is fixed & trusted
tap a cup to begin
Pairing the ruler {1,…,3} with the cups
injective: no cup gets two · surjective: no cup left out
both green = a bijection — |A| is real
Fig. 9. Tap cups to hang ruler numbers on them — a perfect pairing makes the count real.

So here is the definition, and every word of it was set by hand: |A| = n means a bijection exists between A and {1, 2, …, n}. The ruler has n things by definition — it's the yardstick, not a claim about the world. Counting a set is building a bijection to the ruler.

And now watch it turn from philosophy into a weapon, because "How many?" now has a strategy. If I can't point at the things, I don't give up. I pair them with something I can already count. Every single formula in the rest of this chapter is that one sentence wearing a different hat.

03Building things you can count

Let's cash that in immediately. Three shirts, two pairs of trousers: how many outfits? Don't compute it. Draw it, with shirts down the side and trousers across the top, so that every outfit is a cell.

Fig 10 · The fan-out — one shirt, and its whole row of outfits blooms at once
click a shirt to fan its row
Click a shirt on the left: its whole row of outfits blooms — one shirt, paired with every trouser. Click all the shirts to fill the grid.
Fix one shirt and it fans out to meet every trouser — N rows of M = N×M, never N+M.
3 × 4 = 12 outfitsfilled 0 of 12 cells.
gold ring marks the active outfit.
Fig. 10. Click a shirt to fan its row, a trouser to fill its column — N rows of M outfits, not N+M.

Count the cells: three rows of two. That's it — that's where multiplication came from, and it isn't a rule about counting that someone handed down. It's the shape of a grid, and the phrase "rows of" is the multiplication. Here's what's actually doing the work: each outfit pairs with exactly one choice-tuple (which shirt, which trousers), and every tuple builds exactly one outfit. That pairing is a bijection, so counting outfits is counting tuples, and tuples are the cells of a grid.

That's the multiplication principle: make k choices in a row, with n₁, n₂, …, nₖ options at each step, and you build n₁ · n₂ ··· nₖ objects — three shirts, two trousers, 3 × 2 = 6 outfits. But it comes with a condition, and this is the exact inch where good students break. So let's break it deliberately.

Here are two situations that feel identical and aren't. First: a menu where ordering the fish deletes a wine option. Second: seating five people, where after you seat one, the set of remaining people has changed. Both feel like "the choices depend on each other." Both feel illegal. Only one is — so put the two grids side by side.

The rectangle test — both look like a product. Predict which one lies, then tear the edge.
MENU · main × wine Pin Cha Sau Mal order the Salmon Sa order the Steak St order the Risotto Ri ragged wines per main: SEATING · seat 1, then 2 who's left — always 4 seat A first A B C D E seat B first B A C D E seat C first C A B D E seat D first D A B C E seat E first E A B C D rect left after seat 1:
Both grids read like a plain product: 3×4 and 5×4. But one hides a rule that breaks it. Which one lies?
Predict: which product lies?
After the reveal: click any main (Sa/St/Ri) or any first-seat (A–E) to inspect that branch.
The product rule: the second count can't depend on the first choice.
red = torn pairing. Edge notches in, count drops, 3×4=12 lies — actual ?.
green = every row 4 wide. Straight edge → 5×4=20 holds.
menu → ? wines · 3×4=? claimed • seating → ? left · seat 1 , remaining · · · ·
Fig. 11. Menu vs. seating: a ragged edge lies, a rectangle multiplies.

There it is, and the eye gets it before the words do. The menu's grid is ragged — different rows have different lengths, it isn't a rectangle, and the product lies. The seating grid is a rectangle — after you seat anyone at all, there are always exactly 4 people left, and it doesn't matter who you seated.

So say the condition exactly, because everyone states it vaguely: the number of options at each step must be fixed. Not the options themselves. The menu changed its length. The guest list only changed its membership. One is a rectangle, one isn't, and that is the entire difference between fluency and paralysis.

Good, so now run the multiplication principle to exhaustion. Line up 3 people out of 5: first slot 5 choices, second 4, third 3. That's 5 × 4 × 3 = 60, and notice you just solved it with no formula at all. Step through what happens when we try to write that in factorial notation.

The cut — drag the slice; keep the product, divide out the tail
pool of 5 tickers  ·  gold = ranked, red = still in the pool 5 × 4 × 3 × 2 × 1 = 5!  — drag the cut after k blocks 5 4 3 2 1 #1 NVDA #2 AAPL #3 MSFT P(5, 3) = 60 5 × 4 × 3 = 5! ÷ (5−k)! = 5! leftover ranks · (5−k)! 2! = 2 these shuffles are the overcount
k = 3
5 × 4 × 3 = 60 (= 5! ÷ 2!)
Why (n−k)! sits on the bottom of P(n,k)
the first k blocks multiply into P(5,k)
the last 5−k blocks are (5−k)! — divided out
drag k to 5: nothing left, so 0! must be 1
Fig. 12. Fill 3 ranks from 5 tickers one at a time — 5×4×3 = 60, no formula needed. Write it as factorials and the unused tail (2·1) has to be divided out: 5!/2! = 5×4×3, which is exactly why (n−k)! sits on the bottom of P(n,k) = n!/(n−k)!. Drag the cut all the way to k = n and nothing is left over, so the formula must still give 120 — which forces 0! = 1, confirmed independently by the empty arrangement.

So n! — read "n factorial" — is just n · (n−1) ··· 2 · 1: the multiplication principle run all the way down. And 5! is 5×4×3×2×1, which is too much — it has an extra 2×1 tail we never used. So kill the tail: 5!/2! = 5!/(5−3)!, which is 120/2 = 60 — the same sixty you just counted by hand. That's P(n,k) = n!/(n−k)!, the number of ways to arrange k things out of n. It is not magic and it is not new. It's 5×4×3 wearing a coat, and (n−k)! is precisely the part you never used, cancelled.

And 0! = 1. Not "by convention," because that's a teacher admitting defeat: two independent roads force it. Road one: how many ways to arrange zero things in a row? Exactly one, the empty arrangement — and remember from Section 1 that the empty thing is a real thing. Road two: arranging all n of them must give n!, and the formula we just built says it's n!/(n−n)! = n!/0!, which only works if 0! = 1. For n = 5 it reads 120/0!, and only 120/1 = 120 hands back 5! itself. Two roads, one answer, and it was never a convention.

One housekeeping note so notation never ambushes you. You'll see P(n,k), ⁿPᵣ, and (n)ₖ in different books. Three costumes, one idea — each of them says P(5,3) = 60, so you haven't missed anything.

04★ The overcount — the keystone of the chapter

Everything so far has been setup. This section is the chapter, and honestly it's most of combinatorics. So we're going to do it the hard way: you're going to answer a question, and you're going to get it wrong, and being wrong is the point.

Five people are in a room, and everyone shakes everyone else's hand exactly once. How many handshakes? Commit to a number before you touch anything, and really commit.

5 in a room — guess the handshakes, then fold the mirror twins and watch 20 become 10
the naive recipe: shaker × shakee 5 × 4 = 20 fold the mirror twins — fibre = 2 2 guess the handshakes first commit a number in the controls — then it unlocks
Click a faint chord in the room. Its two arrows — A→B and B→A — bloom, then collapse into one gold handshake.
commit a guess to begin
Why you divide by exactly 2
red = naive recipe (5 · 5×4 = 20 arrows)
gold = one real handshake · arrows 0/20 · shakes 0/10
green = every fibre lands on 2 — the reason to ÷2
Fig. 13. the handshake: you were 2× right — fold the mirror twins and 20 becomes 10.

If you said 20, I want to be very clear about something: that is a good answer, and it isn't sloppy. You used the multiplication principle you just earned, and you used it correctly — pick a shaker (5 ways), then pick a shakee (4 ways), 5 × 4 = 20. Your recipe is airtight, and it really does produce 20 things.

So look at what it produced. "A shakes B" and "B shakes A" are two different recipes — and one handshake. Every single handshake in that room got built exactly twice. Not sometimes twice, not roughly twice, but exactly twice, every time. Your recipe didn't fail, because your recipe was 2-to-1, so: 20 / 2 = 10.

And there's the whole chapter, in one sentence you can carry for the rest of your life:

Count the easy thing. Ask how many times each answer got built. Divide by that.

You were never wrong. You were 2× right. And now you hold the general tool instead of a corrected number, so let's name it: the quotient principle, or the overcount principle. If a recipe builds each target exactly d times, then #targets = #recipes / d — the handshakes were 20 recipes at d = 2, so 20/2 = 10.

Now let's make the machinery visible on the smallest case that leaves nowhere to hide. Three people, choose two: write out all six orderings by hand — AB, BA, AC, CA, BC, CB. No formula, just a list you can look at. Now group them.

Forget the order, and 6 deals fold into 3 hands — where C(n,k) comes from
6 ordered deals — order still matters predict the count, then fold the order away
forget order → how many hands survive?
predict, then fold the order
Equal stacks of orders pile onto each hand
an ordered deal — order matters
folded 0/6 — 6 ÷ 2 = ? hands
Fig. 14. Ordered deals fold onto hands — C(n,k) = n!/(k!(n−k)!)

Three groups, and every group has exactly two in it — not roughly two, exactly, and you can see it. So 6/2 = 3. Now notice why you divided by 2, because nobody handed you a rule saying "order doesn't matter." You divided by 2 because you looked at the map and counted the fibres. Each group is a fibre: all the recipes that build one particular target.

Now weaponize it. Take n people and pick a committee of k, then line up all n of them: that's n! orderings. Call the first k the committee and the rest outsiders, and ask how many times each committee got built. Shuffle the k insidek! ways, same committee. Shuffle the n−k outside(n−k)! ways, same committee. So the map from orderings to committees is exactly k!(n−k)!-to-one — five people picking two gives 2 × 6 = 12 orderings per committee, and 120/12 = 10. Therefore:

C(n,k) = n! / (k!(n−k)!)

Read that again and notice what just happened: the formula arrived already understood. It's the first thing you computed with the tool — it isn't the tool, and that's the difference between owning combinatorics and renting it. One degree off the template — identical items, a circular table, a committee with a designated chair, two people who must sit together — and someone who memorized C(n,k) is stuck. You just find the map and count the fibres.

Two loose ends before we move. First, the test you'll actually use, and it's a question rather than a rule: relabel the order of your picks — did you get a different object? Different object means order is real, so it's a permutation, and same object means your recipe built it more than once, so divide it out. That works forever, because it's just the keystone asked as a question. And enjoy this one: a "combination lock" is a permutation lock. Everybody knows the word is wrong, nobody's fixing it, so reach for the test, never the noun.

Second: C(n,k) = C(n,n−k) — both C(5,2) and C(5,3) come to 10. You could verify that by cancelling factorials, which teaches you nothing and you'd forget by Thursday. Don't. Draw one line through the n people instead — k on the left, n−k on the right — and read it from both sides.

Interactive · one split, two names — why C(8,k) = C(8,8−k)
k = go‑team size 8−k = stay‑team size mirror 56 56 0 1 2 3 4 5 6 7 8
drag the line — choose who GOES
goes: C(8,3)=56 stays: C(8,5)=56
the two lit bars are a mirror pair — the link between them stays dead level, at every k
C(8,3) = 8!/(3!·5!) = 56 = 8!/(5!·3!) = C(8,5)
C(8,3) = C(8,5) = 56
What you're looking at — the same split, read two ways, counted once
green = the go group, size kC(8,k) ways to pick it
red = the stay group, size 8−kC(8,8−k) ways — but it's the same line, so the same choice
mirror at k=4: bar k and bar 8−k are reflections, so the link between them is always level — the two counts are equal, always
Fig. 15. One line splits 8 people into go and stay. Every k lights a mirror pair in Pascal's row, and the link between them stays dead level — the picture never moves, only the sentence does, because C(8,k) = C(8,8−k) always.

Choosing who goes is the same act as choosing who stays — one line, read two ways. That's a bijection, it's zero computation, and your eye finished the proof before this sentence did.

05When the overcount goes ragged

That division had a hypothesis, and nobody says it out loud. Go back to the three groups in Figure 14: all the same size, which is exactly why 6/2 was legal. Change one group's size and the division stops meaning anything. Division is legal only when every target gets built exactly the same number of times.

And when it isn't, nothing warns you: there's no error, you get a plausible wrong number, and you walk away happy. Let's watch it happen.

The Fold — divide by symmetry, then watch the skyline hold or break
predict: how many classes?
click a ring — how many others rotate onto it?
What you're looking at — dividing by symmetry bets every pile is the same height
4 beads on a ring — rotations are the same necklace · 16 raw rings
assume 4 is the wager — the dashed level every pile is expected to reach · 16 ÷ 4 = ?
green pile meets the level (fibre = order, divide exact) · red falls short (fibre < order, the bet breaks) — verdict — fold to test —
Fig. 16. Guess 16÷4=4, then fold the 16 raw rings into their real rotation-classes and read the skyline: RRRR, BBBB and RBRB have short orbits, so three piles fall below the assumed level of 4 — the true count is 6, not 4. No error fires; the wager just wasn't true. Toggle to handshakes and the piles come out perfectly even (every fibre is size 2), so 12÷2=6 lands exact. The arithmetic never changed — only whether the fibres were equal.

Ragged fibres, no division. That trapdoor sits under a large share of all combinatorics errors, and now you can see it before you fall in. Which leaves one question standing: if the overcount isn't uniform, what do you do?

Take three overlapping sets and try to count their union. Adding is illegal — we proved that with the deck back in Section 1, and these pieces obviously overlap. So instead of arguing about formulas, let's audit one dot: put a single point inside all three circles and give it a running tally.

Fig 1.17 · one dot's ledger — inclusion–exclusion grinds every count down to exactly 1
A B C the ragged fibre from fig 1.16 — why you can't divide outer 1 · edge 2 · middle 3 this dot's ledger over-count → correct → 1 0 1 2 3 erased 0 0 0 0 0 0 0 0
dot ∈ A ∩ B ∩ C
0 of 7 applied — press run
drag, then run the 7 terms
One dot, one ledger: inclusion–exclusion drives every point's count to exactly 1.
green = ledger settled on exactly 1; lamp lights.
tally: +1+1+1→3 over-counts, −1−1−1→0 erases, triple +1→1 restores.
press run — watch it climb to 3, crash to 0, recover to 1.
Fig. 17. Drag the dot, run the seven terms, watch its tally ride 0→3→0→1.

Follow the ledger. It's in A: +1. In B: +1. In C: +1. Tally is 3 — that dot got counted three times, and it's one element, so subtract the three pairwise overlaps: −1, −1, −1. Tally is now 0, which means the dot has been erased. But it's a real element of the union, so it must count exactly once, and we add it back: +1. Done.

That's inclusion–exclusion: |A∪B∪C| = |A|+|B|+|C| − |A∩B| − |A∩C| − |B∩C| + |A∩B∩C|. The + on the triple term is not a sign rule you memorize. It's a repair, forced by watching one dot's tally go wrong. Drag the dot into exactly two circles and re-run it: +1+1−1 = 1 ✓, and the triple term never touches it. Every term in that formula is something you watched become necessary. Which is exactly why the four-set case is reachable instead of terrifying — you don't recall a pattern, you audit a dot.

Inclusion–exclusion is the keystone again. Almost nobody says that out loud, and it's the difference between one idea and a pile of formulas. You built a count, and it overcounted, but here the overcount is not uniform: the middle dot got built three times, the edge dots twice, the outer dots once. Ragged fibres. So you can't divide. You subtract, dot by dot, until every element's ledger reads exactly one.

Divide when the overcount is even. Subtract when it's ragged. One wisdom, two arithmetics.

One last tool, and it costs us nothing because we built it six rungs ago. Thirteen people are in a room, and assigning each person their birth month is a function: people → months. Now ask the only question that matters: could that function be injective?

Pigeonhole — you're the dealer: give 13 people 13 distinct months, and watch the last one get forced.
13 12 PEOPLE MONTHS TAKEN
FORCED COLLISION — 13 > 12
0/13 placed · 12 free months · clean
Click a month to give it to the glowing person. Give all 13 their own.
No injection can exist — the last one is forced, not unlucky.
person — must send one arrow to a month.
glowing ring — the one you're placing now.
collision — two people, one month; past 12 it's unavoidable.
Fig. 18. You deal 13 people into 12 months — the last one is forced to collide.

If it were injective, we'd have a perfect copy of 13 distinct things sitting inside 12, and an injection can never grow a set. Impossible. So the function is not injective, and "not injective" means exactly what the arrow diagram showed: two arrows crash into one dot. Two people, same month. Done — one line, zero new machinery. That's the pigeonhole principle: there is no injection from a bigger finite set into a smaller one, so a collision is forced.

Now let me be honest about the part that's genuinely uncomfortable, because pretending it isn't is how you lose someone's trust. We just proved that two people in that room share a birth month — and we learned no name and no month. Mathematics flatly refuses to tell us which. That should feel strange. Sit in it for a second. And then flip it, because that strangeness is the power: pigeonhole is what you reach for when you can prove something must exist and could never find it by searching. It's why hash tables must eventually collide, and why no compression program can shrink every possible file — there are more files than there are shorter files, so some file must get bigger. Same one line, different room.

06Favourable over total — the first probability

We can count, so let's spend it. Flip two coins: what's the chance you get one head and one tail? Commit to a number, then run it.

Interactive · why two coins land on ½, not ⅓ — grab the slider and tear the middle box open
flip two: coin coin Ω looks like 3 equal outcomes … Ω HH HH one of each HT HT HT TH TH TT TT green “one of each” = 1/3 of Ω 10,000 real (penny, dime) pairs land here ↓ 0.500 0.333 0 1 reality · 0 pairs · p̂ = —
guess, then drag to split the box
Ω is a choice you were making.
A = {HT, TH} grows from 1/3 to 2/4 = 0.500.
penny & dime: Ω = 4 equally-likely atoms.
wrong Ω → code obediently parks on 0.333.
Fig. 19. Two coins “look like” three outcomes, but Ω is really 4 equally-likely atoms — drag to split the box, then RUN and watch reality park on 0.500.

A huge number of people say 1/3, and I want to defend that answer for a moment, because it's disciplined. The outcomes look like two heads, one head, two tails — three outcomes, one of them favourable, so 1/3. That's exactly the tool we taught you, applied carefully.

Now make one coin a penny and one a dime, and just look. Penny-heads/dime-tails and penny-tails/dime-heads are two different things sitting on the table, and they always were. The real outcomes are HH, HT, TH, TT — and two of those four are favourable, so the answer is 1/2. The simulation in that figure votes with reality, not with your gut: ten thousand flips park on 0.5 and never go near 0.33.

Here's the lesson, and it's the most expensive inch in this chapter. You weren't careless. Your Ω — your sample space, the set of all outcomes — was wrong. And a wrong Ω is invisible from inside the arithmetic, so you could check your division all day and never find it, because the bug isn't in the division. That's why nobody can debug this error on their own: they were never told that Ω is a choice they were making.

So state the rule with its hypothesis visible, the way it should always have been taught: P(A) = |A| / |Ω|, and this is legal only when Ω is partitioned into genuinely equally-likely atoms. And notice — that's exactly the multiplication-principle grid you already trust. Two coins, 2 × 2 = 4 cells, each cell one atom, each atom symmetric with the others, so one head and one tail reads 2/4 = 1/2. The grid was the honest Ω all along.

Every rung under that formula was set by hand in this chapter. Partition Ω into atoms — we built partitions. An event A is a union of atoms — we built unions. Count A, count Ω by pairing each against the ruler — we built counting. Nothing was borrowed, and nothing was assumed.

And now the last beat, which costs nothing because we pre-paid the debt thirteen steps ago at the vending machine. Look at what P actually is: it takes a SET and hands back a number. That's a function — and a function never needed a formula, and it never needed a numeric input, so it's the vending machine. The buttons are events. That sentence — probability is a function on sets — is the first line of Chapter 9, and you already own it.

So let's put the whole chapter in one picture. Every ×, every ÷, every − you'll ever write in a counting formula is bookkeeping for how many-to-one your map is.

One map, six disguises — every count is recipes ÷ d. Drag the cut and test whether the fibres are level.
RECIPES 12 TARGETS 12 1-to-1 6/6 Ch2 →
d = 1
12 ÷ 1 = 12 · flat
Keystone: targets = recipes ÷ d.
order tickets → price bins
cut sits levelDIVIDE.
cut ragged → SUBTRACT overlaps.
DIVIDE SUBTRACT IMPOSSIBLE
Fig. 20. Drag the cut: level means divide, ragged means subtract, overflow cracks the map.

That's Chapter 1. Look at what you're actually walking out with — and it's one sentence, not nine formulas: count the easy thing, ask how many times each answer got built, and correct for it — divide if the overcount is even, subtract if it's ragged. With that you can re-derive C(n,k), inclusion–exclusion and pigeonhole from nothing, with zero memory. And you can diagnose a wrong count as one of exactly three named diseases: a wrong sample space, an illegal addition across overlapping cases, or an uncorrected overcount. That turns "I got it wrong" into a debuggable event instead of a verdict on your intelligence.

And there's a bridge already under your feet. We counted finite collections all day — pair them with the ruler {1, …, n} and stop. But here's the question this chapter can't answer: what happens when the count doesn't stop? When the pairing runs on forever and you're adding up infinitely many shrinking pieces? That's a series, and it needs a limit. Hiding inside it is a single fact, a/(1−r): with a = 1 and r = ½ it reads 1/(1−½) = 2, exactly where 1 + ½ + ¼ + … lands. That one fact powers half the "hard" tricks in this entire course, along with its strange continuous cousin, e. That's next.

iolinked.com
Written by Ajai Raj