How can a Hamiltonian determine the Hilbert space? Sometimes, when discussing quantum field theory, people speak as if a Hamiltonian determines what the Hilbert space is. For example, in this answer AccidentalFourierTransform says

Imagine an $H_0$ that depends on the phase space variables $P$,$X$. [...] If you add the perturbation $\vec{L} \cdot \vec{S}$, with $\vec{S}$ the spin of the particle, then you change the Hilbert space, because the new space has three phase space variables $P,X,S$, and you cannot span the latter with a basis of the former.

This kind of language also pops up when introducing the free scalar field -- lots of lecture notes and textbooks speak of 'building' or 'constructing' the Hilbert space, or 'finding' the 'Hilbert space of the Hamiltonian'.
This kind of reasoning seems exactly backwards to me. How can one possibly define a Hamiltonian, i.e. an operator on a Hilbert space, if we don't know the Hilbert space beforehand? Without a Hilbert space specified, isn't $H = p^2/2m + V(x)$ just a meaningless string of letters with no mathematical definition? I find this shift of perspective so bewildering that I feel like I missed a lecture that everybody else went to.
For example, when dealing with the harmonic oscillator, it is possible to show that the Hilbert space must contain copies of $\{|0 \rangle, |1 \rangle, \ldots \}$ using only the commutation relations. But there's no way to pin down how many copies there are unless we use the fact that the Hilbert space is actually $L^2(\mathbb{R})$ which shows that $a |0 \rangle = 0$ determines a unique state. Similarly I would imagine for quantum fields we should start with a Hilbert space where the individual states are classical field configurations, but I've never seen this done in practice -- there seems to be no input but the Hamiltonian itself. How could that possibly be enough?
 A: The point is that sometimes one starts from a more or less explicit algebraic formalism where only algebraic manipulations of algebra elements are initially used. Here operators are not operators in a precise Hilbert space, but just elements of a unital $^*$-algebra and only compositions (multiplication with scalars, sum and algebra product) and the involution operation (formal adjoint) are used. Next one sees if this algebra, with further technical conditions (some operator must be self-adjoint, some representation must be irreducible) or physical requirements (a suitable state exists) uniquely determine  a Hilbert space where this algebra is faithfully represented in terms of operators with suitable domains. 
For instance, the algebra of $a,a^*$ completely determines the standard harmonic oscillator representation in $L^2(\mathbb R, dx)$ if assuming that $a^*a$ is essentially self-adjoint on a dense common invariant domain and the arising representation is irreducible. 
In QFT as soon as one has an algebraic version of field operators, a state construct the Hilbert space representation through the GNS reconstruction theorem for instance.
Sometime some hypotheses turn out to be incompatible as it happens for the case of Haag's theorem.
In summary, the Hamiltonian itself, viewed as an element of a unital $^*$-algebra is not enough to determine a Hilbert space where the theory can be implemented in the standard way, the whole algebra should to be fixed and more information is usually necessary.
