# An Efficiently Generated Family of Binary de Bruijn Sequences

We study how to generate binary de Bruijn sequences efficiently from the class of simple linear feedback shift registers with characteristic polynomial f(x)=x^n+x^n-1+x+1 ∈F_2[x], for n ≥ 3, using the cycle joining method. Based on the properties of this class of LFSRs, we propose two classes of successor rules, each of which generates O(2^n-3) de Bruijn sequences. The cost to produce the next bit is O(n) time and O(n) space for a fixed n.

## Authors

• 1 publication
• 4 publications
• 13 publications
• 45 publications
• ### General Criteria for Successor Rules to Efficiently Generate Binary de Bruijn Sequences

We put forward new general criteria to design successor rules that gener...
11/15/2019 ∙ by Zuling Chang, et al. ∙ 0

• ### The 2-Adic Complexity of Two Classes of Binary Sequences with Interleaved Structure

The autocorrelation values of two classes of binary sequences are shown ...
11/24/2020 ∙ by Shiyuan Qiang, et al. ∙ 0

• ### A Graph Joining Greedy Approach to Binary de Bruijn Sequences

Using greedy algorithms to generate de Bruijn sequences is a classical a...
04/21/2020 ∙ by Zuling Chang, et al. ∙ 0

• ### Sampling Markov Models under Constraints: Complexity Results for Binary Equalities and Grammar Membership

We aim at enforcing hard constraints to impose a global structure on seq...
11/28/2017 ∙ by Stephane Rivaud, et al. ∙ 0

• ### On Greedy Algorithms for Binary de Bruijn Sequences

We propose a general greedy algorithm for binary de Bruijn sequences, ca...
02/23/2019 ∙ by Zuling Chang, et al. ∙ 0

• ### Efficient Algorithm for the Linear Complexity of Sequences and Some Related Consequences

The linear complexity of a sequence s is one of the measures of its pred...
12/25/2019 ∙ by Yeow Meng Chee, et al. ∙ 0

• ### ERSFQ 8-bit Parallel Binary Shifter for Energy-Efficient Superconducting CPU

We have designed and tested a parallel 8-bit ERSFQ binary shifter that i...
02/14/2019 ∙ by A. F. Kirichenko, et al. ∙ 0

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

A binary de Bruijn sequence of order is an -periodic sequence in which each -tuple occurs exactly once per period. There are such sequences Bruijn46 . They have been studied for a long time as they appeared in multiple disguises Ral82 ; see more details in Fredricksen’s survey Fred82 . More recently, certain families of such sequences are used in more applied areas such as bioinformatics, communication systems, coding theory, and cryptography.

One can build de Bruijn sequences of order by taking Hamiltonian paths of an -dimensional de Bruijn graph over symbols. This is equivalent to finding Eulerian cycles of an -dimensional de Bruijn graph. While a complete enumeration of all such cycles can be done, e.g., by an algorithm of Fleury, this rather naive approach is painfully slow. It has, therefore, been a major concern to strike a good balance between minimizing the computational costs and maximizing the number of sequences that can be explicitly built. On top of this consideration, depending on the specific application domains, additional requirements may be imposed. In cryptography, for instance, the preference is towards de Bruijn sequences with particular linear complexity profiles while in DNA fragment assembly certain substrings may be more or less desirable than others.

A well-known generic construction approach is called the cycle joining method (CJM) (see e.g.Fred82 ; Golomb ). Its main idea is to join all cycles produced by a given Feedback Shift Register (FSR) into a single cycle via their shared pair of conjugate states. There are a good number of CJM-based fast algorithms in the literature. Most of them produce a very limited number of sequences. Let us sample a few. As was shown in Fred72 , one can generate the granddady de Bruijn sequence in time and space per bit. A related sequence, the grandmama, was built in Dragon18 . Etzion and Lempel proposed some algorithms to generate de Bruijn sequences based on the pure cycling register (PCR) and the pure summing register (PSR) in Etzion84 . Their algorithms generate a remarkable number, exponential in , of sequences at the expense of higher memory requirement. Jansen et al. established a requirement to determine some conjugate pairs in Jansen91 , leading to another fast algorithm. In Sawada16 , Sawada et al. proposed a simple de Bruijn sequence construction, which is a special case of the method in Jansen91 . Gabric et al. generalized the last two results to form a simple successor rule framework that yield more de Bruijn sequences in Gabric18 . Further generalization to the constructions of -ary de Bruijn sequences was done in Sawada17 ; Gabric19 . Recently, Chang et al. proposed a new criteria for successor rules in chang19 . They applied this criteria to efficiently construct numerous de Bruijn sequences based on the PCR and the PSR by imposing new orders on their respective cycles.

