ZKSF logo, a neon quantum brainZKSF
← All articles

Quantum Entanglement Explained: Build a GHZ State and Run It

Last updated · 12 min read · ZKSF team

Open in Colab

Run this one yourself. The notebook builds the circuit and reads the certificate for the run below, with no account and nothing to install.

The short version

  • Two gates build it. A Hadamard puts the first qubit in superposition and a chain of CNOTs carries that superposition to the rest
  • The proof is short. Matching coefficients shows no product decomposition exists, so neither qubit has a state of its own
  • 1,000 shots returned only 000 and 111. The measured 531/469 split is ordinary shot noise against an ideal 500/500
  • What is absent is the result. No shot returned 001, 010 or any other intermediate string, which is the observable signature of entanglement

Entanglement is the property that separates quantum computation from an expensive classical simulation of itself. This article constructs the canonical entangled states, the Bell state on two qubits and the GHZ state on three or more, explains the mechanism by which the circuit produces them, and reports a certified run of the exact circuit given below.

What entanglement is, stated precisely

A composite state is entangled when it cannot be written as a product of states of its parts. That is the definition, and it is worth preferring over the usual informal descriptions because it is checkable.

Consider two qubits in the state (|00> + |11>)/sqrt(2). Suppose it could be written as a product (a|0> + b|1>) tensor (c|0> + d|1>).

Expanding gives ac|00> + ad|01> + bc|10> + bd|11>. Matching coefficients requires ad = 0 and bc = 0, so either a or d vanishes and either b or c vanishes; any such choice forces ac or bd to vanish as well, contradicting the requirement that both equal 1/sqrt(2).

No product decomposition exists. The state is entangled, and the argument is a short proof rather than an appeal to intuition.

The physical consequence is that neither qubit has a state of its own. The pair has one description, and measuring either member yields 0 or 1 with equal probability while fixing the other outcome. This correlation is stronger than any classical model with pre-assigned values can reproduce, which is the content of Bell's theorem and has been confirmed experimentally under increasingly strict conditions, work recognised by the 2022 Nobel Prize in Physics.

A GHZ state, named for Greenberger, Horne and Zeilinger, generalises this to three or more qubits: an equal superposition of all-zeros and all-ones. Every qubit is bound into a single indivisible whole, and the register commits to 000 or 111 together.

The circuit, and why it works

Two gates suffice. The Hadamard maps |0> to (|0> + |1>)/sqrt(2), placing a qubit in equal superposition. The CNOT flips its target when its control is |1| and leaves it alone otherwise.

The mechanism is worth following carefully, because it is the point where the classical intuition fails. Applying H to the first qubit of |00> gives (|00> + |10>)/sqrt(2), which is still a product state. The first qubit is in superposition, the second is definitely zero. Applying CNOT then maps |00> to |00> and |10> to |11>, giving (|00> + |11>)/sqrt(2).

The essential feature is that CNOT acts on the superposition as a whole rather than on a definite value. It does not copy the first qubit, which the no-cloning theorem forbids. It correlates the two, and correlation of a superposition is entanglement. Chaining further CNOTs along the register propagates the correlation to every qubit and produces a GHZ state of any width.

OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
creg c[3];
h q[0];
cx q[0],q[1];
cx q[1],q[2];
measure q -> c;
GHZ state circuit diagram: a Hadamard on q0 followed by a chain of CNOTs entangling q1 and q2, then measurement
GHZ state circuit diagram: a Hadamard on q0 followed by a chain of CNOTs entangling q1 and q2, then measurement

Read the diagram left to right as time. The cyan box is the Hadamard that creates the superposition. The emerald dots and crosses are the CNOTs: a filled dot marks the control, the circled cross marks the target it flips. The dials on the right are measurements.

The four Bell states

The two-qubit case has exactly four maximally entangled states, forming an orthonormal basis of the two-qubit space. They are produced by the same H-then-CNOT circuit applied to the four computational basis inputs.

Input   Circuit output                    Name
 |00>   (|00> + |11>)/sqrt(2)             Phi+
 |10>   (|00> - |11>)/sqrt(2)             Phi-
 |01>   (|01> + |10>)/sqrt(2)             Psi+
 |11>   (|01> - |10>)/sqrt(2)             Psi-

