Alphabeta Math
Pipeline-generated
How statement and proof provenance work

The first chip identifies the source of the statement or construction; the second identifies the source of its local proof or verification.

  • Literature-sourced: the exact statement appears in a cited source; only wording and notation differ.
  • AI-adapted: a semantically identical restatement of literature-sourced material, modulo indexing, notation, and boundary cases adopted by the library.
  • AI-generated: a genuinely novel statement formulated by AI, with no source for the claim itself.

These labels describe origin, not correctness: citations and verification chips remain separate evidence.

Quantum Order Finding and Rational Reconstruction

1 · Prerequisites

2 · Summary

This page defines denominator-bounded rational reconstruction using normalized finite continued fractions and an exact integer window. It proves the finite-rational Legendre bridge needed for a rational phase sample, candidate uniqueness, and the reconstruction bit bound. The order-finding construction starts from the valid residue ∣1⟩, whose modular-multiplication orbit has Fourier eigenphases k/r; phase estimation therefore yields a uniform mixture over indices, not a promise that ∣1⟩ is an eigenvector. A candidate denominator is retained only after the exact modular power test, and the algorithm returns the minimum retained value. The page gives an explicit clean reversible modular multiplier, its correctness and schoolbook resource bounds, then separates controlled-multiplier calls, black-box controlled-Ux queries, gates, and classical bit work. The gate estimate uses ideal exact arbitrary-angle QFT gates; it claims no finite-alphabet compilation or uniform circuit family.

3 · Logical flowchart

4 · Definitions, theorems and proofs

LemmaStatement: Literature-sourcedProof: AI-adaptedjudge pass (gpt-6-luna)Open item page →

Finite-rational Legendre criterion before the terminal convergent

Statement

Let A,p∈Z and D,q∈Z>0, with A/D and p/q reduced and D>2q. If ∣A/D−p/q∣<1/(2q2), then p/q is a convergent of the normalized finite regular continued fraction of A/D. This is a finite-rational statement; it does not invoke the irrational-input Legendre theorem.

Facts & Assumptions

Given: Reduced A/D with D>2q, and reduced p/q with q>0 and ∣A/D−p/q∣<1/(2q2).

[F1]

A rational continued fraction terminates at its Euclidean quotient list, and normalized finite expansion chooses the representation whose last digit is at least 2 unless the expansion is an integer (The continued-fraction algorithm terminates exactly on rational numbers, Normalized finite regular continued fractions are unique).

[F2]

For convergents, pn=anpn−1+pn−2 and qn=anqn−1+qn−2, and the finite-prefix formula is (Tpj+pj−1)/(Tqj+qj−1) for the positive remaining tail T (Convergents of a regular continued fraction, Convergents are given by the standard recurrences and tail formula, Complete-quotient tail formula).

[F3]

Adjacent convergents satisfy pjqj−1−pj−1qj=(−1)j−1 (Determinant identity for consecutive convergents).

[F4]

The complete quotient is T=aj+1 at the last digit and otherwise T>aj+1; the denominator recurrence is increasing after the possible initial equality q0=q1=1 (Complete quotients in the continued-fraction algorithm, Convergents of a regular continued fraction).

[F5]

Reduced means coprime numerator and positive denominator, with gcd 1. If d is coprime to u and d∣uv, then d∣v (Coprime integers: gcd⁡(a,b)=1, If gcd⁡(a,b)=1 and a∣bc then a∣c; and if a∣c, b∣c and gcd⁡(a,b)=1 then ab∣c). Rational absolute value is multiplicative and satisfies the triangle inequality (Absolute value and the triangle inequality).

Proof

1.1givenF1F2F3F5algebra

By [F1], write A/D=[a0;…,as] in normalized finite form. Since D>2q≥2, A/D is not an integer, so s≥1. Its terminal convergent equals A/D by [F1] and [F2]. By [F3], any common divisor of ps,qs divides 1, so this pair is coprime. Cross multiplication gives Aqs=psD. Since gcd⁡(A,D)=1, [F5] gives D∣qs; since gcd⁡(ps,qs)=1, it also gives qs∣D. Both denominators are positive, so they are equal: qs=D.

2.1givenF2step 1.1algebra

If q=1, then p is an integer and ∣A/D−p∣<1/2. Put a0=⌊A/D⌋ and e:=A/D−a0∈(0,1). The only possible such integers are a0 and a0+1. The first is the zeroth convergent. If p=a0+1, then e>1/2, hence a1=⌊1/e⌋=1; the recurrence in [F2] gives p1/q1=(a0+1)/1. Thus p/q is a convergent.

2.2givenF2F4step 1.1choose

Suppose q≥2. Since q<D=qs, choose the largest j with qj≤q. Then 0≤j<s; the only repeated initial denominator can be q0=q1=1, so qj>0 and s0:=qj−1/qj lies in [0,1] (with q−1=0 when j=0). Put T=aj+1 if j+1=s, and otherwise let T be the complete quotient after the prefix. By [F4], T≥aj+1, and x:=q/qj satisfies 1≤x<aj+1+s0≤T+s0=:L.

3.1F2F3F5step 2.2algebra

Put ε=pjqj−1−pj−1qj=±1 by [F3]. The integers u=ε(qj−1p−pj−1q) and v=ε(pjq−qjp) satisfy (p,q)=u(pj,qj)+v(pj−1,qj−1) by expansion and ε2=1; hence x=u+vs0. Cross multiplication using the tail formula [F2] gives pq−AD=(upj+vpj−1)(Tqj+qj−1)−(Tpj+pj−1)(uqj+vqj−1)q(Tqj+qj−1)=ε(u−vT)qj2xL. Since q=xqj, it follows that q2∣A/D−p/q∣=x∣u−vT∣/L. Finally L=T+s0 and x=u+vs0, so u−vT=x−vL and q2∣A/D−p/q∣=x∣x−vL∣/L.

4.1givenstep 3.1algebra

The hypothesis makes the expression in step 3.1 less than 1/2. If v≤−1, then ∣x−vL∣≥x+L, so x∣x−vL∣/L>x≥1. If v≥2, then ∣x−vL∣≥2L−x>L because x<L, so again x∣x−vL∣/L>x≥1. Both alternatives are impossible.

