# Immortal typewriting monkeys, infinite card shuffles, and All-Knowing libraries.

While the construction of sentences is in every way the result of individual experience, In a sense the sentence produced is in no way 'original'. But what do I mean by that?

## The Immortal, Typewriting Monkey

Are you perhaps familiar with this thought experiment: Say we have an immortal monkey with a typewriter (and an endless amount of paper) given the task of randomly hitting keys on the typewriter for all eternity. Logically, it *must* produce the complete works of Shakespeare, and every other book ever made, and this entire article too. The monkey will in fact eventually produce every single coherent and meaningful sentence ever written. If this confuses you, thats okay. Its not quite obvious why this is the case at first, hopefully I can help give you some context through a simpler example of the same idea.

## The Immortal, Card Shuffling Monkey


Lets take a step back and think of a slightly easier version of the same thought experement. say we have the same immortal monkey, and give them a well deserved break from all that typewriting. Instead, we give it a deck of 52 standard playing cards. The cards are perfectly organized in the usual arrangement from ace to king. Now, the monkey has the very important job of shuffling that card pack at random, taking a small break between each shuffle. Once the deck is truly randomized, What is the probability of shuffling the deck back into the exact order it started with?

### Card Shuffling Math, Metaphorical Needles In Haystacks

To calculate the amount of arrangements a standard deck can produce is actually really simple. Its 52! or 52x51x51x49... and that comes out to equal 8 x 10^67 different possible arrangements for a deck of cards total. More arrangements than there are atoms which make up the earth. Out of all those arrangements, just one of them is the one you started with. That means, the actual probability of ending back up with the arrangement that was started with is somewhere around 1 in 10^68. Hows that for a needle in a haystack?

For numbers this stupidly big or probabilities so absurdly low, the human mind simply fails to grasp their actual scale beyond "really big" and "really small". We just don't have enough context or brain power to understand how insane the scale of these values are. You'd have better luck trying to comprehend the size of the universe. Still, they are finite numbers all the same. A stupid big number is still theoretically countable, and a close-to-zero probability is still a theoretical chance.

# Improbable Certainty

For reasons that we will cover in a moment, an immortal monkey a deck of cards and a literally eternal time frame will HAVE to cycle through every single one of those arrangement of cards. Any configuration with a non-zero probability will eventually happen. This is not to say that anything can happen, the monkey will never magically pull an Uno card appear out of thin air, but everything that CAN happen within the rules of the set WILL happen given enough time. Sort of like physics version of Murphys Law. In this case, every single deck arrangement will show up. 

## Matter Of Time

The real question is: how long on average will it actually take for the deck to shuffle back into the original position by chance? Just what kind of time-scales are we talking about for such improbable events to actually, reasonably have a chance of *playing* out? Get it? Playing? Because were talking about cards? Yeah, you got it ;)

## Cycles In Motion

A very smart french guy called Henri Poincaré dealt with this problem back in the late 1800s. Only, his concern wasn't with the shuffle of cards, but rather the complex motions of particles in real world dynamical systems. To scientist and mathematicians seasoned in differential equation analysis, questions about how the motions and arrangements of particles are related to probability, and how those motions might form cycles, are very important. Those questions formed the backbone of our current understandings of order, entropy, the nature of physical/quantum information and the flow of time. But thats a story for another day. Back to mr. Poincare.

Henri proved using rigorous theorems: Given enough time, Any random walk through a finite set must eventually return to where it started, and eventually cycle through every possible configuration of state. The amount of time needed for a complete cycle back to the beginning is known as the Poincare recurrence time. It doesnt really matter what the set is composed of. Whether its a deck of cards randomly shuffled or the molecules of water in a glass moving in a random brownian motion.

In simple words, Given enough time a card deck being randomly shuffled MUST return to its original arrangement eventually, and also pass through every other configuration of cards too. Its just a question of how much time is needed for a full cycle on average.

## Scientific Magic?

