Conditional Shor candidate membership
Abstract
Conditional continued-fraction membership for actual modular phase estimation
Parameters is the actual padded modular-multiplication model: modulus N at least two, base coprime to N, and an independently chosen target width whose dimension holds the residues. The counting width n gives Q equal to two to the n. The true order r is positive and strictly smaller than N. The candidate algorithm takes only y.val, Q and N; s and r occur in the theorem’s conditions, not as algorithm inputs.
Theorem 1.1 (Reduced phase candidate).
\forall c \in \mathit{Parameters},\; \forall n \in \mathit{Nat},\; \forall s \in \operatorname{Fin}\left(\operatorname{period}\left(c\right)\right),\; \forall y \in \operatorname{Fin}\left(2^{n}\right),\; \operatorname{modulus}\left(c\right)^{2} \le 2^{n} \Rightarrow \left(\operatorname{Nearest}\left(2^{n}, \frac{\operatorname{val}\left(s\right)}{\operatorname{period}\left(c\right)}, y\right) \Rightarrow \left(\operatorname{reduced}\left(\operatorname{val}\left(s\right), \operatorname{period}\left(c\right)\right) \in \operatorname{candidates}\left(\operatorname{val}\left(y\right), 2^{n}, \operatorname{modulus}\left(c\right)\right) \land \operatorname{Dvd}\left(\operatorname{den}\left(\operatorname{reduced}\left(\operatorname{val}\left(s\right), \operatorname{period}\left(c\right)\right)\right), \operatorname{period}\left(c\right)\right)\right)\right)
Proof. Machine-checked in Lean as D5/S3/Quantum/ShorContinuedFractions.shor_nearest_candidate (✓ std3). ∎
Citation. aicyberg (2026). Finite-register phase estimation and spectral Shor order finding. URL: https://github.com/solanaqubits/leanbook/tree/9b742770a2a5dbcf30cf9abc44e711194e957a00.
Commentary.
For every c, n, hsize : N squared at most Q, s : Fin r and y : Fin Q, the hypothesis is the existing circular Nearest Q (s.val / r) y. The conclusion places the distinguished reduced s/r in candidates and says that this fraction’s denominator divides r. Its denominator is exactly r divided by gcd(s.val,r), by the generic rational denominator formula. No assertion is made that every list entry divides the order.
Nearest means that some integer z makes the absolute difference s.val/r minus y.val/Q minus z at most 1/(2Q). Since s.val is below r, y.val is below Q and r is below N, the resolution N squared at most Q excludes nonzero z. This includes s equal to zero and either non-strict rounding tie. The reduced denominator is at most r and its square is strictly below Q, converting the non-strict grid error into the strict Legendre bound. Mathlib’s existing Legendre theorem supplies a real-convergent index. The exact finite-list correspondence supplies membership, and the denominator bound passes the observable filter.
Theorem 1.2 (Coprime true-order membership).
\forall c \in \mathit{Parameters},\; \forall n \in \mathit{Nat},\; \forall s \in \operatorname{Fin}\left(\operatorname{period}\left(c\right)\right),\; \forall y \in \operatorname{Fin}\left(2^{n}\right),\; \operatorname{modulus}\left(c\right)^{2} \le 2^{n} \Rightarrow \left(\operatorname{Nearest}\left(2^{n}, \frac{\operatorname{val}\left(s\right)}{\operatorname{period}\left(c\right)}, y\right) \Rightarrow \left(\operatorname{Coprime}\left(\operatorname{val}\left(s\right), \operatorname{period}\left(c\right)\right) \Rightarrow \operatorname{period}\left(c\right) \in \operatorname{mapRatDen}\left(\operatorname{candidates}\left(\operatorname{val}\left(y\right), 2^{n}, \operatorname{modulus}\left(c\right)\right)\right)\right)\right)
Proof. Machine-checked in Lean as D5/S3/Quantum/ShorContinuedFractions.shor_coprime_candidate (✓ std3). ∎
Citation. aicyberg (2026). Finite-register phase estimation and spectral Shor order finding. URL: https://github.com/solanaqubits/leanbook/tree/9b742770a2a5dbcf30cf9abc44e711194e957a00.
Commentary.
Under the same hypotheses and Nat.Coprime s.val r, the true order r belongs to the list obtained by mapping Rat.den over candidates. mapRatDen in the displayed statement denotes this map. The proof consumes reduced-phase membership and the exact denominator formula with gcd equal to one. This establishes existence within observable candidates; it does not provide an observable certified selector of the exact order.
The generic list admits zero and integer rationals, and the recovery theorem admits r equal to one and s equal to zero. Since N is at least two, the recovery resolution excludes n equal to zero; the existing QPE marginal still admits that counting width. No assumption r divides Q is used. A passing modular exponentiation test alone says that the tested exponent is a multiple of the order, by the pinned orderOf_dvd_iff_pow_eq_one theorem. Exactness needs additional information.
For a single actual counting measurement, fix any c : QuantumShorOrderFindingCore.Parameters and n : Nat with N squared at most Q, where N = c.modulus, r = c.period and Q = 2^n. Use exactly the existing modularOperator and input of c: the target starts in computational basis state one, the residue permutation fixes padding, and the counting and target widths remain independent. Let E be the finite set of y : Fin Q for which r belongs to (candidates y.val Q N).map Rat.den. Thus E records that the observable candidate list contains the true order. The algorithm still takes only y.val, Q and N; r defines its success event and is not supplied to it.
Write p(y) for the actual complete target-register marginal normSquared (runQPE c.modularOperator n c.input y), k(s,y) for probability Q (s.val / r) y, and A for 4 / Real.pi squared. All quotients and probability sums below are real after casting natural values. The notation sum(i,T,f) means the finite sum of f over i in T. Normalization of the actual marginal makes its sum over E the probability of this single-run list-membership event. The resulting application of the existing results is
\operatorname{sum}\left(y, E, \operatorname{p}\left(y\right)\right) \ge \frac{4}{\mathit{pi}^{2}} \cdot \frac{\operatorname{totient}\left(r\right)}{r}
To obtain an admissible label for each s : Fin r, round the real number Q times s.val / r to an integer m. The pinned abs_sub_round gives absolute rounding error at most one half. Here 0 < r < N and N squared at most Q imply r < Q. Since 0 is at most s.val and s.val + 1 is at most r, these inequalities give 0 at most m and m < Q. Taking y.val = m and the integer shift zero in Nearest gives the required circular error at most 1/(2Q). The argument permits s equal to zero and either non-strict midpoint tie; it does not require a unique nearest label.
Let C be the finite set of s : Fin r with Nat.Coprime s.val r. For each s in C, D5/S3/Quantum/ShorContinuedFractions.shor_coprime_candidate puts the chosen nearest label in E, and D5/S3/Quantum/ShorCountingMarginal.shor_phase_accuracy_bound gives k(s,y) at least A there. Each kernel value is a squared complex norm and hence nonnegative, so sum(y,E,k(s,y)) is at least A for s in C and at least zero for every other phase. This bounds event mass within each component before combining the components; no distinctness of the chosen labels is needed.
The exact actual-input identity D5/S3/Quantum/ShorCountingMarginal.shor_qpe_probability_mixture and interchange of finite sums give
\operatorname{sum}\left(y, E, \operatorname{p}\left(y\right)\right) = \frac{1}{r} \cdot \operatorname{sum}\left(s, \operatorname{Fin}\left(r\right), \operatorname{sum}\left(y, E, \operatorname{k}\left(s, y\right)\right)\right)
Summing the component bounds and multiplying by the positive weight 1/r therefore gives
\operatorname{sum}\left(y, E, \operatorname{p}\left(y\right)\right) \ge \frac{1}{r} \cdot \operatorname{sum}\left(s, C, A\right)
Fin.sum_univ_eq_sum_range identifies the phase sum with the range from zero to r exclusive. Nat.coprime_comm matches the predicate to the pinned Nat.totient definition, so C has exactly Nat.totient r elements. The last constant sum is therefore (Nat.totient r) times A, giving the displayed bound. This is a count in the actual spectral mixture, with no independently sampled latent-phase hypothesis. The derivation includes r equal to one and phase zero, needs no divisibility between r and Q, and adds no restriction on n to the original resolution; N at least two and N squared at most Q already exclude widths zero and one.
The supplied actual QPE uses the inverse final Fourier transform. Using the chapter’s positive Fourier convention reflects the observed grid label through negation modulo Q, as described by the owning counting-marginal result. One must apply the nearest condition to the reflected label before using this recovery statement. More explicitly, let rho be finEquiv.symm applied to negative finEquiv of the label. For a positive-Fourier output b, the corresponding success event is rho(b) in E, so candidates is evaluated at rho(b).val. The existing target-vector correspondence and this involutive permutation give that reflected event the same probability sum and lower bound. The formula above uses the supplied inverse-QFT labels; it does not identify the unreflected positive-Fourier candidate event with E. The normalization and existing pointwise peak lower bound are unchanged.
The deterministic membership theorems supply the conditional recovery step; the single-run event bound follows from their composition with the actual mixture, the phase peak bound and the finite coprime count. It establishes list membership success only. It supplies no exact-order selector, assertion that all candidate denominators divide r, repeated-sample independence, ideal least-common-multiple product law, factoring reduction, full bit or gate complexity, hardware guarantee or empirical performance. A finite recursively generated list alone supplies no such complexity claim. The general supplied-R clock statement remains broader than this actual modular N-bound specialization.
Two independent resets recover the true period in an all-pairs denominator list with a uniform finite-clock lower bound. Fix the same actual Parameters c in both runs, N = c.modulus, r = c.period, and Q = 2^n with N squared at most Q. In each run prepare the original counting state and the original target input c.input, then use c.modularOperator and the inverse final Fourier transform. Independence is an explicit sampling assumption: the two complete preparations and measurements have joint output mass p(y)p(z), where p is the actual marginal above. Reusing an unreset target or an arbitrary correlated joint state does not supply this law. The two runs have the same true r; no independent choice of base or period is made.
Define D(y) = (candidates y.val Q N).map Rat.den. Define L(y,z) by taking every d in D(y), every e in D(z), and appending lcm(d,e), exactly List.flatMap followed by List.map. Both lists are functions only of observed integers and the supplied N and Q. Define the success predicate E2(y,z) by r belonging to L(y,z). The period appears only in this mathematical test of success. Repeated list entries and several successful denominator pairs still give just one event at the observed pair (y,z). Write 1_E2 for its indicator, equal to one when membership holds and zero otherwise. The probability is therefore
\operatorname{Pr}\left(\mathit{PairEvent}\right) = \operatorname{sum}\left(\mathit{yz}, \operatorname{FinPair}\left(Q\right), \operatorname{indicatorPairEvent}\left(\mathit{yz}\right) \cdot \operatorname{p}\left(\operatorname{fst}\left(\mathit{yz}\right)\right) \cdot \operatorname{p}\left(\operatorname{snd}\left(\mathit{yz}\right)\right)\right)
Here PairEvent denotes E2, indicatorPairEvent is its indicator, FinPair(Q) denotes Fin Q times Fin Q, and fst and snd select its two coordinates. Each factor p is nonnegative and has total mass one by shor_distribution_normalized, so the joint mass is nonnegative and sums to one. This normalizes the event over actual observations, rather than counting candidate occurrences.
The conditional continued-fraction bridge applies separately to each phase s,t in Fin r and each pair of nearest observations y,z. The nearest-label construction above exists for every phase. shor_nearest_candidate places the reduced s/r and t/r in the corresponding candidate lists. Their denominators are d_s = r/gcd(s.val,r) and d_t = r/gcd(t.val,r). Since both gcds divide r, Nat.div_lcm_eq_div_gcd and Nat.gcd_gcd_gcd_right give the exact identity
\operatorname{lcm}\left(\mathit{ds}, \mathit{dt}\right) = \frac{r}{\operatorname{gcd}\left(\operatorname{gcd}\left(s, t\right), r\right)}
The displayed ds and dt denote d_s and d_t. Natural s and t in this identity mean their values in the range from zero to r exclusive. Thus the joint primitive condition gcd(gcd(s,t),r) = 1 suffices for E2(y,z). Neither numerator must individually be coprime to r. This only identifies the distinguished recovered denominators; it makes no divisibility claim about every entry of D(y) or D(z).
Let H_r be the number of jointly primitive ordered phase pairs. A sufficient elementary estimate is H_r at least r squared divided by two. To see this, any nonprimitive pair has some prime p dividing r and both numerators. Among Fin r at most r/p values are divisible by p: division by p injects them into Fin(r/p), since p divides r. The union bound on the Cartesian squares of these sets gives a bad-pair count at most the sum over p dividing r of (r/p) squared. After division by r squared this is at most the sum of 1/p squared over the distinct prime factors. Overlaps only weaken this upper bound.
Separate primes 2, 3 and 5. Every other prime divisor is an odd integer at least seven and at most r, hence lies among 7+2k for k from zero to r exclusive. The original reciprocal_square_shifted_finite_tail_le, with its complete hypothesis a > 0, bounds the sum of 1/(a+k) squared for k < n by 1/a squared + 1/a. Its proof separates the first term and compares each later term with 1/(a+k) - 1/(a+k+1); this finite sum telescopes, and the remaining reciprocal endpoint is nonnegative. Applying this original law at a = 7/2 and n = r gives
\operatorname{sumPrimeReciprocalSquares}\left(r\right) \le \frac{1}{4} + \frac{1}{9} + \frac{1}{25} + \frac{1}{4} \cdot \left(\frac{4}{49} + \frac{2}{7}\right)
The right side is 21739/44100, strictly below one half. The good and bad phase pairs partition the r squared pairs, so 2 H_r is at least r squared. This is a sufficient halfdensity estimate, not an exact count. The exact ideal independent-phase Euler product, product over p dividing r of (1 - 1/p squared), is a separate statement obtained by counting simultaneous divisibility conditions. The union estimate here does not establish that identity, and the finite-clock event is a different event.
Now fix a phase pair (s,t) before summing any actual observations. Its component product kernel is K_(s,t)(y,z) = k(s,y)k(t,z). Every such product is nonnegative. If the pair is jointly primitive, choose nearest y and z. The conditional bridge puts that observed pair in E2, and shor_phase_accuracy_bound gives each component factor at least A = 4/pi squared. Consequently the sum of K_(s,t) over the entire event E2 is at least A squared. For a nonprimitive phase pair the same event sum is at least zero. This is a lower bound on a fixed component’s event mass. It does not add point probabilities for several phase choices to the same observation, and it does not require nearest choices for different phases to be distinct.
The exact actual-input mixture p(y) = (1/r) sum_s k(s,y) holds for the original modular input. Multiplying the two marginals under the independent-reset law expands p(y)p(z) as (1/r squared) times the sum over all ordered phase pairs of K_(s,t)(y,z). Multiply by the single indicator of E2 and interchange the finite sums. This yields
\operatorname{Pr}\left(\mathit{PairEvent}\right) = \frac{1}{r^{2}} \cdot \operatorname{sum}\left(\mathit{st}, \operatorname{FinPair}\left(r\right), \operatorname{eventKernelMass}\left(\mathit{st}, \mathit{PairEvent}\right)\right)
eventKernelMass(st,E2) is the sum over observed pairs of the indicator of E2 times that component’s K. Summing the fixed-component lower bounds gives Pr(E2) at least (H_r/r squared) A squared. Halfdensity and A squared = 16/pi to the fourth power therefore give
\operatorname{Pr}\left(\mathit{PairEvent}\right) \ge \frac{8}{\mathit{pi}^{4}}
No latent phase is an extra algorithm input or an extra physical measurement in this derivation. The phase-pair indices occur only in the exact expansion of the actual product distribution. Colliding nearest observations cause no overcount: each actual pair has one indicator, and its product mass is decomposed into nonnegative mixture components before the estimate is applied.
For the positive final Fourier transform, keep the identical actual pre-Fourier state V = runControlled c.modularOperator n c.input. Put Aplus(y)(u) = QFT Q (fun k => V(k)(u)) y, and pplus(y) = normSquared(Aplus(y)); normSquared sums over the full target carrier, including padding. Let e be (ZMod.finEquiv Q).toEquiv and nu = e.symm after negation after e. This permutation has nu(0) = 0, is involutive, and has value Q - y.val for nonzero y. The zero branch is essential. For every output y the full target vectors satisfy Aplus(y) = runQPE c.modularOperator n c.input (nu(y)).
At the kernel level this follows from phase_conj and phase_shift_int: reflecting the nonzero label changes the exponent by the integral frequency k, while label zero is fixed. The same V columns are used on both sides, so vector equality gives pplus(y) = p(nu(y)). Reindexing by nu proves sum_y pplus(y) = 1; its values are nonnegative squared norms. For every predicate F on observed pairs, reindexing by the product permutation (nu,nu) gives the exact equality of sums
\operatorname{sum}\left(\mathit{yz}, \operatorname{FinPair}\left(Q\right), \operatorname{reflectedPositiveEventMass}\left(F, \mathit{yz}\right)\right) = \operatorname{sum}\left(\mathit{yz}, \operatorname{FinPair}\left(Q\right), \operatorname{inverseEventMass}\left(F, \mathit{yz}\right)\right)
The first summand is 1_F(nu(y),nu(z)) pplus(y)pplus(z), and the second is 1_F(y,z) p(y)p(z). In particular the corrected positive event is r in L(nu(y),nu(z)), and its probability under two independent positive-QFT resets is at least 8/pi to the fourth power. The product law pplus(y)pplus(z) is nonnegative and normalized. No equality or lower bound for the raw unreflected event r in L(y,z) under positive QFT is asserted. The proof reflects actual observations in both coordinates; it uses no equivariance of a nearest-label selection.
The native positive Fourier circuit has the same correspondence. For every OracleModel and its Interpretation, QuantumAlg.QuantumFourierTransform.Source.circuit_action identifies the binary-label matrix of Source.circuit oracles n with QFT Q. Applying that matrix to each actual column fun k => V(k)(u) gives precisely the target vector runQPE c.modularOperator n c.input (nu(y)). Thus the corrected positive event and its normalization apply to this native circuit action on the actual input, with the same two-reset assumption.
All of these recovery estimates retain every Parameters c and counting width satisfying N squared at most Q. They include r = 1, zero phase numerators, zero observed labels, repeated prime factors of r, both non-strict nearest midpoint ties, and r not dividing Q. For r = 1 the jointly primitive phase-pair count is one and the prime set is empty. The original tail law includes n = 0 with empty sum; its observation family remains the full reciprocal-square sequence, so the estimate also covers an empty tail. Reflection and native circuit equality themselves hold for every n, including n = 0 and Q = 1; the recovery resolution with N at least two excludes those smallest widths.
This is an application of the existing candidate, counting, Fourier and arithmetic results. The conclusion is membership of the common true period in a finite list computed from two observations under an explicitly independent preparation law. It provides no efficient exact-order selector, recursive factoring algorithm, complexity theorem, hardware assertion or claim of mathematical novelty. The ideal Euler product and the separate unit-group factor-success estimate require their own exact statements and sampling correspondences.
A minimum-passing selector turns the preceding membership event into an exact-output event. The conditional candidate-membership statements above concern individual phases; the selector application here uses generic list and order facts. For arbitrary natural a and N and any finite list L of natural exponents, use the expression select(a,N,L) = List.argmin id (L.filter (fun d => decide (0 < d ∧ Nat.powMod a d N = 1))). This is notation for a composition of existing functions. The filter keeps positive exponents passing modular exponentiation, and argmin id returns their smallest natural value as some m, or none when the filtered list is empty. The inputs are a, N and L. There is no true-order input, latent-phase input or exactness flag.
For the order interpretation, fix any c : QuantumShorOrderFindingCore.Parameters and set a = c.base, N = c.modulus and r = c.period = orderOf (a : ZMod N). Thus N is at least two, a is coprime to N, and r is positive. The selector contract holds for every finite L, independently of the counting width, resolution and manner in which L was obtained. Nat.powMod_def identifies the executable test with a^d modulo N. Since 1 < N, ZMod.natCast_eq_natCast_iff’ and Nat.cast_pow identify Nat.powMod a d N = 1 with (a : ZMod N)^d = 1. The modulus condition ensures that the literal natural residue one is the canonical residue one.
Let S denote the filtered list in that expression. If select(a,N,L) = some m, List.argmin_mem puts m in S. Filter membership therefore supplies m in L, 0 < m, and Nat.powMod a m N = 1. The order API orderOf_dvd_of_pow_eq_one then gives r dividing m. For every d in L with 0 < d and Nat.powMod a d N = 1, List.le_of_mem_argmin gives m at most d. This is minimality among passing entries of this particular list. Entries that fail the test impose no such comparison, and missing exponents are not searched. In particular, r at most m follows from orderOf_le_of_pow_eq_one, but m equal to r does not follow from a return alone.
The exactness criterion for every c and L is
\forall c \in \mathit{Parameters},\; \forall L \in \operatorname{List}\left(\mathit{Nat}\right),\; \operatorname{select}\left(\operatorname{base}\left(c\right), \operatorname{modulus}\left(c\right), L\right) = \operatorname{some}\left(\operatorname{period}\left(c\right)\right) \Leftrightarrow \operatorname{period}\left(c\right) \in L
For the forward direction, argmin membership already puts the returned r in L. Conversely, suppose r is in L. Its positivity and the identity (a : ZMod N)^r = 1 put r in S. By List.argmin_eq_none, a nonempty S cannot yield none, so write its result as some m. Order minimality gives r at most m, while argmin’s comparison with the passing entry r gives m at most r. Antisymmetry forces m = r. The two inequalities use different facts: r is the globally least positive return exponent, and m is the least passing exponent present in the supplied menu. Membership of r connects these two minima.
The failure contract is equally exact: select(a,N,L) = none if and only if, for every d in L, it is false that both 0 < d and Nat.powMod a d N = 1. Indeed List.argmin_eq_none says S is empty, and filter membership translates emptiness into that condition. None reports absence of a positive passing entry in L; it does not report absence of an order. These statements include empty lists, zeros, nonpassing entries, repeated values, arbitrary list order, and r = 1. List.argmin keeps the first entry in a tie; because its score here is id on natural values, tied scores are the same exponent. No assumption that every entry of L divides r, or is already a multiple of r, is needed.
Apply this generic contract to the same actual two-reset experiment above. Fix the same c and n in both runs, Q = 2^n, N squared at most Q, and the actual c.modularOperator and c.input. Keep D(y) = (candidates y.val Q N).map Rat.den and L(y,z) = (D(y)).flatMap (fun d => (D(z)).map (Nat.lcm d)). The membership event PairEvent remains E2(y,z), namely r in L(y,z). Define ExactPairEvent(y,z) by select(a,N,L(y,z)) = some r. The generic criterion identifies these predicates at each observed pair, including zero labels. The algorithm evaluates the same finite menu from the observed labels; only the mathematical success predicate mentions the unknown r.
Write pminus(y) = normSquared (runQPE c.modularOperator n c.input y), so pminus is precisely p from the membership calculation. Assume explicitly that the joint law of the two complete preparations and measurements is pminus(y)pminus(z). For any event F, let Prminus(F) be the finite sum over all (y,z) in Fin Q times Fin Q of if F(y,z) then pminus(y)pminus(z) else zero. The nonnegative normalized product law above makes this its event probability. Pointwise replacement of ExactPairEvent by PairEvent leaves every summand unchanged, hence
\operatorname{Prminus}\left(\mathit{ExactPairEvent}\right) = \operatorname{Prminus}\left(\mathit{PairEvent}\right)
\operatorname{Prminus}\left(\mathit{ExactPairEvent}\right) \ge \frac{8}{\mathit{pi}^{4}}
The lower bound is exactly the existing two-reset membership bound after that event rewrite. It does not require a new phase-sampling law or a second count of successful candidates. An observation pair has one exact-success indicator regardless of how many occurrences of r or successful denominator pairs its list contains. The phase-mixture and primitive-pair derivation above continue to supply the bound, with the same actual c, n, target padding and resolution. No period-divides-Q hypothesis is added.
For the positive final Fourier transform, use exactly the same V = runControlled c.modularOperator n c.input, the same Aplus and pplus, and the same zero-safe involution nu defined above by negation through ZMod.finEquiv Q. Define ExactPositivePairEvent(y,z) by select(a,N,L(nu(y),nu(z))) = some r. Reflect both measured labels before forming their candidate lists. Define Prplus(F) by the corresponding finite sum with the explicitly independent joint law pplus(y)pplus(z). The full target-vector identity on this common V gives pplus(y) = pminus(nu(y)); nu(0) = 0 and involutivity include the zero branch. Apply the existing product-permutation equality to the predicate ExactPairEvent. Together with its pointwise membership equivalence this gives
\operatorname{Prplus}\left(\mathit{ExactPositivePairEvent}\right) = \operatorname{Prminus}\left(\mathit{ExactPairEvent}\right)
\operatorname{Prplus}\left(\mathit{ExactPositivePairEvent}\right) \ge \frac{8}{\mathit{pi}^{4}}
For every OracleModel and Interpretation, Source.circuit_action identifies the native positive Fourier circuit matrix on binary labels with QFT Q. Acting on each same actual column fun k => V(k)(u), it yields runQPE c.modularOperator n c.input (nu(y)) as a full target vector. Thus the reflected selector event has the same bound for that native circuit action under two independent resets. The argument supplies no lower bound for selecting from the raw unreflected positive-label menu L(y,z), and no guarantee for dependent resets, an unreset target or an unspecified correlated state.
A finite counterexample shows why a passing minimum is not a total exact-order certificate. Take N = 21, a = 2, Q = 512 and observed labels y = z = 43. The actual candidate-denominator list at either label is D = [1, 11, 12]. In the flatMap order specified above, L = [1, 11, 12, 11, 11, 132, 12, 132, 12]. Here 21 squared is at most 512, orderOf (2 : ZMod 21) = 6, and select(2,21,L) = some 12. The true order is absent from this menu. The passing distinct entries are 12 and 132, and their least value is still twice the order. This is an arithmetic example for the finite candidate computation and selector; no positive actual probability of this particular label pair is asserted.
The example also separates modular verification from the order-dependent gcd argument below. Treating the returned 12 as the true order would use 2^6 modulo 21, which is one, whereas the true-order half-power is 2^3 modulo 21. The passing test therefore cannot replace the true-order premise in that classical reduction. Nor does taking all candidate-pair least common multiples certify each entry or guarantee that a missing r appears. List-relative minimization preserves the exact-success event precisely because it returns r when r is present, not because it repairs every incomplete menu.
The resulting guarantee is bounded-error exact-order output: the probability that the returned value equals r is at least 8/pi to the fourth power under the stated experiment. A return some m contains no flag telling whether this equality event occurred. Some returns may be larger positive multiples; none is only menu failure. This is not a Las Vegas exact-order procedure that recognizes every unsuccessful attempt and certifies every returned order. Repetition without an additional exactness check does not by itself provide that certificate.
Exact certification can be studied with extra resources. For a positive passing m and a complete verified prime factorization of m, the existing orderOf_eq_of_pow_and_pow_div_prime API gives exact order m if (a : ZMod N)^(m/p) is unequal to one for every prime p dividing m. The powMod bridge expresses those tests with natural modular exponentiation as well. Obtaining the complete factors is a separate task from verifying supplied factors and tests; the finite menu does not supply them. This criterion is a possible further application, not an extra certificate output by select, and no efficient method of obtaining those factors is asserted here.
The minimum argument uses the existing List.argmin, Nat.powMod, ZMod and orderOf APIs and introduces no new mathematical content. A related minimum-of-multiples argument is explicit in Ekerå, On the success probability of quantum order finding, Section 4.1.7 (https://arxiv.org/html/2201.07791v2#S4.SS1.SSS7): after its candidate processing, all returned values are positive multiples and one is the true order, so their minimum is the order. That paper’s offset search and smoothness-based processing are distinct from the all-pairs menu here. Its performance estimates are not assumptions or consequences of this application. The original candidate and actual-marginal results retain their literature attribution above.
Finite lists and an executable powMod test provide a specified computation, not a full resource analysis. The existing logarithmic convergent-length statement counts list entries or Euclidean stages; it does not bound every recursive list operation or rational arithmetic bit cost. This application supplies no efficient sampler of the full unit group, recursive factoring algorithm, end-to-end bit or gate cost, or physical hardware guarantee. The exact-output event concerns the counting observations for a fixed actual base. The separate classical Good event below concerns true-order factor extraction under its own unit-sampling law. Their probabilities require an explicit common sampling construction before they can be combined.
The classical postprocessing event has a separate finite-group description. Let I be any nonempty finite index type, let each G(i) be a finite cyclic group, and specify epsilon(i) of order two. For an actual tuple x in the product, put d(i) = orderOf(x(i)), m = orderOf(x), and v(i) = d(i).factorization(2). Define Good(x) by Even(m) and x^(m/2) unequal to the tuple epsilon. Then failure of Good(x) is equivalent to existence of a natural t with v(i) = t for every i. The product group need not be cyclic, and the factor sizes can differ. Identity elements and nonidentity elements of odd order remain in the domain. For a singleton I every tuple fails this event. This is the common binary-valuation argument in Section 5, page 16 of Shor, as cited in Library/QuantumChannels/shor1997gateorbits.md; the statement is an application of the pinned finite-group and factorization results.
Here is the complete algebraic correspondence. Mathlib’s Pi.orderOf expresses m as the least common multiple of the positive d(i), and Finset.factorization_lcm expresses its binary valuation as the maximum of the v(i). For an even positive multiple M of the order d of an element g in a cyclic factor, (g^(M/2))^2 = 1. The count IsCyclic.card_orderOf_eq_totient at order two, together with Nat.totient_two, makes epsilon the unique element of order two. Thus g^(M/2) equals epsilon exactly when it is unequal to the identity. By orderOf_dvd_iff_pow_eq_one, the complementary identity condition is d dividing M/2. Nat.dvd_div_iff_mul_dvd rewrites this as 2*d dividing M; Nat.factorization_le_iff_dvd and Nat.factorization_mul reduce it to d.factorization(2) strictly below M.factorization(2), since the factorization inequalities at every other prime already follow from d dividing M. Therefore the actual local half-power equals epsilon exactly when those two binary valuations agree. Applying this with M = m in every coordinate proves the even-order case. If m is odd, all v(i) vanish and Good already fails.
For the actual arithmetic application take any odd natural N greater than one. Index I by the distinct prime factors p in N.primeFactors, and take G(p) = (ZMod (p^(N.factorization p))) units. These are the full prime-power moduli, including exponents greater than one. The index is nonempty; every exponent N.factorization p is positive and every p is odd. ZMod.isCyclic_units_of_prime_pow supplies cyclicity. In each factor, epsilon(p) is the literal unit -1. Its square is one and it differs from one: ZMod.neg_one_eq_one_iff permits equality only for modulus one or two, whereas p is at least three and p^(N.factorization p) is at least p. Hence its order is two.
The arithmetic equivalence E from (ZMod N) units to the product of these actual G(p) is the composition of Units.mapEquiv applied to (ZMod.equivPi N hN).toMulEquiv and MulEquiv.piUnits, where hN proves N unequal to zero. MulEquiv.orderOf_eq preserves the order of every unit, map_pow preserves every natural power, and the ring equivalence sends the literal -1 to the coordinatewise literal -1. Consequently the actual event Even(orderOf u) and u^(orderOf u/2) unequal to -1 corresponds exactly to Good(E(u)). Its complement corresponds to the set of actual tuples whose local binary order valuations all agree. No replacement distribution or independent phase variable enters this correspondence.
Restrict E with Equiv.subtypeEquiv to obtain a bijection between the actual failing units and the common-valuation tuples. Nat.card_congr gives equal cardinalities for these event subtypes. On the whole carriers, Nat.card_congr and Nat.card_pi give card((ZMod N) units) equal to the product of card(G(p)). Therefore uniform sampling of the full unit group transports to uniform sampling of the full product, and the failure mass is exactly the common-valuation tuple count divided by that product cardinality. The identity is included on both sides. These exact event and cardinality transports identify the count to which the finite cyclic-product estimate applies.
D5/S3/FiniteGroups/Cyclic/HalfOrderSynchronization.failure_count_le supplies the actual-product count used here.
The finite cyclic-product estimate bounds the common-valuation tuple count times 2^(k-1) by the full product cardinality, where k is the number of distinct prime factors. Its anchored Boolean encoding and the same actual-unit CRT correspondence give uniform Good mass at least 1 - 1/2^(k-1). Non-prime-power N has at least two distinct prime factors by the pinned prime-factor-cardinality characterization, so this mass is at least one half. The count and its normalization are developed in the owning finite-group result. For every N greater than two, the true-order Good event also implies both proper nontrivial gcd factors simultaneously, each dividing N. Coprimality supplies positivity of every original natural representative; order minimality excludes half-power one, Good excludes half-power minus one, and symmetric coprime cancellation in the squared-difference product proves the two strict gcd bounds. The owning finite-group exposition gives the exact original-power and canonical-representative correspondence via congruence, including the lower bounds needed for natural subtraction. Adjoining these factor certificates to the same Good event gives an equivalent success subtype with equal cardinality, so the identical uniform probability bound applies to the certified event. Identity remains sampled and has false Good; arbitrary positive congruent representatives are retained. The synchronization statement itself also applies when N is a prime power; it gives no positive success bound in that case. The unit sampling law and the counting-register distribution above describe different random choices, so their probabilities require their own joint sampling assumptions before they can be combined.
References
- Truth anchor:
D5/S3/FiniteGroups/Cyclic/HalfOrderSynchronization.failure_count_le - Truth anchor:
D5/S3/Quantum/ShorContinuedFractions.shor_coprime_candidate - Truth anchor:
D5/S3/Quantum/ShorContinuedFractions.shor_coprime_candidate - Truth anchor:
D5/S3/Quantum/ShorContinuedFractions.shor_nearest_candidate - Truth anchor:
D5/S3/Quantum/ShorCountingMarginal.shor_phase_accuracy_bound - Truth anchor:
D5/S3/Quantum/ShorCountingMarginal.shor_qpe_probability_mixture - Dependency: D5/S1/Depth/ContinuedFractions/FiniteRationalConvergents
- Dependency: D5/S3/Quantum/ShorCountingMarginal