Unit 2: Ada's ordered procedure

What these systems are

30 min: video 8, reading 10, activity 12 page v0.1.0, video v0.1.0
Release candidate. The unit videos are added in the first release.

Video

Unit video

The narrated video for Unit 2, about 8 minutes, is published with the first release.

Learning purpose: Lovelace, the Analytical Engine, Note G, and what it takes to specify a computation exactly.

Accessible text alternative: the transcript linked below, and this page, which covers the same material.

Transcript of the Unit 2 video

The narration is spoken by synthetic voices made for this course, each shown on screen as a drawn robot. No person is speaking.

Watch what changes

Headed 'Explicit state change'. A table on the left, headed 'Illustrative lines, not from Note G', shows two lines; line 1 is selected: multiply V1 and V2 and write the result to V3. Line 2, dimmed, adds V3 and V4 into V4. On the right the store is shown before and after line 1. Before, V1 holds 2, V2 holds 3, V3 holds 0 and V4 holds 10. V1 and V2 are highlighted as the inputs read; after the operation V3 has changed from 0 to 6, while V1 (2), V2 (3) and V4 (10) are marked unchanged. A closing note says only the destination, V3, changes; nothing else was told to change. Open diagram at full size (opens in a new tab)
The printed 1843 Note G diagram (facsimile, [P2a]). Its header row is lifted out and enlarged, and each column heading is named in turn: number of operation, which step and in what order; nature of operation, which operation; variables acted upon, what it reads; variables receiving results, what it writes; indication of change, what changes in the store; and statement of results, what the result should be. The closing line says every operation states which step it is, what it reads, what it writes and what its result should be, so every line can be checked on its own. Open diagram at full size (opens in a new tab)
Two boxes are drawn apart, with the gap between them marked 'physically apart'. On the left is the store, holding four columns, V1 = 2, V2 = 3, V3 = 0 and V4 = 10; it is labelled memory. On the right is the mill, labelled operations. The value 2 travels from V1 across the gap to the mill, then the value 3 from V2. In the mill the multiplication happens: 2 times 3 equals 6. Below them a two-line procedure appears, labelled illustrative lines, not from Note G: line 1, V1 times V2 into V3, which is selected, and line 2, V3 plus V4 into V4. The 6 travels back across the gap into the store, and V3 changes from 0 to 6. V4 is marked untouched, and line 2 is marked next, in order. These are illustrative values, the same as in the state-change animation. Open diagram at full size (opens in a new tab)
On the left, under the label 'Illustrative lines, not from Note G', two lines of a procedure: line 1, V1 times V2 into V3, and line 2, V3 plus V4 into V4. On the right, the store starts with V1 = 2, V2 = 3, V3 = 0 and V4 = 10. Run in order, line 1 then line 2: V3 becomes 6, then V4 becomes 6 plus 10, 16. The two lines then swap places and run again from the same start: line 2 first writes 0 plus 10, so V4 stays 10, then line 1 makes V3 6. The two end states are side by side and differ at V4, 16 against 10, marked 'different end state'; a caption says that swapping two lines gives a different procedure. The store then clears, the lines return to their order and an arrow shows them running top to bottom. Line 2 is then bracketed as a group with a loop arrow labelled 'repeat', and a caption says Note G marks out a group of operations to be repeated (Lovelace 1843, Note G). A table on the right shows that how many passes the group makes depends on which value is wanted: for the first value one pass, V4 ends at 16; for the second, two passes, 22; for the third, three passes, 28, with a pass counter ticking beside the bracket. The closing line says one procedure with a controlled repetition gives a family of answers, not one. Open diagram at full size (opens in a new tab)

Reading time: about 10 minutes. Activity: about 12 minutes.

1. The document

