# The parity of the sum of a multiset (of integers) and of the cardinality of the odd submultiset are equal

This is a fairly simple concept, yet surprisingly difficult [for me] to state simply.

Given a multiset of integers, $M$, of finite (but arbitrary) cardinality.

And, $S_m$ is the sum over the elements of $M$, $S_m=\Sigma M$

And, $O_m$ is a submultiset of $M$ containing only the elements of $M$ that are odd.

Is there a formal proof that shows that $parity(S_m) = parity(|O_m|)$ ?

A few years ago I mentioned to a colleague that if all he wanted to do was compute the parity of the sum of (large integer) values in a distributed data source then it would not be necessary to first collect all the values, one could just sum the sums. It then struck me that even this was not necessary as the parity of the sum would be even if the collected multiset had an even number of odd numbers, and odd otherwise.

This might not sound like much of a win, but it has a few advantages:

1. You only need to check, and keep track of, the parity of a list by flipping a bit if a new number is odd.
2. Due to the self-similar nature each distributed system needs only report whether it is itself even or odd.

Since the time this idea first sprung to mind I have periodically searched the internet for a formal proof, without success.

I know that a proof must either exist, or should be easily constructed given the following:

1. The sum of a finite number of even integers is even.

2. The sum of two integers is odd $iff$ one summand is odd, and even otherwise.

I can think of at least three, rather inelegant, informal proofs, with the simplest being:

Successive odd values can be paired together, if all pair up (even number of odd values) then the sum would be even (from 1). If one value remains unpaired then it is odd (from 2).

I would like to see an elegant, or at least formal, proof of this rather simple idea.

• I added a number theory tag. If you had included that then likely you would not have needed to wait $6$ years for an answer! Nov 14, 2021 at 0:49
• @BillDubuque, if I knew enough to do that I may not have needed to ask in the first place :) as evidenced by me not even knowing what branch this question would belong to. Nov 21, 2021 at 21:39
• One way is to google "parity math" leading to the Wikipedia page on parity - which mentions "number theory". Nov 21, 2021 at 21:43

Yes, arithmetic $$\!\bmod 2\,$$ shows a sum has parity = number $$\rm\color{#c00}N$$ of odd summands:
\begin{align}\bmod 2\!:\,\ \overbrace{E_{\:\!i} \equiv 0}^{\large \rm evens},\ \overbrace{O_i\equiv 1}^{\large\rm odds}\ \Rightarrow\ & E_1\!+\cdots +E_k\!+O_1+\cdots+ O_{\color{#c00}N}\\[.2em] \equiv\,\ &\ 0\,+\cdots+\ 0\ +\ 1\,\ +\cdots+\ 1\\[.2em] \equiv \,\ &\rm\: \color{#c00}N \end{align}\qquad
Remark  To be 'formal' per you request: we used the Congruence Sum Rule multiple times above, to replace a summand by a congruent summand, viz. evens $$\, E_{\:\!i}\equiv 0,\,$$ and odds $$\,O_i\equiv 1.\,$$ Even more formally we can recast the above into a rigorous induction on the the number of summands.