Hi everyone, I am studying calculus right now from a book called ''The Principles of Mathematical Analysis'' by Walter Rudin

The subject is Real and Complex number systems. And I didn't understand some paragraphs.I attached a picture, you can see there the paragraph.I understood the first 3 paragraphs where he proves that p2=2 there is no rational p that satisfies because if p=m/n=2 , a rational number m can be divided by 4 and n can be divided 2 therefore it's not a rational number according to the definition of rational number.

Now the part that I didn't really understand is after that , the paragraph that starts ''We examine the situation closely..'' and the rest of the text. I didn't understand how he came to those 2 equations that defined p and q. And how he proved that there is a q>p in group A and in group B there is q<p.

I would appreciate if someone can help me understand this part.Thanks.