[Math] Weights of Binary Linear Code

coding-theory

I was looking at this problem related to coding theory: How do we know a linear code have even weight?

Can anyone explain how we know either all codewords have even weight or half the codewords have even weight and half have odd weight? This fact seems to just be stated without being proven…

Best Answer

Since the discussion in the comments between @GitGud and the OP seems to converging far too slowly to a solution, and since I wrote the answer wherein the statement in question occurred, here goes with a few hints for a different approach which will, along the way force you to learn some useful facts about binary vectors.

Suppose $\mathcal C$ denotes a linear binary code. Partition $\mathcal C$ into two subsets $\mathcal C_0$ and $\mathcal C_1$ consisting respectively of all the codewords of even Hamming weight and all the codewords of odd Hamming weight.

  • Show that for every linear binary code, $\mathcal C_0$ is a non-empty set. Hint: find a codeword of even weight in $\mathcal C$. (Subhint: $0$ is an even integer).

  • Explain why if $\mathcal C_1$ is an empty set, then we have proved part of the statement in question.

Digression:

  • Show that the sum of two binary vectors of even Hamming weight is a vector of even Hamming weight.

  • Show that the sum of two binary vectors of odd Hamming weight is also a vector of even Hamming weight.

  • Show that the sum of a binary vector of odd Hamming weight and a binary vector of even Hamming weight is a vector of odd Hamming weight.

End of digression

Suppose that $\mathcal C_1$ is non-empty and let $x$ denote a fixed element of $\mathcal C_1$.

  • Show that $x + \mathcal C_0 = \{z \colon z = x + y, y \in \mathcal C_0\}$ is a collection of $|\mathcal C_0|$ distinct vectors, all of which have odd Hamming weight. Argue that $x + \mathcal C_0 \subset \mathcal C_1$ and so it must be that $|\mathcal C_1| \geq |\mathcal C_0|$.

  • Show that $x + \mathcal C_1 = \{u \colon u = x + v, v \in \mathcal C_1\}$ is a collection of $|\mathcal C_1|$ distinct vectors all of which have even Hamming weight. Argue that $x + \mathcal C_1 \subset \mathcal C_0$ and hence $|\mathcal C_1| \leq |\mathcal C_0|$.

Conclude, if you dare, that either $\mathcal C_1 = \emptyset$ and so all the codewords in $\mathcal C$ have even Hamming weight, or that $\mathcal C$ contains codewords of even Hamming weight as well as odd Hamming weight and that $$|\mathcal C_1| = |\mathcal C_0| = \frac 12 |\mathcal C|.$$