I have a high-level description of a quantum stabiliser code and a small brain, and I'd like to write code to compile the former to a Stim circuit. The high-level description contains the stabiliser measurements to perform each round, and then generally detectors should be built by comparing measurements of the same stabiliser in consecutive rounds. Taking the rotated surface code as an example, the stabilisers (in the bulk) are XXXX and ZZZZ products.
In the first ever round of measurements, however, I can't compare to the previous measurement of a stabiliser, because it doesn't exist. I can still build detectors at the end of this round, but they depend on the initial states of the data qubits. e.g. If I initialise all the data qubits in |0>, then the first ZZZZ measurements should output +1 deterministically (using the convention that outcomes are +1 and -1), so I can build a 'one-measurement detector'. The XXXX measurements individually are random, however, so I can't turn them into detectors. Vice versa if I initialise all the data qubits in |+>.
I've read the paper that explains how Stim works, and I'm almost certain it's telling me I should be able to figure out which 'potential detectors' in the first round will be deterministic, using only Tableaus and PauliStrings - i.e. without dropping down to the circuit level. But my aforementioned small brain can't quite connect the dots. Is anyone able to help?
(Other info: I'm reluctant to swap to a design where the user specifies themself which detectors are/aren't deterministic in round 1. My current workaround, apart from being shamefully ugly, is too slow: it involves building a circuit representing the initialisation steps, then checking in turn whether each potential detector is deterministic by asking for the circuit's detector error model, then seeing if this throws an error saying there's non-deterministic detectors.)