The IMO 2026 Problem 1 blackboard: boards, moves, reachability, and the gcd of -adic valuations
DefinitionIMO2026P1_BlackboardThe model for IMO 2026 Problem 1. A board is a Multiset ℕ: the source says the integers are "not necessarily different", so multiplicity matters and order does not.
A move picks m > 1 and n > 1 from different places and replaces them by and . "Different places" is modelled as m ∈ s together with n ∈ s.erase m, not as m ≠ n. This distinction is the whole modelling risk of the problem: a board holding two copies of must admit a move, yielding and . Had distinctness been imposed on values, such a board would be wrongly terminal and part (a) of the problem would be false for it.
Reachability is the reflexive-transitive closure of the move relation, so a board is reachable from itself by the empty chain. A board is terminal when it admits no move at all, which — since a move needs two entries above — holds exactly when at most one entry exceeds . bigPart collects the entries above , with multiplicity.
gcdExp p s is the quantity in the source's Claim: the gcd of the -adic valuations of all entries, folded from the seed . The seed is the identity for gcd, so entries equal to — whose valuation is — do not affect the result, and the empty board gives .
import Mathlib.Tactic
import Mathlib.NumberTheory.Padics.PadicVal.Basic
import Mathlib.RingTheory.UniqueFactorizationDomain.Nat
namespace IMO2026P1
/-!
The blackboard process of IMO 2026 Problem 1 (proposed by Giancarlo Kerg, LUX).
The board is a `Multiset ℕ`: the source says the integers are "not necessarily different",
so multiplicity matters and order does not.
A move picks `m > 1` and `n > 1` **from different places** and replaces them by
`gcd m n` and `lcm m n / gcd m n`. "Different places" is modelled as `m ∈ s` together with
`n ∈ s.erase m`, rather than as `m ≠ n`: that is what makes the move available when the same
value occupies two places, for instance on a board containing two copies of `2`.
Confucius "continues to make moves while it is possible to do so", so a terminal board is one
admitting no move at all. Since a move needs two entries exceeding `1`, a board is terminal
exactly when at most one entry exceeds `1`.
-/
/-- A blackboard. -/
abbrev Board := Multiset ℕ
/-- One move: replace `m, n > 1` taken from different places by `gcd m n` and
`lcm m n / gcd m n`. -/
def Move (s t : Board) : Prop :=
∃ m n : ℕ, 1 < m ∧ 1 < n ∧ m ∈ s ∧ n ∈ s.erase m ∧
t = Nat.gcd m n ::ₘ (Nat.lcm m n / Nat.gcd m n) ::ₘ (s.erase m).erase n
/-- Boards reachable by finitely many moves, including zero moves. -/
def Reachable : Board → Board → Prop := Relation.ReflTransGen Move
/-- No move is possible. Equivalently, at most one entry exceeds `1`. -/
def IsTerminal (s : Board) : Prop := ¬ ∃ t, Move s t
/-- The entries of the board that exceed `1`. Part (a) asserts this is a singleton at a
terminal board. -/
def bigPart (s : Board) : Board := s.filter fun x => 1 < x
/-- The quantity in the source's Claim: the gcd of the `p`-adic valuations of all entries.
The gcd is folded with identity `0`, which is correct because `gcd 0 x = x`, so entries equal
to `1` — whose valuation is `0` — do not affect it. -/
def gcdExp (p : ℕ) (s : Board) : ℕ :=
(s.map fun x => x.factorization p).fold Nat.gcd 0
end IMO2026P1
Read-back
What the Lean code literally says, in plain math · claude-opus-5
Read-back — declaration bundle (5 definitions, no theorems)
All five declarations live inside a single namespace, so their full names are qualified by it; the file contains definitions only — no lemma, no theorem, no proof obligation, and no sorry.
Board
Board is introduced as a reducible abbreviation for the type of finite multisets of natural numbers, . It takes no arguments, declares no new type, and carries no invariant: a "board" is an unordered finite collection of natural numbers with multiplicities, and every natural number is allowed as an entry, including and . Nothing constrains a board to be nonempty, to have a fixed cardinality, to consist of positive numbers, or to have distinct entries. Because the abbreviation is reducible, and are interchangeable everywhere below.
Move
takes two explicit arguments (no implicit or instance arguments) and returns a proposition. It asserts the existence of two natural numbers and — both existentially bound, both ranging over all of — satisfying five conjoined conditions:
where denotes multiset erasure, which removes exactly one copy of from (and returns unchanged if does not occur in ), and denotes multiset insertion, which adds one copy of to . Spelled out: is required to be strictly greater than ; is required to be strictly greater than ; is required to be a member of ; is required to be a member of the multiset after one copy of has been deleted; and is required to be equal, as a multiset, to the multiset obtained by deleting one copy of from , then deleting one copy of from the result, and then inserting the two values and . The final clause is an equation, not an inclusion or a membership: once and are fixed, is pinned down exactly, so holds precisely when some admissible choice of produces exactly the multiset .
Distinctness. The two chosen numbers are not required to be distinct as values. The only separation imposed is positional: must occupy some copy in , and must occupy some copy in the multiset that remains after one copy of has been removed. Concretely, if the board contains two (or more) copies of the same number , then is permitted, because after erasing one copy of the other copy is still present; in that case the move deletes both copies of and inserts together with , i.e. the board becomes . Conversely, if occurs exactly once in , the requirement fails for , .
Re-use of a single position. The relation does not permit the same occurrence (position) to be used twice: the second element is drawn from , whose multiplicity of is one less than that of , so a value occurring only once cannot serve as both and . Two chosen values may coincide only when backed by two separate copies.
Entries not eligible. Entries equal to or can never be selected as or , since and are false; such entries can only sit passively in the untouched remainder .
Division. The quotient is natural-number (floor, truncating) division, the total operation that returns when the divisor is . Under the hypotheses actually present, forces , so no division by zero can occur here, and since divides the quotient is exact; the file nonetheless asserts nothing about exactness — the expression is whatever truncating division returns. Each move removes two copies and inserts two values, so cardinality is preserved by construction, but no declaration in the file states this.
Reachable
is defined, with no arguments written on the left-hand side, as a relation on boards: it is the reflexive–transitive closure of . Thus holds exactly when there is a finite — possibly empty — chain of boards
with for each . In particular holds for every board , including the empty board and boards from which no move is possible, because the empty chain () is allowed. The relation is directed: does not entail . No bound on the length is asserted, and nothing asserts that such a chain terminates or that any particular board is reachable from any other.
IsTerminal
takes one explicit argument and asserts the negation of an existential over boards:
i.e. there is no board to which is related by . Unfolding , and using that the target is uniquely determined by the choice of and (so a witness exists as soon as an admissible pair exists), this says exactly: there do not exist with , , and . In terms of entries, holds precisely when does not contain two distinct occurrences (counted with multiplicity) of entries exceeding — equivalently, when at most one entry of is strictly greater than . Boards with zero such entries and boards with exactly one such entry are both terminal; a board with a single entry repeated twice is not terminal. Entries equal to or never obstruct terminality, regardless of how many of them there are. The quantification is over all boards of type ; no restriction to boards of the same size or reachable boards is imposed.
bigPart
takes one explicit argument and returns a board: the sub-multiset of consisting of those entries satisfying , retained with their multiplicities, and with all entries equal to and discarded. The filtering predicate requires a decidability instance, which is supplied automatically by the decidability of the strict order on ; this is the declaration's only instance argument and it imposes no mathematical content. of the empty board is the empty board, of a board of all s (or all s, or any mixture of s and s) is the empty board, and of a singleton is if and otherwise. This definition is not referenced by any other declaration in the file; in particular no connection between and , or is stated anywhere.
gcdExp
takes two explicit arguments, a natural number and a board , and returns a natural number. It first maps every entry of to , the exponent of in the prime factorisation of (the multiplicity of in the list of prime factors of ), producing a multiset of natural numbers of the same cardinality as ; it then folds that multiset with the binary operation on , starting from the initial value :
The fold is over an unordered multiset and is therefore well-defined only because is commutative and associative; those two facts are supplied as typeclass instance arguments (the commutativity and associativity instances for on ) and are the declaration's only implicit/instance content.
The starting value. Since for every , the seed is the identity element of and therefore contributes nothing to a nonempty board; its only visible effect is to fix the value on the empty board, where .
An entry of valuation zero. For the same reason, an entry with does not collapse the result to : taking with leaves the accumulated value unchanged. The result is exactly when every entry has valuation (or the board is empty); otherwise it is the greatest common divisor of the nonzero valuations present.
Primality. The definition places no hypothesis on : is an arbitrary natural number, and no assumption, typeclass or otherwise, requires to be prime. For , , or any composite , the exponent is for every (a non-prime never occurs in a list of prime factors), so for every board .
Degenerate entries. and by the totality of the factorisation function (the factor list of and of is empty); in particular an entry equal to is treated as having valuation , not an infinite or undefined valuation, and thus leaves unchanged. On a singleton board the value is ; on a board of all s it is ; on the empty board it is .
Degenerate cases across the file
- Empty board . No can satisfy , so no move exists: holds, holds only for , , and for every .
- Singleton board . After erasing the unique copy of nothing remains, so no second element exists and is terminal for every , including . .
- Board of all s (any multiplicity). is false, so no entry is eligible; the board is terminal, is empty, and is .
- An entry equal to . Ineligible for selection ( is false), discarded by , and assigned valuation by . A board such as is terminal.
- Division. The only division is , in truncating natural-number division; under the standing hypothesis the divisor is nonzero, and no statement in the file asserts that this division is exact or that its result is positive. Multiset erasure is likewise total and silently returns the multiset unchanged when the erased element is absent, though both erasures in occur under explicit membership hypotheses.
- Duplicate entries. Multiplicities matter throughout: membership, erasure, filtering and mapping all respect multiplicity, and two equal entries count as two occurrences for the purposes of and .
What is NOT asserted anywhere in this file
- No theorem of any kind. The file contains only definitions and an abbreviation; it proves nothing, states no lemma, and contains no proof or
sorry. - Nothing asserts that is prime, or that has any relationship to , , or — in particular no invariance of under a move is claimed.
- Nothing asserts that is related to terminality, to the number of eligible entries, or to anything else; it is defined and never used.
- Nothing asserts that preserves cardinality, the product of the entries, the multiset of prime factorisations, or any other quantity.
- Nothing asserts that divides , that the displayed quotient is exact, or that the two inserted values are positive, distinct, or different from and .
- Nothing asserts termination: there is no claim that iterating halts, that a terminal board is reachable from every board, that the process is well-founded, or that any decreasing measure exists.
- Nothing asserts confluence, determinism, or uniqueness of the terminal board reachable from a given board; is a relation and may relate one board to many.
- Nothing asserts that is symmetric or an equivalence, nor any bound on the number of steps.
- Nothing constrains a board to be nonempty, finite in a bounded sense, free of s and s, of fixed cardinality, or with distinct entries.
- No characterisation of in terms of counting entries greater than is stated as a lemma; that reading is obtained by unfolding the definition, not by an asserted equivalence.
- No existence claim is made: nothing states that any board admits a move, or that any board is terminal.