The universe (which others call the Library) is composed of an indefinite and perhaps infinite number of hexagonal galleries, with vast air shafts between, surrounded by very low railings. From any of the hexagons one can see, interminably, the upper and lower floors.
A short story by Jorge Luis Borges, and one of his most compelling metaphysical speculations. The opening sentence above sets the scene. The entire universe is composed of hexagonal rooms, extending infinitely far above and below and in every direction, connected by corridors and stairs. Human beings live there, and travellers' tales over the centuries have never reported an end to the rooms. And each room is full of books, just books. And every book is full of nonsense.

The narrator tells of the history of ideas about the Library, of old philosophers and mystics disputing whether it could be infinite or bounded, and the eventual realisation of the central fact of the Library: that absolutely every single truth is contained in it. It's akin to the infinite monkeys theorem, in that enough randomness will contain by chance any amount of sense; though in this universe the books are just there, not created. As far as anyone knows they are infinitely old. It's not even stated whether they're printed or manuscript.

The story is a strange mix of this impossible situation with concrete literalism. It's not told as a metaphor, it's told about a real library with walls and corridors, and off each room is one cell big enough to sleep standing up in, and another for a toilet. The people need sleep, they need to poo, but there is no mention of food produced, or birth, or manufacture, or any kind of society, it's just people, all of whom are librarians, wandering their vast spaces.

But the people can die, and the books can be destroyed. They can be thrown over the edge into the air shafts, and there they (apparently) fall infinitely far and decay as they do. There are dialect divisions a hundred floors above or below, or miles away, there were different languages in the past, they remember the discussions of olden times. People commit suicide as they despair of finding the truth, of finding the secret rooms or special books or ends of the universe, of finding those books that explain everything.

For the Library is infinite, and the alphabet the books are all written in is finite, and each book is of the same determinate size and the four bookshelfed walls of each room hold the same number of books, and there is no sense in or way of predicting either the content of any one book or its arrangement near any other: from all this it appears that any book is a totally random selection of characters, and every possible selection appears randomly somewhere in the Universe.

The entire works of Shakespeare must appear somewhere. The works of Shakespeare with one letter changed near the end of the ninety-seventh page. Shakespeare and telephone book alternating. The solutions to all life's problems. Catalogues of all the books in the library, and instructions for how to find any book you want even though they're randomly arranged. False catalogues and mad instructions. Every truth, every lie, and oceans of gibberish so vast as to dwarf the remotest chance of finding any more sense than xathndsjs dakkdsss gi abajajjaststst pyramids hauaxxxxx mcxxxxp.

Is it infinite? The narrator speculates. Could it be ultimately circular: if you travel far enough across the universe could you return to the same point? We find this idea familiar now in cosmology, and like the narrator of The Library of Babel we don't know whether it's true. There are only finitely many possible books, though the number is Vast, but why should there be only one copy of each? The inhabitants have never seen any two alike, of course, but no two random selections would bear any resemblance to each other: the odds of someone seeing two that close are vanishing. In an unbounded Library every book would occur infinitely often. And strictly, if they're totally random, there's no logical reason why a given possibility must occur; it is just vanishingly unlikely not to.

In the node God made the integers, all else is the work of man, dido mentions the idea put forward by mathematician Emile Borel in 1927 (and therefore conceivably known to Borges, writing in the 1930s) that there is a constant that contains the true answers to every question: encode the question as a number, and check that number's place in the constant. Borel apparently meant this to be a reductio ad absurdum of the uncountable infinity of real numbers; but it's Borges's Library of Babel encoded as a number. Yes, Borel's constant exists, but so does every other variation on it, giving wrong answers in this or that place.

Borges's story is not mathematical in nature: he being Borges, it is a tale of heretics and paradoxes and impieties and commentaries. it is of course also a kind of parable for the infinite possibilities within Borges's writing.