Rational Diophantine set for the non-squares

Related to Hilbert's Tenth problem.

Is there polynomial with integer coefficients $$P(a,x_1,...,x_n)$$ such that $$P(A,X_i)=0$$ has rational solutions $$X_i$$ iff $$A$$ is not the square of integer (or as another question not the square of rational)?

We think if $$P$$ is homogeneous and ask about integer solutions, scaling the solution might cause problems: $$A^2,A X_1, A X_2, ...$$

Over the integers solution is trivial via Pell equation:

$$(2+x_1^2+x_2^2+x_3^2+x_4^2)^2- a x_5^2=1$$

• I guess the intended meaning is "Is there $n$ and $P\in\mathbf{Z}[a,x_1,\dots,x_n]$ such that for every $A\in\mathbf{Q}$, there exists $X\in\mathbf{Q}^n$ such that $P(A,X)=0$ iff $A$ is the square of an integer"? – YCor Oct 15 '19 at 11:54
• @YCor No, I don't ask about this. The part after "iff" is A is NOT the square of integer. The rest of the comment is correct. – joro Oct 15 '19 at 12:05
• OK thanks (and sorry, actually I focussed on the first quantifiers). – YCor Oct 15 '19 at 12:11
• How about some easier sets? Like "$A>5$? – Mark Sapir Oct 15 '19 at 21:07
• $A>5$ is too easy: $P = Q^2 + R^2$ where $$Q = (A-5) (x_1^2 + x_2^2 + x_3^2 + x_4^2) - (x_5^2 + x_6^2 + x_7^2 + x_8^2)$$ and $R = (A-5) x_9 - 1$. – Noam D. Elkies Oct 15 '19 at 21:40

The set $$A$$ of non-squares (of rationals) is Diophantine in $$\mathbb{Q}$$ by [1]. The set $$B:=\mathbb{Q}\smallsetminus\mathbb{Z}$$ is also Diophantine by [2]. The set of non-squares of integers is equal to $$A\cup B$$, hence Diophantine.

[EDIT] The paper [1] treats arbitrary (non-)$$n$$-th powers, but the case of (non-)squares was proved earlier by Poonen [4].

[1] Colliot-Thélène, Jean-Louis; van Geel, Jan, Le complémentaire des puissances $$n$$-ièmes dans un corps de nombres est un ensemble diophantien, Compos. Math. 151, No. 10, 1965-1980 (2015). ZBL1346.14066..

[2] Koenigsmann, Jochen, Defining $$\mathbb Z$$ in $$\mathbb Q$$, Ann. Math. (2) 183, No. 1, 73-93 (2016). ZBL1390.03032..

[3] Dittmann, Philip, Irreducibility of polynomials over global fields is diophantine, Compos. Math. 154, 761-772 (2018). ZBL06861881.

[4] Poonen, Bjorn, The set of nonsquares in a number field is diophantine, Math. Res. Lett. 16, No. 1, 165-170 (2009). ZBL1183.14031.

• Thank you. This appears to solve an open problem: mathoverflow.net/questions/199191/… – joro Oct 16 '19 at 13:50
• @joro Yes, very good point! – Laurent Moret-Bailly Oct 16 '19 at 13:54
• A comment in the other question doubts correctness about the other question, is it valid? – joro Oct 16 '19 at 15:35