The infinite monkey theorem: Given an infinite amount of time, a monkey hitting random keys on a typewriter will eventually write the complete works of Shakespeare.

It is one of the most famous thought experiments of all time, an illustration of what happens when you take probabilities to their logical extreme: The infinite monkey theorem states that since there are calculable odds that a monkey hitting random keys on a typewriter will unintentionally write the first words of Hamlet (“Bernando: ‘Who’s there?” / Francisco: ‘Nay, answer me: stand, and unfold yourself.’”), eventually a monkey would manage to type the entire play.

The idea has a long history. Aristotle played with a variant of the idea when he noted that atoms could randomly arrange into any possible form. Scientists and mathematicians in the early 20th century used the current incarnation, with monkeys as a stand in for a machine producing a (It’s a good idea to use the monkeys as a metaphor. In an experiment, six Sulawesi crested macaques in an English zoo only managed to fill up 5 wordless pages, mostly with the letter ‘s.’ They also pooped on the typewriter and bashed it with a rock.)

In a literary interpretation, writer Jorge Luis Borges, who believed that stories should have exactly one fantastical element, imagined a group of monkeys on typewriters producing not just Shakespeare but the entire literary contents of the British Museum. And if a monkey had enough time (“Strictly speaking, one immortal monkey would suffice,” Borges wrote in an essay), its output could fill “The Total Library,” a library containing every possible combination of spaces, punctuation, and letters. The Total Library would contain a lot of gibberish, but also every poem, book, and written work that could ever be written.

Mathematicians have spent time calculating how long it would take a monkey to write a copy of Hamlet (even if they perform better than the macaques in England, the answer is a really long time -- orders of magnitude longer than the universe has existed). But Borges’s Total Library idea suggests an important corollary to the Infinite Monkey Theorem: a monkey hitting random keys on a typewriter would mostly likely write something superior to Shakespeare long before it produced a copy of Hamlet

The logic is simple. The odds of a monkey writing an intelligible sentence are low, but the odds of one writing a sentence from Hamlet are astronomical because there are many possible intelligible sentences but a limited number of sentences in Hamlet. In the same way, there are a limited number of works by Shakespeare, but there are an almost infinite number of plays and books that are better than Shakespeare ranging from a copy of Hamlet with one small, superior tweak to yet-to-be-written sci-fi novels to George R.R. Martin’s Game of Thrones series.

Of course, amidst all the gibberish, it would be hard to identify the great new works of literature, so the corollary comes with an important qualification that it requires a group of unpaid comparative literature majors with infinite time to find the intelligible monkey-authored books and debate which are better than Hamlet or King Lear. Unfortunately this may not turn out so well: In Borges’s Total Library, the paradox that all human knowledge and creativity is present in the library but hidden by a deluge of gibberish leads the librarians to a state of “suicidal despair” and “cult-like behaviors.”

Let it be known: this might actually matter. The impossible amount of time it would take a monkey to randomly write Hamlet, for example, has been cited as a challenge to evolution. If it would take a monkey infinitely long to do so, the argument goes, isn’t a process of evolution governed by random mutations equally doomed to failure?

There are many rebuttals to this, as well as to other challenges based on the infinite monkey theorem. But this corollary provides its own. The anti-evolution argument ignores alternative but equally successful courses of evolution just like the monkey theorem ignores the much more likely outcome of the monkeys outdoing Shakespeare.

For too long, we've maligned the literary potential of a million monkeys typing on a million typewriters. Monkeys would write something superior to Shakespeare long before they produced a copy of Hamlet.