The Hilbert space of a gauge theory is defined by BRST symmetry. In the path integral formalism, it is necessary to introduce ghosts in order to fix the gauge for a non-abelian theory. This theory now contains states of negative norm, hence it is a pseudo-Hilbert space. The Lagrangian of this theory has an additional symmetry, i.e. a symmetry in which the ghost fields act as infinitesimal parameters. Associated with this symmetry are both a Noether current and a Noether charge, the latter is referred to as the BRST charge. The BRST charge is a nilpotent operator, i.e. $Q^2=0$. This behaviour allows one to speak of a cohomology, which can be understood as follows: Since the BRST charge is a quantum operator, we can ask ourselves what happens when we let it act on some state $|\Psi\rangle$. Since the operator $Q$ is nilpotent, $Q|\Psi\rangle=0$ if $|\Psi\rangle$ can be written as $|\Psi\rangle=Q|\Phi\rangle$, i.e. $$Q|\Psi\rangle=Q^2|\Phi\rangle=0.$$ But there is also the possibility of states vanishing under the action of the BRST charge without them being defined by $Q|\Phi\rangle$. Such states are said to be in the cohomology of the charge operator. They are identified as the physical states of the theory and do not contain ghosts or antighosts. Furthermore, one can argue that the cohomology does not change under unitary time evolution due to the fact that the Hamiltonian commutes with $Q$. The BRST formalism also works for string theory, which contains spin 2 particles, i.e. gravitons.