In the tutorial example of Stim, there is a repetition code example.
The circuit is the following:
stim.Circuit('''
R 0 1 2 3 4
TICK
DEPOLARIZE1(0.04) 0 2 4
CX 0 1 2 3
TICK
CX 2 1 4 3
TICK
X_ERROR(0.01) 1 3
MR 1 3
DETECTOR(1, 0) rec[-2]
DETECTOR(3, 0) rec[-1]
REPEAT 24 {
TICK
DEPOLARIZE1(0.04) 0 2 4
CX 0 1 2 3
TICK
CX 2 1 4 3
TICK
X_ERROR(0.01) 1 3
MR 1 3
SHIFT_COORDS(0, 1)
DETECTOR(1, 0) rec[-2] rec[-4]
DETECTOR(3, 0) rec[-1] rec[-3]
}
X_ERROR(0.01) 0 2 4
M 0 2 4
DETECTOR(1, 1) rec[-2] rec[-3] rec[-5]
DETECTOR(3, 1) rec[-1] rec[-2] rec[-4]
OBSERVABLE_INCLUDE(0) rec[-1]
''')
I am confused by the meaning of the lines such as:
DETECTOR(1, 0) rec[-2]
Question 1: What does X and Y mean in Detector (X,Y)?
In the doc it says it represents "coordinates" but what does it mean? I am a beginner in Stim I only know the very basic of the initial tutorial (hence I am looking for a very basic answer).
Question 2: My understanding of a detector is that it should compare the outcome of two measurements and return TRUE if they are not consistent. For instance if Z measurements output 00 or 11, the detector will return False. If the measurement is 01 or 10 it will return True.
- What does it mean to only put a single measurement outcome in a detector? For instance, the line DETECTOR(1, 0) rec[-2].
- What does it mean to put more than 2 measurement outcomes in a detector? For instance, the line DETECTOR(1, 0) rec[-2] rec[-4].
Yes
– Peter-Jan Mar 12 '24 at 16:49Detectors are not called. The circuit is ran and then using the measurement results one can check which detectors are violated
– Peter-Jan Mar 12 '24 at 16:52The detector can know this by simulating the noiseless (Clifford) circuit.
– Peter-Jan Mar 12 '24 at 16:53