Such a notion had huge implications for physics. Theoretically, a cup of water *could* (as in, the universe doesn't strictly disallow it) turn into ice at room temperature, all the atoms have a very real possibility of spontaniously aligning themselves just right to become crystal ice. After mixing cream into coffee and stirring well, its possible that by sheer chance alone the coffee and creme will seperate back perfectly into one side of pure cream and one side of pure coffee. Just by chance.


# Order To Entropy

## Oceans Of Chaos...

The problem is: the actual likely-hood of every water molecule in a glass of water all simultaneously arranging themselves into lattice crystals of ice at room temperature at the exact same moment, or the chance of every molecule of creamer ending up on one side of the cup and all the coffee on the other, are both about as close to zero as you can get.

Remember earlier about how a deck of 52 cards has more arrangements than there are atoms in the earth? Well, thats nothing. There are more atoms of air in a single matchbox, than there are stars in the universe. Yes, you read that right. Theres more air molecules in your lungs right now then there are stars in the entire observable universe. Thats just how small and numberous atoms really are.

If a mere set of 52 playing cards already yielded more arrangements than the number of atoms which make up the earth, think of the number of arrangements you would get from the set of a matchbox or a glass of water filled with a billion billion trillion atoms. And out of ALL those arrangements, only maybe a handful are those specially ordered cases like all the molecules arranging themselves on one side with the other side perfectly empty. the VAST VAST VAST majority of those practically infinite arrangements are disordered random distributions of atoms.

## Islands Of Order...

Highly ordered arrangements of molecules are so extremely rare compared to all the vastly more numerous and therefore more probable disordered arrangements, that it would take time scales MUCH longer than the lifespan of the universe for these hyper-rare arrangements of molecules to have a reasonable chance of occurring.

The last proton would decay and the final black hole would evaporate long before your glass of water ever mathemagically turned into ice. Those special, highly organized but near-impossible molecule arrangements are like tiny islands of near-impossible order, spread out in a endless ocean of highly probable disorder.

### Philosophical Sidenotes

If you put faith in the scientific model of our universes timeline, then it can be understood that the universe started with perfect order. At the very beginning of time, all the energy in the universe which eventually formed into every piece of matter in the current universe, was condensed into a single infinitesimal point in space-time.
The most accepted theory of how universe will end is with perfect disorder, or entropy. Due to the constantly accelerating expansion of the universe, All forms of usable energy will eventually dissipate and distribute evenly across the universe as cosmic background radiation. 

All the interesting complexity which allows you and me to exist, and even the concept of time itself, arises from that universal flow from ultimate order to ultimate disorder. Within that flow is uncertainty, and with uncertainty comes possibility. From possibility guided by simple rules, arises complexity. Orderly systems arise from chaos, and chaotic systems arise from order.

Assuming we take Ponticare's ideas of cyclic paths and recurrence time to its logical extreme, perhaps it is justification for the idea that the universe itself is cyclic and eternal. On large enough time frames, perhaps all the cosmic background energy across the entire universe will condense back in on itself in a feat of sheer improbability over an eternal time-span. Probably not, but its a fun thought!

One of Futurama's episodes "The Late Philip J. Fry" uses this idea in a hilarious fashion, and is what comes to mind when I think of the concept. However the idea of a cyclic, eternal universe is nothing new and stems back to ancient eastern teachings. It would be a hilarious twist of irony if science and mathematics ultimately came to some of the same conclusions about the universe which ancient religions already arrived at a couple thousand years before.

=> https://www.youtube.com/watch?v=Qi7egXgYcgk Relevant clip from the Futurama episode mentioned

### What Is Disorder
The scientific word for "disorder" in this context is entropy. Entropy has a much more technical definition which relies on an understanding between order, disorder, and the way the universe handles pure information, but for our purposes its close enough to just say they are the same. The more randomly distributed a set becomes, the higher the entropy/disorder becomes. A known fact is that all closed systems eventually tend towards complete entropy. Once a system reaches maximum entropy, there is no way to know how the system got to that point in the first place. In other words, the information encoded in the path of the system took to move from order to disorder has been fundementally lost.


# Back To Words

Where were we again? Oh yeah, immortal monkeys with typewriters. Words are really just combinations of letters. In the case of english, a base of 26 letters plus a few denoting things like periods, spaces, and paranthesis. Ground breaking stuff, I know. One question to ask is how many different combinations of letters can we produce? How many total words are possible to make using just 26 letters? If we set no limit to how many letters we can string together, the answer is obviously an infinite amount. But if we set the limit to say 10 letters total, the answer is 26^(1+2+3+4+5+6+7+8+9+10)= 25^55. In other words more stupid big numbers. How many different combinations of words are there? The answer, again, is a biiiig number, but countable.

## Getting Shakespeare From Probability

There is a small probability of typing any word by randomly hitting characters on the keyboard. A much smaller possibility of constructing a full sentence. Almost a near-zero chance of writing a 1 to 1 copy of shakespeares works, or any other creative writing, by chance. But on infinite timescales, anything with a non-zero chance is a certainty. 

Now that we have the boring stuff out of the way, and we understand how order can arise from sheer probability, lets explore the most comprehensive library in the world built upon the very concept.

# The Library of Babel

I now want to introduce you to a very special library. This library contains everything that ever has been and ever will be written. Every sentence of this article is there, exactly how i worded it. As well as every near-copy of the article with one word added, or removed or changed. What happened to Amelia Airhart is here, as well as everything that didnt. Every truth, every lie, even the meaning of life, the universe, and everything in it (its 42 btw).
No, this isnt a trick to fool you, nothing is being "generated" in real time to fit your query or anything like that. Its all really there, mathematically speaking. perfectly catagorized and labeled in the library of babel. Take a look:

=>https://libraryofbabel.info/ The library of babel link
I urge you to check out the "theory" page which goes over the juicy, mathy internals of how the library works.

## A Hell Of A Library
If you browse the library at random, you will quickly find that almost every single page of almost every single book is filled to the brim with nonesense strings of charaters, numbers, and punctuations. To find a sensible word is hard, finding enough sensible words coming together to form a single sentence is much harder. Yes indeed, an infinite library that contains every single thought, sentence, idea, and truth. But for each and every island of order, is a vast infinte ocean of random garbled nothingness. Order out of chaos. 

Its one thing to mull over the typewriting monkey thought experiment, a cute abstract curiosity. Its quite another thing all together to be faced with the logical outcome of such a concept in tangible form. One could quite literally spend the rest of their lives combing through virtually endless books before encountering a single coherent paragraph.

## Take A Stroll

To take the website one step further, someone made a python "game" well... more like a walking simulator, that generates a 1 to 1 recreation of the library as it was originally envisioned by the author who wrote the original short story. Loading up the program, you're free to start wandering around the halls of a practically infinite and perfectly structured library.

Curious, you start pulling out book after book and scanning them. What meets your gaze? Nonsense. Books filled from head to toe with nothing but random strings of letters, numbers, and punctuations. Yet you KNOW the meaning is there, every string of words you can muster, every complete book ever made, every incomplete book never made, what the winning lottery numbers for tommorow are. Somewhere in that library, properly accounted for, catagorized. You 'just' have to be lucky enough to find it. Lucky enough to stumble into an island of order in an ocean of chaos.

This virtual experience is perhaps the closest one can get to grasping the sheer magnitude of... i don't know, really. Whatever it is, it helps me understand the value and rarity of order meaning. How amazing my minds abiity to construct intentional, planned out combinations of words to convey ideas. The entire sum of every thought i've ever had is less than a drop in the bucket of all concievable thoughts and every possible combination of sentences.

=> https://keiwan.itch.io/library-of-babel-3d The Library Of Babel 3D Simulation


# The Function of Intention

Words are not much on their own though. They are merely a tool for conveying bits of experience with other people in a commonly accepted format. You can program a computer to randomly generate words and every so often a proper sentence will pop out. Big whoop. 

When I write this sentence, Its intentional. When you read this, you must interpret the intentions of my words and deduce what they mean. Its an innately human thing. We are story tellers, and there is no story without a teller. When I describe a "beautful, perfectly smooth, red apple" You can probably picture such an apple in the minds eye, because of your own experiences with the concepts of 'smooth', 'red', and 'apple'. Experience is the real meat and potatoes to how we interact with the world, not the words used to catagorize and define them.

It does not really matter if this sentence, or every sentence ever to be constructed in the history of the human race, is theoretically somewhere in an abstract library constructed from the pure combinatorics of language. In the real world for all practical purposes the only way words and coherent ideas can ever actually manifest is through intelligent conciousnesses complex enough to require such tools to descibe things. This article is completely original in terms of physical reality, because no-one else has cobbled together words in exactly this way. Still, really gives a new perspective to the whole idea of originality, huh?

#Conclusion
Wow, This sure is a huge post huh? Don't ask me what made me sit down and write all of this. Sometimes when you start you cant stop, ya know? Alright, well thank you for joining me on this excursion into madness. I hope to see you next time!

=> ./ Back To Gemlogs