To justify the "equating like parts", use the following result.
If a,b,c,d are rationals, c,d >= 0 and c is not the square of a rational, then
a+sqrt(c)=b+sqrt(d)
implies a=b and c=d.
Proof:
Note that if we either have a=b or c=d that the other equality falls out immediately, so let us...