That these four span the space is what makes Bell-basis measurement possible, and that measurement is the operation underlying quantum teleportation and superdense coding. The teleportation protocol is worked through in the teleportation walkthrough.

A certified run

The circuit above was submitted at 1,000 shots. The router inspected the gate list, found every gate Clifford, and dispatched the job to the Stim stabilizer engine, which simulates such circuits exactly at any width.

counts:     {"000": 531, "111": 469}
error_info: {"method": "stabilizer (Gottesman-Knill)",
             "truncation_error": 0.0,
             "shot_noise_only": true, "shots": 1000}

A perfect GHZ state collapses to 000 or 111 with equal probability, so the ideal split over 1,000 shots is 500/500. The measured 531/469 is ordinary shot noise. The standard deviation of a fair binomial at n = 1000 is about 16, so a deviation of 31 is roughly two sigma and unremarkable.

The three qubits always agreed, which is the observable signature of entanglement as distinct from three independently random bits. Because the stabilizer method is exact, the run carries a truncation error of exactly zero and a public ZCC-v0.1 certificate that resolves without an account.

The GHZ / Bell state template in the ZKSF Android app, with its OpenQASM source and the circuit preview it produces
The GHZ / Bell state template in the ZKSF Android app, with its OpenQASM source and the circuit preview it produces. Get the Android app

Why the same circuit runs at 5,000 qubits

A point worth drawing out, because it contradicts a common assumption. This circuit is maximally entangled in the sense that the state cannot be factored at all, and yet it simulates trivially at any width: a 5,000-qubit GHZ state with 5,000 layers of depth completes in 0.56 seconds.

The reason is that entanglement is not the resource that makes classical simulation hard. Every gate here is Clifford, and the Gottesman-Knill theorem guarantees polynomial-time classical simulation of Clifford circuits regardless of how entangled the resulting states are.

What makes simulation hard is non-Clifford resource, commonly called magic, and a GHZ circuit contains none. The argument is developed in Clifford circuits and Stim.

This is the single most useful correction to make early: entangled does not imply hard, and wide does not imply expensive.

Where GHZ states are used

  • Quantum error correction. Stabilizer codes protect a logical qubit inside an entangled block of physical qubits, and GHZ-like states appear throughout syndrome extraction
  • Metrology. An N-qubit GHZ state accumulates phase N times faster than a single qubit, giving a sensitivity scaling as 1/N, the Heisenberg limit, against the 1/sqrt(N) standard quantum limit available to any classical probe
  • Foundational tests. GHZ states refute local hidden-variable theories deterministically, with a single measurement outcome rather than a statistical inequality, which is a sharper argument than the two-qubit Bell case
  • Hardware benchmarking. GHZ fidelity is a standard device metric precisely because the ideal result is classically computable and the state is maximally fragile to decoherence

Running it

GHZ is the first of the ready-to-run templates in the console. Open the app, select GHZ / Bell state, and run it. Extend the CNOT chain to four, five, or five thousand qubits and observe that the certificate continues to hold and the wall time grows quadratically rather than exponentially.

For an algorithm rather than a state, Bernstein-Vazirani recovers a hidden bitstring in one query, and Grover's search demonstrates amplitude amplification.

Common questions

What is a GHZ state?

A GHZ state is the n-qubit generalisation of a Bell pair. Every qubit is entangled with every other, so measuring one determines all the rest. For three qubits it is an equal superposition of 000 and 111 and nothing else, which is why a correct run returns only those two outcomes, at roughly half each. It is the standard test circuit for entanglement because any deviation from that two-outcome split is a direct measure of device error.

How do you build a GHZ state circuit?

One Hadamard followed by a chain of CNOTs. The Hadamard puts the first qubit in superposition, and each CNOT copies that superposition onto the next qubit, so an n-qubit GHZ state needs one Hadamard and n-1 CNOTs. That shallow structure is exactly why it is the circuit everyone uses to benchmark hardware. The ideal answer is known, so the gap between the ideal and the measured counts is the machine's error.

Run your own 100-qubit circuit, with an error bar.

Share this articleLink copied