Depth-first quantum circuit path summation (source code)

= Depth-first quantum circuit path summation

Expand a <quantum circuit> <matrix element> by inserting <computational basis> resolutions between gates, then enumerate the intermediate strings depth first. The active stack stores one basis label and accumulator per <quantum circuit> layer, using polynomial space for polynomially many qubits and gates. Recompute entries rather than storing an exponential matrix or state vector. The output probability requires the <Born rule> sum of squared amplitude moduli.