Imperfect Loops
How our cycles add up to something
Loops, cycles, oscillations, whatever you want to call them, show up everywhere in nature. There’s a reason for that: for something to persist while still being dynamic, it has to cycle back to where it started. But coming back to where you started isn’t the same as being unchanged.
Take for example the story of The Stonecutter (what follows is an abbreviated version):
A poor stonecutter worked every day harvesting slabs from a great rock. One day he delivered a slab to a rich man, and envied the rich man’s possessions and leisurely life. He wished he were a rich man.
A voice answered: “Your wish is heard; a rich man you shall be!”
As a rich man, the umbrella his servants held over his head didn’t keep the sun’s rays from burning his face. He cried out: “The sun is mightier than I; oh, if I were only the sun!”
And a voice answered: “Your wish is heard; the sun you shall be.”
As the sun, a cloud hid the earth from him. “The cloud is mightier than I? Oh, that I were a cloud!”
And a voice answered: “Your wish is heard; a cloud you shall be!”
As a cloud, he rained down on the earth. But the rock was not affected by the rain. “Is the rock, then, mightier than I? Oh, if I were only the rock!”
And a voice answered: “Your wish is heard; the rock you shall be!”
As a rock, he was not affected by the heat of the sun or the force of the rain. But along came a stonecutter who broke a great block off his surface. “Is a mere child of earth mightier than a rock? Oh, if I were only a man!”
And a voice answered: “Your wish is heard. A man once more you shall be!”
And a man he was. His bed was hard and his food scanty, but he had learned to be satisfied with it. And as he never asked for things he did not have, or desired to be greater and mightier than other people, he was happy at last.
The story begins and ends with the stonecutter in the same place: as a humble laborer. And yet in another sense, there’s been an enormous shift: he’s happy at last. The loop hasn’t changed his material conditions, but it caused a shift on a different level—a shift in perspective.
In the immortal words of Terry Pratchett:
Why do you go away? So that you can come back. So that you can see the place you came from with new eyes and extra colors. And the people there see you differently, too. Coming back to where you started is not the same as never leaving.
Moving by returning where you started
Sound has a ceiling. We can’t hear things higher pitched than about 20,000 Hz. This puts a constraint on how high pitched a song can get. You can’t have a song that simply goes up in pitch forever.
Or can you?
The Shepard–Risset glissando is an auditory trick where two tones are played at the same time one octave apart. The lower one gradually gets louder as the higher one gets softer, until it finally fades out, to be replaced with a soft low note. The result is something that seems to just keep increasing in pitch.
Using a similar idea, you can create a Risset rhythm that seems to infinitely increase in tempo.
In both these cases, we have a loop — the music loops around to the same pitch/tempo, and yet it feels higher or faster because there was no point where it stepped back down. We’ve looped around, and yet there’s been a psychological change in the listener: they feel like they’ve been going “up” for the duration of the loop.