In this paper we provide more successor rules to generate a new family of de Bruijn sequences. We use the CJM to join all cycles generated by a special LFSR, which has the characteristic polynomial , for each order . We notice that it generates all of the cycles of the PCR and of the Complemented PCR (CCR) of order . We can then take advantage of the known successor rules on these registers that have been proven to generate de Bruijn sequences efficiently. The successor rules that we are proposing here are divided into two classes. Each class can generate de Bruijn sequences efficiently. The correctness of the first class is shown by a known method used in Jansen91 ; Gabric18 ; chang19 . The validity of the second class is proved by a new and more general method.

In terms of organization, Section 2 gathers some preliminary notions and useful known results. Sections 3 and 4 provide the treatment on the two classes, respectively. The last section contains a summary and a few directions for follow-up investigations.

## 2 Preliminaries

An -stage shift register is a clock-regulated circuit with the following properties. It has consecutive storage units. Each unit holds a bit. As the clock pulses the circuit shifts the bit in each unit to the next stage. The register becomes a binary code generator if one appends a feedback loop that outputs a new bit based on the -bit initial state . The corresponding Boolean feedback function outputs on input . A feedback shift register (FSR), therefore, outputs a binary sequence that satisfies the recursive relation

 sn+ℓ=f(sℓ,sℓ+1,…,sℓ+n−1) for ℓ=0,1,2,….

For , if for all , then we say that is -periodic or with period and write . The least among all periods of is called the least period of .

We call the -th state of . The predecessor and the successor of are denoted, respectively, by and . For , let

. Extending the definition to any binary vector or sequence

, let . For an arbitrary state of , the states

 ˆv:=¯¯¯¯¯v0,v1,…,vn−1 and ˜v:=v0,…,vn−2,¯¯¯¯¯¯¯¯¯¯vn−1

are the conjugate state and companion state of , respectively. Hence, is a conjugate pair and is a companion pair.

Any FSR, on distinct initial states, generates distinct sequences that form a set of cardinality . All sequences in are periodic if and only if the feedback function is nonsingular, i.e., can be written as , for some Boolean function whose domain is  (Golomb, , p. 116). Here we deal only with nonsingular feedback functions. An FSR is linear or an LFSR if its feedback function is linear. Otherwise, it is nonlinear or an NLFSR. Further properties of LFSRs are treated in, e.g.GG05 and LN97 .

The left shift operator maps a periodic sequence

 s:=(s0,s1,…,sN−1)↦(s1,…,sN−1,s0),

with the convention that fixes . The right shift operator is defined analogously. The set

 [s]:={s,Ls,…,LN−1s}={s,Rs,…,RN−1s}

is a shift equivalent class or a cycle in . Sequences in can be partitioned into distinct cycles. If consists of exactly cycles , then its cycle structure is

 Ω(f)=C1∪C2∪…∪Cr.

When , the corresponding FSR is of maximal length and its output is a de Bruijn sequence of order . We follow Jansen et al. in calling the unique lexicographically least -stage state in each cycle the cycle representative of .

If any distinct pair of cycles and in has the property that the state has its conjugate state , then interchanging the successors of and joins and into a single cycle. The feedback function of this new cycle is

 ˆf:=f(x0,x1,…,xn−1)+n−1∏i=1(xi+¯¯¯¯vi). (1)

Similarly, if the companion states and are in two distinct cycles, then interchanging their predecessors joins the two cycles. If this process continues untill all of the cycles in can be joined into a single cycle, then we obtain a de Bruijn sequence. This construction is known as the cycle joining method (CJM).

