Wednesday 16 September 2020

Red and Blue checkers riddle

 Image you have a circle of red and blue checkers. Between every two checkers, you add a red checker if they have the same colour, and a blue checker if they have a different colour. Then you remove the original tokens. You repeat this process indefinitely. For wat starting conditions does the circle end up with only red tokens?


In case you are on mobile, and the video does not load, here is the link: https://www.youtube.com/watch?v=JC75OzQzILk

The video gives a visual solution, but if this unrigorous solution is not satisfying, below is a more rigorous one:

A wheel as described in the problem is isomorph with the finite ring defined by:

$$\mathcal{W_n} = GF(2)[X]/(X^n+1)$$

Where for our isomorphism works as follows.

Let $\delta_0$ be 0 if the top token is red, and 1 is the top token is blue. The walk clockwise, and for each token you pass, perform the same procedure, but use $\delta_1$, $\delta_2$ and so on instead. 

Now are element of our finite ring can be written as $$\sum_{i=0}^{n-1}\delta_ix^i$$

Or expanded:

$$\delta_0+\delta_1x+\delta_2x^2+...+\delta_{n-1}x^{n-1}$$

Summing two elements is evidently equivalent to combining two wheels (where we combine two the same tokens to a red token and two different tokens to a blue token). Each delta just follows the $$GF(2)$$ rules.

Rotating the system one turn clockwise, is equivalent to multiplying with $x$. This can be shown as follows

$$\begin{align*}xs&\equiv x(\delta_0+\delta_1x+\delta_2x^2+...+\delta_{n-1}x^{n-1})\\&\equiv\delta_0x+\delta_1x^2+\delta_2x^3+...+\delta_{n-2}x^{n-1}+\delta_{n-1}x^{n}\\&\equiv\delta_0x+\delta_1x^2+\delta_2x^3+...+\delta_{n-2}x^{n-1}+\delta_{n-1}x^{n} +\delta_{n-1}(x^n+1)\\&\equiv\delta_0x+\delta_1x^2+\delta_2x^3+...+\delta_{n-2}x^{n-1}+\delta_{n-1}x^{n} +\delta_{n-1}(x^n+1)\\&\equiv\delta_0x+\delta_1x^2+\delta_2x^3+...+\delta_{n-2}x^{n-1}+\delta_{n-1} \end{align*}$$

This means that our initially described operator is the same as multiplying our initial state $s$ with $x+1$.

So our system becomes only red tokens if and only if $$\exists a: s(x+1)^a\equiv0$$

Definition 1:

$$\mathcal{W_n} = GF(2)[X]/(X^n+1)$$

We call $\mathcal{W_n}$ a wheel and $n$ the size of the wheel. In words, a wheel with size $n$ is the quotient ring of of the polynomial ring over the second order galois field

Definition 2:

For any element $w \in \mathcal{W}$ the element has period $p$ if $$wx^p \equiv w$$ Note that an element can have multiple periods.

Trivially, each of the following statements are true:

  1. The period is a divider of the size of the wheel.
  2. If $p$ is a period, ever multiple is also a peroid.
  3. If $a$ and $b$ are periods gcd$(a,b)$ is a period
  4. if $a$ and $b$ have period $p$, so does $a+b$
  5. if $a$ has period $p$, so does $ab$ for all $b$

Definition 3:

$$u \equiv \sum_{i=0}^{n-1}x^i$$

Theorem 1:

$$\forall a,b \in \mathcal{W_n} a \equiv b \Leftrightarrow a+b \equiv 0$$

Proof: Trivially follows from the fact that $a+a\equiv 0$ in GF(2)

Theorem 2:

$\forall a,b \in \mathcal{W_n}$ If $a(x+1) \equiv 0$ then $a \equiv 0$ or $a \equiv u$

Proof:

Let $a=:\sum_{i=0}^{n-1}\delta_ix^i$. 

$$\begin{align*}a(x+1) &\equiv 0 \\ (x+1)\sum_{i=0}^{n-1}\delta_ix^i &\equiv 0 \\(x+1)\sum_{i=0}^{n-1}\delta_ix^i &\equiv \sum_{i=0}^{n-1}0x^i \\ \sum_{i=0}^{n-1}\delta_i + \delta_{i-1}x^i &\equiv \sum_{i=0}^{n-1}0x^i \\\delta_i + \delta_{i-1} &\equiv 0\\\delta_i &\equiv \delta_{i+1}\\\delta_i &\equiv \delta_0\end{align*}$$

Corollary 2.1:

 If $a(x+1) \equiv 0$ then $ax^j \equiv a$ for all $j$

Theorem 3:

If $a(x+1)$ has period $p$, $a$ has period $2p$.

Proof:

$$\begin{align*}a(x+1) &\equiv ax^p(x+1)\\(a+ax^p)(x+1) &\equiv 0\\a+ax^p &\equiv (a+ax^p)x^p\\a+ax^p &\equiv ax^p+ax^{2p}\\a &\equiv ax^{2p}\end{align*}$$

Corollary 3.1:

If $s(x+1)^a\equiv0$ then $s$ has period $2^a$

Lemma 4.1:

$(a+b)^2 \equiv a^2+b^2$

Proof: Trivially proven by distributive property. Note that $2\equiv 0$ so this is equivalent to the real numbers.

Lemma 4.2:

$(x+1)^{2^y}\equiv x^{2^y}+1$

Proof by induction:

Base case:

$(x+1)^{2^1}\equiv x^{2^1}+1$ is trivially true

Induction step:

Assume

$$(x+1)^{2^y}\equiv x^{2^y}+1$$

then is

$$(x+1)^{2^{y+1}}\equiv \left((x+1)^{2^y}\right)^2 \equiv \left(x^{2^y}+1\right)^2=x^{2^{y+1}}+1$$

Theorem 4:

If $a$ has period $2^y$ then $s(x+1)^{2^y}\equiv 0$

Proof:

 $$s(x+1)^{2^y} \equiv s(x^{2^y}+1) \equiv s(x^{2^y}+1) \equiv sx^{2^y}+s\equiv s+s \equiv 0$$

Epilog

From theorem 3 and 4 follow that our procedure will finish with all red tokens if and only if it has a period of a power of two. In other words, if there exists a power of two such that if I rotate the wheel with an amount of tokens equal to that power of two, if I end up with the same wheel. And in practice youonly have to check powers of two that are divisors of the size of the wheel, so there are not many cases to check.