A working almanac Sunday, 29 November 2026
Reviery

Topic: Discrete Math  ·   —  6 min read

The math of things you can’t cut in half

A language model has no token number 2063.5. I got curious, read up on why, and followed that small fact through GPT-2's vocabulary, a password rule and a curriculum report to find out what discrete math is, and where it stops.

There is no such thing as half a token. Hand that sentence to GPT-2, an old OpenAI language model whose files are still public, and before anything clever happens it gets cut into ten pieces, each one swapped for a whole number. ” half”, with its leading space, is number 2063. ” token” is 11241. The full stop is 13. A number 2063 exists and so does a 2064, and between them the model’s lookup table has nothing at all, so no 2063.5 will ever reach it.

That small fact made me curious, because it is more or less the definition of a whole branch of mathematics. Oscar Levin’s open textbook starts from the dictionary: discrete means “individually separate and distinct”. Then it makes the point with people, observing that “nobody reading this has 1.32419 children.” Discrete math is the math of things you can count off one at a time, like letters, people, true-or-false answers or the steps of a program.

I wanted to know what else was in there, so I gave the subject some free time and read up, for no better reason than that it interested me. That meant the open textbooks and the original papers, with every example worked through myself, by hand or with a few lines of script, before it goes in here. Following one token gets you surprisingly far into the subject, so that’s where I’ll begin.

A list, a lookup and some counting

GPT-2 works from a fixed list of 50,257 tokens, and that list introduces three of the subject’s basic objects at once.

Treat the list as a collection with no repeats, where the only question is whether something belongs, and you have a set. The table that turns each token into its number is a function, which just means every input gets exactly one output. I downloaded the published files to check the property that makes this table usable: the numbers run from 0 to 50,256 with no gaps and no duplicates. Since no two tokens share a number, you can also run the table backwards and turn numbers into text again.

The third object is a count. How many bits does a token number need? Fifteen bits give 32,768 different patterns, which falls short. Sixteen give 65,536, which covers the list and leaves 15,279 patterns over. That’s the whole calculation, and it sets the least room a stored token number can take if you pack them tightly.

Even the 50,257 turned out to have a tidy explanation. GPT-2 builds its vocabulary with byte pair encoding, a data-compression trick from 1994 that keeps replacing the most common pair of neighbouring bytes with a single new symbol. Sennrich and colleagues adapted the idea to split words into pieces, and their paper states the bookkeeping outright: “The final symbol vocabulary size is equal to the size of the initial vocabulary, plus the number of merge operations”. GPT-2 starts from the 256 possible byte values. Its merge file has 50,000 lines, and the vocabulary holds one extra entry, an end-of-text marker. 256 + 50,000 + 1 = 50,257. I enjoyed that more than a grown adult probably should.

Multiply, and the numbers leave the building

Most of counting’s power comes from a rule that looks too simple to matter. If you fill a sequence position by position, and each position draws from its own fixed set of options, the number of possible sequences is those option counts multiplied together. MIT’s Mathematics for Computer Science calls it the Product Rule.

GPT-2 reads at most 1,024 tokens at a time. The number of different inputs of exactly that length is therefore 50,257 multiplied by itself 1,024 times, which I had Python work out in full: a number with 4,815 digits. Nothing memorises its way through a list that size.

The same rule sits behind a shift in password advice. NIST, the US standards body, published its current guidance for government systems in July 2025. A password used on its own now has to be at least 15 characters, and sites following it are told they “SHALL NOT impose other composition rules”, meaning no more demands for one capital and one symbol. Here’s the arithmetic as I worked it out. Eight random characters drawn from all 95 printable keyboard characters, space included, give 958, about 6.6 quadrillion possibilities. Lowercase letters alone give 2611, about 3.7 quadrillion, at eleven characters, which isn’t enough. At twelve they give 2612, about 95 quadrillion, which is comfortably more. Variety only raises the base of that power, while length raises the exponent, and the exponent wins.

Those counts come with a catch, though. They assume every password is equally likely, and people don’t choose that way. NIST’s own wording is that “estimating entropy for user-chosen passwords is challenging”, which is partly why sites must also compare new passwords against a blocklist of common and leaked ones. The same document adds that many attacks don’t care about length at all, keystroke logging and phishing among them. So treat a count like this as a ceiling on how hard guessing could be.

The report that dropped the name and kept the hours

Why bother with this now, when AI seems to run on statistics? I went to the people who write the curriculum guidelines for computer science degrees, expecting a clear answer, and found an argument with itself. CS2023, the joint guideline from ACM, the IEEE Computer Society and AAAI, retired the old heading “Discrete Structures” and replaced it with “Mathematical and Statistical Foundations”. The stated reason is that growing fields such as AI, machine learning and data science, “many of which have continuous mathematics as their foundations”, need more than the old name covered.

Then you reach the table of recommended teaching hours.

SubjectMinimum core hoursHours in the fuller version
Discrete mathematics2940
Probability1140
Statistics1040
Linear algebra540
Calculus040
Fuller version = CS Core plus KA Core hours added together. Source: CS2023, Mathematical and Statistical Foundations.

In the minimum set, discrete math gets 29 of 55 hours, more than half. The report also says programs “ought to consider as much as possible from the more expansive” version, with AI and data science given as the reason, and there all five subjects land on 40 hours each, which makes discrete math one fifth. Which figure you quote depends on what you’re trying to prove. I’d rather quote both.

The renaming seems fair to me, and the token shows why. The moment number 2063 enters the smallest GPT-2, it is replaced by a list of 768 decimal numbers, and everything after that is arithmetic on continuous values. Counting tokens will never tell you why the model writes a decent sentence. It tells you what can be fed in, how much room each piece takes, and how absurdly many inputs exist. The discrete part is the doorway, and you still have to go through it.

First stop: one small word

The report’s core list for discrete math is short enough to repeat: sets, relations and functions; recursive definitions; proofs; counting; modular arithmetic; logic; graphs; and order notation, the shorthand for how running time grows. That’s roughly the route I plan to take.

Logic comes first, and inside logic one word. Next I want to look at when an “if … then …” sentence counts as broken, because the official answer surprised me and turns out to be more than two thousand years old.

Sources

All of it was checked against these originals in November 2026, and the sums are my own:

More entries

  1. What Germany wants from you before your first hen arrives

    Germany's first Newcastle disease outbreaks in 30 years sent me to the rules for keeping a few hens. A notification before the first bird, a state fund, a vaccination duty and a small standing list of chores.

    6 min read
  2. Who the 2030 quantum deadline applies to

    I went through seven documents that put a year on the post-quantum switch and wrote down who each is addressed to. Most of them turn out not to bind anybody I know, and Germany's says so itself.

    7 min read
  3. What a tonne of clinker owes at the EU border

    I read "97.5%" as a 2.5% charge, and I was off by a factor of more than twenty. Here is the actual sum for a tonne of cement clinker under the EU carbon border rules.

    6 min read