# How to write the state associated to a family of stabilizers

The answer is probably obvious but I am missing something.

Let's say I have a quantum state $$|\psi \rangle$$ on $$n$$ qubits stabilized by $$n$$ Pauli operators $$\{g_1,...,g_n\}$$.

My question is: How can I express this quantum state as a function of the stabilizers?

The motivations behind my question are that in this paper, on page 11 right after the beginning of the part A, they claim that a pure state stabilized by a family $$\{g_1,...,g_n\}$$ can be written in density matrix form as ( * ):

$$|\psi\rangle \langle \psi |=\frac{1}{2^n} \prod_{i=1}^n (1+g_i)$$

I am not understanding this. For me, this equation only implies that $$|\psi\rangle$$ will necessarily be stabilized by $$\pm g_i$$ but we do not know if it is a $$+$$ or a $$-$$.

For instance, I can show that $$|\psi\rangle$$ will be stabilized by any $$\pm g_k$$ ($$k \in [1,n]$$) because, first (I use $$g_k^{\dagger}=g_k$$ as it is an $$n$$-Pauli operator):

$$\pm g_k |\psi \rangle \langle \psi | (\pm g_k^{\dagger}) = g_k |\psi \rangle \langle \psi | g_k^{\dagger}=\frac{1}{2^n} \left(\prod_{i\neq k}^{n} (1+g_i) \right) g_k (1+g_k)g_k^{\dagger}=|\psi \rangle \langle \psi |$$

And then, for $$A$$ unitary, $$A |\psi \rangle \langle \psi | A^{\dagger} = |\psi \rangle \langle \psi | \Rightarrow A |\psi \rangle = e^{j \phi} |\psi\rangle$$. Then, as $$A=g_k$$ is also Hermitian, $$e^{j \phi}=\pm 1$$, hence $$|\psi\rangle$$ is stabilized by $$\pm g_k$$.

So, in the end, how can we write a nice expression for a quantum state, knowing its stabilizers?

( * ): Maybe I am wrongly interpreting what they say though.

Note that $$(1+g_k)/2$$ is the projection onto the $$+1$$ eigen-subspace of $$g_k$$, which is why that expression from the paper works. If $$|\psi \rangle$$ was stabilized by $$-g_k$$ instead of $$g_k$$, you had to have $$(1-g_k)$$ in that expression instead of $$(1+g_k)$$.

As for your proof, it only shows $$g_k|\psi \rangle$$ is either $$+|\psi\rangle$$ or $$-|\psi\rangle$$. To see it can not be the latter, assume $$g_k|\psi\rangle=-|\psi\rangle$$, which means $$(1+g_k)|\psi\rangle=0$$, but it means $$|\psi\rangle\langle \psi|\psi\rangle=1/2^n \prod_k (1+g_k)|\psi\rangle =0$$. Therefore $$|\psi\rangle$$ should be the $$+1$$ eigen state.

• Thanks a lot, you clarified what confused me! Apr 21, 2022 at 18:17

When you apply the projector $$P + I$$, and $$P$$ only has eigenvalues of 1 and -1, only states in the +1 eigenstate of $$P$$ will remain, because the -1 eigenvalues were shifted up to 0 by adding the identity. So the eigenspaces with eigenvalue -1 get scaled by a factor of 0; they are projected away when doing the multiplication. This is why the expression you listed at the start is correct.

In Stim, this method is exactly how it converts stabilizers into state vectors. It generates a random state vector and then multiplies it by $$P + I$$ for each stabilizer generator $$P$$ and then renormalizes the state vector to have unit length.

VectorSimulator VectorSimulator::from_stabilizers(const std::vector<PauliStringRef> &stabilizers, std::mt19937_64 &rng) {
size_t num_qubits = stabilizers.empty() ? 0 : stabilizers.num_qubits;
VectorSimulator result(num_qubits);

// Random state almost certainly overlaps the desired state.
std::uniform_real_distribution<float> dist(-1.0, +1.0);
for (auto &s : result.state) {
s = {dist(rng), dist(rng)};
}

// Project out the non-overlapping parts.
for (const auto &p : stabilizers) {
result.project(p);
}
if (stabilizers.empty()) {
result.project(PauliString(0));
}

return result;
}

• Ok thanks, I see. That's a detail but I guess you also have to check that this random input state vector must not be a stabilizer state (to avoid having the $0$ vector after a projection for some stabilizer if it appeared to be in the $-1$ eigenspace of some stabilizer) Apr 21, 2022 at 18:17
• @StarBucK Yes, it's possible to get very unlucky and pick a state that is perpendicular to the desired output. But it's actually incredibly unlucky for that to happen. And in fact the whole process is surprisingly numerically stable, because the stabilizers are balanced yes/no projections and are all independent so order can't matter much. Apr 21, 2022 at 18:24
• For example, consider if all the generators were Z products. Then the only way for the process to fail is for there to be exactly 0 amplitude on the single satisfying state, which is going to occur less than once per ten million invocations. ... actually, that's a bit high for a computer program I should probably make it retry 10 times so it fails less than once per trillion trillion trillion trillion trillion invocations. Apr 21, 2022 at 19:08
• Yes of course it is very highly unlikely to happen. This was my way to be sure to fully understand your approach! Thanks again! Apr 22, 2022 at 9:16

This answer is a complement to the answer provided by Seyed. Here is an explicit proof.

Let's assume that $$\rho=\prod_{k=1}^n \Pi_k$$, where $$\rho=|\psi\rangle\langle \psi |$$ and $$\{\Pi_k\}_k$$ is a family of projector which commute pairwise.

We can easily show that for any $$p \in [1,n]:$$ $$\Pi_p |\psi\rangle = |\psi \rangle$$. Indeed:

$$\Pi_p |\psi \rangle = \Pi_p |\psi \rangle \langle \psi| \psi \rangle=\Pi_p \left(\prod_{k=1}^n \Pi_k \right)| \psi \rangle=\left(\prod_{k=1}^n \Pi_k \right) |\psi \rangle = |\psi\rangle \langle \psi | \psi \rangle = |\psi \rangle$$

Where the right handside of the third equality used the fact that $$[\Pi_{k \neq p},\Pi_p]=0$$ and $$(\Pi_p)^2=\Pi_p$$ because it is a projector.

The question asked is a particular case where $$\Pi_k = (1+g_k)/2$$ which projects on the $$+1$$ eigenspace of the Pauli $$g_k$$.