The notional machine, from bytes to a logic engine
2026-10-26
A program runs on one computer. But the machine you imagine while you read it is a different machine at every layer — and that imagined machine is the one you actually program.
Notional machine (du Boulay, 1986): the computer you imagine while you read a program — what things exist, what they do, and what happens next.
It is not in the hardware. It is taught. And no error message will ever tell you that yours is wrong.
Each rung is implemented by the rung below it. Each rung up buys you expression and costs you visibility.
Rungs 1 and 2: the machine you can see all of.
One instruction can do one of three things:
Then repeat, forever.
The job: sum the squares of the even numbers in a list. For [1 2 3 4] the answer is 20.
| what the job needs | so every machine must provide |
|---|---|
| somewhere to keep a running total | storage that survives a step |
x * x, and + |
arithmetic |
| “only the even ones” | a way to choose |
| “every element of the list” | a way to repeat |
Every rung has to be able to do this one job. That is what makes the rungs comparable — and what makes their differences interesting.
Rung 3: the first thing in the machine that the hardware has never heard of.
The hardware has registers and memory. It has no idea what a function call is.
Everything you can see in the trace is real memory. Everything that makes it a frame is a convention someone maintains.
Rung 4: the state stops being memory and becomes the program itself.
The rule: to evaluate a call, substitute the arguments into the body, then keep going.
(+ (* 2 2) (* 3 3)) → (+ 4 9) → 13
The syntax is the tree — you can see which subtree is being replaced.
A real Scheme does not rewrite text. It keeps environments and a stack of pending operations, and it compiles to the same three machine moves as everything else.
The substitution trace is a model. And a model of the machine you should imagine while reading a program is exactly what a notional machine is.
Rung 5: the same machine as rung 4, with a different idea about data.
| rung 4 (Scheme) | rung 5 (Clojure) | |
|---|---|---|
| the machine | rewrite the text | rewrite the text |
| who does the recursion | you write it | filter / map / reduce |
| lines in the trace | 10 | 4 |
| anything overwritten | no | no |
Same machine, one level of thinking moved into the library. That is what a library is: someone else’s notional machine, ready to use.
Rung 6: the top of the ladder, and the end of steps.
There is no loop. You state what must be true of the answer, and the machine finds values that make it true.
Adding a condition is not editing a program. It is adding a fact.
There is no next instruction. The state is a substitution (what we have learned so far) plus a frontier (what is left to try).
The engine underneath is a search. That is the same machine as last week’s SAT solver — and it is what is running inside a package manager deciding whether your dependencies can be installed.
Where this leaves you, and what is above.
| what you see | what is really happening |
|---|---|
0.1 + 0.2 gives 0.30000000000000004 |
rung 1: floats are not decimals |
| a stack overflow | rung 3: the frame stack is finite and real |
| “this one line is slow” | rung 1: it is still a loop, whatever it is called |
| a lazy sequence realising at a strange moment | rung 5: the pipeline is not free |
A leak is the layer below showing through. When something makes no sense, ask which rung you are actually standing on.
| machine | you say | it works out |
|---|---|---|
| SQL | which rows you want | how to find them |
| a spreadsheet | a formula per cell | what order to recompute |
| an LLM prompt | what you want, in English | the steps (sometimes) |
None of these asks you for a loop. All three are the same move as rung 6: state the answer, let the machine search.
We are not going to write six languages. You will write one: JavaScript, or TypeScript.
It is a synthesis of the rungs you just climbed:
map, filter, reduce on arrays — rung 5The point of the ladder was never to learn six languages. It was to be able to see the parts of the one you use.
The bottom rung is last Wednesday: gates, which compute with no notion of a step.
The top rung is last Wednesday too: a search for an assignment, which is the SAT problem the boolean lecture ended on.
Seven machines, one computer. And the course you are in is the ladder: bits, then files, then gates, then instructions, then languages — and now you know what is above languages.
CS 2010 · Seven Machines