De Bruijn torus
# De Bruijn torus

In combinatorial mathematics, a De Bruijn torus, named after Dutch mathematician Nicolaas Govert de Bruijn, is an array of symbols from an alphabet (often just 0 and 1) that contains every possible matrix of given dimensions m × n exactly once. It is a torus because the edges are considered wraparound for the purpose of finding matrices. Its name comes from the De Bruijn sequence, which can be considered a special case where n = 1 (one dimension).

One of the main open questions regarding De Bruijn tori is whether a De Bruijn torus for a particular alphabet size can be constructed for a given m and n. It is known that these always exist when n = 1, since then we simply get the De Bruijn sequences, which always exist. It is also known that "square" tori exist whenever m = n and even (for the odd case the resulting tori cannot be square).

The smallest possible binary "square" de Bruijn torus, depicted above right, denoted as $(4,4;2,2)_2$ de Bruijn torus (or simply as $B_2),$ contains all 2×2 binary matrices.

## $B_2$

Apart from "translation", "inversion" (exchanging 0s and 1s) and "rotation" (by 90 degrees), no other $(4,4;2,2)_2$ de Bruijn tori are possible – this can be shown by complete inspection of all $2^{16}$ binary matrices (or subset fulfilling constrains such as equal numbers of 0s and 1s).

The torus can be unrolled by repeating n−1 rows and columns. All n×n submatrices without wraparound, such as the one shaded yellow, then form the complete set:

    10111 10001 00010 11011 10111

## Larger example: $B_4$

An example of the next possible binary "square" de Bruijn torus, $(256,256;4,4)_2$ (abbreviated as $B_4),$ has been explicitly constructed.

The image on the right shows an example of a $(256,256;4,4)_2$ de Bruijn torus / array, where the zeros have been encoded as white and the ones as red pixels respectively.

## Binary de Bruijn tori of greater size

The paper in which an example of the $(256,256;4,4)_2$ de Bruijn torus was constructed contained over 10 pages of binary, despite its reduced font size, requiring three lines per row of array.

The subsequent possible binary de Bruijn torus, containing all binary 6×6 matrices, would have $2^{36}$ = 68,719,476,736 entries, yielding a square array of dimension 262,144×262,144, denoted a $(262144,262144;6,6)_2$ de Bruijn torus or simply $B_6.$ This could easily be stored on a computer—if printed with pixels of side 0.1 mm, such a matrix would require an area of approximately 26×26 square metres.

The object $B_8,$ containing all binary 8×8 matrices and denoted $(4294967296,4294967296;8,8)_2,$ has a total of $2^{64}$ ≈ $18.447×10^{18}$ entries: storing such a matrix would require 18.5 exabits, or 2.3 exabytes of storage. At the above scale, it would cover 429×429 square kilometres.

The following table illustrates the super-exponential growth.

| n | Cells in a submatrix = $n^2$ | Number of submatrices = $2^{n2}$ | $B_n$ side length = $2^{(n2/2)}$ |
| - | - | - | - |
| 2 | 4 | 16 | 4 |
| 4 | 16 | 65 536 | 256 |
| 6 | 36 | 68 719 476 736 | 262 144 |
| 8 | 64 | $~1.84×10^{19}$ | $~4.29×10^9$ |
| 10 | 100 | $~1.27×10^{30}$ | $~1.13×10^{15}$ |
| 12 | 144 | $~2.23×10^{43}$ | $~4.72×10^{21}$ |
| 14 | 196 | $~1.00×10^{59}$ | $~3.17×10^{29}$ |
| 16 | 256 | $~1.16×10^{77}$ | $~3.40×10^{38}$ |
| 18 | 324 | $~3.42×10^{97}$ | $~5.85×10^{48}$ |
| 20 | 400 | $~2.60×10^{120}$ | $~1.61×10^{60}$ |
