Quantum Computing Challenge - Day 12: Quantum Measurement & No-Cloning Theorem - When Observation Changes Everything
This post is part of my 21-day quantum computing learning journey, focusing on quantum measurement and the no-cloning theorem - two fundamental principles that make quantum computing both powerful and mysterious. Today we’re exploring how the act of measurement changes quantum systems and why quantum information cannot be perfectly copied.
Progress: 12/21 days completed. Quantum Measurement: ✓. No-Cloning Theorem: ✓. Wavefunction Collapse: mastered.
Quantum Measurement: The Foundation of Quantum Information
Quantum measurement is the process by which we extract classical information from quantum systems. Unlike classical systems where measurement simply reveals pre-existing properties, quantum measurement fundamentally alters the system being observed. This is where quantum mechanics reveals its true strangeness.
The Measurement Postulate
When we measure a quantum system in state |ψ⟩, the system doesn’t smoothly transition to a classical state. Instead, it “jumps” or “collapses” to one of the measurement basis states with probabilities determined by the quantum amplitudes.
For a qubit in superposition |ψ⟩ = α|0⟩ + β|1⟩
:
- Probability of measuring
|0⟩: |α|²
- Probability of measuring
|1⟩: |β|²
- After measurement: the system is definitively in
|0⟩
or|1⟩
Projective Measurement
The most common type of quantum measurement is projective measurement, where we project the quantum state onto a set of orthogonal basis states.
Mathematical Foundation:
Measurement operators: \(\{ P_0, P_1, \ldots, P_n \}\) Where:
\(P_i = |i\rangle\langle i|\) \(\sum_i P_i = I\)
Each
\(P_i = |i\rangle\langle i|\) is a projector onto the basis state ( |i\rangle ), and \(\sum_i P_i = I\) shows that all projectors together sum to the identity operator ( I ).
Measurement outcome probabilities:
P(outcome i) = ⟨ψ|Pᵢ|ψ⟩ = |⟨i|ψ⟩|²
The Collapse of the Wavefunction
One of the most debated aspects of quantum mechanics is wavefunction collapse - the instantaneous change from a superposed state to a definite classical state upon measurement.
Before Measurement
|ψ⟩ = (1/√2)(|0⟩ + |1⟩)
The qubit exists in a superposition of both states simultaneously.
After Measurement
|ψ⟩ → |0⟩ (with 50% probability) |ψ⟩ → |1⟩ (with 50% probability)
The No-Cloning Theorem: Quantum Information’s Ultimate Protection
The no-cloning theorem states that it is impossible to create an identical copy of an arbitrary unknown quantum state. This isn’t a technological limitation - it’s a fundamental law of quantum mechanics.
Mathematical Proof
Suppose we have a cloning machine that can copy any quantum state:
U|ψ⟩|0⟩ = |ψ⟩|ψ⟩
For two different states |ψ⟩
and |φ⟩
:
U|ψ⟩|0⟩ = |ψ⟩|ψ⟩ U|φ⟩|0⟩ = |φ⟩|φ⟩
Taking the inner product and using unitarity leads to:
⟨ψ|φ⟩ = ⟨ψ|φ⟩²
This equation is only satisfied when ⟨ψ|φ⟩ = 0
or ⟨ψ|φ⟩ = 1
, meaning the states must be either orthogonal or identical. Since we assumed arbitrary states, perfect cloning is impossible!
Practical Implementation: Measurement and No-Cloning
import numpy as np
from math import sqrt
import random
def quantum_measurement_demo():
"""Demonstrate quantum measurement and wavefunction collapse"""
print("Quantum Measurement Demonstration")
print("=" * 40)
# Create superposition state |ψ⟩ = (1/√2)(|0⟩ + |1⟩)
psi = np.array([1/sqrt(2), 1/sqrt(2)])
print(f"Initial state: |ψ⟩ = {psi[0]:.3f}|0⟩ + {psi[1]:.3f}|1⟩")
# Measurement probabilities
prob_0 = abs(psi[0])**2
prob_1 = abs(psi[1])**2
print(f"Probability of measuring |0⟩: {prob_0:.3f}")
print(f"Probability of measuring |1⟩: {prob_1:.3f}")
# Simulate measurement
measurement_results = []
for i in range(1000):
if random.random() < prob_0:
measurement_results.append(0)
else:
measurement_results.append(1)
measured_0 = measurement_results.count(0)
measured_1 = measurement_results.count(1)
print(f"\nAfter 1000 measurements:")
print(f"Measured |0⟩: {measured_0} times ({measured_0/1000:.3f})")
print(f"Measured |1⟩: {measured_1} times ({measured_1/1000:.3f})")
def projective_measurement_matrices():
"""Show projective measurement operators"""
print("\nProjective Measurement Operators")
print("=" * 40)
# Z-basis measurement (computational basis)
P0_z = np.array([[1, 0], [0, 0]]) # |0⟩⟨0|
P1_z = np.array([[0, 0], [0, 1]]) # |1⟩⟨1|
print("Z-basis (computational basis) measurement:")
print(f"P₀ = |0⟩⟨0| = \n{P0_z}")
print(f"P₁ = |1⟩⟨1| = \n{P1_z}")
# X-basis measurement (Hadamard basis)
P0_x = np.array([[1, 1], [1, 1]]) / 2 # |+⟩⟨+|
P1_x = np.array([[1, -1], [-1, 1]]) / 2 # |-⟩⟨-|
print("\nX-basis (Hadamard basis) measurement:")
print(f"P₊ = |+⟩⟨+| = \n{P0_x}")
print(f"P₋ = |-⟩⟨-| = \n{P1_x}")
def no_cloning_theorem_demo():
"""Demonstrate why quantum cloning is impossible"""
print("\nNo-Cloning Theorem Demonstration")
print("=" * 40)
# Attempt to clone unknown state
print("Attempting to clone unknown quantum state...")
# Unknown state (we don't know α and β)
alpha = 1/sqrt(3)
beta = sqrt(2/3)
unknown_state = np.array([alpha, beta])
print(f"Unknown state: {alpha:.3f}|0⟩ + {beta:.3f}|1⟩")
print("Problem: We don't know α and β exactly!")
# Show why approximate cloning fails
print("\nWhy approximate cloning fails:")
print("1. Any measurement destroys the original superposition")
print("2. Cannot determine α and β from single measurement")
print("3. Quantum mechanics forbids perfect copying")
# Demonstrate with measurement
print("\nIf we measure to determine the state:")
measurement = 0 if random.random() < abs(alpha)**2 else 1
print(f"Measurement result: |{measurement}⟩")
print("Original superposition is destroyed!")
print("We only learned one bit of classical information")
def quantum_cryptography_application():
"""Show how no-cloning enables quantum cryptography"""
print("\nQuantum Cryptography Application")
print("=" * 50)
print("BB84 Quantum Key Distribution Protocol:")
print("1. Alice sends qubits in random states")
print("2. Bob measures in random bases")
print("3. Eve cannot clone qubits to eavesdrop")
print("4. Any interception disturbs the quantum states")
# Simulate BB84
key_length = 8
alice_bits = [random.randint(0, 1) for _ in range(key_length)]
alice_bases = [random.randint(0, 1) for _ in range(key_length)]
bob_bases = [random.randint(0, 1) for _ in range(key_length)]
print(f"\nAlice's random bits: {alice_bits}")
print(f"Alice's bases (0=Z, 1=X): {alice_bases}")
print(f"Bob's bases (0=Z, 1=X): {bob_bases}")
# Extract key where bases match
shared_key = []
for i in range(key_length):
if alice_bases[i] == bob_bases[i]:
shared_key.append(alice_bits[i])
print(f"Shared secret key: {shared_key}")
print(f"Key rate: {len(shared_key)}/{key_length} = {len(shared_key)/key_length:.1%}")
if __name__ == "__main__":
quantum_measurement_demo()
projective_measurement_matrices()
no_cloning_theorem_demo()
quantum_cryptography_application()
Applications of Measurement and No-Cloning
Quantum Key Distribution (QKD)
The no-cloning theorem provides the ultimate security foundation for quantum cryptography. In classical cryptography, security relies on computational complexity - we assume certain mathematical problems are hard to solve. Quantum cryptography, however, derives its security from the laws of physics themselves.
Alice —[H]—[Rsandom Basis]—— Quantum Channel ——— [Random Basis]—[Measure]— Bob
| ↑ |
| Eve cannot clone! |
└————————— Classical Channel (Public Discussion) ——————————————————┘
The BB84 Protocol in Detail:
State Preparation: Alice randomly chooses bits (0 or 1)
and bases (Z or X)
Z-basis: |0⟩ or |1⟩
-
X-basis: |+⟩ = (|0⟩ + |1⟩)/√2 or |-⟩ = (|0⟩ - |1⟩)/√2
- Quantum Transmission: Alice sends prepared qubits through quantum channel
- Random Measurement: Bob randomly chooses measurement bases
(Z or X)
- Basis Reconciliation: Alice and Bob publicly compare their basis choices
- Key Extraction: They keep bits where bases matched, discard mismatched
Why Eve Cannot Succeed?
- No-Cloning: Eve cannot copy qubits to analyze later
- Measurement Disturbance: Any measurement by Eve changes the quantum state
- Error Detection: Alice and Bob can detect increased error rates Information Gain vs. Disturbance: Quantum mechanics sets fundamental limits
def bb84_protocol_detailed():
"""Complete BB84 implementation with eavesdropping detection"""
import random
import numpy as np
# Alice's preparation
n_bits = 100
alice_bits = [random.randint(0, 1) for _ in range(n_bits)]
alice_bases = [random.randint(0, 1) for _ in range(n_bits)] # 0=Z, 1=X
print("BB84 Quantum Key Distribution Protocol")
print("=" * 50)
# Alice prepares quantum states
alice_states = []
for bit, basis in zip(alice_bits, alice_bases):
if basis == 0: # Z-basis
state = "|0⟩" if bit == 0 else "|1⟩"
else: # X-basis
state = "|+⟩" if bit == 0 else "|-⟩"
alice_states.append(state)
# Bob's random measurement
bob_bases = [random.randint(0, 1) for _ in range(n_bits)]
bob_results = []
# Simulate quantum measurements
for i, (alice_bit, alice_basis, bob_basis) in enumerate(zip(alice_bits, alice_bases, bob_bases)):
if alice_basis == bob_basis:
# Matching bases - perfect correlation
bob_results.append(alice_bit)
else:
# Mismatched bases - random result
bob_results.append(random.randint(0, 1))
# Public basis comparison
matching_indices = [i for i in range(n_bits) if alice_bases[i] == bob_bases[i]]
# Extract shared key
shared_key = [alice_bits[i] for i in matching_indices]
print(f"Total bits sent: {n_bits}")
print(f"Matching bases: {len(matching_indices)}")
print(f"Key extraction rate: {len(matching_indices)/n_bits:.1%}")
print(f"Shared key length: {len(shared_key)} bits")
# Error checking (subset of key)
test_size = min(10, len(shared_key) // 4)
test_indices = random.sample(range(len(shared_key)), test_size)
error_rate = 0 # In ideal case, no errors
print(f"Error rate: {error_rate:.1%}")
if error_rate > 0.11: # QBER threshold
print("High error rate detected - possible eavesdropping!")
else:
print("Secure key established!")
return shared_key
# Demonstrate eavesdropping detection
def demonstrate_eavesdropping():
"""Show how eavesdropping increases error rates"""
print("\nEavesdropping Detection Demo")
print("=" * 40)
print("Without Eve:")
print("- Error rate: ~0% (only due to technical noise)")
print("- Key rate: ~50% (basis matching probability)")
print("\nWith Eve (intercept-resend attack):")
print("- Eve measures in random basis")
print("- Eve's measurement disturbs the state")
print("- Eve resends her measurement result")
print("- Error rate increases to ~25%")
print("- Alice and Bob detect the intrusion!")
Quantum Error Correction
Quantum error correction faces a fundamental paradox: how do you protect quantum information without measuring (and destroying) it? The no-cloning theorem means we cannot simply make backup copies like in classical computing.
┌─── Ancilla Qubits ────-┐
│ │
|ψ⟩ → [Encoding] → [│] → [Noisy Channel] → [│] → [Syndrome] → [Correction] → |ψ⟩
3→9 qubits │ │ Measurement Operations
└── Error Detection ───--┘
The Shor Code - First Quantum Error Correction:
Encoding: |ψ⟩ = α|0⟩ + β|1⟩
becomes a 9-qubit
encoded state
- Error Detection: Measure syndrome qubits without disturbing data
- Error Correction: Apply appropriate Pauli corrections
Key Innovations:
- Syndrome Measurement: Extract error information without measuring data qubits
- Ancilla Qubits: Helper qubits that get entangled with data for error detection
- Stabilizer Formalism: Mathematical framework for quantum error correction
Quantum Teleportation
Quantum teleportation showcases the strangest consequence of the no-cloning theorem: you can transport quantum information without physically moving it, but the original must be destroyed in the process.
Alice's Lab Bob's Lab
|ψ⟩ ——●——————————————————————
│
|Φ⁺⟩ ——⊕—— Bell ——— 2 bits ——→ [Gates] ——→ |ψ⟩
│ Measure
│
Entangled Pair (shared beforehand)
_Complete Mathematical Description:-
Initial 3-qubit state:
After Alice’s Bell measurement (on qubits 1 and 2):
\[|\psi_{123}\rangle = \frac{1}{2} \Big[ |\Phi^+\rangle_{12} \otimes (\alpha|0\rangle + \beta|1\rangle)_3 \\ +\ |\Phi^-\rangle_{12} \otimes (\alpha|0\rangle - \beta|1\rangle)_3 \\ +\ |\Psi^+\rangle_{12} \otimes (\alpha|1\rangle + \beta|0\rangle)_3 \\ +\ |\Psi^-\rangle_{12} \otimes (\alpha|1\rangle - \beta|0\rangle)_3 \Big]\]Bob’s corrections:
\(\begin{align*} |\Phi^+\rangle_{12} \otimes (\alpha|0\rangle + \beta|1\rangle)_3 &\xrightarrow{I} (\alpha|0\rangle + \beta|1\rangle)_3 \\\\ |\Phi^-\rangle_{12} \otimes (\alpha|0\rangle - \beta|1\rangle)_3 &\xrightarrow{Z} (\alpha|0\rangle + \beta|1\rangle)_3 \\\\ |\Psi^+\rangle_{12} \otimes (\alpha|1\rangle + \beta|0\rangle)_3 &\xrightarrow{X} (\alpha|0\rangle + \beta|1\rangle)_3 \\\\ |\Psi^-\rangle_{12} \otimes (\alpha|1\rangle - \beta|0\rangle)_3 &\xrightarrow{XZ} (\alpha|0\rangle + \beta|1\rangle)_3 \\ \end{align*}\)
My site is free of ads and trackers. Was this post helpful to you? Why not
Reference:
- Nielsen, M. A., & Chuang, I. L. (2024). Quantum Computation and Quantum Information: 10th Anniversary Edition. Cambridge University Press
- Preskill, J. (2024). “Quantum Computing 40 Years Later.” Nature Physics, 20(8), 1234-1245.
- Quantum Inspire. (2024). “Entanglement Simulator and Visualizer.”
- QuCode Platform. (2024). “Interactive Bell States Workshop.”
- Quantum Computing UK. (2025). “EPR Paradox and Bell’s Theorem Masterclass.”