Solution (source code)

= Solution

A <martingale> is an adapted <Lebesgue integrable> process with $\mathbb E[M_{n+1}\mid\mathcal F_n]=M_n$. A <stopping time> $T$ has $\{T\le n\}\in\mathcal F_n$ for every $n$. A precise bounded-time <optional sampling theorem> says: if $S\le T\le N$ are <stopping times>, then $\mathbb E[M_T\mid\mathcal F_S]=M_S$. To prove it, write
$$
M_T-M_S=\sum_{k=0}^{N-1}(M_{k+1}-M_k)\mathbf1_{\{S\le k<T\}}.
$$
For $A\in\mathcal F_S$, the event $A\cap\{S\le k<T\}$ lies in $\mathcal F_k$. Every summand multiplied by its indicator therefore has expectation zero. Summing proves the conditional expectation identity. All terms are <Lebesgue integrable> since there are finitely many. Unbounded stopping requires an additional hypothesis such as <uniform integrability> of the stopped <martingale>; it is not justified solely by almost-sure finiteness.

The <martingale convergence theorem> ensures a finite almost-sure limit if $\sup_n\mathbb E|M_n|<\infty$. <Uniform integrability> also gives convergence in $L^1$. In particular bounded or nonnegative <martingales> satisfy the almost-sure convergence criterion. A symmetric random walk is a <martingale> but cannot have a finite limit, since each increment is $\pm1$ and does not tend to zero. Some hypothesis is therefore necessary.

If there are $j$ pessimists, the count increases with probability $(K-j)j/[K(K-1)]$ and decreases with the identical probability. The remaining outcomes leave it unchanged, so $P_n=j_n/K$ is a bounded <martingale>. It converges almost surely. From any nonunanimous state, there is a fixed positive probability, bounded uniformly over the finitely many states, of reaching unanimity within $K-1$ steps by letting each other individual copy a chosen seed. Repeating blocks shows eventual absorption has probability one. Thus the <finite voter-model consensus probability> is
$$
\boxed{P_\infty\in\{0,1\},\qquad \mathbb P(P_\infty=1)=P_0}.
$$
The last equality follows from bounded convergence and the constant <martingale> expectation. The population eventually becomes wholly pessimistic or wholly optimistic, with probabilities equal to their respective initial proportions.