In 1843 an English scientific journal published a translation of a French-language account of Charles Babbage's Analytical Engine. The account had been written by Luigi Menabrea, after Babbage presented the engine at meetings in Turin in 1840 [P1], [P3, pp. 129-130]; the translator was Ada Lovelace, who signed her work with her initials. She appended seven notes of her own, labelled A to G, and they run substantially longer than Menabrea's article they accompany [P2, pp. 666-731], [P3, p. 136].

The picture below is Babbage's general plan of the engine, Plan 25, dated 6 August 1840 [P4].

Babbage's general plan of the Analytical Engine, dated 6 August 1840: a large ring of gear wheels, long rows of columns marked V, and the operation, variable and number cards drawn as separate parts.

Babbage's general plan, Plan 25, 6 August 1840 [P4]. Photograph: ArnoldReinhold, Wikimedia Commons, CC BY 4.0.

Note G — the last of them — sets out how the engine could be made to compute a sequence called the Bernoulli numbers. Unit 6 explains what those numbers are and makes you work one out by hand. This unit is about the form of what Lovelace wrote, because that form is one half of the comparison the whole course rests on.

The full bibliographic citation for the memoir, the translation and the notes is held in References and source policy. This page cites it as (Lovelace 1843, Note G).

2. What Note G actually is

Note G is a prose note, and inside it is a table.

The table is the part this course works from, and what matters is that it is a table rather than a description of a method or an argument that a method would work in principle. It is laid out in order: one line per operation, running from the first thing the machine does to the last. Each line identifies the operation to be performed, the storage columns it takes its inputs from, and the column that receives the result (Lovelace 1843, Note G). Each line also gives its step number, which columns change, and what the result should be, as a formula. So every line can be checked on its own: read the inputs, do the operation, and compare with what the table says should come out.

The printed Note G diagram from 1843: a table of numbered operations for computing Bernoulli numbers, one line per operation, with columns for the operation, its inputs, and the destination of each result.

The Note G diagram as printed, 1843 (facsimile [P2a]): a processed image of the printed plate, public domain, via Wikimedia Commons.

Babbage's design kept two functions physically separate: a store, holding numbers in columns, and a mill, performing arithmetic on numbers brought to it from the store [S1], [P3, pp. 117-118]. Memory in one place, operations in another, and a written procedure saying which values move between them and in what order.

The engine was never completed [S1], [S4], [S12]. Nothing in Note G was ever executed on the machine it was written for. That is worth sitting with: the procedure had to be exact with no chance to run it and catch mistakes, which is the opposite of how most of us write instructions.

3. Three properties worth naming

These three words come back in every later unit, so it is worth being precise about them now.

Determinism

Given the same starting values and the same sequence of operations, the procedure produces the same result. Every time. Not usually, not with high probability — every time.

This is a strong property and it is easy to underrate because it feels obvious. Its practical consequence is that a disagreement between two runs is not variation, it is a fault. Something is broken and can be found. That is a completely different world from one in which two runs are simply expected to differ, which is where Unit 3 takes you.

Explicit state

The state of the machine is the collection of values currently held in its storage columns. Every value in that state is either a stated starting value or was put there by an earlier line.

There is no quantity that is merely understood to be available. If a value is needed and was not stated at the start, you can point at the line that produced it. When you write a procedure by hand, this is the property that fails first: human instructions are full of objects and quantities that were never introduced, and we do not notice because we supply them ourselves as we read.

Control flow

The order of the lines is part of the meaning. Swap two of them and you have a different procedure, not the same procedure written differently.

The order is also not always a straight run from top to bottom. Note G's diagram marks a group of operations to be repeated, with the number of repetitions depending on which Bernoulli number is wanted (Lovelace 1843, Note G). The teaching point needed here is visible in the table itself: a procedure with a controlled repetition computes a whole family of answers, not one answer. That is the difference between a worked trace of one case and a general procedure with a stopping rule — and it is worth saying that a recipe is usually the second of those, not the first. A recipe that says "simmer until it thickens" has a stopping rule and works for any quantity. The contrast is not recipes against algorithms; it is one answer against a family of them.

