O, for a muse of bananas!
There are a lot of versions of the Infinite-Monkey Theorem out there. The Jargon File's entry says, in part:
“If you put an infinite number of monkeys at typewriters, eventually one will bash out the script for Hamlet.” (One may also hypothesize a small number of monkeys and a very long period of time.) This theorem asserts nothing about the intelligence of the one random monkey that eventually comes up with the script.
[...]
This theorem has been traced to the mathematician Émile Borel in 1913, and was first popularized by the astronomer Sir Arthur Eddington.
The theorem obviously abstracts away from certain known properties of monkeys and typewriters, like the fact that monkeys don't know that you're supposed to strike only one key at a time (unless one of them's the shift key), and so the typewriters would all be terminally jammed up after the first few letters. (Don't try to tell me Borel was using a Selectric in 1913.) Or, if one could somehow get around that obstacle, there's still the fact that, long before the monkeys produced anything worth reading, the typewriters' manufacturer would have stopped producing the requisite style of ribbon, or even gone out of business entirely.
As you may be thinking, that's not the point. The theorem isn't really about monkeys and typewriters; it's about patterns and probabilities. On the other hand, some people seem to have missed the point quite spectacularly (although not so spectacularly as to waste a vintage Underwood), as the Jargon File further reports:
In mid-2002, researchers at Plymouth University in England actually put a working computer in a cage with six crested macaques. The monkeys proceeded to bash the machine with a rock, urinate on it, and type the letter S a lot (later, the letters A, J, L, and M also crept in). The results were published in a limited-edition book, Notes Towards the Complete Works of Shakespeare.
More recently, as has been noted in two recent Language Log posts ("Monkey Shakespeare," by Bill Poser, and "A Random Monkey Begins Julius Caesar," by Geoff Pullum), some rather brighter researchers have hit upon the notion that the monkeys could be replaced by computers, too. The Monkey Shakespeare Simulator uses a Java applet to produce pseudo-simian pseudo-random strings of characters and compare them to the complete works of the Unmortal Bard. (The version of the theorem being tested here is, "If you have enough monkeys banging randomly on typewriters, they will eventually type the works of William Shakespeare"—hey, why stop at Hamlet?) Every time a simulated monkey types a string of characters corresponding to the beginning of any of Shakespeare's plays (they say they want the works, but they don't seem to be grepping the sonnets), the program lets you know. As of this writing, the best effort yet has been the first twenty characters of Coriolanus, namely "1. Citizen. Before w"—that's some seriously deathless prose, there.
Note that the applet only looks for text at the beginning of a play; if a virtual monkey goes and pounds out this:
The next thing when she waking lookes vpon,
(Be it on Lyon, Beare, or Wolfe, or Bull,
On medling Monkey, or on busie Ape)
Shee shall pursue it, with the soule of loue.
...it will count for naught, unless the busie Ape in question has the great good fortune to have typed the first act and a half of A Midsummer Night's Dream immediately before it.
Geoff Pullum points out that, abstracting away from most of the things that need to be abstracted away from, "it's not a speculation that one day we'll get the whole of the Immortal Bard's works out of an untiring team of monkeys working away on keyboards; it's definitely true — unless astronomy imposes its cosmic time limit on everything and the earth is destroyed or the universe shuts down before we get there." Of course, the reason it's definitely true is that, with an infinite amount of time to work in, the monkeys always get another chance; if, this time through, they happen to get everything right except that they type "letters congriung to that effect" in Hamlet IV.iii, well, they'll have a chance to put the u and the i in the right order in another few millennia when it comes round again. (This is not quite a fair complaint, mathematically speaking, because infinite time is clearly not enough all by itself: if you gave the monkeys typewriters that were missing the letter S, then you could prove that they would never even write Shakespeare's name, no matter how many chances you give them.) The fact is, this is one of the worst valid procedures you could come up with for producing the complete works of William Shakespeare. Wouldn't it make more sense to let the monkeys go, wait for them to evolve into something with the capacity for language, and then see whether one of 'em might eventually write the plays on purpose? Before you scoff, keep in mind that this approach (or something very like it) has actually worked once; the infinite-typewriter technique, though demonstrably sound in theory, has never pulled it off in practice.
Also, I think the whole faithful-reproduction-of-the-Bard angle has been overemphasized. There are a hell of a lot of other quite remarkable things that your infinite-monkey setup will produce. For example, there's roughly a fifty-fifty chance that, before coming up with Shakespeare's version of Hamlet, the monkeys will produce one that is nearly identical to it, but with the names Rosencrantz and Guildenstern reversed. They will also—probably ages and ages before they get around to the 'real' Hamlet—come up with an alternative script in which the hesitant title character is replaced by the decisive Moor of Venice, who kills Claudius at the first opportunity, so that the whole thing ends happily after a single brief act. (The Comedy of Othello, Prince of Denmark is easier for the monkeys to type accurately because it is considerably shorter; the fact that it doesn't already exist is of no concern.) Then, too, the monkeys will also happily give you things like the full text of an article that will appear in Linguistic Inquiry seventeen years later, complete with appropriate bibliographic references to other works that will be published in the interim. They might even churn out the lyrics to Chris Yacich's classic song "I Like Bananas (Because They Have No Bones)," or the complete works of William Shatner. Eventually, the monkeys will type the exact text of this very blog entry itself! (But I did it first, or at least I think I did.)
The tricky part, of course, is combing through all the b'in-p1:s]Ij"PpXeygefFPXD)gg8Ns garbage, and non-rhyming limericks, and EBCDIC-encoded cake recipes that reverse the proportions of flour and baking powder, and garbled instructions for the care and feeding of Nubian dairy goats, to find the good stuff. The one great advantage of using the works of Shakespeare is that at least we know what we're looking for.