The
starts with an infinite sequence of prisoners wearing either black (0) and white (1) hats. One introduces an equivalence relation on sequences of hats $x, y$ as follows:
Define $x \sim y$ if and only if $x$ and $y$ differ in only finitely many hats
$$ x \sim y \iff |\{n \in \mathbb{N}: x(n) \neq y(n)\}| < \infty $$
In the following I will „show“ that there is no finite number $N$ of differences between two sequences for which this definition is sound! Of course my „proof“ must be wrong, but I cannot see where I run into trouble.
So here we go:
Suppose there is a finite $N$. Consider a set $X_N$ where the sequences may differ in some of the first $N$ hats but are identical for the remaining hats $n > N$, e.g.
$$ X_N = \{ x(n): n > N \implies x(n) = 0) \} $$
Of course
$$ \forall x,y \in X_N: x \sim y $$
and therefore there is an equivalence class $[x] \supset X_N$.
Two examples $a,b \in X_N$ are
$$ n \le N: a(n) = 0 $$
$$ n \le N: b(n) = 1 $$
Now consider a new sequence $c \notin X_N$, $c \in X_{N+1} \supset X_N$
$$ n \le N+1: c(n) = 1 $$
The following statements are obviously true
$$ c \not\sim a \qquad (A) $$
$$ c \sim b \qquad (B) $$
(A) holds because $c$ differs from $a$ in the first $N+1$ hats. (B) holds because $c$ differs from $b$ in only one hat $n+1$.
But (A) is not consistent with transitivity $a \sim b \wedge b \sim c \implies a \sim c $.
Therefore I conclude that $c \sim a$ must hold, which is possible if I use $X_{N+1}$ instead of $X_N$. But that means that there cannot be any finite $N$ for which the above mentioned definition of $\sim$ holds. In other words, for an equivalence class $[x]$ with $X_N \subset [x]$ one concludes
$$ \forall N \in \mathbb{N}: X_N \subset [x] \implies X_{N+1} \subset [x] \implies \ldots $$
and therefore
$$ \exists x,y \in [x]: |\{n \in \mathbb{N}: x(n) \neq y(n)\}| = \infty $$
Where am I wrong?
You were missing an existential quantifier for $N$ in the definition of $\sim$. (Or you can simply omit $N$.) $$x\sim y \,\overset{\text{def}}\iff\, |\{n:x(n)\ne y(n)\}|<\infty\,.$$ In other words, you can't take a fixed number $N$ which is valid for each equivalent pairs.
If $N$ is not fixed, you won't run into such problems. Say $a$ and $b$ differ by $N$ and $b$ and $c$ differ by $M$ digits, then $a$ and $c$ will differ by at most $N+M$ digits, which is still finite.