4.2givenF4step 2.2step 3.1algebra

If v=1, then u=x−s0 is an integer. If s0<1, x≥1 implies u>0; if s0=1, then j≥1 and qj=qj−1=1, while q≥2 forces x≥2. Thus u≥1. Also q<qj+1 implies u<aj+1, so L−x=T−u≥1. Hence x(L−x)/L≥x/(x+1)≥1/2, contradicting the strict hypothesis. Thus v≠1.

5.1F1step 4.1step 4.2algebra∎

The alternatives v≤−1, v≥2, and v=1 were excluded in steps 4.1–4.2, so v=0. Then (p,q)=u(pj,qj), hence p/q=pj/qj and p/q is the jth convergent. The proof includes the terminal case j+1=s because only T≥aj+1 was used, allowing equality at the terminal tail.

LemmaStatement: AI-adaptedProof: AI-generatedjudge pass (gpt-6-luna)Open item page →

Uniqueness of denominator-bounded phase candidates

Statement

Let N≥1, Q>4N2 be integers and 0≤y<Q. There is at most one reduced fraction p/q with 1≤q≤N satisfying 2∣yq−pQ∣≤q.

Facts & Assumptions

Given: Integers N≥1, Q>4N2, an integer y with 0≤y<Q, and reduced fractions with positive denominators.

[F1]

A fraction is reduced when its integer numerator and positive denominator are coprime; coprime means gcd equal to 1 (Common divisor, and the greatest common divisor gcd⁡(a,b), with the convention gcd⁡(0,0):=0, Coprime integers: gcd⁡(a,b)=1).

[F2]

Rational subtraction is computed by cross multiplication: p1/q1−p2/q2=(p1q2−p2q1)/(q1q2) when q1,q2>0 (Arithmetic on the rationals).

[F3]

Rational absolute value is multiplicative and satisfies ∣u+v∣≤∣u∣+∣v∣ (Absolute value and the triangle inequality).

Proof

1.1givenF2F3algebra

For any fraction p/q passing the test, division by the positive integer 2Qq gives ∣y/Q−p/q∣≤1/(2Q). Thus two passing fractions have distance at most 1/Q by the triangle inequality.

2.1givenF1F2step 1.1algebra∎

If p1/q1 and p2/q2 are distinct reduced fractions, [F2] makes their difference a nonzero integer divided by q1q2, so its absolute value is at least 1/(q1q2)≥1/N2. Since Q>4N2, 1/Q<1/(4N2)<1/N2, contradicting the bound from step 1.1. Therefore the two fractions coincide.

LemmaStatement: Literature-sourcedProof: AI-adaptedjudge pass (gpt-6-luna)Open item page →

Elementary lower bound for the totient ratio

Statement

For every integer r≥1, φ(r)/r≥1/(1+log⁡2r), with φ(1)=1.

Facts & Assumptions

Given: An integer r≥1 and its distinct prime divisors.

[F1]