Given an FSR with feedback function , its adjacency graph , or simply if is clear, is an undirected multigraph whose vertices correspond to the cycles in . Two distinct vertices are adjacent if they share a conjugate (or companion) pair. The number of edges between any two distinct vertices is the number of shared conjugate (or companion) pairs, with a specific pair assigned to each edge. There is a bijection between the set of spanning trees of and the set of all inequivalent de Bruijn sequences constructible by the CJM on input  AEB87 .

We now introduce two simple FSRs that will be used often. The pure cycling register (PCR) of order is an LFSR with feedback function and characteristic polynomial

 fPCR(x0,x1,…,xn−1)=x0 and fPCR(x)=xn+1. (2)

The complemented cycling register (CCR) of order is an LFSR with feedback function

 fCCR(x0,x1,…,xn−1)=x0+1. (3)

For a given order , the cycle representatives in and are called the necklace and the co-necklace, respectively. Both can be determined in time Gabric18 . Most fast algorithms to generate de Bruijn sequences are based on these two FSRs.

Inspired by the PCR and the CCR, we use the LFSR of order with characteristic polynomial

 fPCCR(x)=xn+xn−1+x+1=(xn−1+1)(x+1), (4)

which we call the pure and complementary cycling register (PCCR) of order . For , the successor of any -stage state is

A moment of observation confirms that each cycle in

is either

 (c0,…,cn−2,c0,…,cn−2) or (c0,…,cn−2,¯¯¯¯¯c0,…,¯¯¯¯¯¯¯¯¯¯cn−2),

i.e., consists exclusively of all of the cycles in both the PCR and the CCR of order . This is why we name the LFSR in Equation (4) the pure and complementary cycling register (PCCR) of order .

Let us now state several useful facts. First, let be the Euler totient function. Then the number of cycles in of order is

 ¯¯¯¯Zn=Zn−1+Z∗n−1, where
 Zn−1=1n−1∑d|(n−1)ϕ(d)2n−1d and Z∗n−1=Zn−12−12(n−1)⋅∑2d∣(n−1)ϕ(2d)2n−12d

are the number of cycles in and in of order , respectively Fred82 . A proof for and a sketch of the proof for were due to Golomb Golomb . A more thorough discussion is provided by Sloane in (Sloane02, , Section 3). Second, suppose that we divide the cycles in into two disjoint parts, namely the PCR cycles and the CCR cycles . Then, excluding the all one cycle , their respective cycle representatives must be -stage states with the respective forms

 0,c1,…,cn−2,0  and  0,c1,…,cn−3,0,1.
###### Example 1.

Let . The cycles in consists of cycles generated by the PCR of order , namely

 P1:=(05), P2:=(00001), P3:=(00011), P4=(00101), P5:=(00111), P6:=(01011), P7:=(01111), P8:=(15),

and cycles generated by the CCR of order , namely

 C1:=(0000011111), C2:=(0001011101), C3:=(0010011011), C4:=(0101010101).

The cycles are presented in increasing lexicographical order within their respective types. The cycle representatives of and are, in that order,

 000000, 000010, 000110, 001010, 001110, 010110, 011110, 111111, 000001, 000101, 001001, 010101.

