ExplorationsThe Thue-Morse sequence connects substitution with binary parity
A Pattern Built by Flipping Its Copy
Begin with 0 and make a copy in which every 0 becomes 1 and every 1 becomes 0, then append that changed copy. Repeating this gives 0, then 01, then 0110, then 01101001. This is the Thue-Morse sequence: its infinite continuation repeats many smaller blocks but never settles into one endlessly repeated block.
Interactive laboratory
Current view: Copy and flip
See the appended copy before and after each bit changes.
Begin with one zero
Round 0 is complete with 1 bit. The construction starts with one zero.
Positions start at zero. Read across each line before continuing on the next; wrapping does not change the sequence.
Complete construction transcript
Every completed row for the selected rule is recorded here, independent of playback.
- Round 0:
0 - Round 1:
01 - Round 2:
0110 - Round 3:
01101001 - Round 4:
0110100110010110
- 0
- an outlined tile containing zero
- 1
- a filled tile containing one
- new half
- a vermilion outline marks the appended copy during a step
Tiles are read left to right and then onto the next line. Outlined zeroes and filled ones carry printed values as well as colour. During a step, the new half is first copied unchanged, then complemented; only the complemented row is a completed Thue-Morse stage.
Round 0 is complete with 1 bit. The construction starts with one zero.
- Completed rounds
- 0
- Committed bits
- 1
- Zeroes / ones
- 1 / 0
Try this
If a row contains five zeroes and three ones, how many of each would remain after appending its complement?
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.
- 00 followed by 101The copy of zero is flipped to one.
- 0101 followed by 100110Each bit of the appended copy changes to its opposite.
- 01100110 followed by 100101101001The old row stays intact as its complement is appended.
- 0110100101101001 followed by 100101100110100110010110The completed row has eight zeroes and eight ones.
What you are seeing
The old half stays while the new half changes
Start with a tile marked zero. Make a second tile, change its zero to one, and place it after the first. You now have 01. Copy those two tiles, flip both copied values to obtain 10, and append that pair. The row is now 0110. Repeating the same construction gives the rows above.
Tiles wrap onto another line when the screen is narrow, but the string still reads left to right, then from the end of one line to the start of the next. The line breaks are a drawing choice, not another mathematical operation. Reset returns to the single starting zero.
Why it starts to make sense
A complement pairs every zero with a one
Every zero in the old half has a one at the corresponding position in the new half, and every one has a zero. Consequently each completed doubling contains exactly as many zeroes as ones. This statement concerns complete power-of-two rows. A shorter prefix such as 011 need not be balanced.
Turning off the flip produces 0, then 00, then 0000, so the control is a different sequence. Its simplicity helps isolate which operation creates the structure. The Thue-Morse claims on this page do not apply to that altered rule.
The key idea
A bit can be determined without building the previous bits
Number the positions from zero. Write a position in binary, count its ones and keep the parity of that count: an even count gives zero and an odd count gives one. Position six is 110 in binary, with two ones, so the bit there is zero. Position seven is 111, with three ones, so its bit is one.
The binary-parity table compares this direct calculation with the copied construction. These are two descriptions of one sequence, rather than two unrelated patterns that happen to look alike. The proof below explains why their agreement continues beyond the displayed rows.
Formal statement
Finite construction rows define an infinite sequence
Let and , where the bar exchanges zero and one in every position and juxtaposition means concatenation. Each row starts with the previous row, so every position eventually has a fixed value. Those values define the infinite sequence .
If counts the ones in the binary expansion of , then
The recurrence is equivalent to the substitution and . The finite construction stops at 256 bits here for readability, not because the mathematical rule ends.
Proof
A new leading binary digit explains the complemented half
The first row agrees with the parity rule at position zero. Suppose a row of length agrees at all its positions. Every new position is , with . Its binary expansion is that of , padded to places, with an additional leading one. Its digit-sum parity is therefore the opposite of the parity at . Appending the complement produces exactly those opposite bits. Induction proves the parity description at all positions.
Balance has a shorter argument: if the old row has zeroes and ones, its complement has zeroes and ones. Their concatenation has of each. Neither proof depends on how the tiles are coloured or how many fit on a screen.
Limits and further questions
Local repetition and global periodicity are different
The sequence certainly repeats short pieces: 01 and 10 occur many times. A periodic sequence requires one fixed positive shift to work at every position, or at every sufficiently late position for eventual periodicity. Testing a chosen shift can find a mismatch, but passing a finite test does not establish that the shift works forever.
For example, 0110 has only one comparison at shift three, and it agrees. In 01101001, positions two and five disagree, ruling out period three from the beginning. The period view states both the tested range and any witness rather than calling a short agreement a repeating infinite sequence.
The infinite Thue-Morse sequence is known to be overlap-free, a stronger theorem stated in the linked Allouche-Shallit survey. It follows that it has no three consecutive identical non-empty blocks, whereas any eventually periodic tail contains such a triple. That proves non-periodicity using a published theorem, not using this page's finite period checks. The deeper result is cited rather than presented as something established by the animation.
What is actually established
Every statement on this page, with its status, its exact scope, and the date that status was last checked.
At position n, the Thue-Morse bit is the parity of the number of ones in n’s binary representation.
- Scope
- Every non-negative integer position, for the copy-and-complement rule starting at 0.
- Why
- Positions in the next half have the form 2^m + j. Their binary representation adds one leading 1 to j, so their parity is the complement of the earlier bit. Induction proves agreement at every constructed length.
- Status checked
Every completed construction row after the first doubling has equal numbers of zeroes and ones.
- Scope
- The power-of-two prefix after any positive number of copy-and-complement rounds. This does not say every arbitrary prefix is exactly balanced.
- Why
- A bit and its complemented copy contribute one zero and one one. Pairing the two halves proves the count without sampling.
- Status checked
No three consecutive bits of the Thue-Morse sequence are equal, so every stretch of equal bits has length one or two.
- Scope
- Every position of the infinite complemented construction. Stretches of length two do occur, for instance positions 2 and 3 of 0110.
- Why
- The bit at position 2k + 1 is the complement of the bit at position 2k, because adding a final 1 to the binary form of 2k changes the number of ones by exactly one. So a stretch of equal bits cannot include both members of any pair 2k and 2k + 1. Three consecutive positions always include such a pair, so three equal bits cannot occur.
- Status checked
The infinite Thue-Morse sequence is not eventually periodic.
- Scope
- The infinite complemented construction, not the finite displayed prefix or the unflipped control.
- Why
- The cited overlap-free theorem implies cube-freeness, whereas an eventually periodic tail contains three consecutive copies of its period block. The page proves the elementary parity and balance results, not the overlap-free theorem.
- 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.
- Jean-Paul Allouche, Jeffrey Shallit, The ubiquitous Prouhet-Thue-Morse sequence. Link
Author-hosted survey. Section 2 gives the binary digit-sum definition; section 3 states the overlap-free theorem and the substitution rule. The elementary parity and balance arguments are supplied on this page.
Bibliographic record checked. This is not an independent verification of the proof.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: source text.
Author-hosted survey confirms title, authors and the sequence definitions.
Related by mechanism
Connected by how they work, not by sharing a topic label.