On the additive period length of the Sprague-Grundy function of certain Nim-like games
Jens Askgaard
Denmark
jaskgaard˙[email protected]
Abstract.
We examine the structure of the additive period of the Sprague-Grundy function of Nim-like games, among them Wythoff’s Game, and deduce a bound for the length of the period and preperiod.
1. Introduction
Consider a sequence (Yx)x=0∞ of finite subsets of Z. They define a function G:N0→N0 by
[TABLE]
where mex(Y)=min(N0∖Y) is the minimal excluded operator, defined for any finite subset Y of N0 or Z. Such functions appear as Sprague-Grundy functions in the study of certain impartial combinatorial games, such as Nim [1]. We will impose the condition of additive periodicity on (Yx)x=0∞, as defined below.
Definition 1.1** (Additive periodicity).**
Let (Yx)x=0∞ be a sequence of finite subsets of Z. Then (Yx)x=0∞ is additively periodic, if there exists P′∈N0 and p∈N1 such that for all x≥P′, we have Yx+p=Yx+p. The uniquely determined smallest numbers P′,p for which this condition holds are called the preperiod length and the period length of (Yx)x=0∞.
A function G:N0→N0 is additively periodic, if there exists P~∈N0 and p∈N1 such that for all x≥P~, we have G(x+p)=G(x)+p. Again, the smallest numbers P~,p for which this condition holds are called the preperiod length and the period length of G.
Originally shown in [2], additive periodicity of (Yx)x=0∞ implies that G will be additively periodic as well. The motivation for this paper was to find the optimal bound for the period length of G, given only the period length of (Yx)x=0∞, and the upper and lower bounds of the elements in the sequence (Yx−x)x=0∞.
To cover some practical cases from game theory where a finite number of the values of the Sprague-Grundy function are not defined by (Yx), we will introduce a seed in the definition of G, inspired by a similar definition in [6].
Definition 1.2** (Nim sequence).**
Let (Yx)x=0∞ be a sequence of additively periodic finite subsets of Z. Let L∈N0, and let [g0,…,gL−1] be an L-tuple, where for all x,x′∈{0,…,L−1}, we have gx∈N0, and gx=gx′ implies x=x′. Let G:N0→N0 be defined by
[TABLE]
Then we call G for a Nim sequence over (Yx)x=0∞, and [g0,…,gL−1] is its seed.
Note that it is inconsequential what the sets (Yx)x=0L−1 are. So in any given example, we may redefine L as max(L,P′) and pretend that the sequence (Yx) is additively periodic for all indices. Thus, we will silently assume that P′=0 in this paper.
We study Nim sequences using their difference functions, the definition of which is given in [5].
Definition 1.3** (Difference function).**
Given a function G:N0→N0, we define its difference function d:N0→Z by d(x)=G(x)−x. If G is additively periodic, we define its difference period starting at x≥P~ as the p-tuple [d(x),…,d(x+p−1)].
Given Yx⊆Z, we use the notation d(Yx)=Yx−x.
It is clear that G is additively periodic, if and only if its difference function is periodic, so d(x+p)=d(x) for all x≥P~. Similarly, if (Yx) is additively periodic, then d(Yx+p)=d(Yx), so maxx∈N0d(Yx),minx∈N0d(Yx) will be well-defined.
Example 1.4**.**
Let M∈N1 and M∈−N1. For all x∈N0, define
[TABLE]
so p=1 and maxd(Yx)=M−1, mind(Yx)=M+1. Let the seed be empty.
Then p=M+∣M∣ with P~=0, as the difference period becomes:
[TABLE]
Inspired by this example, we formally define M and M as constants determined by (Yx)x=0∞.
Definition 1.5** (Difference bounds).**
Let (Yx)x=0∞ be a sequence of additively periodic finite subsets of Z. Then, we define the constants M=maxx∈N0d(Yx)+1, M=minx∈N0d(Yx)−1, and M=∣M∣+M.
The reason why we offset these maximal and minimal values with 1 is that they will become the bounds for the difference function d of G, as we will prove in this section.
Now we can formulate the main result of this paper:
Theorem 1.6**.**
Let G be a Nim sequence over (Yx)x=0∞ that has period length p. Then G is additively periodic, and the length p of its period is bounded by:
[TABLE]
where KM,M∈N1 is a constant, approximately defined by
[TABLE]
Here, Li(x)=∫2xlogt1dt is the logarithmic integral, and the symbol ∼ signifies that KM,M has the same divergence speed as the expression.
The first part of this theorem, that G is additively periodic, was proven by Pink in his diploma thesis. His proof was simplified by Dress and Flammenkamp in [2], which was followed by an even simpler proof by Landman in [3]. These proofs all rely on pigeon-hole methods, which lead to larger bounds for p.
The canonical example of additive periodicity in game theory is Wythoff’s Game, which we will briefly discuss.
Example 1.7** (Wythoff’s Game).**
For all y∈N0, define a Nim sequence Gy by
[TABLE]
Then Gy(x) is the Sprague-Grundy value of the position (x,y) in Wythoff’s Game, as defined in [1] and [3].
We give a matrix showing the first values of Gy(x).
[TABLE]
Wythoff showed that the positions, where Gy(x)=0, are defined by
[TABLE]
where φ is the golden ratio. That is, the zeroes approximately lie on the two diagonals emanating from the corner whose slopes equal φ (see [7]). However, the remaining values were considered to be chaotic (see [1]), until the proof by Pink was published. Indeed, let P~y,py be the preperiod length and the additive period length of Gy. Set
[TABLE]
With p=y′<y∏py′, assuming x≥y′<ymaxP~y′+y we find Yx+p=Yx+p. We can now use expression (1.1) plus Theorem 1.6 to create an induction proof which shows that each Gy is additively periodic, as in [2] or [3].
The following table shows the preperiod length and the period length for the first few rows.
[TABLE]
The lemmas in this introduction and their methods of proof are directly derived from Landman. As he uses a more narrow framework which only uses d implicitly, we give the proofs in full; the reader familiar with any of the papers cited here are free to read only the lemmas in this section and skip their proofs.
Lemma 1.8**.**
Let G be a Nim sequence over (Yx)x=0∞. Then G is a bijective function, meaning that G is a permutation of N0.
Proof.
Injectivity of G follows from the definition of the mex operator and the requirement of the seed that gx=gx′ for x=x′.
Surjectivity of G: With x,y∈N0, there might be four causes why G(x)=y:
G(x)<y; this can at most occur y times.
y∈Yx; this can at most occur ∑j=0p−1#Yj times.
With x<L, so G(x) lies in the seed; this can at most occur L times.
G(x′)=y for some x′<x. As (i), (ii) and (iii) occurs only finitely many times, (iv) must happen.
∎
Thus, we can imagine G as a greedy permutation that always chooses the smallest number not contained in Yx, as in [5].
Lemma 1.9**.**
Let G be a Nim sequence over (Yx)x=0∞. Then there exists some C∈N0 such that
[TABLE]
Proof.
Set M^=max(0,M) First, assume d(x)≤M^ for all indices x<L in the seed. Assume there exists x∈N0 with d(x)>M^. As M^∈/d(Yx) and x+M^∈N0, there must exist x0<x such that G(x0)=x+M^ due to the greedy definition of G. Set a=min{a′∈N0∣G−1(x+M^−a′)>x}>0. For all a′<a, set xa′=G−1(x+M^−a′)<x.
We must have x+M^−a∈Yx0∪…∪Yxa−1, and xa−1≤x−a. Then
[TABLE]
which is a contradiction.
If d(x)>M^ for some x<L, we first sort the seed so g0<g1<⋯<gL−1; as the mex-operator depends on sets, this does not change the other values of G.
If G(L)>gL−1, we must have G(L)=gL−1+1 due to the bounds on (Yx). If g(L)<gL−1, we have d(L)<d(L−1)−1. In both cases, we add G(L) to the seed, offset L with 1 and sort the seed again. Then, either d(L−1) will remain the same, or d(L−1) will decrease with 1. We continue this process of adding more elements to the seed, until d(L−1)=M^, which must happen because G is surjective. Now set C=L, and continue as in the first part of the proof.
∎
Lemma 1.10**.**
Let G be a Nim sequence over (Yx)x=0∞. Then there exists some C∈N0 with C≤maxx<Lgx+1 such that
[TABLE]
Proof.
Set M^=min(0,M). Assume that x∈N0 is the first index where d(x)<M^. As in the proof of Lemma 1.9, we can assume that the seed is sorted by size, so x≥L. We have assumed G(x−1)≥x−1+M^, so G(x−1)>G(x). If x>L, then G(x)∈Yx−1, and
[TABLE]
which is a contradiction.
If x=L, we add G(L) to the seed, offset L with 1 and sort the seed again. Then, d(L−1) will decrease with 1. We continue this process until G(L−1)<G(L), when we set C=L and continue as in the first part of this proof.
This process could at most be repeated maxx<Lgx−L times, where L is the original size of the seed. So the maximal size of the increased seed is L+maxx<Lgx−L=C−1.
∎
Corollary 1.11**.**
Let G be a Nim sequence over (Yx)x=0∞. If G is additively periodic with preperiod length P~, we have for all x≥P~
[TABLE]
Proof.
Follows, as the difference values in the period repeat themselves.
∎
As we want d to be bounded by a negative M and a positive M, we need to deal with the degenerate case when it is not.
Theorem 1.12**.**
Let G be a Nim sequence over (Yx)x=0∞. If M≥0 or M≤0, then G is additively periodic with period length p=1.
Proof.
Assume M≤0. By Lemma 1.9 we find C∈N0, so for all x≥C we have G(x)≤x. As in the proofs of Lemma 1.9+1.10, we keep extending the seed by adding G(x) and sorting it, until we reach an index L with G(L)=L. Then the seed will be equal to {0,…,L−1}, and G(x)=x for all x≥L, so the difference period becomes [0].
The proof for M≥0 is similar.
∎
Remark 1.13**.**
Knowing the bounds for the difference function, we can establish that G is additively periodic. To generalize Landman’s argument, by Lemma 1.9+1.10 and the surjectivity of G, we have for x∈N0 sufficiently large
[TABLE]
Then, we calculate G(x) as
[TABLE]
Now there are 2M possibilities for what elements the set {G(x′)−x∣x−M≤x′<x}∩{M,…,M−1} can contain. Using the pigeon-hole principle, we find r,r′∈N0, r<r′ such that
[TABLE]
As d(Yx+rp)=d(Yx+r′p), we use (1.13) to show that G(x+rp)=G(x+r′p). Then, we continue inductively to show that for all y≥x+rp, we have G(y)=G(y+(r′−r)p).
Landman’s proof implies that KM,M≤2M. In the next section, we will deduce another proof of the additive periodicity which, while still using pigeon-hole methods, yields a smaller bound.
2. Periodicity conditions
Throughout this section, (Yx)x=0∞ stands for a sequence of additively periodic finite subsets of Z with period length p that defines the difference bounds M∈−N1,M∈N1. Also, G is a Nim sequence over (Yx) with a seed of length L. We mention that while p always stands for the smallest number that satisfies Yx+p=Yx+p, if we find an integer p′∈N1 such that G(x+p′)=G(x)+p′ for all x≥P~′ for some P~′∈N0, then p′,P~′ may not be the true period / preperiod length. However, the true period length p of G will divide p′.
We begin with a simple lemma that contains an important definition.
Lemma 2.1** (Exclusion Lemma).**
Let (x,y) be an inversion of G; that is, x<y with G(x)>G(y). Then for all a∈Z with x+ap≥L, we have
[TABLE]
We say that (the difference value) G(y)−x is excluded at the index x (mod p).
Proof.
As G is a greedy permutation, we must have G(y)∈Yx. Then d(x+ap)∈/d(Yx+ap)=d(Yx)∋G(y)−x.
∎
We mention two simple facts. First, the excluded value is bounded by M<G(y)−x<M. Second, the excluded value can be calculated without knowing the exact values of y and G(x).
Lemma 2.2**.**
Let R∈N1. Then G is additively periodic with period length p that divides Rp, if and only if there exists x∈N0 that fulfills these two conditions:
{G(x+k)modRp∣0<k<Rp}={0,…,Rp−1},
{G(x′)∣x′<x}=⋃k=0Rp−1Uk∩N0**
where Uk={G(x+k)−aRp∣a∈N1}.
Proof.
Assume a) and b) are true. For k,k′∈{0,…,Rp−1}, as G(x+k)≡G(x+k′)(modRp) when k=k′, the sets (Uk)k=0Rp−1 are mutually disjoint. Then:
[TABLE]
For x+1, a) holds because:
[TABLE]
Then {G(x+1+k)−aRp∣a∈N1}=Uk+1 for k<Rp−1, and
{G(x+1+Rp−1)−aRp∣a∈N1}={G(x)}∪U0, so b) holds as well. We can now continue inductively to show that for all x′≥x, we have G(x′+Rp)=G(x′)+Rp, so x must be (larger than) the preperiod length.
Assume now that G is additively periodic. Set x=P~. If a) does not hold, there must exist k,k′∈{0,…,Rp−1} with k=k′ and G(x+k)≡G(x+k′)(modRp); assuming G(x+k)<G(x+k′), we have G(x+k)=G(x+k′)+CRp=G(x+k′+CRp) for some C∈N1. As ∣k−k′∣<Rp, this is a contradiction.
If b) does not hold, there must exist x′<x,C∈N0 such that G(x′)=G(x+k+CRp)=G(x+k)+CRp, which is also a contradiction.
∎
We now define for any x∈N0 the two sets of indices where the permutation G ascends above x, and where it descends below x.
Definition 2.3** (Cut).**
Let x∈N0. We define the cut after x as the pair of sets (Sx,Tx), where
[TABLE]
With each cut, we associate the sets Sx∗=G(Tx) and Tx∗=G(Sx).
For x,y∈N0, we call the sets Sx,Sy equivalent, written Sx∼Sy, if and only if d(Sx)=d(Sy).
It is clear that ∼ is an equivalence relation, and we will use it to compare any two sets with an index in N0 or Z.
Remark 2.4**.**
Since G is bijective, we always have
[TABLE]
Lemma 2.5**.**
Let R∈N1. Then G is additively periodic with period length p that divides Rp, if and only if there exists x≥L such that Sx∗∼Sx+Rp∗, and Tx∗∼Tx+Rp∗.
Proof.
Assume the two sets are equivalent for some x≥L, then we will show the conditions from Lemma 2.2 hold for x+1. We also set R=1; for R>1, simply replace p with Rp in the following argument. Assume there exist x0′,x0′′∈{x+1,…,x+p}, x0′=x0′′ with G(x0′)≡G(x0′′)(modp), G(x0′)<G(x0′′).
If G(x0′)>x+p, that means x0′∈Sx+p, by assumption there exists x1′∈Sx with G(x1′)=G(x0′)−p. If x1′∈Sx+p, we find x2′∈Sx with G(x2′)=G(x0′)−2p. We continue inductively, until we find a∈N0, xa′∈Sx with G(x0′)−ap=G(xa′)∈{x+1,…,x+p}.
Correspondingly, if x0′∈Tx, we find x1′∈Tx+p with G(x1′)=G(x′)+p, and we continue inductively, until we find a∈N0, xa′∈Tx+p with G(x0′)+ap=G(xa′)∈{x+1,…,x+p}.
We use the same process with x0′′ to find b∈Z such that G(x0′′)+bp=G(xb′′)∈{x+1,…,x+p}, so G(xa′)≡G(xb′′)(modp). If x0′∈Tx, x0′′∈Sx+p, then G(xa′)=G(xb′′) as both G-values are bounded between x+1 and x+p, . As xa′=xb′′, this contradicts the injectivity of G . If instead x0′,x0′′∈Sx+p, we find xb′′∈Sx with G(x0′)=G(x0′′)−bp=G(xb′′), again contradicting the injectivity of G. If x0′,x0′′∈Tx, we find xa′∈Tx+p with G(x0′′)=G(x0′)+ap=G(xa′), again with a contradiction. Thus, condition a) is proven.
Now, let x0′∈{x+1,…,x+p}, a∈Z, x0′′∈N0 such that G(x0′′)=G(x0′)−ap. If a<0, we must have x′<x′′ for condition b) to hold. If we assume x′>x′′, we have x0′∈Tx or x0′′∈Sx+p (possibly both), and as above, we can find a contradiction by showing G is not injective. If a>0, we must have x0′>x0′′ for b) to hold. If we assume x0′<x0′′, we have x0′∈Sx+p or x0′′∈Tx+p, and the contradiction follows in the same manner.
Now assume G is additively periodic. Then, for x≥P~+M, it is trivial to show the other implication.
∎
Lemma 2.6**.**
Let R∈N1 and x≥L. Then:
If Sx∼Sx+Rp, then Tx∗∼Tx+Rp∗.
If Sx∗∼Sx+Rp∗, then Tx∼Tx+Rp.
Proof.
Set R=1; for R>1, replace p with Rp in the following argument.
To prove a), let N=#Sx, and let {x1,…,xN}=Sx be in ascending order. First assume G(x1)+p<G(x1+p), so G(x1)+p>x+p. If G(x1)+p∈Tx+p∗, its inverse must belong to Sx∖{x1}. So G−1(G(x1)+p)∈{x2+p,…,xN+p}∪{x+p+1,…}, which means we have an inversion (x1+p,G−1(G(x1)+p)) that excludes G(x1)+p−(x1+p)=d(x1) at the index x1+p. Subtract p from the index to see that d(x1) is excluded at its own index, which is a contradiction. If G(x1)+p>G(x1+p), we find an inversion (x1,G−1(G(x1+p)−p)) in the same manner that would exclude d(x1+p) at the index x1, also a contradiction.
As we now have G(x1)+p=G(x1+p), let us look at x2. If G(x2)+p<G(x2+p), we would have G−1(G(x2)+p)∈{x3+p,…,xN+p}∪{x+p+1,…}, and we would find an impossible exclusion. The same thing happens if G(x2)+p>G(x2+p). So G(x2)+p=G(x2+p), and we continue inductively for each n∈{3,…,N} to show G(xn)+p=G(xn+p), which implies Tx∗∼Tx+Rp∗.
To prove b), let {y1,…,yN}=Sx∗ be in ascending order and continue using similar ideas. For instance, if G−1(y1)+p<G−1(y1+p), then (G−1(y1)+p,G−1(y1+p)) is an inversion that would exclude d(G−1(y1)) at the index G−1(y1)+p.
∎
Note that the reverse implications of a) and b) are not true in general.
The proof technique of the previous lemma will be re-used in the first part of the following proof.
Lemma 2.7**.**
Let R∈N1. Then G is additively periodic with period length p that divides Rp, if and only if there exists x≥L such that Tx∼Tx+Rp, and Tx∗∼Tx+Rp∗.
Proof.
(You may replace p with Rp in the following argument). Assume the sets are equivalent. If Tx=∅, let x^=maxTx, else let x^=x. We show that for all xn∈{x1,…,xN}={x+1,…,x^−1}∖Tx, we have G(xn)+p=G(xn), where x1,…,xN are in ascending order, and N∈N0 is the length of the sequence.
First assume G(x1)+p<G(x1+p). As x1∈/Tx, we have G(x1)>x, so G(x1)∈/Tx∗. Per assumption we have G(x1)+p∈/Tx+p∗, so G−1(G(x1)+p)∈{x2+p,…,xN+p}∪{x^+p,x^+p+1,…}. Then (x1+p,G−1(G(x1)+p)) is an inversion that excludes d(x1) at the index x1+p, which is a contradiction. If we assume G(x1)+p>G(x1+p), the inversion (x1,G−1(G(x1+p)−p)) impossibly excludes d(x1+p) at the index x1.
We continue inductively for each n∈{2,…,N}, and find G(xn)+p=G(xn+p). We now realize that Tx^∗∼Tx^+p∗, and Sx^∗∼Sx^+p∗ is shown by
[TABLE]
So the conditions of Lemma 2.5 are fulfilled for x^.
If we assume G is additively periodic, it is trivial to show the other implication for x sufficiently large.
∎
Corollary 2.8**.**
Let R∈N1. Then G is additively periodic with period length p that divides Rp, if and only if there exists x≥L such that Sx∼Sx+Rp, and one of the following statements holds:
Tx∼Tx+Rp; or
Sx∗∼Sx+Rp∗.
Proof.
Combine Lemma 2.6 with Lemma 2.7 for a), and with Lemma 2.5 for b).
∎
We can now prove the additive periodicity of G with an improved bound for the period length. The same result was given by Dress and Flammenkamp in [2], which used a somewhat different proof technique.
Theorem 2.9**.**
Any Nim sequence G is additively periodic, and the length p of its period is bounded by:
[TABLE]
Proof.
Let x∈N0 be sufficiently large so the bounds from Lemma 1.9 and 1.10 hold. Then look at the sets (d(Sx+rp),d(Tx+rp))r=0∞. By the pigeon-hole principle, there exists r,r′∈N0, r<r′ such that d(Sx+rp)=d(Sx+r′p) and d(Tx+rp)=d(Tx+r′p), when G becomes additively periodic with period length less or equal to (r′−r)p by Corollary 2.8.
The maximal value of r′−r can be calculated by counting all possibilites for (d(Sx),d(Tx)). We have #Sx≤M and #Tx≤∣M∣. By taking a sum over i=#Sx=#Tx, we get
[TABLE]
using the Chu-Vandermonde identity.
∎
Note that we could replace all references to (Sx,Tx) in this proof with any one of the pairs (Sx∗,Tx),(Sx,Tx∗),(Sx∗,Tx∗) and still reach the same result.
3. Cut sets
To move beyond the pigeon-hole proofs, we need to create a framework where cuts exist without reference to the permutation G or the sets (Yx), so x∈Z becomes a dummy variable.
Definition 3.1** (Cut set).**
Let x∈Z and Sx,Tx⊆Z, and let d:Sx∪Tx→Z. Then we define Cx=(Sx,Tx,d) as a cut set, if and only if these four requirements hold:
For all y∈Sx, we have y<x+21 and y+d(y)>x+21.
For all y∈Tx, we have y>x+21 and y+d(y)<x+21.
#Sx=#Tx<∞.
For all y,y′∈Sx∪Tx, we have y+d(y)=y′+d(y′), if and only if y=y′.
With each cut set, we associate the sets
[TABLE]
We say that two cut sets Cx and C~x~=(S~x~,T~x~,d~) are equivalent, written Cx∼C~x~, if and only if Tx∼T~x~, Tx∗∼T~x~∗, and d(y)=d~(y−x+x~) for all y∈Sx∪Tx.
It is clear that ∼ is an equivalence relation, and each element in an equivalence class [C0] corresponds to an x∈Z.
We now need to replace the sets (Yx). For this, we will use exclusions.
Definition 3.2** (Exclusions and possible zeros).**
Let Cx=(Sx,Tx,d) be a cut set. Let x′∈Sx. For all x′′∈Sx with x′<x′′ and x′+d(x′)>x′′+d(x′′), the difference value x′′+d(x′′)−x′ is excluded at the index x′, and for all y∈{x+1,…,x′+d(x′)−1}∖Tx∗, the value y−x′ is excluded at the index x′. These are the positive exclusions.
Let y′′∈Tx. For all y′∈{x+1,…,y′′−1} with either y′∈/Tx, or y′∈Tx with y′+d(y′)>y′′+d(y′′), the difference value y′′+d(y′′)−y′ is excluded at the index y′. These are the negative exclusions.
We say there is a possible zero (in difference value) after the cut, if and only if x+1∈/Tx∪Tx∗. We say there is a possible zero before the cut, if and only if x∈/Sx∪Sx∗.
We cannot find exlusions of the value [math] by looking at one cut set only. For this, we need to have two cut sets in succession.
Definition 3.3** (Direct successor).**
Let Cx,C~x~ be two cut sets. We call C~x~ for a direct successor of Cx, if and only if there exists a cut set Cx+1=(Sx+1,Tx+1,d~), which fulfills Cx+1∼C~x~ and the following conditions:
Initially, we set Sx+1=Sx∖{x′∈Sx∣x′+d(x′)=x+1}, and Tx+1=Tx∖{x+1}. Then we adjoin one or zero indices to Sx+1 and/or Tx+1, based on these criteria:
With x+1∈Tx∩Tx∗, we cannot adjoin any indices.
With x+1∈Tx∗∖Tx, we adjoin x+1 to Sx+1, and d~(x+1)>0 can be set to any value where x+1+d~(x+1)∈/Tx∗.
With x+1∈Tx∖Tx∗, we adjoin x′∈{y∈Z∣y>x+1}∖Tx to Tx+1, and set d~(x′)=x′−(x+1).
With x+1∈/Tx∪Tx∗, meaning that Cx has a possible zero after the cut, we have two options:
We adjoin x+1 to Sx+1 and a new index x′ to Tx+1 such that d~(x+1) fulfills the conditions from (iii), and x′ fulfills the condtions from (iv). Then, we say that the value [math] is excluded at the index x+1.
We add nothing, meaning that Cx+1 has a possible zero before the cut. Then, we say that (Cx,Cx+1) has a matching zero.
Note that these conditions will guarantee that #Sx+1=#Tx+1.
To handle exclusions, we need to define a collection of several cut sets.
Definition 3.4** (Cut set with several rows).**
Let x∈Z and R∈N1. Then we define Cx=(Cx,r)r=0R−1 as a cut set with R rows, if for all r,r′∈{0,…,R−1}, where Cx,r=(Sx,r,Tx,r,dr) is a cut set, we have:
Tx,r∼Tx,r′ and Tx,r∗∼Tx,r′∗, if and only if r=r′.
If the difference value k∈Z is excluded at the index x′ in Cx,r, then x′∈Sx,r′∪Tx,r′ implies that dr′(x′)=k.
We say that two cut sets Cx and C~x~=(C~x~,r)r=0R−1 with the same number of rows are equivalent, written Cx∼C~x~, if and only if Cx,r∼C~x~,r for all r∈{0,…R−1}.
Definition 3.5** (Direct successor).**
Let Cx,C~x~ be two cut sets with R rows. We call C~x~ for a direct successor of Cx, if and only if there exists a cut set Cx+1=(Cx+1,r)r=0R−1 with Cx+1,r=(Sx+1,r,Tx+1,r,d~r), which fulfills Cx+1∼C~x~ and the following conditions for all r,r′∈{0,…,R−1}:
Cx+1,r is a direct successor of Cx,r.
If (Cx,r,Cx+1,r) excludes the difference value [math] at the index x+1,
then (Cx,r′,Cx+1,r′) cannot have a matching zero.
Definition 3.6** (Path).**
Let R∈N1, M∈−N1 and M∈N1. Then Γ(R,M,M)=(V(R,M,M),E(R,M,M)) is the digraph, where the vertices V(R,M,M) are all cut sets Cx=(Sx+1,r,Tx+1,r,d~r)r=0R−1 with R rows which fulfill ⋃r=0R−1dr(Sx,r∪Tx,r)⊆{M,…,M}, and the edges are defined by the direct successors from Definition 3.5.
With J∈N0, we call C0,C1,…,CJ for a path in Γ(R,M,M), if and only if (Cj,Cj+1)∈E(R,M,M) for all j∈{0,…,J−1}. We also use the terms ancestor and successor, defined in the standard way for a digraph.
We will usually abbreviate the notation as Γ=(V,E).
We think of a cut set as an R×M matrix of difference values. The entries with undefined difference functions are left blank. A path with J elements can be considered as an R×(M+J−1) matrix that defines R common difference functions d0,…,dR−1, one for each row.
Example 3.7**.**
Here is an example with a cut set and a possible successor in Γ(3,−2,3).
[TABLE]
(The horizontal lines mark the cut between positive and negative difference values.)
Example 3.8**.**
Let R∈N1, and let us look at the digraph Γ(R,−2,2). It follows from Theorem 2.9 that if R>(24)=6, then the digraph is empty. If R=6, we can construct an infinite path in Γ with a cycle of four cut sets C0,…,C3,C4∼C0. Here is an example:
[TABLE]
(The first horizontal line marks the end of S0,r, and the second line marks the beginning of T4,r.)
It can be shown that these four cut sets form a connected component, and that all connected components in Γ(6,−2,2) consist of exactly four cut sets, which may be created by applying the same permutation of the six rows to our four cut sets. Note that the path has two separate row cycles, one 4-cycle which cycles the top four rows, and one 2-cycle which cycles the lower two rows. This implies that a Nim sequence with M=−2, M=2 and a difference period of length 6p cannot exist, as we will show.
Definition 3.9** (Cycled cut set).**
Let Cx,C~x~ be two cut sets with R rows. We call C~x~ for the cycled cut set of Cx, if and only if for all r∈{0,…,R−1}
[TABLE]
where π is the row permutation that cycles all rows of Cx upwards, defined by π(r)=(r−1)modR.
We now establish the connection between this abstract setup and the Nim sequence G. We need the additive period length of G to be a multiple of p, which explains the clumsy definition of R in the following lemma.
Lemma 3.10**.**
Let G be a Nim sequence over (Yx) that has additive period length p. Let G have difference function d, preperiod length P~ and additive period length p, and let (Sx,Tx) be the cut after x∈N0 defined by G.
Set R=plcm(p,p). Then there exists a path of cut sets C0,…,Cp with R rows, where Cj=(Sj,r,Tj,r,dr)r=0R−1, which fulfills:
Cp* is the cycled cut set of C0;*
For all x≥P~, where j∈{0,…,p−1}, r∈{0,…,R−1}, C∈N0 is uniquely defined by x=j+rp+CRp, we have:
[TABLE]
With k∈Z, where j+k∈Sj,r∪Tj,r, we have dr(j+k)=d(x+k).
Proof.
Set x′=(⌈pP~⌉+C′)p for some sufficiently large C′∈N0. Write the difference period of G, as it begins at the index x′, in a R×p matrix. Extend the matrix to the left with the elements of d(Sx′+rp) and to the right with the elements of d(Tx′+p−1+rp) in each row with index r, as in Example 3.8, so the path C0,…,Cp−1 will be represented by the matrix. Conditions a) and b) now follow directly.
∎
Lemma 3.11**.**
Let C0,…,Cp be a path of cut sets with R rows, where Cp is the cycled cut set of C0, and none of C1,…,Cp−1 is the cycled cut set of C0.
Then there exist an additive periodic sequence (Yx)x=0∞ of finite subsets of Z with period length p, and a Nim sequence G over (Yx) with additive period length p that divides Rp, and preperiod length P~. For all x≥P~, where i,j∈{0,…,p−1}, r,r′∈{0,…,R−1}, C,C′∈N0 is uniquely defined by x=j+rp+CRp, x−1=i+r′p+C′Rp, we have G(x) defined by
[TABLE]
Proof.
First, G is uniquely defined: If j∈Ti,r′, either i) or iii) from Definition 3.3 is true, and in both cases j∈/Sj,r.
Second, G is injective. If j∈/Sj,r∪Ti,r′, then j∈Ti,r′∗ leads to a contradiction with iii) or ivA) in Definition 3.3, which gives j∈Ti,r′ or j∈Sj,r. Similarly, j∈Sj,r∗ leads to a contradiction with i) or ii). If j∈Sj,r∪Ti,r′, injectivity is guaranteed by d) in Definition 3.1 and rules i)-ivB) in Definition 3.3.
Set P~=∣minr,jdr(j)∣. For x≥P~, we define the difference function d(x)=G(x)−x, and the cuts (Sx,Tx) as in Definition 2.3. Then Sx∼Sj,r, Tx∼Tj,r, so #Sx=#Tx for x≥2P~, when we define the seed [g0,…,gP~−1] as
[TABLE]
where SP~−1∗ and S2P~−1∗ are disjoint, as P~ is the maximum of dr(j).
Now the additive period begins directly after the seed, as
[TABLE]
The seed is then equal to N0∖{G(x)∣x≥P~}. When we set G(x)=gx for x<P~, then G will be injective.
Finally, G is surjective. If we assume x∈N0∖G(N0) with G(x)>x, we have #Sj,r=#Si,r′+1 and #Tj,r=#Ti,r′, which contradicts c) in Definition 3.1. We reach a similar contradiction with G(x)<x and G(x)=x.
Now we define Yx for x≥P~ as
[TABLE]
and show that G(x)=mex({G(x′)∣x′<x}∪Yx). Assume that (x,y) is an inversion of G. If G(y)−x>0, then G(y)−x is positively excluded in Cj,r, so G(y)=(G(y)−x)+x∈Yx. We find negative and zero exclusions in the same way.
It follows from b) in Definition 3.4 and b) in Definition 3.5 that d(x) cannot be excluded at the index x, so G(x)=x+d(x)∈/Yx.
∎
The most interesting conclusion from these two lemmas is that given a Nim sequence G over (Yx), we can construct a seed of length no larger than ∣M∣ as in the previous proof. This seed will define, together with (Yx), another Nim sequence G′ that will have the same difference period as G. Of course, we could also have proven this fact directly.
4. Optimization
In this section, we will use C0 as a standard representation of the equivalence class [C0].
While our new framework has removed the sets (Yx), we are now forced to deal with exclusions. However, all excluded values are strictly bounded between M and M, so if all difference values in a cut set are either M or M, they could never be excluded. This motivates our next definition.
Definition 4.1** (Optimized cut set).**
Let C^0=(S^0,r,T^0,r,d^r)r=0R−1∈V(R,M,M). We call C^0 for a optimized cut set, if and only if ⋃r=0R−1d^r(S^r∪T^r)⊆{M,M}. If C0=(S0,r,T0,r,dr)r=0R−1∈V, we call C^0 for the optimized cut set of C0, if and only if T0,r∼T^0,r and T0,r∗∼T^0,r∗ for all r∈{0,…,R−1}.
Let C^1=(S^1,r,T^1,r,d^r)r=0R−1∈V be an optimized cut set with (C^0,C^1)∈E. We call C^1 for the optimized successor of C^0, if and only if (C^0,C^1) has no matching zeros.
In general, we call a row of a cut set C0,r for optimized, if it is optimized if considered as a cut set with one row. A difference value dr(x) is called optimized, if dr(x)∈{M,M}.
It is easy to show that the optimized cut set of C0 and the optimized successor of C^0 are both uniquely defined.
Lemma 4.2** (Optimization Lemma).**
Let C0=(S0,r,T0,r,dr)r=0R−1∈V(R,M,M). Then its optimized cut set C^0 is a successor of C0.
Proof.
We create a path C0,…,CM−1,CM∼C^0, where the difference values not defined by C0 are set inductively for x=1,…,M by
[TABLE]
We show that CM∼C^0. If x∈T0,r∗, then dr(x+∣M∣)=M, so M+x=∣M∣+M+x∈TM,r∗. If instead x∈/T0,r∗, either dr(x+∣M∣)=M=M, which implies x+∣M∣+M=M+x∈/TM,r∗. Or dr(x−M)=M, which can only happen when M<x, which implies M+x∈/TM,r∗.
If x∈T0,r, then x≤∣M∣ and dr(x)=M. Then dr(M+x)=M, so M+x+M≤M, implying M+x∈TM,r. If instead x∈/T0,r, either dr(x)=M, so dr(M+x)=M, or dr(x)=M with ∣M∣<x. In both cases, we have M+x∈/TM,r.
CM will be optimized, as no difference value in C0 can be a part of CM.
∎
The process of creating the path C0,…,C^0 is called the optimization of C0. We can optimize an already optimized cut set this way, which implies that if there exists a connected component in Γ containing only one element, it must be a non-optimized cut set.
Example 4.3**.**
Here is the optimization of the cut set from Example 3.7.
[TABLE]
Lemma 4.4**.**
Suppose (C0,C1)∈E(R,M,M), and let C^0=(S^0,r,T^0,r,d~r)r=0R−1 be the optimized cut set of C0. Then C^0 has a direct successor C~1=(S~1,r,T~1,r,d~r)r=0R−1 with T1,r∼T~1,r and T1,r∗∼T~1,r∗ for all r∈{0,…,R−1} , defined by
[TABLE]
and the possible adjoined difference values will be d~r(1)=dr(1), and d~r(k+1)=−k.
Proof.
As T^0,r∼T0,r, T^0,r∗∼T0,r∗, and the two possible non-optimized difference values in C~1 are the ones adjoined to C1 when it is defined as a successor of C0, it is clear that T1,r∼T~1,r and T1,r∗∼T~1,r∗.
The adjoined values stem from C1 and cannot exclude themselves. An adjoined positive value must occur at index 1 and cannot be positively excluded by the values of S^0, and an adjoined negative value at index k+1 has k+1+dr(k+1)=1 and cannot be negatively excluded by the values of T^0. Thus, C~1 is a valid cutset.
∎
Lemma 4.5**.**
Suppose C0∈V(R,M,M) lies in a connected component with more than one element. Then, its optimized cut set C^0 is an ancestor of C0.
Proof.
We find a path C0,…,Cj−1,Cj∼C0 for some j>∣M∣. Then, we create a path C^0,C~1,…,C~j−1,C~j∼Cj by adjoining difference values from C1,…,Cj to C^0 as in Lemma 4.4.
∎
It follows from Lemma 4.2 and 4.5 that each connected component in Γ containing more that one element is fully characterized by its optimized cut sets, and the cut sets that connect them. The following lemma shows that these optimized cut sets can be connected with paths using near-optimized cut sets. The enumerations of the exceptions in the lemma should be compared with the enumerations in Definition 3.3.
Lemma 4.6**.**
Let (C0,C1)∈V(R,M,M) with difference function d. Then there exists a path D0,…,DNM+1 in Γ for some N∈N0 with difference function d~, where D0∼C^0 and DNM+1∼C^1. For all j∈{0,…,NM}, it holds for (Dj,Dj+1) that the pair has no matching zero, and for all r∈{0,…,R−1}, x∈Sj∪Tj∪Sj+1∪Tj+1, we have d~r(x)∈{M,M} — except that exactly one of the following exceptions apply:
There are no exceptions, so Dj+1 is the optimized successor of Dj;
There exists x∈Sj∪Sj+1 and a difference value k∈{1,…,M−1} such that for all r∈{0,…,R−1}, we have d~r(x)∈{M,k,M};
There exists x∈Tj∪Tj+1 and a difference value −k with k∈{1,…,∣M+1∣} such that for all r∈{0,…,R−1}, we have d~r(x)∈{M,−k,M};
There are matching zeros in (Dj,Dj+1).
Proof.
Set N+=#({dr(1)∣r=0,…,r−1,dr(1)>0}∖{M}), and let these positive difference values dr(1) smaller than M be k1>k2>…>kN+.
Set N−=#({dr(k+1)∣r=0,…,r−1,k∈N1,k+dr(k+1)=0}∖{M}), and let these negative difference values larger that M be −k1′>−k2′>…>−kN−′. Let N0∈{0,1} be the indicator for whether (C0,C1) has matching zeros, and set N=N0+N++N−.
Initially, we define a path D0,…,DM+1, where D0∼C^0, and the T– and T∗– sets of D1 are equivalent to those of C1 as in Lemma 4.4. Then we define D1,…,DM+1 as the optimization of D1. Now we extend this path between its endpoints, so it becomes
[TABLE]
All difference values in this extended path will be optimized, except for those values and matching zeros corresponding to the non-optimized values of d. In D1, we adjoin the matching zeroes. Between DN0M+1 and D(N0+N+)M, we adjoin the positive non-optimized d-values. In the final part of the path, we adjoin the negative non-optimized d-values. The process is as follows:
(ivB) If N0=1, so there exist one or more matching zeros, we create D1,r by adding nothing to the row, if there is a matching zero in (C0,r,C1,r); if (C0,r~,C1,r~) has no matching zeroes, we define D1,r~ as the optimized successor of D0,r~.
To check that this process is valid, we look at a path C0′,…,C3M+1′ of cut sets with one row with difference function d′. First we set C0′∼D0,r, and C0′,…,CM′ is the optimization of C0′, so again CM′∼D0,r. We assume there is a matching zero in row r and adjoin it in CM+1′, and the rest of the path is repeated optimization, so C2M+1′∼C3M+1′∼DN0M+1,r. Due to the matching zeros, we find that some difference values in this row must have a certain value:
[TABLE]
(Indices with blank d′-values cannot be determined.) For instance, as d′(M+1)=0, we must have d′(∣M∣+1)=M and thus d′(∣M∣+1)=M, as the path is optimized before the index M+1; and as d′(M+1)=M, so M+1+d′(M+1)=M+1, we must have d′(1)=M, so 1+d′(1)=M+1.
When we compare the optimized difference values in C1′,…,CM′ with C2M+1′,…,C3M′, we see that for x∈{1,…,M},
[TABLE]
We now examine the possible exclusions in the beginning and the end of the path. In C1′ it might happen that kn∈{1,…,M−1} is excluded at the index 1, and with kn′∈{1,…,∣M+1∣}, we might exclude −kn′ at the index k+1. This is why we need to change the rows with the matching zeros first in the path D0,…,DNM+1. After the optimization of CM+1′, nothing can be excluded at the index 2M+1. There might appear new exclusions at M+∣M∣+1, but as no new non-optimized difference values are adjoined at the index aM+∣M∣+1 for a∈N0 in DN0+1,…,DNM+1, these exclusions do not matter.
(ii) For n∈{1,…,N+}, we create D(N0+n−1)M+1,r by adjoining kn to the row r at the index (N0+n−1)M+1, if the corresponding row in C1 fulfills dr(1)=kn; otherwise, we define D(N0+n−1)M+1,r~ as the optimized successor of D(N0+n−1)M,r~. We reuse the notation C0′,…,C3M+1′, where we now have C0′∼D(N0+n−1)M,r, and C0′,…,CM′ is the optimization. We adjoin the difference value kn in CM+1′, and the rest of the path will be optimized. Now, the certain difference values become:
[TABLE]
For x∈{1,…,M},
[TABLE]
It might happen that kn′ is excluded at the index 1, if kn′>kn. If kn′<kn, then kn′ cannot be exluded at the index 1 or M+1, as then C1,r could not be a successor of C0,r. The possible new exclusions at M+∣M∣+kn+1 cannot affect the adjoined values in D0,…,DNM+1.
(iii) For n′∈{1,…,N−}, we create D(N0+N++n′−1)M+1,r by adjoining −kn′ to the row r at the index (N0+N++n′−1)M+kn′+1, if the corresponding row in C1 has the difference value dr(1+kn′)=−kn′; otherwise, the row becomes the optimized successor as above. We redefine the path C0′,…,C3M+1′ similarly, so the certain difference values become:
[TABLE]
For x∈{1,…,M},
[TABLE]
It might happen that −kn′′ is excluded at the index 1+kn′, if kn′′>kn′. The possible new exclusions at M+∣M∣+1 cannot affect the adjoined values in D0,…,DNM+1.
(ivA) We should mention the case when two difference values k and −k′ are adjoined to C1,r. If either of these difference values are optimized, we proceed as above. If both are non-optimized, so k=kn and k′=kn′′, we adjoin kn to D(N0+n−1)M+1,r, and −kn′′ to D(N0+N++n′−1)M+1,r; all other values of d~r are optimized. The fixed difference values will then be as in case (ii) and (iii) combined.
For all j∈{0,…,(N+1)M} and r,r′∈{0,…,R−1} with r=r′, we must have Dj,r∼Dj,r′. If we assume that Dj is an invalid cut set with Dj,r∼Dj,r′, Lemma 2.7 shows that for all j′>j, Dj′ would be invalid for the same reason, but DNM+1 is a valid cut set.
∎
In passing, we have shown that the order of the matching zeros and the non-optimized difference values in the path cannot be altered.
Example 4.7**.**
We create a near-optimized path in Γ(3,−2,3) between the cut sets from Example 3.7.
[TABLE]
Remark 4.8**.**
We notice as a general pattern in the C′–paths that before a non-optimized difference value is adjoined, it is excluded at the same index (modM). In case (ii), if a positive difference value kn is adjoined to the near-optimized path at index (N0+n−1)M+1, it will be excluded at the indices aM+1 with a<N0+n−1. Similarly, before −kn′′ is adjoined , it will be excluded at the indices aM+1+kn′′ for a<N0+N++n′−1. A matching zero is excluded at index 1 before it is adjoined.
It follows that if C^0,…,C^M is a path of optimized cut sets, and kn is adjoined to CM+1,r, then in all rows r′ where kn is excluded at the index 1, the value must be adjoined to CM+1,r′. The same is true for matching zeros. For negative difference values, if −kn′′ is adjoined to CM+1,r at the index M+1+kn′′, the value must be adjoined in all other rows where −kn′′ was excluded at the index 1+kn′′.
5. Binary representations
In this section we only need to deal with optimized difference values, so we simplify the notation by writing + for M, and − for M.
Definition 5.1** (Binary representation).**
Let C0∈V(R,M,M). The binary representation of C0 is an R×M matrix B0=[b0,r,m]r=0,…,R−1,m=0,…,M−1 with entries in {+,−} defined by
[TABLE]
where C^0=(S^0,r,T^0,r,d^r)r=0R−1 is the optimized cut set of C0.
Let cm be the symbol for the m’th column of B0, so
[TABLE]
Let τ be the column permutation that cycles all columns of B0, defined by τ(m)=(m−1)modM.
The permutation τ represents the rotation of the columns from B0 to B1, where B1 is the binary represantion of a direct successor C1 of C0. For instance, if C^1 is the optimized successor of C^0, then B0,r,m=B1,r,τ(m) for all r,m.
Note that B0 cannot have two identical rows, as it would violate condition a) in Definition 3.4.
Definition 5.2** (Reversible).**
Let (C^0,C1)∈E(R,M,M) fulfill the conditions from Lemma 4.6. We call (C^0,C1) for reversible, if and only if C^0 and C1 lie in the same connected component. If this holds, we say that there is a reversible shift in their binary representations from B0 to B1.
Example 5.3**.**
Continuing Example 3.7, here are the binary representations of the cut set and its successor.
[TABLE]
When we ignore the τ–rotation of the columns, we see that (c0,c4) and (c2,c3) in the ancestor have been swapped. As we will prove below, all these shifts are reversible.
Lemma 5.4**.**
Let (C^0,C1)∈E(R,M,M) fulfill the conditions from Lemma 4.6. Then the following two statements are equivalent:
(C^0,C1)* is reversible.*
Either B0/τ=B1/τ, or we can create B1/τ by swapping two columns in B0/τ.
Proof.
(i) If C1 is the optimized successor of C^0, then B0/τ=B1/τ. To create a path from C1 to C^0, we optimize C1.
(ii), (iii), (ivB) In the proof of Lemma 4.6, we showed that in each of these cases, exactly two of the optimized difference values at the indices modulo M will change. So for each row r where a non-optimized difference value is adjoined, a + is swapped with a −:
[TABLE]
(We have normalized the column indices, so +k will be adjoined at the index [math].)
It follows that if b0,r,m1=+, b0,r,m2=− with m1,m2∈{0,…,M−1}, we can always find a successor Cj to C^0 where these two entries become swapped in Bj/τ. Begin to optimize C^0, then adjoin to the path the following non-optimized difference value in column cm1:
[TABLE]
We can do the same with C^1, so when we swap b0,r,m1 and b0,r,m2, we can create a path that will swap these entries back. The question is what happens in the other rows.
Let r′,r′′∈{0,…,R−1}. By Remark 4.8, if b0,r′,m1=+ and b0,r′,m2=−, these entries will be swapped as well. Suppose that (b0,r′′,m1,b0,r′′,m2)=(−,+) for all r′′. Then we are swapping the entire columns cm1 and cm2, and when we swap the entries back in the r’th row, all other entries will be swapped. So (C^0,C1) is reversible.
However, if (b0,r′′,m1,b0,r′′,m2)=(+,−) for some r′′, the swap will result in (cm1,cm2) being changed, as they have different numbers of pluses and minuses after the swap. So when the entries of the r’th row are swapped back to their original state, b0,r′′,m2 and b0,r′′,m1 will also be swapped, so (cm1,cm2) will remain changed after the two shifts. It does not matter which path we follow and how many other columns we shift in the binary representation, as the entries b0,r,m1 and b0,r′′,m1 now shift together. Thus, (C^0,C1) becomes irreversible.
∎
It follows that if Cx and Cy lie in the same connected component, then we can create By by some column permutation of Bx. Using this fact, we can prove our main theorem.
Theorem 5.5**.**
Any Nim sequence G is additively periodic, and the length p of its period is bounded by p≤KM,Mp. Here, KM,M is the maximal value of lcm(p1,…,pn), where p1,…,pn∈N1 for some n∈N1 with the constraints that ∑i=1npi=M−1, and n≤min(∣M∣,M).
Also, there exists a Nim sequence G for which p=KM,Mp.
Proof.
Given a Nim sequence G with additive period length p, we set R=plcm(p,p) and create the path C0,…,Cp as in Lemma 3.10, where Cp is the cycled cut set of C0. As we can continue the path to reach CRp∼C0, it follows that Bp is created by a column permutation of B0. Let c0,…,cM−1 be the columns of B0, and let π(cm)=[b0,π(r),m]r=0R−1. It follows from Definition 3.9 that π(c0),…,π(cM−1) is a permutation of c0,…,cM−1.
We say that {cm,π(cm),…,πpi−1(cm)} constitute a pi–cycle, if pi∈N1 is the smallest number such that πpi(cm)=cm. The first elements [b0,r,m]r=0pi−1 will be repeated in cm, so b0,r,m=b0,r+api,m for a∈{0,…,R/pi−1}. Now the elements of cm are all identical, if and only if {cm} is a 1–cycle. If there are n column cycles of length p1,…,pn in B0, we must have R=lcm(p1,…,pn), because every pi must divide R, and two rows in B0 cannot be identical.
We need to examine how the columns shift from B0 to Bp. If pi happens to divide M, we can space out the columns of the pi–cycle at the indices 0,R/pi,…,R−R/pi, and use the τ–rotation to shift the columns; otherwise, we need to swap at least one column of the pi–cycle. If pi≥2, and cm1,cm2 belong to the same pi–cycle, it is easy to see that there exist row indices r′,r′′ such that (b0,r′,m1,b0,r′,m2)=(b0,r′′,m2,b0,r′′,m1)=(+,−), so we cannot swap these columns by Lemma 5.4. If cm1 belongs to a pi–cycle and cm2 belongs to a pi′–cycle with pi, pi′ coprime, we cannot swap cm1 and cm2 for the same reason. However, if {cm1} is a 1–cycle, we can swap cm1 with any another column in a reversible shift. To ensure a reversible shift is possible from B0 to Bp, we just need to include a 1–cycle in B0.
The problem of maximizing R is equal to finding max(lcm(p1,…,pn)) under the constraint that ∑i=1npi=M−1. Finally, there is a bound for M and M. As each of the n cycles must contain both one + and one −, we must have min(∣M∣,M)≥n, before we can achieve the maximum value for R.
A Nim sequence G with maximal period length given M and M can be found by first creating a binary representation which permits the desired number of pi–cycles with lengths 1,p1,…,pn, which are found under the constraints given above. For each column swap, we find the resultating binary representation, convert them to optimized cut sets, and connect them with a near-optimized path. Finally, we use Lemma 3.11 to find (Yx) and the seed.
∎
Proof of Theorem 1.6.
To maximize R, we need to have as many prime factors as possible in p1,…,pn. So if M−1 is equal to the sum of the n smallest prime numbers, the solution is ∏i=1npi, where p1=2, p2=3, …, and pn is the n’th smallest prime.
By an extension of the Prime Number Theorem (see [8], [10]), the asymptotic value of the sum of all primes smaller or equal to x∈N1 is
[TABLE]
and the product of all primes smaller or equal to x, the primorial (see [9]), has the asymptotic value
[TABLE]
Combining these formulas, we find
[TABLE]
which gives the asymptotic value of KM,M.
∎
Remark 5.6**.**
The proof assumes that we can choose the elements of each Yx freely between the difference bounds. If (Yx) is given, the maximal bound KM,Mp may shrink, if the excluded elements do not permit the optimal number of column cycles. The bounds of Theorem 2.9 and Remark 1.13 may also shrink.
Example 5.7**.**
Let us find the maximum value of R in Γ(R,−3,3). As M=6=1+2+3, we define a binary representation with a 1-cycle, a 2-cycle and a 3-cycle (example, left below). As it happens that maxR=2∗3=6, we could define a binary representation as in Example 1.4 with one 6-cycle, which cycles its columns by the τ–rotation (example, right below). In this case, {−2,…,2} are excluded at every index, so we must have p=1, and the difference period will be [+3,+3,+3,−3,−3,−3].
[TABLE]
If we look at Γ(R,−4,2), we can use the left binary representation if we change the 1-cycle from all pluses to all minuses. Changing the right example, we can define another 6-cycle so the difference period becomes [+2,+2,+2,+2,−4,−4]. If we look at Γ(R,−5,1), we can no longer use the left example, but we can define a 6-cycle so the difference period becomes [+1,+1,+1,+1,+1,−5].
We now expand our framework, so we can give a bound for the length of the preperiod, or rather P~−L, where L is the length of the seed. This bound must also depend on the seed, as we can make the preperiod length arbitrarily long by including large elements in the seed.
Given R,R∈N1, we now consider a cut set Cx=(Sx,r,Tx,r,dr)r=0R+R−1 to have R+R rows, where the top R rows define the preperiod. For r∈{R,…,R+R−1}, we redefine the row rotation of the period as π(r)=((r−R−1)modR)+R, so it cycles the bottom R rows. For r∈{0,…,R−1}, we define the row rotation of the preperiod as
[TABLE]
This rotation cycles all rows with indices 0,…,R−2, as the bottom row of the preperiod will continue into the period.
A Nim sequence with preperiod length (R−1)p+x′ and period length Rp, where x′∈{1,…,p}, corresponds to a path C0,…,Cp−1 in Γ(R+R,M,M) . For j<p−x′, the cut sets Cj=(Sj,r,Tj,r,dr)r=1R+R−1 lack one top row compared to the remaining cut sets in the path. This [math]’th row will be added in Cp−x′. One cut set Cp, a direct successor of Cp−1, is adjoined at the end of the path, where
[TABLE]
We have Cp,R−1∼Cp,R+R−1, where the preperiod shifts into the period, so Cp will violate condition a) in Definition 3.4. We can define a legal cut set C~p by removing the illegal row at the index R−1 before we move all other rows in the preperiod one index down. When now x′<p, C~p∼C0; or with x′=p, the cut sets will be equivalent when we ignore the top row of C0.
Example 5.8**.**
The first values in the Nim sequence G3 from Wythoff’s Game in Example 1.7 corresponds to a path C0,…,C6 in Γ(5,−5,3).
[TABLE]
(The horizontal line separates the preperiod from the period.)
Theorem 5.9**.**
Let G be a Nim sequence over (Yx)x=0∞ that has period length p. Let G have seed [g0,…,gL−1], period length p and preperiod length P~.
Set K^=maxx<Lgx−L. Then the preperiod length is bounded by
[TABLE]
and for M≥11, we have
[TABLE]
where KM,M is defined as in Theorem 5.5.
Proof.
Let c0,…,cM−1 be the columns of B0/τ. We say that π(cm1)=cm2 in Bj/τ if and only if bj,r,m1=bj,π(r),m2 for all r∈{0,…,R−1}, ignoring the values of the period. Then {cm,π(cm),…,πpi−1(cm)} constitute a pi–cycle in the preperiod, if pi∈N1 is the smallest number such that πpi(cm)=cm.
Any shift of the columns in Bp affects both the period and the preperiod. It follows that if we have a pi–cycle in the preperiod, the columns of the cycle must correspond to pi′–cycle in the period, where either pi′ divides pi, or pi divides pi′, or pi=pi′.
As written above, the difference values of G defines a path C0,…,Cp, where Cp has two equivalent rows. As Cp−1 is a legal cut set, and the shift from Bp−1 to Bp creates two identical rows in Bp, it follows that this shift is irreversible. We find two columns cm1,cm2 where this shift swaps bp−1,R−1,m1=+ with bp−1,R−1,m2=−, so these entries become equal to (bp,R+R−1,m1,bp,R+R−1,m2)=(−,+). This shift cannot affect any other rows, as the shift will also be irreversible in these rows, which should all cycle back to the entries of B0. So (bp−1,r,m1,bp−1,r,m2)=(+,−) for all r=R−1. (There might be other irreversible shifts affecting the preperiod in the path, but they too cannot affect any other rows than the row R−1.)
Assume there are two column cycles in the preperiod of length p1 and p2 with p1,p2 coprime, and that all other cycles have length pi which either divides p1 or p2. We can define the columns of Bp−1/τ in the p1–cycle by the left pattern below, and define the columns in the p2–cycle by the right pattern below.
[TABLE]
Let cm1 belong to the p1–cycle and cm2 to the p2–cycle. Then there is exactly one row index r, where (bp−1,r,m1,bp−1,r,m2)=(+,−), and we define the columns, so r=R−1. We then let R=1, and set (bp−1,R,m1,bp,R,m2)=(−,+), and bp−1,R,m=bp−1,R−1,m for m∈{0,…,M−1}∖{m1,m2}. Now the swapping of (bp,r,m1,bp,r,m2) is irreversible, and makes the rows R−1 and R identical.
As we must have a common 1–cycle in the preperiod and period to swap the columns from B0/τ to Bp/τ, we find the maximal value of R as R=p1p2 under the constraint p1+p2=M−1. So if say M is even, we have max(p1p2)=2M(2M−1)→(2M2) as M→−∞,M→∞.
If we have three column cycles in the preperiod of lengths p1,p2,p3, all coprime, when (bp−1,r,m1,bp−1,r,m2)=(+,−) for some r<R, there will always exist r′<R, r′=r with (bp−1,r′,m1,bp−1,r′,m2)=(+,−). Thus, it is impossible to make an irreversible shift that only affects one row in the preperiod, which shows that we cannot have more than two column cycles with coprime period lengths.
To show that P~−L+p≤KM,Mp, it is enough to examine the extreme case where p=max(lcm(p1,…,pn))p with ∑i=1npi=M−1. If we have two columns cm1,cm2 that either belong to a pi– and a pi′–cycle, or the same pi–cycle, it is impossible to find an irreversible shift between cm1 and cm2 in the preperiod that would not affect rows in the period. As the 1–cycle that is used to swap columns must have identical elements in the period and the preperiod, we cannot find an irreversible shift that affects this 1–cycle. This assumes that we can fit three cycles of coprime period lengths in the period, and M=11=1+2+3+5 is the smallest value where this is possible. So with M≥11 and p maxed out, we cannot have any values in the preperiod at all, unless we have large elements in the seed.
We can adjoin some additional K^ values to the start of the preperiod, but only if they are not excluded or cause any exclusions. So we must adjoin negative difference values equal or smaller to M. The maximal number of negative values we can adjoin this way is maxx<Lgx−L, as shown in Lemma 1.10.
∎
Example 5.10**.**
We can expand the left binary representation of Example 5.7 to seven rows, where the top six rows represents the preperiod. Here we have 7=R+R>6=KM,M, which is possible, as M=6<11.
[TABLE]
Left is Bp−1/τ, right is Bp/τ. The irreversible shift swaps bp−1,5,1 with bp−1,5,5.
Example 5.11**.**
Here is a path in Γ(3,−1,2) with p=3, where the preperiod is extended by K^=2.
[TABLE]
As d0(0)=2 excludes 1, this cannot be a legal path unless d0(0) belongs to the seed.
6. Conclusion
In this paper, we have established bounds for the period length and the preperiod length of Nim sequences. To do this, we defined several concepts, such as cut sets and binary representations. These concepts could possibly be used in the study of specific combinatorial games, like Wythoff’s game and Chomp.