De Bruijn sequence
In combinatorial mathematics, a k-ary De Bruijn sequence B(k, n) of order n, named after the Dutch mathematician Nicolaas Govert de Bruijn, is a cyclic sequence of a given alphabet A with size k for which every possible subsequence of length n in A appears as a sequence of consecutive characters exactly once.
Each B(k, n) has length kn.
There are k! k (n − 1)/kn distinct De Bruijn sequences B(k, n).
According to De Bruijn himself,[1] the existence of De Bruijn sequences for each order together with the above properties were first proved, for the case of alphabets with two elements, by Camille Flye Sainte-Marie in 1894, whereas the generalization to larger alphabets is originally due to Tanja van Ardenne-Ehrenfest and himself.
History
The earliest known example of the De Bruijn sequence comes in Sanskrit prosody. The mnemonic yamātārājabhānasalagā was invented by Sanskrit prosodists to memorize the names of three-letter patterns as per the naming convention for three-letter sequences of long and short letters in Pingala's Chandah Shaastra (c. 200 BC). Denoting a long letter as L and short as S, this mnemonic corresponds to the sequence SLLLSLSSSL. By allowing wrapping around, the last two letters can be dropped from the mnemonic to give the circular mnemonic yamātārājabhānasa. The corresponding sequence is SLLLSLSS which is a B(2, 3) sequence for A = {S, L}.[2][3]
Though the name De Bruijn is attached to these sequences due to his proof of K. Posthumus' conjecture in 1946, in 1975 he acknowledged that priority in this proof belonged to C. Flye Sainte-Marie, who had independently published it in 1894. In fact, after becoming aware of this a literature search by De Bruijn revealed several other independent, previous publications of both the conjecture and its proof. [4]
The concept of a De Bruijn sequence is often independently re-discovered. Karl Popper does this in his The Logic of Scientific Discovery, calling the sequences "shortest random-like sequences".[5] Many websites can be found created by people who independently conceived of and calculated these sequences.[6][7][8]
Examples
- Taking A = {0, 1}, there are two distinct B(2, 3): 00010111 and 11101000, one being the reverse and a negation of the other.
- Two of the 2048 possible B(2, 5) in the same alphabet are 00000100011001010011101011011111 and 00000101001000111110111001101011.
Construction
The De Bruijn sequences can be constructed by taking a Hamiltonian path of an n-dimensional De Bruijn graph over k symbols (or equivalently, a Eulerian cycle of a (n − 1)-dimensional De Bruijn graph), or via finite fields.
Example
Goal: to construct a B(2, 4) De Bruijn sequence of length 24 = 16 using Eulerian (n − 1 = 4 − 1 = 3) 3-D De Bruijn graph cycle.
Each edge in this 3-dimensional De Bruijn graph corresponds to a sequence of four digits: the three digits that label the vertex that the edge is leaving followed by the one that labels the edge. If one traverses the edge labeled 1 from 000, one arrives at 001, thereby indicating the presence of the subsequence 0001 in the De Bruijn sequence. To traverse each edge exactly once is to use each of the 16 four-digit sequences exactly once.
For example, suppose we follow the following Eulerian path through these nodes:
- 000, 000, 001, 011, 111, 111, 110, 101, 011,
- 110, 100, 001, 010, 101, 010, 100, 000.
These are the output sequences of length k:
- 0 0 0 0
- _ 0 0 0 1
- _ _ 0 0 1 1
This corresponds to the following De Bruijn sequence:
- 0 0 0 0 1 1 1 1 0 1 1 0 0 1 0 1
The eight vertices appear in the sequence in the following way:
{0 0 0} 0 1 1 1 1 0 1 1 0 0 1 0 1 0 {0 0 0} 1 1 1 1 0 1 1 0 0 1 0 1 0 0 {0 0 1} 1 1 1 0 1 1 0 0 1 0 1 0 0 0 {0 1 1} 1 1 0 1 1 0 0 1 0 1 0 0 0 0 {1 1 1} 1 0 1 1 0 0 1 0 1 0 0 0 0 1 {1 1 1} 0 1 1 0 0 1 0 1 0 0 0 0 1 1 {1 1 0} 1 1 0 0 1 0 1 0 0 0 0 1 1 1 {1 0 1} 1 0 0 1 0 1 0 0 0 0 1 1 1 1 {0 1 1} 0 0 1 0 1 0 0 0 0 1 1 1 1 0 {1 1 0} 0 1 0 1 0 0 0 0 1 1 1 1 0 1 {1 0 0} 1 0 1 0 0 0 0 1 1 1 1 0 1 1 {0 0 1} 0 1 0 0 0 0 1 1 1 1 0 1 1 0 {0 1 0} 1 0 0 0 0 1 1 1 1 0 1 1 0 0 {1 0 1} ... 0} 0 0 0 1 1 1 1 0 1 1 0 0 1 {0 1 ... ... 0 0} 0 0 1 1 1 1 0 1 1 0 0 1 0 {1 ...
...and then we return to the starting point. Each of the eight 3-digit sequences (corresponding to the eight vertices) appears exactly twice, and each of the sixteen 4-digit sequences (corresponding to the 16 edges) appears exactly once.
Uses
The sequence can be used to shorten a brute-force attack on a PIN-like code lock that does not have an "enter" key and accepts the last n digits entered. For example, a digital door lock with a 4-digit code would have B(10, 4) solutions, with length 10000. Therefore, only at most 10000 + 3 = 10003 (as the solutions are cyclic) presses are needed to open the lock. Trying all codes separately would require 4 × 10000 = 40000 presses.
The symbols of a De Bruijn sequence written around a circular object (such as a wheel of a robot) can be used to identify its angle by examining the consecutive symbols facing a fixed point. Gray codes can be used as similar rotary positional encoding mechanisms.
A De Bruijn sequence can be used to quickly find the first or last bit in a word.[9][10]
De Bruijn torus
A De Bruijn torus is a toroidal array with the property that every k-ary m-by-n matrix occurs exactly once. (It is not necessary that the array be expressed toroidally; the array can be mapped into a 2-dimensional array. Because it is toroidal it "wraps around" on all 4 sides.)
Such a pattern can be used for two-dimensional positional encoding in a fashion analogous to that described above for rotary encoding. Position can be determined by examining the m-by-n matrix directly adjacent to the sensor, and calculating its position on the De Bruijn torus.
De Bruijn Decoding
Computing the position of a particular unique tuple or matrix in a De Bruijn sequence or torus is known as the De Bruijn Decoding Problem. Efficient decoding algorithms exists for special, recursively constructed sequences[11] and extend to the two dimensional case.[12] De Bruijn decoding is of interest, e.g., in cases where large sequences or tori are used for positional encoding.
See also
- De Bruijn Torus
- Gray code
- Linear feedback shift register
- n-sequence
- Nicolaas Govert de Bruijn
- De Bruijn graph
Notes
- ^ De Bruijn (1975)
- ^ Rachel W. Hall. Math for poets and drummers. Math Horizons 15 (2008) 10-11.
- ^ Donald Ervin Knuth (2006). The Art of Computer Programming, Fascicle 4: Generating All Trees -- History of Combinatorial Generation. Addison-Wesley. p. 50. ISBN 9780321335708.
- ^ de Bruijn, N. G. "Acknowledgement of Priority to C. Flye Sainte-Marie on the counting of circular arrangements of 2n zeros and ones that show each n-letter word exactly once", T.H.-Report 75-WSK-06, Technological University Eindhoven, 13 pages, 1975.
- ^ Karl Popper (2002). The logic of scientific discovery. Routledge. p. 294. ISBN 9780415278430.
- ^ "Minimal arrays containing all sub-array combinations of symbols".
- ^ "Binary circles".
- ^ "Keypad code finding".
- ^ Anderson, Sean Eron (1997–2009). "Bit Twiddling Hacks". Stanford University. Retrieved 2009-02-12.
{{cite web}}
: CS1 maint: date format (link) - ^ Busch, Philip (2009). "Computing Trailing Zeros HOWTO". Retrieved 2009-05-06.
- ^ Tuliani, Jonathan (2002). "De Bruijn sequences with efficient decoding algorithms". Discrete Mathematics. 226 (1): 313–336. doi:10.1016/S0012-365X(00)00117-5.
- ^ Hurlbert, Glenn; Isaak, Garth (2002). "On the de bruijn torus problem". Journal of Combinatorial Theory, Series A. 64 (1): 50–62. doi:10.1016/0097-3165(93)90087-O.
References
- van Aardenne-Ehrenfest, T. and de Bruijn, N. G. "Circuits and trees in oriented linear graphs." Simon Stevin 28, 203–217, 1951.
- de Bruijn, N. G. "A Combinatorial Problem." Koninklijke Nederlandse Akademie v. Wetenschappen 49, 758–764, 1946.
- de Bruijn, N. G. "Acknowledgement of Priority to C. Flye Sainte-Marie on the counting of circular arrangements of 2n zeros and ones that show each n-letter word exactly once", T.H.-Report 75-WSK-06, Technological University Eindhoven, 13 pages, 1975.
- Flye Sainte-Marie, C. "Solution to question nr. 48." L'intermédiaire des Mathématiciens 1, 107–110, 1894.
- Hurlbert, G. (1993). "On the De Bruijn torus problem" (PDF). J. Comb. Th. (A). 64 (1): 50–62. doi:10.1016/0097-3165(93)90087-O.
{{cite journal}}
: Unknown parameter|coauthors=
ignored (|author=
suggested) (help) - Ralston, Anthony (1982-05). "De Bruijn Sequences-A Model Example of the Interaction of Discrete Mathematics and Computer Science". Mathematics Magazine. 55 (3). Mathematical Association of America: 131–143. doi:10.2307/2690079. ISSN 0025-570X. Retrieved 2009-10-10.
{{cite journal}}
: Check date values in:|date=
(help)
External links
- Weisstein, Eric W. "de Bruijn Sequence". MathWorld.
- De Bruijn sequence
- Combinatorial Object Server, includes a de Bruijn sequence generator among many others
- CGI generator
- Applet generator
- Door code lock
- De Bruijn Sequences