AI proved a math conjecture I made when I was an undergraduate

The problem

Given positive integers nn and kk with k<nk<n, consider n1n-1 balls labelled 1,2,,n11,2,\ldots,n-1. Color them subject to the following rules:

  1. Balls ii and nin-i have the same color.
  2. Balls ii and ik|i-k| have the same color whenever iki\ne k.

What is the maximum possible number of colors?

I recently rediscovered this problem in my undergraduate notes. I proposed this problem “inspired by a homework problem in my discrete mathematics class.” At the time, I experimentally found what appeared to be the answer, but I never managed to prove it rigorously. Years later, I gave the problem to an AI, which revealed the simple algebraic structure behind the conjecture.

My original observation

Let f(n,k)f(n,k) denote the answer. From small examples, I observed the recurrence

f(n,k)=f(max(nk,k),min(nk,k)).f(n,k)=f\bigl(\max(n-k,k),\min(n-k,k)\bigr).

This resembles the Euclidean algorithm, so I conjectured that the answer depends only on gcd(n,k)\gcd(n,k). More precisely, if d=gcd(n,k)d=\gcd(n,k), then

f(n,k)=d2+1.\boxed{f(n,k)=\left\lfloor\frac d2\right\rfloor+1.}

The conjecture is correct and proved by AI. Following are AI-generated contents.

Proof

Think of each ball as a vertex. Join two vertices whenever the rules require the corresponding balls to have the same color. Every connected component must be monochromatic, while different components may receive different colors. Thus, f(n,k)f(n,k) is exactly the number of connected components.

It is convenient to regard the labels as the nonzero elements of Z/nZ\mathbb Z/n\mathbb Z. The first rule says

ii(modn).i\sim-i\pmod n.

The second rule, together with the first, gives an edge between ii and ik(modn)i-k\pmod n. If i>ki>k, this follows directly from iiki\sim i-k. If i<ki<k, then

iki(ki)=ik(modn).i\sim k-i\sim -(k-i)=i-k\pmod n.

The relation \sim is symmetric: if we can move from ii to iki-k, we can traverse the same edge backward and move from iki-k to ii. Thus we may both subtract and add kk. Repeating these moves, and applying negation when desired, produces labels congruent to

±i+qk(modn),qZ.\pm i+qk\pmod n,\qquad q\in\mathbb Z.

Equivalently, one could take only nonnegative qq: because the sequence is periodic modulo nn, a negative value of qq can always be replaced by a nonnegative one. The only caveat is that 00 is not an actual label; we handle that case below.

Now let d=gcd(n,k)d=\gcd(n,k). The subgroup of Z/nZ\mathbb Z/n\mathbb Z generated by kk is precisely the set of multiples of dd. Therefore, repeated addition of kk can change a label by any multiple of dd, and negation can change its residue modulo dd from rr to r-r. It follows that two labels ii and jj are connected exactly when

ji(modd)orji(modd).j\equiv i\pmod d \qquad\text{or}\qquad j\equiv-i\pmod d.

There is one small boundary issue: the label 00 is not a ball. This does not split the component consisting of multiples of dd. In the cycle formed by repeatedly adding kk, removing 00 leaves a path whose endpoints are kk and nkn-k; the first coloring rule connects those two endpoints. Hence all nonzero multiples of dd remain in one component.

We are therefore left to count the residue classes modulo dd after identifying each residue rr with r-r. They are

{0},{1,d1},{2,d2},.\{0\},\{1,d-1\},\{2,d-2\},\ldots.

If dd is odd, there are 1+(d1)/21+(d-1)/2 such classes. If dd is even, there are 1+(d2)/2+11+(d-2)/2+1 because both 00 and d/2d/2 are fixed by negation. In either case, the total is

d2+1.\left\lfloor\frac d2\right\rfloor+1.

Thus

f(n,k)=gcd(n,k)2+1.\boxed{f(n,k)=\left\lfloor\frac{\gcd(n,k)}2\right\rfloor+1.}

The hidden structure

There are two complementary ways to describe the structure behind the problem. The first is concrete and gives the shortest proof; the second places the same argument in a broader group-theoretic setting.

The cyclic-group interpretation

Regard the labels as elements of the cyclic group Z/nZ\mathbb Z/n\mathbb Z. The coloring rules allow the operations

ii+kandii.i\longmapsto i+k \qquad\text{and}\qquad i\longmapsto-i.

The subgroup generated by kk consists precisely of the multiples of d=gcd(n,k)d=\gcd(n,k). Translation by kk therefore moves within a residue class modulo dd, while negation identifies the class rr with r-r. Consequently, the connected components are indexed by

(Z/dZ)/{rr}.(\mathbb Z/d\mathbb Z)/\{r\sim-r\}.

Counting these classes immediately gives d/2+1\lfloor d/2\rfloor+1. This is the most direct interpretation of why the gcd appears in the answer.

The dihedral-group interpretation

Alternatively, write the two original operations as reflections:

s0(i)=i,s1(i)=ki(modn).s_0(i)=-i, \qquad s_1(i)=k-i \pmod n.

Their composition is the translation

s1s0(i)=i+k.s_1s_0(i)=i+k.

Abstractly, two reflections of this form generate the infinite dihedral group DD_\infty, equivalently the affine Weyl group of type A~1\widetilde A_1. The orbit of ii under its action on Z/nZ\mathbb Z/n\mathbb Z is

{±i+qk(modn):qZ}.\{\,\pm i+qk\pmod n:q\in\mathbb Z\,\}.

The coloring graph is essentially the Schreier graph of this action: applying either generator draws an edge, so its connected components are exactly the orbits. Although DD_\infty is infinite, this particular action is finite. The translation ii+ki\mapsto i+k has order n/dn/d, so the action factors through a finite dihedral group.

Thus the two descriptions say the same thing at different levels. The cyclic-group view computes the orbits directly; the dihedral-group view explains why translation and reflection occur together. The gcd formula is the concrete shadow of this underlying dihedral symmetry.