Infection spread on a torus chessboard

EDIT: This answer is actually totally wrong! I'm leaving it up so that others do not make the same mistake as I, but here is an example (thanks to Anton Petrunin) which shows that my supposed non-increasing quantity actually can increase. Initially, three cells are infected, and the restricted perimeter is $10$, but after 3 moves, the restricted perimeter increases to $12$.

enter image description here


Suppose there are only $n-2$ infected cells. Without loss of generality, these infected cells occur in the lower left $(n-1)\times (n-1)$ subgrid of the torus. If not, rotate the torus until one of the columns with no infections is on the right (such a column must exist, since there are at most $n-2$ infections), then rotate until a row with no infections is on top.

The desired invariant quantity is the perimeter of the figure comprising the infected cells only in the lower left $(n-1)\times (n-1)$ subgrid, ignoring wrap-around. Let us call this the "restricted perimeter."

To prove invariance, note that a cell which becomes infected in the top row or right column does not affect the restricted perimeter at all. On the other hand, a cell in the lower left $(n-1)\times (n-1)$ subgrid becoming infected does not increase the restricted perimeter for the same reason as in the non-torus case.

With this definition, the same argument goes through. If there are initially $n-2$ infected cells, then the restricted perimeter is at most $4(n-2)$. But when if the entire torus is infected, the restricted perimeter would be $4(n-1)$.

Here is an example when $n=4$. The left grid is the initial infection, with two infected cells. The restricted perimeter is initially $8$. The right grid is the infection one step later, and the restricted perimeter is still $8$. The edges contributing to the restricted perimeter are highlighted in orange. The topmost orange edge in the second picture might appear strange, since it is between two black squares. But remember, you have to mentally delete the top row and right edge, then consider the perimeter of what remains.

enter image description here