A library with every page
In 1941 Jorge Luis Borges imagined a library of hexagonal rooms whose books hold every possible arrangement of a few letters. Most of it is noise. Somewhere in it is everything ever written, and everything that ever will be.
When it was proclaimed that the Library contained all books, the first impression was one of extravagant happiness.
This library keeps his shape: four walls of five shelves in each hexagon, thirty-two books to a shelf, 410 pages to a book, 40 lines of 80 characters to a page. Borges gave his books 25 symbols. Mine have 29, all 26 letters plus space, comma and full stop, so English can be found in them.
- a
- b
- c
- d
- e
- f
- g
- h
- i
- j
- k
- l
- m
- n
- o
- p
- q
- r
- s
- t
- u
- v
- w
- x
- y
- z
- space
- comma
- full stop
A page is 3,200 characters, each one any of the 29. That makes 293200 different pages: a number 4,680 digits long. Every one of them is on a shelf here, and none of them is stored anywhere.
A library small enough to count
Shrink everything. Give the library two symbols, n and o, and pages three characters long. Now there are exactly eight pages, and the whole library fits on one shelf.
nnn is the first book. Read n as 0 ando as 1, and the page is 000 in binary: 0, the first place on the shelf.
Finding a page here is counting. Read the page as a number, and the number is where it stands. The real library works the same way with 29 symbols instead of two, and 3,200 characters instead of three. The number is just very long.
Shuffled, not stored
Counting has a problem. Shelved in order, the first billion billion books all begin with the same 3,000-odd letter as, and every book differs from the next in its last few characters. Borges's library looks like chaos from any shelf. So each place has to be shuffled into its page, by a shuffle that can be run backwards.
I use a Feistel network. It cuts the page into two halves, mixes one half into a stream of noise, adds that noise to the other half letter by letter, and swaps them. One round barely disguises anything. Six rounds leave no trace of the order underneath, and because each step can be undone, every page still has exactly one place.
| Place | Page |
|---|
The obvious alternative is to multiply the place by a huge number and add another. That shuffles too, and it is easy to run backwards, but it leaves a tell. Neighbouring pages differ from each other in the same pattern, over and over: the stripes in the first panel below. The Feistel shuffle's differences are pure noise.
Multiply and add
Feistel, six rounds
Running it backwards is search
To find your words, the library doesn't look for them. It writes the page they're on, then asks where that page is shelved.
The library reads them as
hello
It fills a page with random letters, seeded by your words themselves, and writes them in.
It runs the six rounds backwards on that page. Out comes a place: a number up to 4,680 digits long.
That number is an address: a hexagon, a wall, a shelf, a volume and a page.
Walk there
How big is it?
About 10 to the power 80 atoms in the observable universe, against about 10 to the power 4,680 pages in the library.
Turn every atom in the observable universe into a universe of its own. Then do it again inside each of those, and again, fifty-eight levels deep. You still have fewer atoms than this library has pages.
Show the whole number
It wraps around
The hexagons are numbered in one long line. Each floor holds 27764 of them, a number 2,338 digits long, and stepping east moves you one number along. Walk east past the last gallery on a floor and you are on the first gallery of the floor above: the galleries are one enormous spiral. The stairs skip a whole floor at a time. After the last hexagon comes the first again.
Hexagon 1: floor 1, gallery 1.
The very last hexagon is nearly empty. 293200 pages don't divide evenly into hexagons of 262,400 pages: there is exactly one left over. So the last hexagon has one book on its first shelf, and that book has one page.
Prior art and thanks
The idea is Borges's, from The Library of Babel. The first library you could actually search is Jonathan Basile's libraryofbabel.info, which holds every page of 3,200 characters and finds text with an invertible random number generator. Reading how he did it is what made me want to build this.
The two libraries are shelved differently. His shuffle is a linear congruential generator with extra mixing; mine is the Feistel network above, so the same words sit in different places in each. Mine is also a place, with galleries, stairs and lamps.
I built this to make Borges's idea something you can walk through. Nothing is stored; every page is computed on your device.
Find your page