A Combinatorial Game and an Efficiently Computable Shift Rule for the Prefer Max De Bruijn Sequence

05/07/2018
by   Yotam Svoray, et al.
Ben-Gurion University of the Negev
0

We present a two-player combinatorial game over a k-ary shift-register and analyze it. The game is defined such that, for each of the player, the only way to avoid losing is to play such that the next state of the game is the next window in the well known prefer-max De Bruijn sequence. We then proceed to solve the game, i.e., to propose efficient algorithms that compute the moves for each player. Finally, we show how these algorithms can be combined into an efficiently computable shift-rule for the prefer-max sequence.

READ FULL TEXT VIEW PDF
POST COMMENT

Comments

There are no comments yet.

Authors

page 1

page 2

page 3

page 4

01/30/2018

An Efficient Generalized Shift-Rule for the Prefer-Max De Bruijn Sequence

One of the fundamental ways to construct De Bruijn sequences is by using...
12/12/2017

Computational Properties of Slime Trail

We investigate the combinatorial game Slime Trail.This game is played on...
04/20/2021

A Polyhedral Approach to Some Max-min Problems

We consider a max-min variation of the classical problem of maximizing a...
01/27/2021

Impartial games with entailing moves

Combinatorial Game Theory has also been called `additive game theory', w...
04/26/2017

A Reverse Hex Solver

We present Solrex,an automated solver for the game of Reverse Hex.Revers...
03/22/2020

The Computational Complexity of Evil Hangman

The game of Hangman is a classical asymmetric two player game in which o...
09/06/2018

Player Experience Extraction from Gameplay Video

The ability to extract the sequence of game events for a given player's ...
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

Combinatorial game theory is not only an interesting theory on its own, it links to many other fields of mathematics. For example, Conway and Sloane showed in 

conway1986lexicographic that the “losing positions” of some combinatorial games give linear error detecting and correcting codes. Using this view of these codes as combinatorial games, Fraenkel and Rahat showed in fraenkel2002complexity that the codes can be computed in polynomial time and memory.

In this paper we demonstrate a similar application of combinatorial game theory to coding: we show that the optimal play (when both players apply their only non-losing strategies) of a certain combinatorial game constitutes the well known prefer-max De Bruijn sequence (defined below). Then, parallel to the work of Fraenkel and Rahat in fraenkel2002complexity , we also show how non-losing strategies can be computed in linear time and memory, yielding an efficiently computable shift-rule (mapping a state of a shift register to its follower) for the sequence.

We use lower-case Greek letters to denote symbols in the alphabet and lower-case Latin letters to denote words in , except for and which represent natural numbers and indexes.

2 The pref-max De Bruijn sequence and the corresponding Hamiltonian cycle in the De Bruijn graph

A De Bruijn sequence of order on the alphabet is a cyclic sequence of length such that every possible string of length (member of ) appears exactly once as a substring bruijn1946combinatorial .

The directed De Bruijn graph of order over the alphabet (also described in  bruijn1946combinatorial ) is the graph whose vertexes are the strings of length over the alphabet (i.e. the set ) and whose edges are such that each vertex is connected with a directed edge to all the vertexes in .

There is a one-to-one correspondence between De Bruijn sequences and Hamiltonian cycles in the De Bruijn graph of the same order and alphabet, described in bruijn1946combinatorial and it is as follows:

  1. If, for each , , and is an Hamiltonian cycle then is a De Bruijn sequence.

  2. A Hamiltonian cycle can be constructed from a De Bruijn sequence by visiting the vertex , then and so on, until we return to where we started.

In this paper we focus on a specific Hamiltonian cycle in the De Bruijn graph called the prefer-max cycle (and the corresponding De Bruijn sequence) defined as follows. For simplicity, we only list the vertexes on the cycle, as the edges are induced.

The -prefer-max cycle, , is such that and if then where is the maximal letter such that .

For example, if we set and , we have: .

Martin Mar34 proved that the cycle given in Definition 2 is Hamiltonian, i.e., that for steps there is always a such that , so is well defined, as demonstrated with Example 2.

The Hamiltonian cycle , given in Definition 2, corresponds to the well known prefer-max De Bruijn sequence (defined, e.g., in Gol81 ). One challenge raised in the literature (see, e.g., SAWADA2017524 ) for such sequences is finding an efficiently computable function that maps each vertex on the cycle to its follower, called a shift-rule. We will arrive to such a rule at the end of the paper.

3 Two properties of the prefer-max cycle

We first state and prove two properties of the prefer-max cycle. These properties will be used later to prove properties of the game that we are going to propose and for its analysis in the following sections.

For the following propositions, let be the order induced by the sequence given in Definition 2, i.e., if where is as given in Definition 2. This is a linear order over because the sequence represents a Hamiltonian cycle of the De Bruijn graph.

Proposition 1.

For any such that , if then .

Proof.

By induction on the length of . If is empty, the statement is true from the definition of the prefer-max cycle (Definition 2). For the induction step, assume that the statement is true for all of some constant length . We need to show that for any and any of length . Since and because the predecessor on the cycle of each of these vertices is a node in we have that at least vertices in this set precede . The term ‘predecessor’ is well defined here because . It assures us that is not the first vertex on the cycle. By the induction hypothesis, we have that , for any . Therefore, there are at least vertices in before . Since the follower of each of these vertices is in and because , we get that must be before . ∎

Consider again the sequence given in Example 2. If we take, for example, and , we see . If we take, as another example and , we see that . More generally we see that for any and whose combine length is two. Note that the proposition does not say where does fit, it may come before , after , or between the two.

Proposition 2.

Considering from Definition 2. For each , exactly one of the following is true for some and :

  • and ;

  • and ;

  • and .

Proof.

Let be a word of length over . From Proposition 1, the subsequence appears on the cycle in a decreasing order. By Definition 2, the subsequence also appears in a decreasing order. Since the predecessor of each node in the second list is either or a node from the first list, we get that if then the follower of must be and that if then the follower of must be . See an illustration of the proof in Figure 1. ∎

Initially, the two lists go together times for some .

When enters, the second list advances and the first does not.

After that, the second list is one step ahead of the first list for the remaining times.
Figure 1: An illustration of the proof of Proposition 2

.

Consider the sequence given in Example 2 again. If we take, for example, , we see that the predecessor of is , the predecessor of is , and the predecessor of is . We see that, in this case, the leftmost digit of the predecessor is either zero or an increase by one of the rightmost digit of its successor. In this case, the node comes before the beginning of the first list considered in the proof, corresponding to having in Figure 1.

4 A combinatorial game

Our next step is a proposal of a combinatorial game that will, after some analysis, be used to derive an efficient computation of the predecessor in the prefer-max sequence. In light of Proposition 2 we ask ourselves: Given , when do we need to increase, keep as is, or take a zero instead of when computing the predecessor of . We propose an indirect answer: A combinatorial game whose rules correspond to these options. One player, called Bob, can force an increase step while the other player, called Alice, can force a zero step when Bob does not want to increase. Alice’s goal is to continue as far as possible without repeating a state and Bob’s goal is to get to a repeated state as fast as he can. As we will prove later, the game is constructed such that best option for both player is to step along the sequence, i.e., that the optimal strategies for both players are equivalent to computing the predecessors of from Definition 2.

The following definition states the rules and the objectives of the game:

The -shift-game is a two-player combinatorial game played by Alice and Bob as follows: A play of the game consists of a sequence such that and if then:

where , are functions, called strategies for Bob and for Alice, respectively, such that for all . The game ends at state if and . Alice wins if and . Bob wins if . If and its a tie.

Note that this definition introduces the notion of strategies for the players. I,e,. that a function is a strategy for Bob if for all and it is a strategy for Alice if for all . For future use, we note the following observation: If is a strategy for Alice or for Bob and for all , then is also a strategy for the same player.

A play of the -shift-game can be such that . In this example, Bob plays on moves , i.e., , Alice plays on , i.e., , and neither play on . In this example, Alice won because the play reached in moves, which is less than moves.

This is a deterministic game with perfect information but it is not impartial (i.e., it is a partisan game), as there are differences, beyond who goes first, between Alice’s and Bob’s goals and moves. See Figure 2 for an illustration of how a round of the game is executed.

1

0

0

1
Figure 2: A flowchart depicting a round of the game. Bob has a priority: if then is (an increase and shift), no matter how Alice plays. The value is only considered when . In this case it determines whether is (a reset and shift) or is (just a shift), corresponding to and to , respectively.

The -shift-game proposed in Definition 4 is a generalization of a game proposed in weiss2007combinatorial for solving a problem in control-theory. There, the game was only for the binary case () in which case the prefer-max sequence is also called ‘prefer-one’. In terms of Definition 4, the binary game was

It is easy to verify that it is equivalent to the -shift-game. Indeed, the game proposed in weiss2007combinatorial and the strategies proposed there to solve it can generate a known shift-rule for the prefer-one sequence as shown in sawada2016surprisingly and in fredricksen1972generation .

Before we move to solving the

-shift-game, we state and prove a complexity property for it. There has been several criteria in the literature for classifying complexities of De Bruijn sequences, e.g., 

(chan1982complexities, ). One such criterion, for binary sequences, is the number of ones in the truth table of the feedback function that generates the sequence. For De Bruijn sequences generated by combinatorial games, this can be translated, e.g., to counting the number of moves that Bob plays, i.e., the number of ones in the truth table of Bob’s strategy. A result that goes along these lines is given in the next proposition:

Proposition 3.

For every play, , of the -shift game, let be the number of times Bob plays and be the number of times Alice plays. Then, .

Proof.

Let . From Definition 4, we get that and that if then

Since , then , and because for all , then . So and the required result follows from this inequality. ∎

If we look back at Example 4, we can count and see that and and verify that .

Next, we turn to establishing a connection between the prefer-max and the shift-game. We will first define a pair of strategies and such that if both Alice and Bob use the respective strategy, the play of the game follows the prefer-max sequence (in reverse). Then, we will show that and are the unique strategies for each of the players, respectively, that guarantee not losing the game. This will give us that the efficient implementations of non-losing strategies for both of the players, that we will provide in Section 5, can serve as an efficient shift-rule for the sequence.

The strategies and use the prefer-max sequence as an internal ‘oracle’, as specified in the following definition:

Considering from Definition 2, let be the strategies for Alice and Bob, respectively, defined by

and

From Definition 2, we can see that is a strategy, i.e., for all , and the next proposition will show that is also a strategy, i.e., for all . The next proposition also shows that the computation of can be reduced to a computation of over a slightly alternated input. We will use this fact to simplify the analysis and to allow a succinct implementation of the strategies.

Proposition 4.

For every , and, for every , .

Proof.

If then cannot be because this word is not in , thus must be zero. From Proposition 1 and Proposition 2, we can see that if we define by , then for every , and , if then , if then , and if then . Therefore, and . This means that if and only if . ∎

For example, for and , if both players play according to the strategies above, then the resulting play is which yields a tie. We can see that in the example above, the play is exactly the prefer-max cycle in reverse. The following proposition establishes that this is true for all and :

Proposition 5.

Let be the play of the -shift-game when Alice uses the strategy and Bob uses the strategy. Then, where is the prefer-max sequence given in Definition 2.

Proof.

From Proposition 2 we know that if then either , or . We also have that contains all of the elements in , because of its relation to the prefer-max De Bruijn sequence. Thus, by Definition 4, every step in the play of the game must follow a (reversed) step in and the proof follows by induction. ∎

From Proposition 5 we have that if Alice plays according to and if Bob plays according to the game ends with a tie. In the next two propositions, we show that each of them wins against any other strategy. Then, in the two propositions that follow, we show that these strategies are the unique strategies with these properties.

Proposition 6.

If Bob applies the strategy he wins against any strategy that Alice may apply which is not and achieves a tie against .

Proof.

First, From Proposition 5 we know that if the players play by the strategies and respectively we get a tie. Now, Assume towards contradiction that there exists a strategy for Alice which wins against . Then, there must be a state where such that , and because otherwise the play is equal to the play with and which is, as said, a tie. Let be the first such state. By Proposition 2 and the Definition 4 of , we have that if then , and if then . If then and . If then and . In both cases and which is in contradiction with the assumption that is a winning strategy. ∎

Proposition 7.

If Alice applies the strategy she wins against any strategy that Bob may apply which is not and achieves a tie against .

Proof.

Assume towards contradiction that there exists a strategy for Bob which wins against and let be the play of the game with these two strategies. Consider the function such that for all in the order specified in Definition 2. By the definition of and of (Definition 4), if we have that . Otherwise, If and we have that thus and , so, by Proposition 2, we have that which gives us that . If and we have to check two cases:

  1. If then , and so, by Proposition 2, we have that which gives us that .

  2. If then and so, by Proposition 2, we have that which gives us that .

Thus, by this enumeration of all the three cases, we see that is a strictly decreasing along the play . Since the minimum of is attained at , we get that in contradiction to the assumption that Bob wins. ∎

The following two propositions establish the uniqueness of both and . Since it is easy to generate the prefer-max sequence from an implementation of these strategies, these results establish a polynomial reduction from computing an efficient shift-rule for the prefer-max sequence to efficient computation of non-losing strategies for both players, a problem that we will solve in the next section.

Proposition 8.

is the only non-losing strategy for Bob.

Proof.

Assume towards contradiction that there exists a non-losing strategy for Bob such that . Let be the play of the game where Bob applies and Alice applies . Let be as in Proposition 7. For , assuming that , we have two options:

  1. If and we have, by the definition of , that . By the definition of then . By the definition of the game, we have that . By Proposition 2, , i.e., .

  2. If and we have two cases:

    1. If , by the definition of , and . By the definition of the game, . By Proposition 2, , i.e., .

    2. If , by the definition of , . By the definition of the game, . By Proposition 2, , i.e., .

We get that is strictly decreasing along the play . In particular, which means that . Since is assumed to be a non-losing strategy for Bob, therefore, by the definition of the ending condition of the game, we must have .

Since , there must be a such that . Therefore, the length of the game, , must be smaller than . By the definition of the game, Bob loses, in contradiction to the assumption that is a non-losing strategy for Bob. ∎

Proposition 9.

is the only non-losing strategy for Alice.

Proof.

Assume towards contradiction that there exists a non-losing strategy for Alice such that . Let be the play of game when Alice and Bob use the strategies and , respectively. Let be the first index in this play such that . Let and be such that . Note that , as either or but not both.

By Proposition 5, since until Alice and Bob applied the strategies and , respectively, we have that , i.e., the game follows the reversed prefer-max sequence until .

We first show that must be zero. Otherwise, assume towards contradiction that . By the definition of , . By Proposition 1, since , then , i.e., . Consider, now, the strategy such that for all and . By Observation 4 is a strategy. Let be such that if and if (exactly one of them must be true because ). By Observation 4 is a strategy. When Bob applies and Alice applies , we have that the play follows the reversed prefer-max sequence until it gets to and then, by the definition of the game, since , it goes to which is a state that was visited before, i.e., Bob wins. This contradicts the assumption that is a non-losing strategy or the fact (Proposition 7) that is a non-losing strategy. Thus .

If then, by the definition of , which, by Proposition 2, means that or . But, since , we have that so, by the definition of the game, since , we have which is a state that we already visited, i.e., Bob wins. This is in contradiction to the assumption that is a non-losing strategy for Alice.

If then, by the definition of and of , which, by Proposition 2, means that or . But, since , we have that so, by the definition of the game, since , we have which is a state that we already visited, i.e., Bob wins. This is in contradiction to the assumption that is a non-losing strategy for Alice. ∎

5 An efficient computation of the non-losing strategies for both players

In this section we propose algorithms for efficient computation of the strategies for both players in the -shift-game. As said before, this can also be translated to an efficiently computable shift rule for the prefer max sequence. The main ingredient in this is the function given in the following definition together with two helper functions, and , that we will later use in the algorithms and in their analysis:

For a state and , let:

be the value of read from position .

be the (maximal) value of .

be the head of .

be the tail of .

The function given in Definition 5 transforms a state to a number by reading its symbols as a number in base from the th place to the left in a cyclic order. The function gives the index of the place from which reading the value is maximal. The function gives this maximal value, i.e., . The function gives the index of the least significant non-zero digit of as reads it.

For example, , , and , so and thus and .

As the function plays a key role in the algorithm for computing the strategies that we propose in the sequel and, consequently, also in the shift-rule for the prefer-max sequence, we state its computational complexity as follows:

Proposition 10.

The function can be computed in time and memory.

Proof.

We can compute each iteration of the based on the in time and memory using the equation where . Computing is and checking which value is the maximal is also since we only need to check if it is greater then the previous maximum, where the first maximum is . Also, from Definition 5, we can can compute from in memory and time. ∎

We turn now to the analysis of the behavior of the function over plays of the shift-game. The following three claims establish bounds on the difference where and are consecutive states in a play of the game. If then, by definition, is either , , or . Since in the third case , we only need to analyze the first two cases.

Claim 11.

.

Proof.

If and then:

Claim 12.

If and , then .

Proof.

Let . Since , we can write and for some and some . Let . From Definition 5, Since the symbol at the head cannot be zero, we have that . Assume towards contradiction that . Then which contradicts that is the head. Thus . ∎

Claim 13.

If and , then .

Proof.

If , , , and then:

The above three propositions give us the tools needed for describing a non-losing strategy for Alice and Bob, as follows. The ‘trick’ for Alice is to force Bob to have at least once every steps of the game if he does not want to lose in these steps. Then, by Claim 11 and Claim 13, we get that increases more than it may decrease between any two states in which we increase the value, which means that Alice guarantees that the play reaches the state with the maximal value of , which is , from which Alice can easily win in moves.

Let be the strategy for Alice defined by

and let be the strategy for Bob defined by

From Definition 5, we can see that and are strategies, i.e., , since .

Our next goal is to prove that is a non-losing strategy for Alice. To this end, we define a variant of the game and establish three claims, as follows.

The infinite shift-game goes exactly as the game in Definition 4 the only difference being that a play does not end when , just when . In this game, Bob wins when the play goes forever, Alice wins if and there is no option for a tie.

Claim 14.

In any play of the infinite shift-game where Alice applies the strategy and Bob applies a strategy