Solution:
We divide the proof into 3 parts: first we exhibit a strategy in four steps for part (a), then we exhibit a strategy in five steps for part (b) with k≤52, and finally we show the optimality of the number of steps of these strategies.
Strategy for part (a)
A possible strategy consists of revealing the following four terms of the sequence: x1000,x1004,x1010,x1045 (or in general xa,xa+4,xa+10,xa+45).
To show this, let us call p the period, and observe that xi=xj if and only if p divides j−i (at this point it is crucial to know that the p terms that repeat periodically are all distinct from one another). Consequently, depending on the value of p between 1 and 10, we will have all and only the identities among the revealed numbers indicated in the following table.
From the table it follows that it is possible to uniquely determine the period depending on which identities are observed.
Strategy for part (b)
It suffices to exhibit a strategy that allows one to distinguish among the first 52 prime periods: the same strategy will, a fortiori, distinguish among the first k≤52 primes.
To describe a possible strategy, let p1,…,p52 be the first 52 prime numbers, and let P be their product. Now consider the set S={1,2,3,4,5}, and define a partition of S as any way of dividing this set into nonempty subsets. For example, {{1,2},{4},{3,5}} is a partition of S (it is understood that the order in which the subsets {1,2},{4},{3,5} are presented is irrelevant in this notation).
We will show below that the set S admits exactly 52 partitions. Let us number these partitions in some way from 1 to 52, in such a way that the first one is the one consisting of the single subset S, and the second one is {{1},{2,3,4,5}}. For every integer i between 1 and 52, consider the function fi:S→S that associates to every element x∈S the smallest y∈S that belongs to the same subset as x in the i-th partition. For example, if the 42nd partition were {{1,2},{4},{3,5}}, then we would have f42(1)=1,f42(2)=1,f42(3)=3,f42(4)=4, f42(5)=3. Note that 1≤fi(x)≤pi for every admissible choice of i and x (the only primes that could cause problems are p1=2 and p2=3, but by how we chose the first two partitions in the list, the problem does not arise).
The strategy consists of revealing the five elements of the sequence whose indices a1,a2,a3,a4,a5 are defined by
an=i=1∑52(fi(n)⋅piP)∀n∈{1,2,3,4,5}
To show that this strategy works, we proceed as in part (a), studying the equalities that can hold among these five elements of the sequence.
Let pi be the period of the sequence, with 1≤i≤52. Since the pi terms of the sequence that repeat periodically are all distinct, as in part (a) we deduce that xan=xam if and only if pi divides am−an. Moreover, since in the sum defining an all the terms are divisible by pi except at most the i-th one, we deduce that pi divides am−an if and only if pi divides fi(m)−fi(n). Finally, since fi(m) and fi(n) are both between 1 and pi, divisibility holds if and only if fi(m)=fi(n), that is, if and only if m and n belong to the same subset of the i-th partition.
It follows that, by checking for which pairs of indices m and n the equality xam=xan holds, it is possible to uniquely reconstruct a partition of S: the index i of that partition in the list of the 52 partitions of S determines the period pi.
It remains to show that there are 52 partitions of S. To this end, let us denote more generally by Bba the number of partitions of b elements into a subsets, that is, the number of ways to represent a set of b elements as a disjoint union of a subsets. Clearly there is only one partition of b elements into b or into 1 subsets, so Bbb=Bb1=1. A partition of b+1 elements into a+1 subsets can be obtained in two ways: either by adding the (b+1)-th element to one of the a+1 parts of a partition of the first b elements into a+1 subsets, or by adding the (b+1)-th element, as a subset by itself, to a partition of b elements into a subsets. The following relations therefore hold
Bbb=Bb1=1,Bb+1a+1=(a+1)Bba+1+Bba
from which it is possible to iteratively complete the table below. The number of partitions of a set of 5 elements is the sum of the numbers in the last row, namely 52.
Continuing the table, and summing the numbers in the
k-th row, one obtains the number of partitions of a set of
k elements.
Optimality of the strategies
The basic idea, to show that one cannot do better than the strategies illustrated above, is to argue that the only information available to the strategy must be contained in the equalities observed among the revealed numbers. An assignment of equalities among k variables, which we imagine represent the k numbers revealed in the k steps of any strategy, determines a partition of the set of these k variables. Hence, in k steps, a strategy can distinguish at most as many periods as there are partitions of a set of k elements, that is, the sum of the numbers in the k-th row of the previous table.
In evaluating the solutions proposed by the contestants for this problem, the previous argument was deemed sufficient.0
However, the formal translation of this intuitive idea is not obvious, since the text of the problem explicitly allows "dynamic" strategies in which each move can depend on the outcome of the previous moves, taking into account various factors, for example the parity of the revealed numbers, whether or not they are prime, their size, and so on.
In what follows, given any subset P of the positive integers, we denote by Succ(P) the set of all sequences of positive integers that have period p∈P and have the first p terms distinct (p is not necessarily a prime number). For brevity we denote elements of Succ(P) by a single letter, that is, we will briefly write x to denote the sequence x1,x2,…,xn,… The goal is to prove the following statement.
Lemma. Let k be a positive integer, and let P be a subset of the positive integers. Suppose there exists a strategy that allows one to determine the period of every sequence in Succ(P) in at most k moves.
Then the number of elements of P is less than or equal to the number of partitions of the set {1,…,k}.
To prove the lemma, we need to introduce some notation. We call an m-outcome a sequence E of m pairs [(a1,v1),…,(am,vm)] of positive integers, where a1,…,am are the indices of the terms revealed by the strategy at moves 1,…,m, and v1,…,vm are the corresponding revealed values.
We define the weight of E to be the number Peso(E)=∣{v1,…,vm}∣, that is, the number of distinct elements among v1,…,vm.
We say that a period p∈P is credible for a given m-outcome E if there exists a sequence z∈Succ(P) of period p such that zai=vi for every i∈{1,…,m}.
We denote by Per(E) the subset of P consisting of the periods credible for E, and we call the uncertainty of E the number Inc(E)=∣Per(E)∣, that is, the number of periods among which we remain uncertain if, after m steps, the strategy has given us E as a result.
Suppose now that there exists a strategy that determines the period of every element of Succ(P) in at most k moves. We may assume that the strategy always performs k moves before stating the period (possibly by adding irrelevant moves).
We define as attainable all the m-outcomes that can be obtained by applying the strategy to some sequence in Succ(P), and we denote by E(m) the set of all attainable m-outcomes. We will prove that the bound
Inc(E)≤CmPeso(E)∀m∈{1,…,k},∀E∈E(m)
holds, where the numbers Cba are defined by setting Cka=1 for every 1≤a≤k, and then working backward
Cma=aCm+1a+Cm+1a+1∀m∈{1,…,k−1},∀a∈{1,…,m}
Assuming this result, for m=1 we will in particular have that
Inc(E)≤C11∀E∈E(1)
This inequality is equivalent to the thesis, since for every 1-outcome E the uncertainty Inc(E), that is, the uncertainty after the first move, is exactly the number of elements of P, since clearly after the first move every period is still credible, while C11 is the number of partitions of {1,…,k} (for a specific value of k this can be verified by explicitly computing C11 by means of the recurrence; for the general case one can show, by induction on m, that the sum
a=1∑mBmaCma
is independent of 1≤m≤k, from which the conclusion follows by comparing the cases m=1 and m=k).
To prove inequality (1), we proceed by backward induction on m. If E∈E(k), then Inc(E)=1, whatever the weight of E is, since by hypothesis the strategy works, so every possible outcome after k moves uniquely identifies the period.
Suppose now that (1) holds for some m+1, with 1≤m≤k−1, and let us show that it holds for m. Consider then an attainable m-outcome E, which we think of as always being of the form [(a1,v1),…,(am,vm)]. Observe that the set Per(E) of periods credible for E is contained in the union of the sets Per(E′), where E′ ranges over all the attainable (m+1)-outcomes that agree with E up to step m. Note also that the index am+1 of every E′ of this type is always the same, since it depends only on the history up to step m. Consequently, all the (m+1)-outcomes we are interested in are obtained by adding to E a pair of the form (am+1,v), where v ranges over a suitable set F of positive integers.
We have thus obtained the inclusion
Per(E)⊆v∈F⋃Per([(a1,v1),…,(am,vm),(am+1,v)])
Now the value v may or may not coincide with one of the values v1,…,vm involved in E. This leads us to think of the union in (2) as the union of the set
v∈{v1,…,vm}⋃Per([(a1,v1),…,(am,vm),(am+1,v)])
and the set
w∈F\{v1,…,vm}⋃Per([(a1,v1),…,(am,vm),(am+1,w)])
In (3) the number of sets we are taking the union of is Peso(E), and each of them has, by the induction hypothesis, a number of elements less than or equal to Cm+1Peso(E). It follows that the number of elements of the first union is less than or equal to
Peso(E)⋅Cm+1Peso(E)
In (4), the sets we are taking the union of are (fortunately) all equal, since the set of periods compatible with a given (m+1)-outcome [(a1,v1),…,(am,vm),(am+1,w1)] coincides with the set of periods compatible with the (m+1)-outcome [(a1,v1),…,(am,vm),(am+1,w2)], whatever positive integers w1 and w2 are, provided they are different from v1,…,vn. Indeed, if p is a period credible given the first (m+1)-outcome, then there exists a sequence z∈Succ(P) of period p such that zaj=vj for j ranging from 1 to m, and zam+1=w1; now, replacing in the sequence z every occurrence of w1 with w2, and vice versa, one obtains a new sequence in Succ(P) of period p and compatible with the second (m+1)-outcome, and hence p is credible also given the second outcome. The converse is analogous.
Finally, observe that all the (equal) sets appearing in the union (4) are the credible periods for suitable admissible (m+1)-outcomes whose weight equals Peso(E)+1, and hence by the induction hypothesis the number of elements of the second union is less than or equal to Cm+1Peso(E)+1.
Returning to (2), we have shown that for every E∈E(m) the bound
Inc(E)≤Peso(E)⋅Cm+1Peso(E)+Cm+1Peso(E)+1=CmPeso(E)
holds, which completes the induction step, and hence the proof of the lemma.
An alternative approach to the lemma consists of arguing by contradiction, by showing that, if the number of elements of P is greater than the number of partitions of {1,…,k}, then for every strategy S in k steps there exist two sequences in Succ(P), of different period, on which the strategy produces the same k-outcome, thus making it impossible to uniquely determine the period.
To show this result, we say that an m-outcome [(a1,v1),…,(am,vm)] is moderate if v1=1 and vi≤max{v1,…,vi−1}+1 for every i∈{2,…,m−1}. We say that a sequence is S-moderate if the strategy S, applied to the sequence, produces a moderate k-outcome (and hence all the m-outcomes obtained along the way are also moderate). In other words, the value revealed (not the index) by the strategy S on an S-moderate sequence at step m is one of the previous values, or the maximum of the previous values increased by 1.
The existence of the two sequences of different period that produce the same k-outcome now follows, by the pigeonhole principle, from three claims.
1. If two k-outcomes of the same strategy S have the same values in the same order, then they also have the same indices in the same order.
2. The number of possible k-outcomes of a given strategy S applied to S-moderate sequences is less than or equal to the number of partitions of {1,…,k}.
3. For every strategy S and for every period p∈P, there exists in Succ(P) at least one S-moderate sequence of period p.
The first claim is proved by induction, using the fact that the index that will be revealed at step m+1 depends only on the indices and values revealed up to step m.
To prove the second claim, observe that, thanks to the first claim, a moderate k-outcome obtained from a given strategy S is uniquely determined by the k-tuple (v1,…,vk) of its values. At this point it suffices to observe that there is a bijective correspondence between such k-tuples and the partitions of {1,…,k} (it suffices to consider the steps at which one obtained as value 1,2,…).
To prove the third claim, consider the largest integer m∈{1,…,k} for which there exists a sequence in Succ(P) of period p whose outcomes are S-moderate up to step m. Observe first that, denoting by a1 the index of the term revealed by the strategy S at the first step, there certainly exists a sequence of period p with xa1=1, so m is well defined, in the sense that the set of which it is the maximum is not empty.
Now if m=k there is nothing to prove. If instead m<k, consider any sequence x∈Succ(P) of period p that achieves the maximum. At step m+1 the strategy S applied to x will produce a pair (am+1,w) for some w>w′+1, where w′ is the maximum of the values revealed in the first m steps. But if we now consider the sequence y obtained by swapping in x every occurrence of w with w′+1, and vice versa, one can check that y is still an element of Succ(P) of period p, and its outcomes are moderate at least up to step m+1 (and coincide with those of x up to step m). This contradicts the maximality of m.
Concluding remarks
The "elephant in the room" in problems of this type is the concept of strategy. The fundamental question one might ask is: what is a strategy? The problem can change a great deal depending on the answer to this question.
In this specific case, the problem could have been formulated using only "static" strategies, in which the "player" must declare at the very beginning all the indices of the terms he wants to reveal. In this formulation a strategy in n steps is thus, from a formal point of view, simply an n-tuple of positive integers, that is, precisely the requested indices. The solutions presented at the beginning for parts (a) and (b) indeed show static strategies that solve the problem in a certain number of moves. As for optimality, the proof becomes much simpler if one restricts to static strategies only, because then a value-swapping argument suffices to rigorously show that the only relevant information consists of the equalities among the revealed values.
A broader class of strategies includes those we might call "deterministic dynamic" strategies. The player now chooses the first index a1 to reveal, and then at each subsequent move chooses the index am+1 based on the m-outcome. The strategy is thus formally made up of a number (the first index) and a function that associates to every m-outcome the next index. Determinism consists in the fact that the initial step is always the same, and the same m-outcome will always lead to requesting the same index at the next step. The two proofs of the optimality lemma given above, as written, are conceived within the class of deterministic dynamic strategies.
An even broader class of strategies includes those we might call "probabilistic dynamic" strategies. After seeing the m-outcome, the player now "rolls a die", and chooses the next index to reveal based on the m-outcome and the outcome of the die (and similarly for the choice of the first index). The same m-outcome can thus now lead to investigating different indices at the next step. The two previous proofs of optimality can, with small modifications, be adapted to also include strategies of this type, provided one assumes that the die behaves "fairly". On the other hand, we cannot allow as a "strategy" the use of an unfair die which, for example, on the first move makes us reveal the 2021st term, and on the second move "by chance" happens to request precisely the term of index 2021+p, where p is the period of the sequence. With such a die, if p is prime, we would always manage in two moves!
0 These are known in the literature as Bell numbers.
1 Result of uncertain attribution, often cited in olympiad literature as Passaro's Lemma. Note that it can be seen as dual to the better-established Damiano's Lemma, or as a corollary of the lesser-known Pierrat's Lemma.