IMO 2024 Q3 #
Let $a_1, a_2, a_3, \ldots$ be an infinite sequence of positive integers, and let $N$ be a positive integer. Suppose that, for each $n > N$, $a_n$ is equal to the number of times $a_{n-1}$ appears in the list $a_1, a_2, \ldots, a_{n-1}$.
Prove that at least one of the sequences $a_1, a_3, a_5, \ldots$ and $a_2, a_4, a_6, \ldots$ is eventually periodic.
We follow Solution 1 from the official solutions. We show that the positive integers up to some positive integer $k$ (referred to as small numbers) all appear infinitely often in the given sequence while all larger positive integers appear only finitely often and then that the sequence eventually alternates between small numbers and larger integers. A further detailed analysis of the eventual behavior of the sequence ends up showing that the sequence of small numbers is eventually periodic with period at most $k$ (in fact exactly $k$).
The condition of the problem. Following usual Lean conventions, this is expressed with
indices starting from 0, rather than from 1 as in the informal statment (but N
remains as the
index of the last term for which a n
is not defined in terms of previous terms).
Equations
- Imo2024Q3.Condition a N = ((∀ (i : ℕ), 0 < a i) ∧ ∀ (n : ℕ), N < n → a n = (Finset.filter (fun (i : ℕ) => a i = a (n - 1)) (Finset.range n)).card)
Instances For
Definitions and lemmas about the sequence that do not actually need the condition of #
the problem
A number greater than any of the initial terms a 0
through a N
(otherwise arbitrary).
Equations
- Imo2024Q3.M a N = (Finset.range (N + 1)).sup a + 1
Instances For
The basic structure of the sequence, eventually alternating small and large numbers #
The definitions of small, medium and big numbers and the eventual alternation #
Small numbers are those that are at most k
(that is, those that appear infinitely often).
Equations
- Imo2024Q3.Condition.Small a j = (j ≤ Imo2024Q3.Condition.k a)
Instances For
Medium numbers are those that are more than k
but at most l
(and include all numbers
appearing finitely often but more than k
times).
Equations
- Imo2024Q3.Condition.Medium a j = (Imo2024Q3.Condition.k a < j ∧ j ≤ Imo2024Q3.Condition.l a)
Instances For
Big numbers are those greater than l
(thus, appear at most k
times).
Equations
- Imo2024Q3.Condition.Big a j = (Imo2024Q3.Condition.l a < j)
Instances For
N'
is such that, by position N'
, every medium number has made all its appearances
and every small number has appeared more than max(k, N+1) times; furthermore, a N'
is small
(which means that every subsequent big number is preceded by a small number).
Equations
- Imo2024Q3.Condition.N' a N = Imo2024Q3.Condition.N'aux a N + if Imo2024Q3.Condition.Small a (a (Imo2024Q3.Condition.N'aux a N + 1)) then 1 else 2
Instances For
The main lemmas leading to the required result #
Lemma 1 from the informal solution.
Similar to Lemma 1 from the informal solution, but with a Small
hypothesis instead of Big
and considering a range one larger (the form needed for Lemma 2).
Lemma 2 from the informal solution.
The indices, minus n
, of small numbers appearing for the second or subsequent time at or
after a n
.
Equations
- Imo2024Q3.Condition.pSet a n = {t : ℕ | ∃ i ∈ Finset.Ico n (n + t), Imo2024Q3.Condition.Small a (a i) ∧ a (n + t) = a i}
Instances For
The index, minus n
, of the second appearance of the first small number to appear twice at
or after a n
. This is only used for small a n
with N' a N + 2 < n
.
Equations
- Imo2024Q3.Condition.p a n = sInf (Imo2024Q3.Condition.pSet a n)