Number of binary square matrices whose every contiguous 2 by 2 submatrix has exactly 2 ones (zeroes)
We will casework on the numbers in the first row of the $n*n$ table in two cases:
- The first row is $1,0,1,0,\dotsb$ or $0,1,0,1,\dotsb$
- There are two consecutive elements in the first set.
First of all, it is clear that in the first case the answer is exactly $2^n$:
Name every row without consecutive elements as simple rows. Now if the first case happens, each row can be a simple row and it is all of the cases without consecutive elements in the first row so, the first case is of $2^n$ cases.
On the other in the second case we will prove that the rest of the table can be constructed uniquely:
The two unit squares under the two consecutive elements of the first row are chosen uniquely and based on these two, the rest of the second row is constructed uniquely. Similarly, the second row has at least two consecutive elements (the two unit squares under the two consecutive elements in the first row are the same) so the third row is constructed uniquely and so on. So in the second case, the rest of the table is constructed uniquely. So the number of cases of the tables of the second kind is equal to the number of binary sets except the two simple sets which is $2^n-2$ so the answer is equal to $2^n+2^n-2=2^{n+1}-2$
The first row can be any of the $2^n$ members of $\{0,1\}^n$. Given the $k$'th row $(x_1, \ldots, x_n)$, the $k+1$'th row can always be $(1-x_1, \ldots, 1-x_n)$. The only other possibility is that the $k+1$'th row is $(x_1,\ldots, x_n)$, but only if the $k$'th row is alternating $(0,1,0,1,\ldots)$ or $(1,0,1,0,\ldots)$. Now use induction on the number of rows...