Algorithm guide · games
Mermin–Peres magic square
Two players share two Bell pairs and win every ideal round. Classical strategies win at most 8/9 across uniform row/column questions.
Circuit size: 4 qubits
XOR parity · Local questions and answers · Shared Bell pairs
Review quantum fundamentals →Notation used in this lesson
- |ψ⟩ and ⟨ψ|
- A state vector (ket) and its conjugate transpose (bra). ⟨a|b⟩ is their inner product.
- α, β and i
- α and β are complex amplitudes; i²=−1. A probability is the squared magnitude |α|².
- XOR, · and ⊗
- XOR adds bits modulo two. In s·x, multiply corresponding bits and XOR them. ⊗ combines registers or operations on different wires.
- U†, Σ and Tr
- U† is the adjoint (inverse for a unitary). Σ sums terms. Tr is the matrix trace, the sum of diagonal entries.
- Probability, shots and angles
- Ideal probabilities describe the model; measured shot frequencies fluctuate. Angles inside trigonometric expressions are in radians unless explicitly labeled turns.
1. The problem
A referee gives Alice a row and Bob a column. Alice must output three bits with even parity, Bob three bits with odd parity, and their intersection bits must agree. They cannot communicate after receiving the questions.
2. How it works
A single fixed classical square cannot satisfy all row and column parities: the total XOR would need to be both zero and one. Quantum players measure context-dependent compatible observables on shared entanglement instead of filling one preexisting square.
Share resource
Prepare two Bell pairs before the questions.
Select one setting
Choose Alice’s row and Bob’s column. Each applies only local basis gates.
Measure answers
Two measured bits per player determine their third through the required parity rule.
Score
Decode all answers and check the shared intersection. Repeat all nine settings to examine the uniform-game average.
3. The mathematics, one idea at a time
The third local bit is reconstructed to enforce the player’s own parity.
This additional intersection constraint is what a classical fixed square cannot satisfy for all nine questions.
XORing all three even rows gives total parity zero; XORing all three odd columns gives one. At least one intersection must fail for a deterministic strategy. Shared randomness cannot improve that average bound.
Work this through by hand
4. One row/column pair before the full game
Four qubits (two Bell pairs) are the fixed resource for this implementation.
Choose row 1 and column 1. Begin with this single setting, then compare all nine.
| Stage | Calculation or state | What it means |
|---|---|---|
| Alice’s local decode | Third row bit = first XOR second | Her row automatically has even parity. |
| Bob’s local decode | Third column bit = 1 XOR first XOR second | His column automatically has odd parity. |
| Intersection check | Compare the bit at their shared cell | The ideal shared-state correlations make it agree. |
Expected outcomes for this example
These are ideal predictions for the stated configuration, not a result already measured by your browser. Rows describing alternative modes or combined events are labeled explicitly.
| Outcome or event | Ideal probability | Interpretation |
|---|---|---|
| Decoded winning answer pairs | 100% ideal for the selected setting | Local answers vary, but parity and intersection rules hold. |
5. Load the worked example in Composer
The worked example can use smaller or simpler inputs than the gallery defaults. The button below loads the exact circuit used in this lesson.
Selected variant: Magic square · row 1 · column 1
- Save any current circuit you want to keep, then open the worked example. Loading it does not execute a paid hardware job.
- Trace the preparation, main operations and measurements against the worked table. Check the gate editor for controls, targets and angles.
- Start with an ideal noiseless simulator compatible with the circuit. Mid-circuit measurement, reset and feed-forward require support from the chosen backend.
- Inspect the live preview. For a recorded experiment, open Execute, set the available backend options and shots, and Run. Sign in when prompted to retain it in My Jobs.
- Read the output as described below before changing one setting and repeating. The guide describes the original example; edits can change the answer.
6. Read the output correctly
Use the Classical bits game decoder. The four raw bits encode two measured bits for each player; they are not the full six-bit answers.
Winning one row/column setting does not establish the 8/9 versus 1 separation. That comparison uses uniformly sampled settings and no communication after questions.
A bit label is a register value; its bar height is a probability or count. For S shots and observed count k, the sampled frequency is k/S. A typical sampling scale for probability p is √[p(1−p)/S]; this is not a strict error bound. Finite samples do not have to match the ideal percentages exactly.
7. Common mistakes & limits
- The simulator’s full record is not information available to an individual separated player.
- A player’s random local answers do not mean the joint strategy is random about winning.
8. Check your understanding
Why can shared classical randomness not exceed 8/9?
Reveal the reasoning
Every fixed deterministic strategy loses at least one setting. A probabilistic mixture averages such strategies, so cannot exceed the same bound.
9. Further study
The lesson’s register mappings, supported inputs and loadable example follow Quantket’s implemented circuit. A reference may use different wire names, bit order or resource conventions.
Gallery reference: defaults, definitions & implementation notes
Available example inputs
Choose a named circuit variant in Algorithms. Each variant fixes its preparation, operations and measurement mapping; the worked variant above is one of them.
- Magic square · row 1 · column 1
- Magic square · row 1 · column 2
- Magic square · row 1 · column 3
- Magic square · row 2 · column 1
- Magic square · row 2 · column 2
- Magic square · row 2 · column 3
- Magic square · row 3 · column 1
- Magic square · row 3 · column 2
- Magic square · row 3 · column 3
Implementation notes
The referee uniformly selects one of nine row/column pairs. Alice returns an even-parity row, Bob an odd-parity column, and the intersection must agree. Neither may communicate after receiving their own question. One fixed square cannot have all rows even and all columns odd: XORing the six constraints gives 0=1. Classical strategies, including shared randomness, therefore win at most 8/9 (88.9%) on uniform questions; two Bell pairs permit ideal 100% success. For example, Alice uses rows 000/000/110 and Bob columns 001/001/001, losing only at row 3 / column 3. A single selected setting does not test this aggregate bound. Classical bits decodes actual measured answers and losses for that setting.
Read your saved result
Check the submitted circuit, measured register and execution settings in Run details. Exact results give computed probabilities; sampled results show frequencies from the recorded shots. Edited circuits and noise can change the expected outcome. The algorithm label records the circuit's origin; it does not certify an edited circuit or a measured result.