Cirq Fundamentals

Lesson 4 of 8

Entanglement and Bell States

The same H + CNOT combination that builds a Bell state in Qiskit builds one in Cirq too, entanglement is a property of the physics, not of any particular SDK.

Building and inspecting a Bell state

import cirq

q0, q1 = cirq.LineQubit.range(2)

circuit = cirq.Circuit([
    cirq.H(q0),
    cirq.CNOT(q0, q1),
])

simulator = cirq.Simulator()
result = simulator.simulate(circuit)
print(result.dirac_notation())
print(abs(result.final_state_vector) ** 2)  # ~[0.5, 0, 0, 0.5] for |00>, |01>, |10>, |11>

The probability vector has 4 entries, one per possible 2-qubit outcome in order 00, 01, 10, 11. Just like Qiskit's Bell state, only 00 and 11 have non-zero probability, 01/10 are impossible: measure either qubit and you instantly know the other's outcome.

Verifying with repeated measurement

circuit_measured = cirq.Circuit([
    cirq.H(q0),
    cirq.CNOT(q0, q1),
    cirq.measure(q0, q1, key='result'),
])

result = simulator.run(circuit_measured, repetitions=1000)
print(result.histogram(key='result'))

cirq.measure(q0, q1, key='result') measures both qubits under one shared key, and .run(circuit, repetitions=1000) (Cirq's equivalent of Qiskit's shots) executes the circuit 1000 times. result.histogram(key='result') tallies the outcomes, covered in full in the next lesson.

TIP

Whichever SDK you use, the pattern for verifying entanglement is identical: build H + CNOT, run it many times, and confirm the "impossible" outcomes (01/10) never (or almost never, on noisy real hardware) appear.

📝 Entanglement and Bell States Quiz

Passing score: 70%
  1. 1.In the 4-entry probability vector [00, 01, 10, 11] for a Cirq Bell state, which entries are zero?

  2. 2.cirq.Simulator().run(circuit, repetitions=1000) is Cirq's equivalent of Qiskit's shots=1000.

  3. 3.Building a Bell state in any quantum SDK requires an H gate followed by a ____ gate.