4. "The first program"

You will have met the claim that Note G is the first computer program [S10, abstract], [S11, sec. 1] and that Ada Lovelace was the first programmer. The claim is useful — it points at something real, and it is why this course starts here. It is also more complicated than a slogan, and the course would be a poor advertisement for verification if it repeated a contested claim without saying so.

What is on firm ground. The notes were published in 1843 with the translation, signed with her initials. Note G contains an ordered table of operations for computing Bernoulli numbers [P2, pp. 722-731]. Those facts do not by themselves show that she was first.

What is genuinely contested.

One more established fact, handled carefully. The published table in Note G contains at least one printed error. One of them -- operation 4, an inverted division -- is established from a facsimile [P2a]; a self-published reconstruction [S7, sec. 5.2] lists further faults in operations 24 and 21. The lab runs the table in exact fractions: with every line as intended it gives the documented value, and with operation 4 as printed the result is different. Who made these errors is still disputed. And what the faulty table computes depends on which errors you fix and which starting values you give it. This course does not work through the detail here; Unit 16 treats the whole episode as its case study in historical honesty, including the mistake this course itself made with it. See Historical Notes for what the sources support.

If that feels unsatisfying, notice what it is modelling. "I know this much, this much is disputed, and here is where you can check" is a stronger position than a confident sentence, and it is exactly the position you will need to take about your own AI-assisted work in Unit 17.

5. The sentence that sets up the course

Writing about the limits of what the engine could do, Lovelace put it this way:

The Analytical Engine has no pretensions whatever to originate any thing.

— (Lovelace 1843, Note G)

Read in context, this is a claim about following orders: the machine can carry out a procedure, and carrying out a procedure is not the same as producing something new. Whether the sentence still applies to the systems we have now is a genuine question that Unit 17 returns to, with the comparison made carefully rather than rhetorically.

For now, notice what the sentence takes for granted. It assumes you can say precisely what the machine was ordered to do, and then check whether it did that. Note G is fully checkable in this sense: every line is written down, and any line can be found to be wrong. Somebody did find one. Because the procedure is written out in full, anyone can check it without trusting its author, and that is how the error was found; nobody knows when it was first noticed (Unit 16). Notice also where the error came from: people made it, and it was printed, in work by some of the most careful minds of the period. Human authorship never guaranteed correctness.

Unit 3 is about a system you cannot check line by line like this.

6. Why this course looks the way it does

This is background rather than argument, and nothing in the unit depends on it.

Ada Lovelace was the daughter of the poet Lord Byron, who left England in 1816, when she was a few months old, and never saw her again [S5], [G1, pp. 605-610, 1227] (the keys resolve in References and source policy). Byron, Percy Shelley, Mary Godwin — later Mary Shelley — Claire Clairmont and Byron's physician John Polidori spent part of that summer on Lake Geneva, at and near the Villa Diodati. The ghost-story challenge that produced Frankenstein; or, The Modern Prometheus (1818) and Polidori's The Vampyre (1819) is conventionally dated to that gathering [G2, pp. 125-126] [G3] [G4]. This course is about a machine that produces plausible speech, and about whether it originates anything. It inherits those themes from that tradition rather than borrowing them. That is why the course's visual design leans dark, with a single red accent, instead of the usual palette of an introductory course. What Lovelace herself made of any of that, and whether it touched her mathematical work at all, is not something this course claims. The connection is a visual motif, not a historical inference.

Summary

Then answer cp02-ordered-steps at the foot of this page.

Timings: video 8 min, reading 10 min, activity 12 min.

Check yourself

This unit has one checkpoint, answered here. A wrong answer says which misunderstanding it matches. Nothing is uploaded.

Local progress is available in a supported browser.

Manage or delete this record

Prefer a terminal?

The same questions, from The verification lab and self-check:

python3 selfcheck.py run --unit 2

Your progress, and every checkpoint in the course