In one sense, there is movement with these loops—inside the listener. In another sense, there is no movement, just an endless circle. And yet the loop never really goes anywhere. Eventually, as I’m listening to these and my attention wanders, the effect falters for a moment and it seems to “reset”. And then I simply get bored and stop listening to it.
Any loop that doesn’t come back precisely to where it began eventually ends.
An Imperfect Circle
There are a number of species of ants considered “army ants”. They form enormous swarms to forage. They raid wasp nests, hunt spiders, and sometimes even eat vertebrates like lizards, frogs, or birds. The colonies are typically nomadic, never staying in one place for long because they quickly exhaust their environment to feed their enormous colony population.
This specialized social foraging requires coordination. To stay together, the ants lay down pheromone trails as they travel, and they return to their temporary nesting site by following the same pheromone track back.
Occasionally, a group of ants can get lost from the pheromone track. Each ant will simply follow the pheromones of the ant in front of it, but if the lead ants encounter an obstacle and need to turn back, they end up following the pheromone trail of those following it. The result is a circle of ants, each following and reinforcing a pheromone trail that leads in a circle. This is called an ant mill.
These loops aren’t perfect. They don’t go back to exactly the same state they were before for a simple reason: ants are living beings. With each loop, they are slowly depleting their energy. Sadly, ant mills generally end with the ants involved simply dying of exhaustion.
Self-Reference and Reproduction
Ant mills are loops that kill. Their imperfection subtracts, slowly draining ants of energy while not leading anywhere else. Yet there are much more persistent loops involved in life.
My son has lately been learning all about the life cycles of animals in preschool. Egg to caterpillar to chrysalis to butterfly, which lays eggs to begin the cycle anew. I’m not sure he totally gets it—he likes to pretend to be a caterpillar who turns into a butterfly, but then as a butterfly he’ll turn back into a caterpillar. I haven’t had the heart to tell him that the way the cycle continues is that the butterfly lays eggs and then dies.
This cycle is possible because we animals contain the instructions for building ourselves within us. We’re all used to this idea, but it’s worth thinking about it for a moment, because it’s pretty bizarre.
Imagine trying to make a machine that creates itself. You might imagine a 3D printer that can print off all of the parts of itself, but that doesn’t quite work—it might make the parts, but it also needs to assemble them, wiring and all.
It’s a bit easier to create a computer program that creates a copy of itself. A quine1 is a computer program that takes no input, but outputs itself.
If you know anything about programming, this might initially seem puzzling—to output, a program would need to use a function to output, usually something like “print”. So to “print” itself, it would need to start with “print” and then contain the entirety of the code itself. But the code itself contains “print”. So you might try:
print “print”
Where the bit in the quotation marks is what gets printed. But notice now we’re just printing “print”, and missing the second print in the quotation marks. So to print out the previous code, we would need something like:
print “print “print””
But now we’ve added something to the code, and once again, we’re not printing the full code. We can keep going like this, adding one more “print” each time, but all we’re doing is printing out the code of the previous version. If we added a bunch of prints and ran the code, and ran the output, and so on, we would run ourselves down just like an ant mill.
We need to pull a little trick, adding a self-reference to the code to keep this loop from going on forever. The trick is that the program stores its own code as data, a string it can print literally and use as instructions. The same text ends up doing double duty. (See footnote 2 for an example solution)2
So in a way, quines “self-replicate”. If you pipe their output into a file, they create another version of the exact same code that you just executed. But that’s not very useful.
Quines are mostly just a novelty for nerds. They’re an odd puzzle that it isn’t immediately obvious how to solve, yet they’re possible in all Turing-complete programming languages (basically any real programming language).
More interesting are theoretical von Neumann probes: space probes that can create more of themselves using materials widely available in the galaxy. Imagine sending off a probe to a distant solar system, the probe autonomously collecting materials from asteroids or planets there and using those materials to create more probes, and then those probes flying off to other solar systems.
This is an idea explored in various ways in science fiction, often with these self-replicators getting out of control, becoming a cosmic virus running rampant in a galaxy with no immune system, mindlessly consuming everything to create more of themselves.
In other words, becoming like life.
Life
If one were to make a self-replicating probe that frequently made errors in the copying process, it wouldn’t proliferate. With frequent enough errors and short enough probe longevity, it would just create a bunch of non-functional copies and then stop working instead of overrunning the galaxy. That doesn’t make for a good science fiction story.
This is the problem that early organic molecules had to “solve” to produce life. We’re used to thinking of evolution as powerful due to the change that comes in from one generation to the next, but that’s secondary to the primary ingredients needed for life to get off the ground in the first place: stability and fidelity.
The universe is populated by stable things. There are a lot of atoms around because they are stable configurations for subatomic particles. The molecules we come across exist because they are stable. Anything that wasn’t stable wouldn’t stay around long enough to become common.
For life to get started, there first had to be molecules that interacted with their environment in such a way that they created more copies of themselves. Common molecules are stable configurations of molecules. Richard Dawkins has called “survival of the fittest” just a special case of the more general principle, “the survival of the stable”.
Ironically, it was the lack of stability in the copying process that led to finding greater stability. Small copying “errors” led to configurations with greater stability or copying fidelity, and those overtook the replicators that came before.
It’s thought that before DNA, RNA was life’s primary information storage molecule. The switch to DNA was because of DNA’s greater chemical stability.
The great irony, then, is that the instability of the previous iterations is what leads to evolution finding greater stability.
Which came first, the chicken or the egg?
This old riddle is seductive because it seems impregnable. It evokes the idea of a perfect, eternal cycle. All chickens come from eggs, and all eggs come from chickens. How could this cycle get off the ground to begin with?
Of course now we know the answer: evolution. Through the gradual accumulation of small changes, each subsequent generation became a bit more chicken-like, until finally a generation came that we would say are chickens. Imperfect loops built chickens.
Quines, on the other hand, have the problem that their copying fidelity is too perfect. Run it as many times as you like, it will just make the same thing. Nothing accumulates, nothing changes. The loop just goes round and round, never really doing anything. Yet replication in the messy real world has led to everything from the incredible branching structures of trees to the complexities of the human brain.
Life is full of loops other than the life cycle. We wake up in the morning, we go to sleep at night, only to wake up again in the morning. We get hungry, obtain food, and eat, so that we have energy to find more food. Put in such stark terms, these loops feel pointless, like they don’t go anywhere. Perhaps it’s put most starkly in the lyrics of the band Metric:
Buy this car to drive to work
Drive to work to pay for this car
But each of these cycles is imperfect—they don’t lead to the exact same state that we were in before. And it’s a good thing, too. We don’t want to be quines, perfectly cycling back to where we were before.
In between the time we wake up and sleep (or between driving to work and making car payments), we do things that add to our life stories. Maybe we go to bed having had a new experience, or learned something, or with one more small piece of our life story in place. Maybe we’ve helped someone, affecting another person’s loop in some small way.
Like the ant mills, eventually the cycles end because we just wear out. But unlike ant mills, each cycle has meaning, and the limited number of repetitions we make around the loop is what gives the whole process value. If our time was infinite, how we choose to spend it wouldn’t have meaning.
We move our legs in a cycle to walk—our muscles and joints return to roughly the same position with each cycle. But each step brings us somewhere. Just like each sweep of your eyes across this screen, you see new words that hopefully add up to something, despite your eyes returning to the same left margin time and time again.
When you finish reading and return to whatever you were doing before, you’ll be much the same person you were when you started. But, perhaps this little cycle has made some small change in you—perhaps not as profound as the change in the stonecutter who found peace in his circumstances, but a change nonetheless.
(If you enjoyed thinking about these loops and self-references, check out Gödel, Escher, Bach by Douglas Hofstadter. Reading it nearly two decades ago inspired this post).
If you enjoyed this, please hit the “Like” ❤️ button, restack, or share this article to help others find it.
If you enjoy Cognitive Wonderland, consider supporting it by becoming a paid subscriber at whatever level feels comfortable for you.
If you’re a Substack writer and have been enjoying Cognitive Wonderland, consider adding it to your recommendations. I really appreciate the support.
Douglas Hofstadter is the originator of the term. He coined quine after Quine, who is known for Quine’s paradox:
“Yields falsehood when preceded by its quotation” yields falsehood when preceded by its quotation.
Here’s one way to create a quine.
Start with these simple 3 steps (separated by semicolons):
s = “x”; substitute s for the first value of “x” in s; print s
Right now this is pretty useless. The second step replaces “x” with “x”, resulting in just printing “x”. We could remove the second step and not lose anything. But this gives us enough structure to now add the self-reference: we just change the initial assignment of s to be those original 3 steps (I’m ignoring complications with quotes as a special character here, and bolding the part that is copied and pasted from the code above to make it more clear):
s = “s = “x”; substitute s for the first value of “x” in s; print s“; substitute s for the first value of “x” in s; print s
Note that we still only have three steps, but now our substitution actually does something: it embeds a second version of s within itself.
(credit to this page for the spirit of this pseudocode solution)




Read this 3 times already, not sure when to stop
> In other words, becoming like life.
"Like" life? Are you softening this to avoid controversy? Everything that I know about biology points to von Neumann probes *being* life.