Unless otherwise stated, we work in Q[X]. Since the case degf=1 is easily dealt with, let degf≥2 and write f(X2)=gh, where g and h both have a positive degree, and g is irreducible. Next, write g=a(X2)+Xb(X2) and h=c(X2)+Xd(X2) to infer (from f(X2)=gh by an obvious argument on the parity of degrees) that
ad+bc=0,(1)
so f=ac+Xbd, whence
af=(a2−Xb2)c.(2)
We now show that a and b are coprime. Alternatively, but equivalently, δ=gcd(a,b) is a constant. To this end, write a=a1δ and b=b1δ, and refer to the irreducibility of g to deduce that δ(X2) is either associated with g, a case to be ruled out in the sequel, or a constant, in which case we are through.
In the former case, a1(X2)+Xb1(X2) is a constant, so b1=0, whence b=0 and g=a(X2), and (1) forces one of a and d to be 0. The fact that g is not constant rules out the case a=0, so d=0, f=ac and h=c(X2). Since f is irreducible,
one of a and c must be a constant, hence so must be one of g and h — a contradiction, since both have a positive degree. Incidentally, notice that we have just proved that b=0.
Notice further that a and X are also coprime: otherwise, a(0)=0, so g(0)=0, hence f(0)=0, contradicting the fact that f is irreducible and degf≥2.
Consequently, a and a2−Xb2 are coprime, so a divides c by (2), and f=(a2−Xb2)c1 for some c1 in Q[X]. Since f is irreducible, one of a2−Xb2 and c1 must be a constant. Since b=0 by the remark at the end of the last but one paragraph, a2−Xb2 cannot be constant, so c1 is a constant.
From now on we work in Z[X]. By the preceding, nf=m(u2−Xv2) for some integers m and n, and some u and v in Z[X]. Fix a prime integer p and write m=pμm1, n=pνn1, u=pαu1, v=pβv1, where α,β,μ,ν are non-negative integers, and none of m1,n1,u1,v1 is divisible by p. To make a choice, let α≤β; the case α>β is dealt with similarly. Since f is primitive, the relation
pνn1f=pμ+2αm1(u12−Xp2(β−α)v12)
implies that ν≥μ+2α. If we show that ν=μ+2α, we are through.
Suppose, if possible, that ν>μ+2α, to deduce that p divides u12−Xp2(β−α)v12, so it also divides u12(X2)−X2p2(β−α)v12(X2)=(u1(X2)−Xpβ−αv1(X2))(u1(X2)+Xpβ−αv1(X2)). Since p is prime, it must divide one of u1(X2)±Xpβ−αv1(X2), and an obvious argument on the parity of degrees shows that u1(X2) must be divisible by p, and hence so must be u1 — a contradiction which concludes the proof.