I saw this post and wondered why the approach described in the accepted answer works. The same problem and solution is described a bit nicer here.
So let's say we receive a stream of $n-2$ pairwise different numbers $a_1 + a_2 + \cdots + a_{n-2}$, from the set $\left\{1,\dots,n\right\}$. What I learned from the above post is that for the problem of finding 2 missing numbers $x$ and $y$, given a stream as described above, can be solved by finding the solution to the following system of equations:
\begin{alignat*}{4} x+y & {}={} & \dfrac{n(n+1)}{2} - (a_1 + a_2 + \cdots + a_{n-2}) \\ x^2 + y^2 & {}={} & \dfrac{n(n+1)(2n+1)}{6} - (a_1^2 + a_2^2 + \cdots + a_{n-2}^2) \end{alignat*}
Now it is easy to convert this into a single pass algorithm which supposedly returns the two missing numbers for a given stream.
How would one prove this algorithm's correctness? I think showing that the system must have exactly two solutions would be enough to prove correctness but I'm not sure how to approach this?
How can I convince myself (and others) that the algorithm is correct?