Binary addition preserving Hamming weights

680 Views Asked by At

Let $x,y$ be two $n$-bit strings, with Hamming weights (number of $1$ bits) equal to $w_{1},w_{2}$, respectively. Let $z$ be the binary representation of the sum $x+y$, where we interpret $x$ and $y$ as binary numbers. If the two strings $x$ and $y$ do not share a position where they both have a $1$ (that is, if there is no $1\leq{}i\leq{}n$ such that the $i^{th}$ bits of both $x$ and $y$ are $1$) then it is clear that the Hamming weight of $z$ is exactly $w_{1}+w_{2}$.

My question is: is the converse also true? Is it true that if the Hamming weight of the binary representation $z$ of the sum $x+y$ is exactly $w_{1}+w_{2}$, then $x$ and $y$ do not share a position where they both have a $1$?

This looks to be true to me, but how does one go about proving this? I tried arguing about how a carry during addition would mess things up, but this gets messy soon. Perhaps a correct induction hypothesis is what I am missing here?

1

There are 1 best solutions below

1
On

Let $ N= \{0,1,...,n-1\}$, $ I_Z(i) $ be the characteristic function of $ Z \subseteq N $, $ a=\{ I_A(i)\}_i, $ $ b=\{ I_B(i)\}_i, $ $w(a)=|A|, w(b)=|B|, w(a+b)=|A\cup B|.$ So $ |A\cup B|=|A|+|B| \Leftrightarrow A\cap B=\oslash. $