Gabric et al. Gabric18 and Sawada et al. Sawada16 proposed several fast algorithms to generate de Bruijn sequences by ordering the cycles in and in lexicographically according to how each cycle’s necklace or co-necklace compares to one another, respectively. In each case, they replace the usual FSR-based generating algorithm by a well-chosen successor rule . Given an FSR with a feedback function , the general thinking behind the approach is to determine some Condition which guarantees that the resulting sequence is de Bruijn. For any state , the successor rule then assigns

 ρ(c0,c1,…,cn−1):={f(c0,…,cn−1)+1%ifc0,…,cn−1 satisfies condition A,f(c0,…,cn−1)otherwise. (5)

To be precise, the successor of is , except when satisfies Condition . In such occasions, the successor is , i.e., the last bit of the successor is the complement of the last bit of the successor when Condition does not hold for . This reassignment of the successor is to ensure that the cycles can be joined into de Bruijn sequence.

The present last three authors and P. Ke carefully studied prior known results on successor rules to come up with new general criteria for successor rules to generate de Bruijn sequences in chang19 . One can also find numerous successor rules defined based on several distinct orderings imposed on the cycles generated by the PCR and and the pure summing register (PSR) of any order with in the said reference. To keep this work self-contained, we reproduce their main theoretical result here.

###### Theorem 1.

(chang19, , Theorem 1) Suppose that there is an order satisfying transitivity on the cycles in of an FSR with a given feedback function .

1. Let be the unique cycle with the property that for any cycle , i.e., is the unique smallest cycle in . Let be a successor rule that can be well-defined in the following way. Suppose that any contains a unique state whose successor can be assigned by to be a state in a cycle with , then can be used to generate a de Bruijn sequence.

2. Let be the unique cycle with the property that for any cycle , i.e., is the unique largest cycle in . Let be a successor rule that can be well-defined in the following way. Suppose that any contains a unique state whose successor can be assigned by to be a state in a cycle with , then can be used to generate a de Bruijn sequence.

Our present work focuses on the PCCR of any order to construct suitable successor rules. In the next section, we use Theorem 1 to prove that a class of successor rules generates de Bruijn sequences by exhibiting the corresponding Condition . Theorem 1 may fail to certify that some successor rules indeed yield de Bruijn sequences. Hence, in Section 4, we exhibit a class of successor rules, for which Theorem 1 is not applicable, and propose a new method to attest that the successor rules in output de Bruijn sequences.

## 3 A Class of Successor Rules from Pure and Complementary Cycling Registers (PCCRs)

We begin this section by giving a general formula for successor rules to generate de Bruijn sequences based on the PCCR of any given order . Theorem 1 confirms the correctness of this formula. We will then use this general formula to define many explicit successor rules.

###### Theorem 2.

For any state produced by , let the successor rule be defined as

 ρ1(c):={c0+c1+cn−1+1if v satisfies Condition A,c0+c1+cn−1otherwise, (6)

where satisfies the Condition if one of the following holds:

1. is the cycle representative of a CCR cycle if .

2. is a uniquely determined state in a PCR cycle if .

Then generates a de Bruijn sequence of order .

###### Proof.

Our proof relies on Theorem 1. We begin by defining a lexicographic order on the cycles generated by the PCCR of order . Given two cycles and , we say that if and only if the cycle representative of is lexicographically less than that of . It is immediate to confirm that this lexicographic order on the cycles is total and that the all zeroes cycle, denoted by , is the lexicographically least.

Let . Except for , each cycle must contain at least one state whose last bit is . Let be the cycle that contains the state . If and is the cycle representative of a CCR cycle , then is unique. The predecessor of is also uniquely determined. If , then is in a PCR cycle and is uniquely determined. This implies that the predecessor of is also uniquely determined. We have thus confirmed that, except for , each cycle has a unique state whose successor is now governed by .

If is the cycle representative of a CCR cycle , then by the definition of the successor of is now , instead of . By (Jansen91, , Theorem 1), the state must be in a PCR cycle that satisfies .

Suppose that and is a uniquely determined state in a PCR cycle . If , then and by its successor will be in the CCR cycle . If , then the unique cycle representative of must have the form

 cj,…,cn−1,1,c2…,cj for some j, where 2≤j≤n−1.

By the actual successor of the predecessor of in is transformed into the state which is in a CCR cycle that contains the state

 cj,…,cn−1,0,¯¯¯¯¯c2,…,¯¯¯¯cj,

which is clearly lexicographically less than the cycle representative of . Hence, .

Since satisfies the requirements in Theorem 1, we conclude that generates a de Bruijn sequence of order . ∎

We note that the unique state in each CCR cycle must be the cycle representative while the unique state in each PCR cycle can be any state in this cycle, as long as there is a way to uniquely identify this state. Different ways of determining this unique state in each PCR cycle yield distinct successor rules and each such rule generates a de Bruijn sequence. We replicate the approach given in chang19 to construct many successor rules by enumerating the ways that the unique state can be defined based on the shift order of the relevant states.

Since , it suffices to uniquely determine the -stage state in a cycle produced by the PCR of order with respect to the cycle’s necklace. Notice that every state in a PCR cycle can be transformed into the necklace by repeated left (or right) shift operations. For a given state , i.e., the last bit of is , by repeated left shifts, we obtain the following consecutive distinct states

 L0u,L1u,…,Ltu

where is the cycle’s necklace. If itself is already the necklace, then . If is not the necklace and there are distinct states whose last bit is in the set , then we say that transforms into the necklace by left shifts and that is the left shift order of . If is the necklace, then its left shift order is declared to be . We will also use the set of states whose first bit is , with the corresponding left shift order defined analogously, in the next section.

All the ingredients to explicitly construct successor rules in the class are now in place and distinct ways to determine the desired state in any PCCR cycle can be explicitly written. The respective proofs of the next two propositions can be easily supplied since the state in a PCR cycle can be uniquely determined. The steps are clear and, hence, the details are omitted for brevity.

###### Proposition 3.

Let be chosen arbitrarily. Suppose that there are distinct states whose last bit is in the cycle generated by the PCR of order . In Condition of in Equation (6), when , the state in the PCCR cycle can be determined in any one of the following ways to guarantee that generates de Bruijn sequences.

1. Let . If , then has left shift order , i.e., it becomes the necklace after left shifts among the states.

2. Let and . Then the left shift order of is .

In Proposition 3, in Case 1 and in Case 2 yield an equivalent de Bruijn sequence. Also in Case 1 and in Case 2 yield an equivalent de Bruijn sequence. All other cases result in pairwise inequivalent de Bruijn sequences. Thus, if we apply the same rule to determine a state uniquely in each PCR cycle in order to reduce the complexity of the algorithm, the total number of inequivalent de Bruijn sequences produced based on Proposition 3 is .

There is another way to determine the unique state and formulate the corresponding successor rules. When performing repeated left shift operations on a state, we allow the states whose last bit is to appear repeatedly.

###### Proposition 4.

In Condition of , when , to guarantee that the resulting sequence is de Bruijn, the state in a PCR cycle can be determined as follows. Let be a nonnegative integer. The state transforms into the necklace of the PCR cycle after left shifts among the states whose last bit is . This approach contributes distinct successor rules to the class .

###### Example 2.

We continue from Example 1 to consider for . The lexicographical order on the cycles, based on the order of their representatives, is

 P1 ≺lex C1 ≺lex P2 ≺lex C2 ≺lex P3 ≺lex C3 ≺lexP4 ≺lex P5 ≺lex C4 ≺lex P6 ≺lex P7 ≺lex P8. (7)

Using the total lexicographical order in (7), one can define an already well-known successor rule that yields a de Bruijn sequence. Our interest here lies, however, in constructing successor rules in the class . The relevant information on the left shift order on the states whose last bit is generated by the PCR of order is supplied in Table 1, where reads is the next state, whose last bit is , after upon left shift operations.

Using Proposition 3, we can provide distinct successor rules. The resulting inequivalent de Bruijn sequences are listed in the first part of Table 2 with the commas between the bits removed. Applying Proposition 4, again for , yields the inequivalent de Bruijn sequences listed in the second part of Table 2. For ease of comparison, the initial state is fixed to be .

There are instances when Propositions 3 and 4 share equivalent de Bruijn sequences in their output. We mark them by the elements in , where refers to Entry in the output of Proposition 3 and Entry in the output of Proposition 4.

There might be multiple other ways to determine a unique state whose last bit is in each of the PCR cycles, leading to distinct successor rules. The interested readers are invited to invent and share their own favourites.

## 4 Another Class of Successor Rules from Pure and Complementary Cycling Registers

This section discusses another class of successor rules based on the PCCR of any given order . As we will see, the conditions of Theorem 1 are not met in this case. This compels us to find another way of identifying a spanning tree.

###### Theorem 5.

Let . For any state produced by , let the successor rule be defined as

 ρ2(c):={c0+c1+cn−1+1if v satisfies Condition A,c0+c1+cn−1otherwise, (8)

where satisfies the Condition if one of the following holds:

1. is a uniquely determined state whose first bit is in a PCR cycle if .

2. The state is the cycle representative of a CCR cycle if .

Then generates a de Bruijn sequence of order .

###### Proof.

Our proof is constructive, i.e., we show how to build a directed spanning tree according to the successor rule whose vertices are all the cycles generated by the PCCR of order .

Except for the all ones cycle , each cycle contains a uniquely determined state satisfying Condition and the conjugate state is in another cycle . By the definition of , the successors of this conjugate pair are exchanged. Then we say that there is an edge between and . Obviously only one of the states and satisfies Condition , so the total number of edges is equal to . Now we define the directions of such edges. For two adjacent vertices and , if the uniquely determined state satisfying Condition is in , then the direction of the corresponding edge between them is from to .

More specifically, let such that is the cycle representative of a given CCR cycle . Then must be in some PCR cycle , forcing . Hence there is an edge from CCR cycle to the PCR cycle .

Suppose that the uniquely determined state in whose first bit is is

 cj,…,cn−2,1,…,cj for some j with 2≤j≤n−2 and cj=0,

then its conjugate state is in a CCR cycle . Therefore there is another edge from the PCR cycle to the CCR cycle .

Because , the state

 0,¯¯¯¯¯c1,¯¯¯¯¯c2,…,¯¯¯¯cj,cj+1,…,cn−2,1

is also in the CCR cycle . Evidently, it is lexicographically less than the cycle representative of the CCR cycle . Hence .

The CCR cycle is the lexicographically least among all of the CCR cycles. Since the cycle representative of the CCR cycle is , the uniquely determined state is , whose conjugate state is in the cycle . This establishes an edge from the CCR cycle to a PCR cycle .

Therefore, if we start from an arbitrary cycle and follow the edges as described above, then there must be a unique path from to and then to . The resulting graph is a directed spanning tree whose root is . ∎

We now make some comments on Theorem 5. First, we can not prove Theorem 5 as a consequence of Theorem 1. Indeed, Figure 1 Above depicts a typical rooted tree based on the successor rule in the proof of Theorem 5. In this figure, . For every , let be the number of PCR cycles, labelled with , with an edge directed to . Let . Notice that, in general, it is hard to determine the lexicographic order of adjacent and . The all zeroes cycle and all ones cycle , for example, are both adjacent to , but . In this situation, Theorem 1 is not applicable.

Now in the proof of Theorem 5, we redefine the direction of some edges and, except for the cycle , there is an edge from each PCR cycle to some CCR cycle. Furthermore, there is an edge from to . If there is an edge from a CCR cycle to a PCR cycle and there is an edge from to a CCR cycle , then the proof has shown that . This fact guarantees that all CCR cycles in satisfy the decreasing lexicographic ordering. So based on the successor rule we can get a spanning tree with root . The process certifies that successfully generates de Bruijn sequences. Figure 1 Below shows a specific spanning tree when , for the indicated choice of state in each of the cycles.

The new method we use to prove Theorem 5 can be viewed as a further generalization of Theorem 1. Finding a spanning tree is the core of such method. Different ways of finding spanning trees may result in different de Bruijn sequences.

According to Theorem 5, different ways of determining the unique state whose first bit is in any PCR cycle lead to different successor rules, generating inequivalent de Bruijn sequences. We use the definition of the left shift order of a state already given above. The following results are straightforward to verify.

###### Proposition 6.

Let be chosen arbitrarily. Suppose that there are distinct states whose first bit is in a cycle generated by the PCR of order . In Condition of in Equation (8), when , the state in a PCR cycle can be determined in either one of the following ways to ensure that generates de Bruijn sequences.

1. Let . If , then the left shift order of is , i.e., the state transforms into the necklace in left shifts among the relevant states.

2. Let and . Then the left shift order of is .

###### Proposition 7.

In Condition of , when , the state in a PCR cycle can be determined as follows to guarantee that generates de Bruijn sequences. Let be a nonnegative integer. The state becomes the necklace in left shifts among the states whose first bit is .

###### Example 3.

Let us consider the construction of successor rule of order . Table 3 provides the left shift order on the states whose first bit is in the cycles generated by the PCR of order .

Using Proposition 6, we obtain distinct successor rules, resulting in the inequivalent de Bruijn sequences. Proposition 7 gives us the inequivalent de Bruijn sequences. All inequivalent output sequences can be found in Table 4.