ExplorationsA sequence of 1s and 2s that lists its own run lengths
The Kolakoski Sequence
Write a sequence of 1s and 2s, split it into runs of equal terms, and count each run: 1, 2, 2, 1, 1, 2 splits into 1, then 22, then 11, then 2, so its run lengths are 1, 2, 2, 1. The Kolakoski sequence is the one whose list of run lengths is the sequence itself, beginning 1, 2, 2, 1, 1, 2, 1, 2, 2, 1. Whether 1s and 2s end up equally common is unproved.
Interactive laboratory
- 11
- 222
- 112
- 21
- 11
- 222
- 11
- 222
- 112
- 21
- 112
- 222
- 11
- 21
- 112
- 21
- 11
- 222
- 112
- 21
- 112
- 21
- The numbers under the brackets
- 1221121221221121122121
- The sequence itself
- 1221121221221121122121
They are the same digits, which is the entire definition rather than a coincidence of these 22 runs.
The same data as a table
| Run | Letter | Length | Terms | Term that set it |
|---|---|---|---|---|
| 0 | 1 | 1 | 0 | term 0 = 1 |
| 1 | 2 | 2 | 1 to 2 | term 1 = 2 |
| 2 | 1 | 2 | 3 to 4 | term 2 = 2 |
| 3 | 2 | 1 | 5 | term 3 = 1 |
| 4 | 1 | 1 | 6 | term 4 = 1 |
| 5 | 2 | 2 | 7 to 8 | term 5 = 2 |
| 6 | 1 | 1 | 9 | term 6 = 1 |
| 7 | 2 | 2 | 10 to 11 | term 7 = 2 |
| 8 | 1 | 2 | 12 to 13 | term 8 = 2 |
| 9 | 2 | 1 | 14 | term 9 = 1 |
| 10 | 1 | 2 | 15 to 16 | term 10 = 2 |
| 11 | 2 | 2 | 17 to 18 | term 11 = 2 |
| 12 | 1 | 1 | 19 | term 12 = 1 |
| 13 | 2 | 1 | 20 | term 13 = 1 |
| 14 | 1 | 2 | 21 to 22 | term 14 = 2 |
| 15 | 2 | 1 | 23 | term 15 = 1 |
| 16 | 1 | 1 | 24 | term 16 = 1 |
| 17 | 2 | 2 | 25 to 26 | term 17 = 2 |
| 18 | 1 | 2 | 27 to 28 | term 18 = 2 |
| 19 | 2 | 1 | 29 | term 19 = 1 |
| 20 | 1 | 2 | 30 to 31 | term 20 = 2 |
| 21 | 2 | 1 | 32 | term 21 = 1 |
- term
- one place in the sequence, drawn as a tile
- run
- a block of equal terms with a bracket under it
- run length
- how many terms that block contains, printed under its bracket
- the pen
- the term whose value fixed the length of the run being written
The top row is the sequence, one tile per term. A bracket under a block of equal tiles marks one run, and the number under the bracket is that run’s length. The outlined tile is the term whose value produced the run being written, so the row of bracket numbers is the top row read again.
22 of 22 runs drawn, covering the first 33 terms. Every one of their lengths is the term at the matching position.
- Terms generated
- 1,000,000
Try this
The sequence starts 1, 2. What forces the third term to be 2 as well?
What is going on
Each explanation begins with a worked example and follows the same operation through intuition, formal statements and proofs. Later sections distinguish what is established from questions that remain open, so you can follow the level of detail useful to you.
- 1221 22 1112211Three terms in hand, so three runs: one 1, then two 2s, then two 1s.
- 122111 22 11 2 11221121The two new terms, 1 and 1, add a run of one 2 and a run of one 1.
- 12211211 22 11 2 1 22 11221121221Seven terms give seven runs, and the first five runs are the ones already written.
- 12211212211 22 11 2 1 22 1 22 11 2122112122122112Ten terms give fifteen, and every line so far is the opening of the next.
What you are seeing
A row of tiles and the lengths of its own blocks
The top row is a sequence of 1s and 2s. Wherever equal tiles sit next to each other they form a block, called a run, and each run is marked with a bracket. Under every bracket is a single number: how many tiles that run contains.
Read those numbers left to right and you get 1, 2, 2, 1, 1, 2, 1, and so on. That is the top row again. The sequence is the list of its own run lengths, which is the only thing being asked of it.
Why it starts to make sense
Each term is an instruction for a later run
Because the two letters alternate from run to run, the only thing left to decide about run number is how long it is, and the rule says that is the -th term. So term 0 describes run 0, term 1 describes run 1, and a term written early becomes an instruction obeyed later.
Follow the outlined tile in the reading view and you are watching that instruction being carried out. It is always behind the writing, never level with it or ahead of it, which is why the sequence can be built from left to right with nothing to guess and nothing to go back and fix.
The key idea
One rule fixes every term, and still hides the simplest count
Nothing here is random and nothing is chosen. Give the two letters and the rule forces the whole sequence, term by term, forever. A reader can generate as much of it as they have patience for.
That makes what happens next unusual. Ask how often a 1 occurs and the answer stops being computable in the same sense: you can count the 1s in any prefix, and the counts do settle near a half, but no argument is known that says they must. The rule that determines everything does not obviously determine that.
Formal statement
The sequence, and the question about it
Fix and let be a sequence over with . Write as maximal runs , so consecutive runs use different letters and run is made of the letter when is even and when is odd. Say is self-describing when
For this is the Kolakoski sequence, entry A000002 in the encyclopedia of integer sequences. Writing for the proportion of 1s among , the conjecture is that . Chvátal proved that every limit point of lies in ; that the sequence converges at all is not known.
Proof
What the construction does establish
Exactly one self-describing sequence over starts with , and the construction here writes it. Suppose runs have been written. Their letters were forced by alternation and their lengths by the terms , so the opening terms are determined, and no other self-describing sequence over these letters can differ from them. Run must then use its own forced letter and have length , so it too is determined, provided has already been written.
It has. Each run contributes at least one term, so after runs at least terms exist, and the index is at most the number of terms written. When it is strictly less, is already on the page. When the two are equal, is the first term of itself, which is the letter that run is made of, and that letter is known before the run is written. Induction completes the argument.
This proves that the picture on screen is the sequence and that it is the only one. It proves nothing about the proportion of 1s, which is the next layer's business.
Limits and further questions
A settled-looking number that nobody has pinned down
After a million terms, 499,986 of them are 1s. That is a count, not a limit, and the difference is the whole of the open problem. The density view draws Chvátal's interval around one half so the gap between the two kinds of statement is visible: the band is proved, the centre of it is not.
The clearest evidence that self-description alone is not enough is one control away. Change the letters to 1 and 3 and the sequence still lists its own run lengths exactly, yet 1s make up 0.397215 of its first million terms rather than anything near a half. Any proof about the classical case has to use something more than the defining property, because the defining property is shared.
Two further questions travel with this one. It is not known whether the sequence is what is called recurrent, meaning that every block occurring in it occurs infinitely often, and no formula is known that gives the -th term without generating the ones before it. The Thue-Morse sequence, linked below, has exactly such a formula, which is a fair measure of how much less is understood here.
What is actually established
Every statement on this page, with its status, its exact scope, and the date that status was last checked.
In the first million terms over the letters 1 and 2, every complete run has exactly the length the sequence records at the matching position.
- Scope
- The first 1,000,000 terms only. The final run of that prefix is excluded because a prefix can cut a run short, so 666,672 complete runs were compared.
- Why
- The prefix is generated, split into runs, and each run length is compared with the term at the same index. Nothing about terms beyond a million follows from this.
- Computation (exact)
- First 1,000,000 terms over the alphabet {1, 2}; 666,672 complete runs compared with the terms at the same indices, in exact integer arithmetic. Algorithm kolakoski-forward-pointer-1.
- Status checked
- Sources
- A000002: the Kolakoski sequence citation unresolved
For each pair of letters, exactly one sequence over those letters begins with the smaller one and has its own terms as its run lengths, and the construction on this page produces it.
- Scope
- The existence and uniqueness of that sequence, for any two whole numbers a and b with 1 <= a < b <= 9. This says nothing about how often either letter occurs.
- Why
- Runs of a two-letter sequence alternate, so run k is made of the letter fixed by whether k is even or odd, and the definition fixes its length as the k-th term. Reading the terms in order therefore forces every run in turn, and the induction in the proof layer shows the pointer always has the term it needs before it needs it.
- Status checked
- Sources
- Problem 5304: Self generating runs citation unresolved
For the letters 1 and 2, every limit point of the proportion of 1s in the first n terms lies between 0.499162 and 0.500838.
- Scope
- Chvátal’s published bounds, quoted here and drawn on the density view. They are not recomputed in this browser, and they concern the limit points rather than any single prefix.
- Why
- The proof is a computer-assisted argument in the cited technical report. This page draws the interval and checks that its own measured proportions fall inside it, which is a consistency check rather than a verification of the theorem.
- Status checked
- Sources
- Notes on the Kolakoski sequence citation unresolved
For the letters 1 and 2, the proportion of 1s in the first n terms tends to one half.
- Scope
- The infinite sequence over {1, 2}. Even the existence of the limit is unproved; the proved statement is the interval above.
- Why
- Widely believed and supported by every computation anyone has published, including the one on this page. Neither the limit nor its value has been established.
- Status checked
- Sources
- Notes on the Kolakoski sequence citation unresolved; A000002: the Kolakoski sequence citation unresolved
Among the first 1,000,000 terms over the letters 1 and 2, exactly 499,986 are 1s, a proportion of 0.499986.
- Scope
- This configuration only: the alphabet {1, 2} and one million terms. A different length gives a different count.
- Why
- Counted from the generated prefix. It sits inside the proved interval, which is what the density view draws, and it is evidence about a million terms and nothing more.
- Status checked
Over the letters 1 and 3 the sequence still lists its own run lengths, and 397,215 of its first 1,000,000 terms are 1s, a proportion of 0.397215.
- Scope
- The first 1,000,000 terms over the alphabet {1, 3}, with 453,397 complete runs compared. Chvátal’s interval is about the letters 1 and 2 and says nothing about this sequence.
- Why
- The failure preset. Self-description on its own does not push the proportion towards a half, so any proof for the classical sequence has to use more than the defining property.
- Computation (exact)
- First 1,000,000 terms over the alphabet {1, 3}; 453,397 complete runs compared and every term counted, in exact integer arithmetic. Algorithm kolakoski-forward-pointer-1.
- Status checked
Sources
Review notes show which bibliographic details Mathomaly has checked and which remain unresolved. Checking a publication record does not independently verify its proof.
- William Kolakoski, Problem 5304: Self generating runs, American Mathematical Monthly 72, 1965.
The problem that attached the name to the sequence. Cited for the statement of the self-describing condition, not for any result about density.
Citation details remain unresolved after review by Mathomaly.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: unresolved.
Author, title, journal and year are as listed in the references of the OEIS entry. Neither the issue nor a library record was inspected, so the record remains unresolved.
- Rufus Oldenburger, Exponent trajectories in symbolic dynamics, Transactions of the American Mathematical Society 46, 1939.
The earlier appearance of the same sequence, cited so the page does not present 1965 as its first description.
Citation details remain unresolved after review by Mathomaly.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: unresolved.
Taken from the references of the OEIS entry, which credits this paper with the earlier appearance. The article itself was not read and the priority claim is repeated rather than checked.
- Vašek Chvátal, Notes on the Kolakoski sequence, DIMACS Technical Report 93-84, 1993.
The source of the proved interval drawn on the density view, and of the statement that the limit itself is unproved. The bounds are quoted, not recomputed here.
Citation details remain unresolved after review by Mathomaly.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: unresolved.
Report number, title and year come from the references of the OEIS entry. The report was not obtained, so the two bounds this page draws are quoted on the strength of that listing alone.
- A000002: the Kolakoski sequence, The On-Line Encyclopedia of Integer Sequences. Link
The published terms the unit tests check the generated ones against, and the entry that collects the open questions about the sequence.
Citation details remain unresolved after review by Mathomaly.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: unresolved.
The first hundred values in the entry’s data file were copied into the unit tests and match the terms generated here. That checks the numbers, not the entry’s attributions and references, which remain unreviewed.
Related by mechanism
Connected by how they work, not by sharing a topic label.