If the distinct prime divisors of r are p1<⋯<pω, then φ(r)/r=∏i=1ω(1−1/pi); the empty product is 1 when r=1 (Euler's product formula φ(n)=n∏p∣n(1−1/p)=∏pk∥n(pk−pk−1) for n≥1, stated through a finite injective list of its prime divisors).

[F3]

Integer multiplication is associative and commutative, and d∣r means r=dc for some integer c (The integers form a commutative ring, Divisibility in Z: d∣a when a=dq for some integer q).

Proof

1.1givenF1

If r=1, then ω=0 and [F1] gives φ(1)/1=1, which is the claimed bound. Suppose r>1.

2.1F1F2step 1.1algebra

For every i, the increasing distinct primes satisfy pi≥i+1: there are only i−1 integers strictly between 1 and i+1, so fewer than i distinct primes can lie there. Therefore each factor in [F1] obeys 1−1/pi≥1−1/(i+1)=i/(i+1). Multiplying positive factors gives φ(r)/r≥∏i=1ωi/(i+1)=1/(ω+1).

3.1F2F3step 2.1algebra∎

Take a prime factor list for r from [F2] and sort its distinct entries as p1<⋯<pω, choosing for each value its first occurrence in that finite list. By associativity and commutativity in [F3], regrouping the list gives r=(p1⋯pω)c for a positive integer c. Thus the distinct-prime product divides r, and since every pi≥2, r≥2ω. Therefore ω≤log⁡2r, so 1/(ω+1)≥1/(1+log⁡2r). This proves the assertion.

DefinitionDefinition: Literature-sourcedProof: Not applicableOpen item page →

Denominator-bounded rational phase reconstruction

Definition

Let N,Q be integers with N≥1 and Q>4N2. A measured phase label is represented by the unique integer y with 0≤y<Q as in For n≥1, every class in Z/n has one representative r with 0≤r<n, so ∣Z/n∣=n; while Z/0 is in bijection with Z. Write the normalized finite regular continued fraction of y/Q as [a0;…,as] and denote its convergents by pj/qj. Every convergent is reduced by Determinant identity for consecutive convergents. A candidate is a convergent whose numerator and denominator are reduced, whose denominator satisfies 1≤qj≤N, and which passes the exact integer test 2∣yqj−pjQ∣≤qj.

The reconstruction result is the unique candidate if the candidate set is nonempty, and is FAIL otherwise. The candidate set includes the terminal convergent whenever it meets the same conditions. Uniqueness, and hence well-definedness of this value, follows from Uniqueness of denominator-bounded phase candidates under Q>4N2.

AlgorithmAlgorithm: Literature-sourcedProof: Not applicableOpen item page →

Rational reconstruction from a phase sample

Definition

Input. Integers N≥1, Q>4N2, and y∈{0,…,Q−1}, with Q=2m and y the label from Quantum phase estimation when this routine is called from QPE.

Output. A reduced fraction p/q with 1≤q≤N, or FAIL.

Instructions. Set u:=y, v:=Q, and j:=0. Repeatedly divide u by the positive integer v, obtaining the unique quotient aj and remainder rj with u=ajv+rj and 0≤rj<v. Append aj; if rj=0, stop, and otherwise set (u,v):=(v,rj), increment j, and repeat. For y=0 this immediately gives the one-digit expansion [0]; for every other input, The continued-fraction algorithm terminates exactly on rational numbers gives termination and the resulting normalized finite expansion is the one in Denominator-bounded rational phase reconstruction. Starting from p−2=0,p−1=1,q−2=1,q−1=0, process the digits in order using pj=ajpj−1+pj−2 and qj=ajqj−1+qj−2; this lists all convergents including the terminal one by Convergents of a regular continued fraction. For each convergent, reject it if q>N; otherwise compute 2∣yq−pQ∣ exactly and accept it precisely when this integer is at most q. Return the first accepted candidate, or FAIL if none exists. The uniqueness result lem-qa-rational-reconstruction-candidate-uniqueness shows there cannot be two. The algorithm makes no floating-point comparison. Its deterministic bit bound is proved separately in thm-qa-rational-reconstruction-bit-cost, which also establishes that these instructions terminate.

TheoremStatement: Literature-sourcedProof: AI-adaptedOpen item page →

Correctness of phase-sample rational reconstruction

Statement

Let integers N≥1, m≥0, Q=2m, and 1≤r≤N satisfy Q>4N2, and let k∈Z with 0≤k<r and gcd⁡(k,r)=1. Let y∈{0,…,Q−1} be any nearest grid label to phase k/r in circular distance, meaning min⁡z∈Z∣k/r−y/Q−z∣≤1/(2Q). Then Rational reconstruction from a phase sample returns k/r. For every phase label y, there is at most one passing candidate with denominator at most N.

Facts & Assumptions

Given: Reduced k/r∈[0,1) with r≤N, Q=2m>4N2 for an integer m≥0, and a nearest circular grid label y.

[F1]

Circular distance is dT(θ,y/Q)=min⁡z∈Z∣θ−y/Q−z∣; for θ∈[0,1), a nearest label has distance at most 1/(2Q) (Circular phase distance modulo one).

[F2]

The reconstruction routine tests the exact condition 2∣yq−pQ∣≤q on normalized finite-CF convergents with q≤N (Rational reconstruction from a phase sample, Denominator-bounded rational phase reconstruction).

[F3]

For reduced A/D with D>2q, a reduced p/q satisfying ∣A/D−p/q∣<1/(2q2) is a convergent of the normalized finite expansion (Finite-rational Legendre criterion before the terminal convergent).

[F4]

At most one reduced fraction of denominator at most N passes the exact reconstruction window when Q>4N2 (Uniqueness of denominator-bounded phase candidates).

Proof

1.1givenF2F4algebra

If k=0, reducedness forces r=1. The only nearest circular grid label is y=0, so y/Q=0 and its normalized finite expansion is [0] with terminal convergent 0/1. This convergent has denominator 1≤N and passes the exact test, so [F2] and [F4] return 0/1=k/r.

1.2givenF1algebra

Suppose k>0. The distance from k/r to either endpoint 0,1 is at least 1/r≥1/N>1/(2Q), by Q>4N2. Therefore a nearest circular label cannot cross an endpoint: if y/Q were on the other side of 0 or 1, the circular distance would be at least the distance of k/r from that endpoint, contradicting [F1]. Thus ∣y/Q−k/r∣≤1/(2Q).

2.1givenF2F4step 1.2algebra

Reduce y/Q to A/D with D>0. If A/D=k/r, its normalized finite expansion terminates at that fraction; its terminal convergent is k/r, whose denominator is at most N, and step 1.2 gives 2∣yr−kQ∣≤r. Thus it passes [F2], and uniqueness [F4] makes the algorithm return it.

2.2givenF3step 1.2algebra

If A/D≠k/r, then ∣Ar−kD∣ is a positive integer, so ∣A/D−k/r∣≥1/(Dr). Combining with step 1.2 gives D≥2Q/r>8N2/r≥8r>2r, because r≤N. Also Q>4N2≥4r2 gives ∣A/D−k/r∣≤1/(2Q)<1/(8r2)<1/(2r2). Applying [F3] with p/q=k/r shows it is a convergent of A/D.

3.1F2F4step 1.2step 2.1step 2.2algebra∎

The same linear error bound in step 1.2 gives 2∣yr−kQ∣≤r. Therefore this convergent passes the exact test and denominator bound in [F2]. By [F4] it is the unique accepted candidate, so the algorithm returns k/r. The two cases establish correctness and candidate uniqueness.

AlgorithmAlgorithm: Literature-sourcedProof: Not applicablejudge pass (gpt-6-luna)Open item page →

Reversible modular multiplication by a unit

Definition

Input. An integer N≥2, n=⌈log⁡2N⌉, a one-bit control c, an n-bit data register z, and integers a,a−1 with 0≤a,a−1<N and aa−1≡1(modN). The data encoding is valid when its unsigned value is less than N.

Residue addition and multiplication are in Z/N with the class operations of The congruence class [a]n and the quotient set Z/n, Addition and multiplication on Z/n by [a]n+[b]n=[a+b]n and [a]n[b]n=[ab]n, and For every natural n, (Z/n,+) is an abelian group, multiplication is a commutative monoid operation, and both distributive laws hold. The inverse condition says [a]N is a unit, equivalently gcd⁡(a,N)=1 by The unit group (Z/n)× and Euler's totient φ(n)=∣(Z/n)×∣ for n≥1 and For n≥1, [a]n is a unit if and only if gcd⁡(a,n)=1. Kets use Dirac Notation Conversion; c,z are ordered computational-basis registers with the unsigned encoding of Finite registers and their ordered computational bases and Big-endian encoding of ordered bit strings, tensor order as in Ordered tensor registers, their inner product, and wire permutations, and circuit denotation as in Denotational semantics of a finite layered circuit. “Clean work” means initialized and returned to zero under Clean and dirty ancillas.

Output. A reversible circuit on c,z and clean work registers which implements the controlled map z↦az mod N for c=1 and valid z, and is the identity on invalid encodings and when c=0.

Instructions. Define the total Boolean function on (c,z) by fa(c,z)={az mod N,c=1 and z<N,z,otherwise. Generate the following explicit NOT/AND/OR DAG for this function. Bit arrays in the instructions below are indexed from least significant bit 0; the input and output port lists retain the repository's most-significant-first register order. Begin with the distinct input identifiers c,zn−1,…,z0 and two constant nodes 0,1. Every gate emission appends a fresh identifier in consecutive order, referencing only existing identifiers. A named bit below is an alias of its node identifier, never an additional gate. Expand every macro call immediately in the stated loop order.

  1. Define XOR⁡(u,v) by emitting, in order, o=OR⁡(u,v), h=AND⁡(u,v), d=NOT⁡(h), and e=AND⁡(o,d), returning e. Define ADD⁡w(U,V,d0) by looping i=0,…,w−1: emit ei=XOR⁡(Ui,Vi), si=XOR⁡(ei,di), hi=AND⁡(Ui,Vi), ji=AND⁡(ei,di), and di+1=OR⁡(hi,ji). Return (s0,…,sw−1) and dw. Define SUB⁡w(U,V) by first emitting NOT⁡(Vi) in increasing i and then calling ADD⁡w(U,NOT⁡(V),1); return its difference bits and carry bit h (the no-borrow bit).
  2. Define SELECT⁡w(h,U,V) by emitting d=NOT⁡(h) and, for i=0,…,w−1, ui=AND⁡(h,Ui), vi=AND⁡(d,Vi), si=OR⁡(ui,vi). It returns the selected bit array S. Public constant arrays below refer to the shared 0,1 nodes and are zero-padded to the displayed width.
  3. Initialize a 2n-bit accumulator P with zero aliases. For i=0,…,n−1, form a 2n-bit row H: for j=0,…,n−1, emit Hi+j=AND⁡(ai,zj), where ai is the constant bit of a; all other row bits alias 0. Replace P by the sum output of ADD⁡2n(P,H,0), ignoring the carry output.
  4. Initialize R to n zero aliases. For ℓ=2n−1,…,0, form the (n+1)-bit array V by V0=Pℓ and Vi=Ri−1 for 1≤i≤n. Call SUB⁡n+1(V,N), obtaining difference D and carry h. Set R to the low n bits of SELECT⁡n+1(h,D,V).
  5. Pad z by a zero high bit, call SUB⁡n+1(z,N), and let h be its carry. Emit v=NOT⁡(h) and g=AND⁡(c,v). Set F=SELECT⁡n(g,R,z). The ordered output ports are Fn−1,…,F0. This completes the finite DAG and its topological order. Construct a second DAG by the identical recipe with constant a−1 in place of a.

Compile each DAG to the clean-target XOR oracle of Coherent XOR function oracle using Reversible embedding of a Boolean circuit, whose exact gate-emission rules apply also to repeated-source ports. Allocate an n-bit clean target, compute fa(c,z) into it, swap the data and target registers with three CNOT gates per bit, then apply the compiled XOR computation for fa−1 to the old-data target, using the new data as input. Each compiled XOR oracle is an involution by A total Boolean XOR oracle is unitary and involutive. Return the concatenated gate list with every compute-copy-uncompute stage included. Separate items thm-qa-modular-multiplication-circuit-correctness and thm-qa-modular-arithmetic-cost establish its basis action and gate/work bounds. No depth bound is part of this algorithm.

TheoremStatement: Literature-sourcedProof: AI-adaptedjudge pass (gpt-6-luna)Open item page →

Correctness of the reversible modular multiplier

Statement

For N≥2, n=⌈log⁡2N⌉, and a unit a(modN) with supplied inverse a−1, the circuit of Reversible modular multiplication by a unit is unitary. On a computational-basis state it fixes the control bit, sends ∣z⟩ to ∣az mod N⟩ if c=1 and z<N, and fixes z if c=0 or z≥N. All Boolean value, target, and scratch registers return to zero. Its action therefore extends coherently to superpositions.

Facts & Assumptions

Given: N≥2, a unit a(modN) and inverse a−1, a one-bit control and an n-bit data register, and the construction in Reversible modular multiplication by a unit.

[F1]

The circuit computes the total function fa(c,z) into a clean target by an XOR oracle, swaps that target with z, then computes fa−1 on the new data to clear the old-data target (Reversible modular multiplication by a unit). Its gate list acts in the declared chronological order on the stated wires (Denotational semantics of a finite layered circuit).

[F2]

Reversible embedding maps ∣x,y,0w⟩ to ∣x,y⊕f(x),0w⟩ for every basis input and target, restores clean work, and extends to superpositions; a clean register begins in its all-zero basis vector (Gate, workspace, and serial-depth costs of reversible embedding, Clean and dirty ancillas).

[F3]

A coherent XOR oracle acts as ∣x,y⟩↦∣x,y⊕f(x)⟩ and is a unitary involution for every total Boolean f on the ordered computational-basis register (Coherent XOR function oracle, A total Boolean XOR oracle is unitary and involutive, Finite registers and their ordered computational bases).

Proof

1.1givenF1algebra

The DAG's XOR formula is (u∨v)∧¬(u∧v), which is u+v modulo 2 for each of the four input pairs. In its adder, Ui+Vi+di=si+2di+1: if both input bits are 1 the carry is 1, if exactly one is 1 the carry is di, and if both are 0 the carry is 0; the displayed sum bit has the corresponding parity. Multiplying by 2i and summing proves U+V+d0=S+2wdw. Subtraction therefore represents U+(2w−1−V)+1=U−V+2w; its carry is 1 exactly when U≥V, and its low bits are U−V modulo 2w. The selector's disjoint branches give U for h=1 and V for h=0.

2.1F1step 1.1inductionalgebra

After the first i product rows, the accumulator is z∑j<iaj2j. This holds initially and is preserved by step 1.1; no overflow occurs because every partial sum is at most az<22n. Thus the final product bits represent az even for invalid input encodings. In the remainder loop, the invariant is that R is the remainder modulo N of the already scanned product prefix and 0≤R<N. Appending bit Pℓ gives V=2R+Pℓ<2N. Subtraction and selection from step 1.1 give V−N if V≥N and V otherwise, so the next value lies in [0,N) and is the new prefix remainder. It fits n bits, making the discarded high bit zero, even when N=2n. Induction proves the final R=az mod N. The final no-borrow comparison gives v=1 exactly when z<N, and selection by c∧v therefore computes precisely fa(c,z). The same argument applies to a−1.

3.1givenF1F4step 2.1algebra

Fix c,z. If c=0 or z≥N, the defining function and its inverse-function counterpart both return z. If c=1 and z<N, the first function returns z′=az mod N<N and the inverse function returns a−1z′ mod N=z, by [F4]. Thus in every case fa−1(c,fa(c,z))=z.

4.1F1F2F3step 3.1algebra

By [F2] and [F3], the first computation adds fa(c,z) into a clean target and restores all value-computation work. A bitwise swap made from CNOTs acts as (u,v)↦(u,u⊕v)↦(v,u⊕v)↦(v,u), so after the three CNOTs per bit the data register contains fa(c,z) and the target contains the old z.

5.1F1F2step 3.1step 4.1algebra

Apply the clean XOR computation for fa−1 to the new data and the target holding old z. Step 3.1 says its output is exactly that old z, so XOR changes the target to z⊕z=0 and restores its computation work by [F2]. Hence all temporary registers are clean and the data/control action is the claimed one.

6.1F2F4step 5.1algebra∎

On valid residue encodings, multiplication by a is a bijection of the residue register because a−1 is its inverse; on invalid encodings and at control 0 the map is the identity. It is therefore a permutation of the full finite computational basis. A basis permutation is unitary, and [F2] supplies the same action on arbitrary superpositions with clean work. This proves the statement.

AlgorithmAlgorithm: Literature-sourcedProof: Not applicableOpen item page →

Modular order finding with rational reconstruction

Definition

Input. An integer N≥3, the standard representative x∈{1,…,N−1} of a unit class modulo N, and an integer b≥1 specifying target failure probability δ=2−b.

The representative is the unique one in 0≤x<N by For n≥1, every class in Z/n has one representative r with 0≤r<n, so ∣Z/n∣=n; while Z/0 is in bijection with Z; unit membership is equivalent to gcd⁡(x,N)=1 by The unit group (Z/n)× and Euler's totient φ(n)=∣(Z/n)×∣ for n≥1 and For n≥1, [a]n is a unit if and only if gcd⁡(a,n)=1. The register ket ∣1⟩ uses Dirac Notation Conversion. The superposition output law for applying the QPE gate list to this non-eigenvector input is supplied by Phase estimation on a superposition of eigenspaces.

Output. An accepted candidate, or FAIL.

Instructions. Set n=⌈log⁡2N⌉, m=2n+3, Q=2m, and t=4(n+1)b. The inequality Q>4N2 follows from N≤2n. Compute the inverse constant by the following binary-integer loop. Initialize (R,S,U,V):=(N,x,0,1). While S>0, use division with remainder to compute q,r with R=qS+r and 0≤r<S, compute the least residue h=(U−qV) mod N, and simultaneously replace (R,S,U,V) by (S,r,V,h). Division and least residues use Division with remainder in Z: for a∈Z and b>0 there are unique q,r∈Z with a=qb+r and 0≤r<b and For n≥1, every class in Z/n has one representative r with 0≤r<n, so ∣Z/n∣=n; while Z/0 is in bijection with Z; use schoolbook binary arithmetic for every update. When the loop stops, return FAIL if R≠1; otherwise set b0:=U and a0:=x. The inverse identity, termination, and preprocessing bit cost are established in Gate and bit cost of modular multiplication and powering. For j=0,…,m−2, compute aj+1=aj2 mod N and bj+1=bj2 mod N. Then aj=x2j mod N and bj=aj−1 mod N for all j<m.

Repeat independently for samples s=1,…,t. Initialize the system register to the valid residue ∣1⟩ and apply the QPE phase-estimation circuit with phase-register length m. Its controlled Ux2j gate is implemented by the explicit controlled modular-multiplication circuit for aj from Reversible modular multiplication by a unit. This procedure uses the QPE gate list on ∣1⟩; it does not assert that ∣1⟩ is an eigenvector. Measure the phase register to obtain y. Run Rational reconstruction from a phase sample with (N,Q,y). If it returns FAIL, retain no denominator from this sample. If it returns p/q, compute xq mod N as follows: set v:=1, a:=x, e:=q; while e>0, if e is odd set v:=va mod N, then set a:=a2 mod N and e:=⌊e/2⌋. Retain q exactly when the final v=1.

After all samples, return the smallest retained positive denominator; return FAIL if none was retained. A passing candidate is not called the order unless it is minimal. The exact criterion xq=1 iff the order divides q is If ord⁡(g)=n then gk=e iff k is an integer multiple of n, the powers g0,…,gn−1 are distinct, and ⟨g⟩ has exactly n elements; if g has infinite order then gj=gk only for j=k. The separate item thm-qa-modular-order-finding-success proves the probability guarantee and the fact that every retained candidate is an order multiple.

TheoremStatement: Literature-sourcedProof: AI-adaptedOpen item page →

Gate and bit cost of modular multiplication and powering

Statement

Let N≥2, n=⌈log⁡2N⌉, and let 1≤x<N be the standard representative of a known unit modulo N. In the explicit schoolbook Boolean construction of Reversible modular multiplication by a unit, each controlled multiplication by a known unit has a Boolean DAG with S,E=O(n2). Under the compiler of Gate, workspace, and serial-depth costs of reversible embedding, the complete clean circuit, including both XOR computations, n swaps, and inverse cleanup, uses O(n2) elementary gates and O(n2) clean work bits. Repeated-squaring constants x2j mod N and their inverses for O(n) powers can be computed in O(n3) deterministic multitape bit transitions. No depth bound is asserted.

Facts & Assumptions

Given: N≥2, 1≤x<N a standard unit representative, the stated schoolbook arithmetic, the reversible circuit in Reversible modular multiplication by a unit, and the resource models in Circuit-family and computation cost model and Classical bit-operation cost.

[F1]

The reversible compiler uses at most 6S+4E+m elementary gates and at most S+E clean work bits for an m-bit output Boolean DAG (Gate, workspace, and serial-depth costs of reversible embedding).

[F2]

The multiplier computes a controlled constant product, a remainder, a validity condition, the inverse cleanup, and n swaps; its correctness is established by Correctness of the reversible modular multiplier and its circuit stages are specified in Reversible modular multiplication by a unit.

[F3]

Bit cost counts multitape Turing-machine transitions and charges classical arithmetic, address/input work, and output writing; it is separate from gate and query costs (Classical bit-operation cost, Circuit-family and computation cost model).

[F4]

Division by a positive integer gives a unique quotient and smaller nonnegative remainder; the Euclidean descent from (N,x) with x>0 terminates at (gcd⁡(N,x),0) (Division with remainder in Z: for a∈Z and b>0 there are unique q,r∈Z with a=qb+r and 0≤r<b, The Euclidean algorithm: for a∈Z and b>0 the remainder descent from (a,b) terminates, and the last nonzero remainder is gcd⁡(a,b)).

[F5]

The operations in Z/NZ are well-defined ring operations, so congruences are preserved by subtraction and multiplication (For every natural n, (Z/n,+) is an abelian group, multiplication is a commutative monoid operation, and both distributive laws hold).

[F6]

A residue class modulo N is a unit exactly when its representative is coprime to N (For n≥1, [a]n is a unit if and only if gcd⁡(a,n)=1).

[F7]

Every residue class modulo positive N has a unique standard representative x with 0≤x<N (For n≥1, every class in Z/n has one representative r with 0≤r<n, so ∣Z/n∣=n; while Z/0 is in bijection with Z).

Proof

1.1givenF2algebra

In the explicit DAG of [F2], XOR emits four nodes, each adder bit emits two XORs and three carry nodes, hence 11 nodes, and subtraction emits one additional NOT per bit, hence 12w nodes at width w. Selection emits 1+3w nodes. The product uses n2 partial-product AND nodes and n adders of width 2n, totaling 23n2 nodes. Its 2n remainder stages use 2n(12(n+1)+1+3(n+1)) nodes. The final comparison uses 12(n+1) nodes, validity/control uses two more, final selection uses 1+3n, and the two shared constant nodes complete the count. Thus S≤100(n+1)2 suffices for all n≥1; every gate has at most two input ports, so E≤2S. The correctness supplier in [F2] proves that the row sums never overflow and that each remainder stage needs only one conditional subtraction; these are exactly the loops just counted.

1.2givenF3F4F5F6F7inductionalgebra

For the inverse computation, initialize (R,S,U,V)=(N,x,0,1) and, while S>0, divide R=qS+r with 0≤r<S, set h=(U−qV) mod N to its least residue, and simultaneously update (R,S,U,V) to (S,r,V,h). Initially R≡Ux and S≡Vx(modN); these two congruences are preserved because r=R−qS≡(U−qV)x≡hx(modN) by [F5]. The remainder pair is exactly the Euclidean descent in [F4], so it terminates at (R,S)=(gcd⁡(N,x),0)=(1,0) by [F6]. The invariant then gives Ux≡1(modN), and [F7] gives the returned inverse constant b0=U∈[0,N). For its cost, at every division 0<S<R≤N; the new remainder is r<R/2: if S≤R/2, then r<S≤R/2, while if S>R/2, then q=1 and r=R−S<R/2. Thus every two successive positive remainder values shrink by at least a factor of two, giving O(n) iterations. The quotients and remainders have O(n) bits, and U,V always lie in [0,N), so the signed intermediate U−qV has O(n) bits as well (its magnitude is at most N2+N). Schoolbook division, multiplication, subtraction and reduction each take O(n2) multitape transitions, including signed reduction by dividing the absolute value and, when needed, replacing a nonzero remainder d by N−d. Hence this explicit loop costs O(n3) transitions. Set a0=x, and for the remaining O(n) powers compute aj+1=aj2 mod N and bj+1=bj2 mod N. Induction gives aj≡x2j and ajbj≡1(modN); each stage uses two O(n2) schoolbook modular products, so all powers and inverses still cost O(n3) transitions.

2.1F1F2step 1.1algebra

Step 1.1 counts the complete Boolean function DAG, including the validity comparison, control, and conditional output, and gives S,E=O(n2). Apply [F1] separately to the forward and inverse functions; the two compiled XOR maps and their clean work each cost O(n2). The swap uses 3n CNOT gates. Adding these counts proves the claimed O(n2) gate and clean-work bounds; [F2] ensures they implement the required map.

3.1F1F3step 2.1step 1.2∎

The resource definition [F3] keeps gate count, classical bit transitions, and oracle queries separate. The preceding counts establish only gate/work and stated classical arithmetic bounds; no circuit layering or depth estimate follows from them.

TheoremStatement: Literature-sourcedProof: AI-adaptedOpen item page →

Bit cost of phase-sample rational reconstruction

Statement

Let N≥1, m≥0, Q=2m>4N2, and y∈{0,…,Q−1} be integers, and set L=⌈log⁡2(Q+1)⌉. Under the multitape bit-transition model of Classical bit-operation cost, Rational reconstruction from a phase sample uses O(L) Euclidean divisions and O(L3) deterministic bit transitions. No real-number arithmetic is used.

Facts & Assumptions

Given: Integers N≥1, m≥0, Q=2m>4N2, 0≤y<Q, the reconstruction routine, and the bit-cost convention.

[F1]

Rational continued fractions are computed by the Euclidean quotient algorithm; integer division has quotient and remainder u=av+r with 0≤r<v, and convergent denominators obey qj=ajqj−1+qj−2 (Rational reconstruction from a phase sample, Finite and infinite regular continued fractions, Convergents of a regular continued fraction, Division with remainder in Z: for a∈Z and b>0 there are unique q,r∈Z with a=qb+r and 0≤r<b).

[F2]

Bit cost counts transitions of a fixed finite-alphabet multitape machine and charges comparison, arithmetic, reading, and output work (Classical bit-operation cost).

Proof

1.1F1givenalgebra

Let qj be the convergent denominators, with q0=1 and q1≥1. The recurrence in [F1] gives qj+2≥qj+1+qj≥2qj whenever both indices exist. Since the terminal denominator is at most Q, every two quotient steps at least double a positive denominator, so the number of Euclidean divisions is at most 2L+O(1)=O(L).

2.1F1F2step 1.1algebra

The reduced denominator of y/Q is at most Q, so the recurrence in [F1] makes each convergent denominator at most its terminal denominator. Since 0≤y/Q<1, the normalized expansion starts with a0=0; its initial convergents satisfy 0≤p0≤q0 and 0≤p1≤q1, and the recurrence with positive later digits preserves 0≤pj≤qj. Thus all convergent numerators and denominators have O(L) bits. By the division algorithm in [F1], binary long division of two such integers can be performed by at most O(L) compare/subtract scans of at most O(L) bits, hence O(L2) multitape transitions under [F2].

3.1F1F2step 1.1step 2.1algebra

Updating a convergent numerator and denominator by [F1] uses a constant number of products and sums on O(L)-bit integers, hence O(L2) transitions per update. Each convergent candidate also requires a constant number of products yqj and pjQ, an absolute difference, a doubling, and a comparison with qj. Schoolbook multiplication and these scans each cost O(L2) transitions. There are O(L) candidates by step 1.1, so total comparison work is O(L3); writing the selected numerator and denominator costs only O(L).

4.1F1F2step 3.1∎

The routine normalizes the rational by exact Euclidean divisions and applies only the integer test from [F1]; all work is covered by the above bounds. Hence its deterministic multitape bit cost is O(L3) and it performs no floating-point comparison.

TheoremStatement: Literature-sourcedProof: AI-adaptedjudge pass (gpt-6-luna)Open item page →

Success probability and repetition for modular order finding

Statement

Let integer N≥3, and let x be a unit modulo N of order r. Use Modular order finding with rational reconstruction with b∈Z≥1 and δ=2−b. One independent phase sample yields denominator r with probability at least 4π2φ(r)r≥4π2(1+log⁡2N). After t=4(n+1)b independent samples, where n=⌈log⁡2N⌉, the algorithm returns the exact order with probability at least 1−2−b. For any requested 0<δ<1, taking b=⌈log⁡2(1/δ)⌉ gives success probability at least 1−δ.

Facts & Assumptions

Given: N≥3, a unit class x modulo N, its order r, and the circuit/sampling instructions in Modular order finding with rational reconstruction.

[F1]

The unit classes form a finite group of size φ(N); an element of a finite group has finite order dividing the group size. Standard representatives identify this group with a subset of {0,…,N−1} (The unit group (Z/n)× and Euler's totient φ(n)=∣(Z/n)×∣ for n≥1, The order of every element of a finite group divides the order of the group, For n≥1, every class in Z/n has one representative r with 0≤r<n, so ∣Z/n∣=n; while Z/0 is in bijection with Z).

[F2]

On valid residues, Ux∣z⟩=∣xz mod N⟩ and invalid n-bit encodings are fixed by the multiplier circuit (Reversible modular multiplication by a unit, Correctness of the reversible modular multiplier).

[F3]

The finite cyclic characters are orthogonal: ∑s=0r−1e2πi(k−ℓ)s/r=r if k=ℓ(modr) and 0 otherwise (Orthogonality of the characters x↦e2πikx/N on Z/NZ).

[F4]

For each eigenphase, phase estimation on a superposition has the eigenspace-weighted outcome mixture; every nearest Q-grid label has probability at least 4/π2 (Phase estimation on a superposition of eigenspaces, Phase-estimation nearest-grid and tail bounds).

[F7]

For every integer s≥3, the circumscribed regular s-gon has perimeter Os=2stan⁡(π/s) and satisfies 2π<Os (Inscribed regular-polygon perimeters increase to 2 pi, while circumscribed perimeters decrease to 2 pi).

[F8]

The cofunction identity gives sin⁡(π/2−x)=cos⁡x, and the Pythagorean identity gives sin⁡2x+cos⁡2x=1 (Cofunction, supplementary, quarter-turn, and reflection identities for the six trigonometric functions, Pythagorean and parity identities for all six trigonometric functions on their natural domains).

[F9]

Sine is strictly increasing on [−π/2,π/2], cosine is strictly decreasing on [0,π], sin⁡0=0, cos⁡(π/2)=0, and π>0 (Signs, monotonicity intervals, and ranges of sine and cosine, Quarter-turn values and shifts by pi/2 and pi, Pi as twice the smallest positive zero of cosine).

[F10]

On its natural domain, tan⁡x=sin⁡x/cos⁡x (Tangent, cotangent, secant, and cosecant on their exact natural domains).

[F11]

Distinct computational-basis vectors of a register are orthonormal (The computational basis is orthonormal).

Proof

1.1givenF1F2algebra

By [F1], r is a positive integer and r≤φ(N)≤N: write φ(N)=dr with integer d by divisibility in [F1]. The group contains its identity, so φ(N)>0; since r>0, d>0 and thus d≥1. Consequently r≤φ(N), while the group counts only standard residue representatives and so φ(N)≤N. The orbit ∣xs mod N⟩, 0≤s<r, consists of distinct valid computational-basis vectors, since equality of two residues would imply a smaller positive power of x is 1.

1.2givenF2inductionalgebra

The algorithm starts with a0=x and b0=x−1 in standard representatives. Suppose aj≡x2j and ajbj≡1(modN). Squaring the first identity gives aj+1≡x2j+1, and the two loop updates give aj+1bj+1≡(ajbj)2≡1. Induction proves both identities for all j<m; every constant remains in [0,N) and is a unit with the supplied inverse. On valid residues, repeated application of [F2] therefore gives Ux2j∣z⟩=∣ajz mod N⟩; on invalid encodings both this power and the multiplier are identity. Thus each controlled multiplier in the QPE gate list is the required controlled power on the full data register, with its work returned clean.

2.1F2F3F11step 1.1algebra

Define ∣ψk⟩=r−1/2∑s=0r−1e−2πiks/r∣xs mod N⟩ for 0≤k<r. The shift action in [F2] gives Ux∣ψk⟩=e2πik/r∣ψk⟩, including the wrap from s=r−1 to s=0. By [F11] and [F3] these are orthonormal unit vectors; the same character sum gives ∣1⟩=r−1/2∑k=0r−1∣ψk⟩.

3.1F3F4F5step 1.2step 2.1

Apply the QPE circuit from [F4] to this decomposition. Its outcome law is the uniform mixture over k=0,…,r−1, each phase being k/r; this uses the superposition law in [F4], rather than an eigenvector promise for ∣1⟩. There are exactly φ(r) indices with gcd⁡(k,r)=1, counted by [F5].

4.1F4F5F6step 1.1step 3.1algebra

For each coprime k, [F4] gives probability at least 4/π2 to a nearest grid label. Here m=2n+3, Q=2m>4N2, and r≤N by step 1.1, so the reconstruction correctness theorem applies and returns reduced denominator r on that event. By [F6], xr=1; hence the algorithm's exact verification retains this denominator. Summing the disjoint eigenspace-mixture probabilities gives one-sample success at least (4/π2)φ(r)/r. By [F5] and r≤N, this is at least 4/[π2(1+log⁡2N)].

5.1F6step 4.1algebra

Every retained q passes xq=1, so [F6] implies r∣q. If the exact denominator r is ever retained, no retained candidate is smaller than r and r itself is present; the algorithm's minimum rule therefore returns r.

6.1givenF7F8F9F10step 4.1step 5.1algebra

First put θ=π/4. Since π>0 by [F9], 0<θ<π/2. The cofunction law [F8] gives sin⁡θ=cos⁡θ; strict monotonicity and the endpoint values in [F9] show both are positive. Thus [F10] gives tan⁡(π/4)=1, and [F7] at s=4 gives 2π<O4=8tan⁡(π/4)=8, so π<4. Now put n=⌈log⁡2N⌉ and u=1/[4(n+1)]. The one-sample lower bound in step 4.1 and π<4, together with 1+log⁡2N≤n+1, give p≥u. Independent resets make the t=4(n+1)b samples independent, hence the probability that no successful sample occurs is at most (1−u)t. Since 1−u≤(1+u)−1, and with integer K=4(n+1) the binomial expansion gives (1+1/K)K≥1+K(1/K)=2, we obtain (1−u)Kb≤2−b. By step 5.1, the output is the exact order except on this event.

7.1givenstep 6.1algebra∎

For arbitrary 0<δ<1, choosing b=⌈log⁡2(1/δ)⌉ gives 2−b≤δ. Thus the stated guarantee follows without using an inexact floating-point threshold.

TheoremStatement: Literature-sourcedProof: AI-adaptedOpen item page →

Separate order-finding query, gate, and bit costs

Statement

Let integer N≥3, n=⌈log⁡2N⌉, b∈Z≥1, and δ=2−b. With the explicit multiplier of Gate and bit cost of modular multiplication and powering and the ideal continuous exact-arbitrary-angle QFT cost model, the algorithm uses O(n2b) controlled modular-multiplier circuits, O(n4b) elementary gates, and O(n4b) schoolbook classical bit transitions. Equivalently these are O(n2(1+ln⁡(1/δ))), O(n4(1+ln⁡(1/δ))), and O(n4(1+ln⁡(1/δ))). With only controlled Ux access, the query count is exactly t(Q−1) for t=4(n+1)b and Q=22n+3; this is not a polynomial query bound. No finite gate alphabet, uniform circuit family, or generator-time bound is asserted.

Facts & Assumptions

Given: The modular order-finding circuit and sample count, the QPE cost model, and the distinct gate/bit/query coordinates in Circuit-family and computation cost model and Classical bit-operation cost.

[F1]

The algorithm uses m=2n+3 phase bits, Q=2m, t=4(n+1)b independent samples, and one controlled modular multiplication for each of the m QPE powers per sample (Modular order finding with rational reconstruction).

[F2]

One phase-estimation run uses Q−1 controlled-Ux calls if only controlled-Ux is supplied; exact ideal QFT gate count is O(m2) (Phase-estimation query and gate costs).

[F3]

Each controlled modular multiplier uses O(n2) gates, while repeated-squaring constants and inverses cost O(n3) classical bit transitions (Gate and bit cost of modular multiplication and powering).

[F4]

Continued-fraction reconstruction costs O(n3) bit transitions when Q=22n+3, and the declared model charges classical arithmetic separately from oracle and gate operations (Bit cost of phase-sample rational reconstruction, Classical bit-operation cost, Circuit-family and computation cost model).

Proof

1.1F1givenalgebra

Since Q=22n+3, its bit length is O(n); [F1] has m=O(n) and t=O(nb). There are exactly tm=O(n2b) controlled modular-multiplier circuits.

2.1F1F2F3step 1.1algebra

By [F3], those arithmetic circuits contribute O(n2)⋅O(n2b)=O(n4b) gates. Each QPE phase preparation and ideal inverse QFT contributes O(m2)=O(n2) more gates per sample by [F2], for total O(n3b), which is bounded by O(n4b) since n≥2. Thus the stated gate bound follows.

2.2F1F3F4step 1.1algebra

Precomputing all modular powers and inverses costs O(n3) bits by [F3]. In each sample, reconstruction costs O(n3) by [F4]. Testing a candidate q≤N by binary modular exponentiation uses O(n) modular products on O(n)-bit values, each with O(n2) schoolbook transitions as in [F3], hence O(n3) bits. Across t=O(nb) samples this is O(n4b), including preprocessing because n≥2 and b≥1.

3.1F1F2F3F4step 2.1step 2.2

Under only controlled-Ux access, [F2] charges exactly Q−1 calls for each run, so t(Q−1) is the total query count. Under compiled known modular arithmetic, the multiplier circuits have the separate cost in step 2.1. The cost coordinates in [F4] are independent, so this gate bound does not turn a black-box controlled-Ux query into a polynomial-cost circuit.

4.1F1F2F3F4step 3.1∎

For b≥1, 1+b=O(1+ln⁡(1/δ)) when δ=2−b, since ln⁡(1/δ)=bln⁡2. This gives the equivalent logarithmic forms. The ideal QFT model uses exact continuous rotations, and none of [F1]–[F4] provides a finite-alphabet compilation or a uniform-family generator, so those claims are outside this theorem.

5 · Examples, counterexamples and false statements

None yet.

Sources