Dicke State Preparation#

dicke_state(qv: QuantumVariable | Sequence[Qubit], k: int | Array, *, method: Literal['deterministic', 'divide-and-conquer'] = 'deterministic') None[source]#

Prepare a Dicke state \(|D^n_k\rangle\) on a QuantumVariable.

A Dicke state is the equal superposition of all basis states of Hamming weight \(k\) on \(n\) qubits, where \(n\) is the number of qubits of qv.

qv has to be initialized to the basis state \(|0\rangle^{\otimes n-l}|1\rangle^{\otimes l}\) beforehand, as in the example below. "divide-and-conquer" requires \(l = k\); "deterministic" accepts any \(l \leq k\) (see method).

Parameters:
qvQuantumVariable or Sequence[Qubit]

The qubits to prepare, initialized as described above.

kint

The Hamming weight (i.e. the number of “ones”) of the desired Dicke state.

method{“deterministic”, “divide-and-conquer”}, optional

Either "deterministic" (arXiv:1904.07358, the default) or "divide-and-conquer" (arXiv:2112.12435). The latter prepares the two halves of qv on disjoint qubits and therefore has roughly half the circuit depth. The former is the full Dicke state unitary \(U_{n,k}\): it also maps an input of Hamming weight \(l \leq k\) to \(|D^n_l\rangle\), and superpositions of such inputs to the corresponding superposition of Dicke states.

Raises:
ValueError

If method is unknown, or if k and \(n\) are plain Python integers (i.e. outside of tracing) and violate \(0 \leq k \leq n\).

Examples

We initialize a QuantumVariable in the “0011” state and from this create the Dicke state with Hamming weight 2.

from qrisp import QuantumVariable, x, dicke_state

qv = QuantumVariable(4)
x(qv[2])
x(qv[3])

dicke_state(qv, 2)

print(qv)

Under Jasp, the Hamming weight may be a traced value. Here we prepare the same state with the shallower divide-and-conquer circuit.

from qrisp import QuantumVariable, x, dicke_state
from qrisp.jasp import jrange, terminal_sampling

@terminal_sampling
def main(k):
    qv = QuantumVariable(4)
    for i in jrange(4 - k, 4):
        x(qv[i])
    dicke_state(qv, k, method="divide-and-conquer")
    return qv

print(main(2))