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.
Shor’s Factoring Algorithm
1 · Prerequisites
- Absolute and Conditional Convergence; Rearrangement; Products
- Algebraic Closure, Embeddings, and Separability
- Algebraic Extensions, Extension Degree, and Finite Fields
- Arc Length and Rectifiable Curves
- Binary Operations, Monoids, Groups and Subgroups
- Boolean Circuits and Nonuniform Complexity
- Bounded Linear Operators and Quotient Spaces
- Circuit Syntax, Denotational Semantics, and Measurement
- Compactness in Metric Spaces
- Completeness, Completion, and Uniform Continuity
- Complex Norms and Realification
- Complexification, Realification and Real Structures
- Composition Series, the Jordan–Hölder Theorem and Solvable Groups
- Computational Problems, Promises, and Cost Models
- Congruences, the Integers Modulo n and the Chinese Remainder Theorem
- Construction of the Natural Numbers
- Construction of the Real Numbers via Cauchy Sequences
- Construction of the Real Numbers via Dedekind Cuts
- Continuity, IVT, EVT, and Uniform Continuity
- Controlled Gates, Phase, and Entanglement
- Cosets, Index and Lagrange's Theorem
- Countability and Uncountability
- Cyclic Groups and Direct Products
- Determinants of Matrices over a Commutative Ring
- Diagonalisation and the Minimal Polynomial
- Divisibility, Euclidean Domains, Principal Ideal Domains and Unique Factorisation
- Divisibility, Greatest Common Divisors and Bézout's Identity
- Dual Spaces, Bilinear and Quadratic Forms, and Sylvester's Law of Inertia
- Effective Numberings, Reductions, Resources, and Randomness
- Eigenvalues, Eigenvectors and the Characteristic Polynomial
- Filters and Ultrafilters
- Finite Counting, Factorials and Binomial Coefficients
- Finite Dimensional Normed Spaces and Riesz Lemma
- Finite Fourier Analysis and the Fast Fourier Transform
- Finite Probability Spaces and Random Variables
- Finite-Dimensional Complex Inner-Product Spaces and Matrix Interfaces
- Formal Languages, Encodings, and Decision Problems
- Foundations of the Real Numbers for Analysis
- Free Modules, Exact Sequences, Projective and Injective Modules
- Fundamental Trigonometric Identities
- Group Actions, Orbits, Stabilisers and Cayley's Theorem
- Group Homomorphisms and the Isomorphism Theorems
- Hilbert Space Geometry and Riesz Representation
- Ideals, Quotient Rings and the Isomorphism Theorems for Rings
- Inclusion–Exclusion, the Pigeonhole Principle and Double Counting
- Independence Borel Cantelli and Zero One Laws
- Infinite Product Measures and Kolmogorov Extension
- Inner Product Spaces, Gram-Schmidt, Projections and Adjoints
- Limits of Real Functions
- limsup, liminf, and Subsequential Limits
- Linear Independence, Bases and Dimension
- Linear Recurrences and Rational Generating Functions
- Linear Transformations, Rank-Nullity and Quotient Spaces
- Matrices, the Matrix of a Linear Map, and Change of Basis
- Measurable Functions and Simple Approximation
- Measurements, POVMs, and Instruments
- Measures and Their Basic Properties
- Metric Spaces
- Modules, Submodules, Quotient Modules and the Isomorphism Theorems
- Monotone Functions, Discontinuities, and Continuity Sets
- Monotone Sequences, Bolzano-Weierstrass, and Cauchy Completeness
- Normal Subgroups and Quotient Groups
- Normed and Banach Spaces
- Order, Zorn's Lemma, and the Axiom of Choice
- Outer Measure and the Caratheodory Extension Theorem
- pi: the Equivalent Characterizations
- Polynomial Rings, the Division Algorithm and Roots
- Power Series and Real-Analytic Functions
- Primes, Euclid's Lemma and the Fundamental Theorem of Arithmetic
- Primitive Roots and Unit Groups Modulo N
- Probability Spaces Random Variables and Expectation
- Product Measures and the Fubini Tonelli Theorems
- Properties of the Integral and the Working FTC
- Pure and Mixed States, Ensembles, and Schmidt Decomposition
- Quantum Fourier-Transform Circuits
- Quantum Order Finding and Rational Reconstruction
- Quantum Phase Estimation
- Qubits, Bloch Sphere, Pauli Algebra, and One-Qubit Gates
- Registers, Tensor Products, and Partial Trace
- Regular Continued Fractions and Diophantine Approximation
- Relations, Functions, and Quotients
- Resource Bounds and Machine Invariance
- Reversible Computation, Ancillas, and Coherent Oracles
- Rings, Subrings, Integral Domains and Fields
- Rⁿ as a Normed Space; Vector-Valued Functions
- Roots, Rational Powers, and Classical Inequalities
- Sequences and Limits
- Sequences and Series of Functions; Uniform Convergence
- Series: Convergence and the Nonnegative Tests
- Sigma Algebras and Borel Sets
- Simple Field Extensions and the Construction of the Complex Numbers
- Sine, Cosine, and the Definition of Pi
- Splitting Fields
- Strongly Continuous Semigroups and Hille Yosida
- Suprema and Infima
- Sylow's Theorems, p-Groups and Nilpotent Groups
- Symmetric Groups, Cycle Decomposition and the Sign Homomorphism
- Tensor Products of Modules
- The Complex Exponential and Euler's Formula
- The Derivative and the Mean Value Theorems
- The Determinant of a Linear Operator, Cofactors and Cramer's Rule
- The Exponential Function
- The Fundamental Theorem of Algebra
- The Fundamental Theorem of Finite Abelian Groups
- The Galois Correspondence
- The Lebesgue Integral and the Convergence Theorems
- The Logarithm and General Powers
- The Polynomial Hierarchy and Relativization
- The Riemann Integral: Definition and Integrability
- The Spectral Theorem, Positive Operators and Singular Value Decomposition
- The ZFC Axioms and the Basic Set Constructions
- Topological Spaces and Continuity
- Topology of ℝ
- Triangularisation, Generalised Eigenspaces and Jordan Canonical Form
- Trigonometric and Oscillatory Examples in One Variable
- Turing Machines, Configurations, and Computation
- Uniform Circuit Families, Promise Problems, and Complexity
- Vector Spaces, Linear Subspaces, Span and Direct Sums
2 · Summary
This page gives a bounded-error factoring procedure for a promised composite integer . It returns immediately for even inputs. For odd inputs, it searches for exact perfect powers by integer roots and returns a proper factor when it finds one. In the remaining odd-composite case, it samples uniformly from by exact rejection sampling. A nonunit sample yields its gcd factor immediately; a unit is passed to the order-finding procedure of quantum-order-finding-and-rational-reconstruction with internal failure target .
Every proposed period is checked directly: it must lie between and , be even, and satisfy . The reduction then computes and tests and . It returns only a divisor checked to lie strictly between and . Minimality of a candidate period is not required for output correctness; a nonminimal candidate can only miss a factor and cause a retry.
For a true order, the CRT proof identifies success through the two-adic valuations of the local prime-power orders. Each possible local valuation has probability at most ; with distinct prime factors, the probability that all valuations agree is at most . Thus the true-order reduction succeeds with probability at least on every odd composite that remains after perfect-power preprocessing. The order finder is exact with probability at least for each fixed unit, so each outer attempt succeeds with probability at least . With for , the total failure probability is at most .
The random-bit sampler uses countable choice and dependent choice only to supply countably many independent fair bits; the CRT and number-theoretic success proofs use finite products and finite choices. Under supplied explicit reversible arithmetic and an ideal exact-angle QFT, the stated gate, multiplier-call and expected arithmetic/post-processing bit-operation bounds are kept separate. No circuit-description generation-time, finite-alphabet or uniform-family bound is asserted. The bare controlled-unitary query branch costs queries and carries no polynomial query claim.
3 · Logical flowchart
4 · Definitions, theorems and proofs
Exact uniform sampling from the nonzero residue representatives
Definition
Input. An integer . The random tape is a countable sequence of independent bits, each taking and with probability . Its countable product law is supplied by Assuming countable and dependent choice, countable products of arbitrary probability spaces under countable choice and dependent choice (The Axiom of Countable Choice (), The axiom of dependent choice: a relation in which every element is related to something admits an -indexed chain).
Set and let be the binary length of , equivalently the least integer with . For each block, read its bits in order as , with the first bit most significant, and set . If , discard this block and read the next bits. Otherwise output and halt.
Whenever it halts, the procedure returns an element of because an accepted block has and the output is .
Mixed CRT signs yield proper gcd factors
Statement
Let , where , the are distinct odd primes, and every . If but , then both and are proper nontrivial divisors of . When , the hypotheses cannot hold, because the proof below shows the only roots are the two global signs.
Facts & Assumptions
Given: The stated factorization of odd , an integer with , and .
The Chinese remainder map is a bijection preserving multiplication, and it restricts to the product isomorphism of the corresponding unit groups for pairwise-coprime moduli (Chinese remainder theorem for a finite pairwise-coprime list: simultaneous residues determine one class modulo the product, and the resulting bijection preserves addition and multiplication, For pairwise coprime positive moduli, the Chinese remainder bijection restricts to an isomorphism of unit groups).
For odd prime and , is cyclic of even order (For every odd prime and , is cyclic of order ).
For a generator of a cyclic group of order , exactly when (If then iff is an integer multiple of , the powers are distinct, and has exactly elements; if has infinite order then only for ).
For a nonzero pair, gcd is a common divisor and is greatest in the usual order (Common divisor, and the greatest common divisor , with the convention ); divisibility is transitive (Divisibility in : when for some integer ).
Every odd prime is at least (Prime and composite integers: is prime when and its only positive divisors are and , The integers form a totally ordered ring). If and , then (If and then and ; hence the set of divisors of a nonzero integer is bounded above by ).
Congruence classes multiply by multiplying representatives, and equal classes are equivalent to congruence (The congruence class and the quotient set , For every natural , is an abelian group, multiplication is a commutative monoid operation, and both distributive laws hold).
Proof
By [F1], has components . Each satisfies , hence is a unit. Choose a generator of its cyclic unit group of even order by [F2], and write . By [F3], exactly when . Among residues modulo even , this gives only or , so is one of the two roots : the second is because is a root and it is distinct from modulo (otherwise , contrary to [F5]). To see the two exponent classes explicitly, write ; is equivalent to , which has the two residue classes modulo .
The signs cannot all be , since CRT injectivity would then give , and they cannot all be , since it would give . Choose indices and with signs and , respectively. This also shows that when the hypotheses are impossible.
Since and , it is a common divisor, so . Since , that prime power divides ; it cannot divide because then it would divide , whereas . Thus and .
Interchanging the two signs in step 3.1 gives . Hence both gcds are proper nontrivial divisors.
Half an even order gives a square root of one
Statement
Let , let be a unit modulo , and let be an even integer with . Then satisfies . If , then additionally .
Facts & Assumptions
Given: , an integer with , an even integer with , and . Here means the order of in the unit group.
Multiplication makes a group, and congruence classes multiply by multiplying representatives (The unit group and Euler's totient for , The congruence class and the quotient set , For every natural , is an abelian group, multiplication is a commutative monoid operation, and both distributive laws hold).
Proof
Write with . Then , so is a square root of one.
If and , then in the unit group. By [F2], , which is impossible because . Thus .
The square relation holds for every accepted even exponent, and step 2.1 supplies the additional nonidentity conclusion when it is the true order.
Two-adic order distribution in odd prime-power unit groups
Statement
Let be an odd prime and . If is uniform in , then for every possible integer ,
Here is the greatest such that , for the positive integer order .
Facts & Assumptions
Given: An odd prime , an integer , and the uniform finite probability law on .
The unit group is cyclic of order (For every odd prime and , is cyclic of order , The unit group and Euler's totient for ).
For a finite-order group element, its powers equal the identity exactly at multiples of its order (The order of a finite group and the order of an element, with when no positive power of is the identity, Powers : natural exponents in a monoid and integer exponents in a group, with , If then iff is an integer multiple of , the powers are distinct, and has exactly elements; if has infinite order then only for ).
For a positive integer , is the greatest with (The -adic valuation of a nonzero integer: the greatest with , with prime ).
A finite uniform probability space assigns each outcome equal weight (Finite probability spaces, outcome weights, events, and event probabilities).
The gcd is a greatest common divisor in the divisibility order and for (Common divisor, and the greatest common divisor , with the convention , is symmetric and unchanged by signs: ; moreover , , , and unless ); Bézout's identity characterizes coprimality, and if are coprime and , then (Divisibility in : when for some integer , Coprime integers: , and are coprime if and only if for some integers ; and in that case the only common divisors of and are and , If and then ; and if , and then , Bézout's identity: for integers not both zero, is the least positive element of ; in particular has an integer solution).
Integer multiplication is associative and cancellation by a nonzero factor is valid (The integers form a commutative ring, The integers have no zero divisors; multiplicative cancellation).
Proof
Since is odd, is even; write with and odd. Choose a generator by [F1]. The map for is a bijection onto the unit group, by the order statement in [F2], so a uniform unit corresponds to a uniform such exponent .
Put . For , write and . Bézout's identity for divides through by to give , so are coprime by [F5]. For every , [F2] gives exactly when , equivalently ; [F5] makes this equivalent to . Hence the least such is . If , then and has order .
The exponent of in is exactly when : if , then is a common divisor and hence divides ; if divides , it divides . Since is the full power of dividing , this is equivalent to . There are such residues among , so this probability is .
For , exactly when the exponent of in is . As in step 2.1, this is exactly when and . The number of such residues is so their probability is . No other valuation occurs because divides .
The cases and exhaust all possible valuations, and each has probability at most by steps 2.1 and 3.1.
Random residue gcd branch for factoring
Statement
Let and choose uniformly from the integers . If , then is a proper factor of . Conditional on , the residue class is uniformly distributed in the unit group .
Facts & Assumptions
Given: An integer and the uniform finite sample space .
Each residue class modulo has a unique standard representative in (For , every class in has one representative with , so ; while is in bijection with , The congruence class and the quotient set ).
A residue is a unit exactly when (For , is a unit if and only if , The unit group and Euler's totient for ).
In a finite uniform probability space, each outcome has equal weight; event probability is the sum of those weights (Finite probability spaces, outcome weights, events, and event probabilities), and when (Conditional probability for ).
The gcd is a positive common divisor and is greatest in the usual order (Common divisor, and the greatest common divisor , with the convention ); for ( is symmetric and unchanged by signs: ; moreover , , , and unless ).
Proof
If , then and by [F4]. Since is positive and divides the nonzero , [F5] gives ; hence and is a proper factor.
The event is nonempty because belongs to it. By [F1] and [F2], the map is a bijection from to : every unit has its unique standard representative, and the zero class is not a unit because [F2] and [F4] give .
Every has probability , so . For any fixed unit representative , its conditional probability is . By [F2], this is the uniform law on the unit group.
Step 1.1 proves the immediate proper-factor branch, and step 2.1 proves conditional uniformity of the unit branch.
Classical randomized order-to-factor success bound
Statement
Let be an odd composite that is not a perfect power, and write its prime-power factorization where the are distinct odd primes, , and is their number. Choose uniformly from and let . The true-order reduction sets when is even and succeeds when is even and ; on that event both gcds give proper factors. This event has probability at least
Facts & Assumptions
Given: The stated odd composite , its prime-power factorization, a uniform unit , and the true order .
Every integer has a finite prime factorization unique up to order (The fundamental theorem of arithmetic: every integer is a product of primes, and the factorisation is unique up to order — if with every and prime, then and for some , For and any injective list of primes containing every prime divisor of , one has ; the exponents are determined by , and for every prime outside the list).
The CRT map restricts to an isomorphism from the unit group modulo to the product of the unit groups modulo the pairwise-coprime prime powers (For pairwise coprime positive moduli, the Chinese remainder bijection restricts to an isomorphism of unit groups).
The uniform product law has independent coordinates (Finite probability spaces, outcome weights, events, and event probabilities, The finite product of finite probability spaces, Product weights normalize, and coordinate events are mutually independent).
For each odd prime power, every possible value of of a uniform unit's order has probability at most (Two-adic order distribution in odd prime-power unit groups).
The half-power of a true even order is a nonidentity square root of one; in each odd prime-power component the only square roots are , and mixed CRT signs give proper gcd factors (Half an even order gives a square root of one, Mixed CRT signs yield proper gcd factors).
The order of a unit is the least positive exponent giving the identity; its powers equal the identity exactly at multiples of that order (The order of a finite group and the order of an element, with when no positive power of is the identity, Powers : natural exponents in a monoid and integer exponents in a group, with , If then iff is an integer multiple of , the powers are distinct, and has exactly elements; if has infinite order then only for ).
The exponent of in a positive integer is the greatest with dividing that integer (The -adic valuation of a nonzero integer: the greatest with ); cancellation by a nonzero integer is valid (The integers have no zero divisors; multiplicative cancellation), and Bézout and Euclid's lemma justify cancellation of coprime factors (Common divisor, and the greatest common divisor , with the convention , Divisibility in : when for some integer , Coprime integers: , and are coprime if and only if for some integers ; and in that case the only common divisors of and are and , If and then ; and if , and then , Bézout's identity: for integers not both zero, is the least positive element of ; in particular has an integer solution).
Each unit group modulo a positive integer is finite, so a unit in it has a finite positive order (The unit group and Euler's totient for , The order of every element of a finite group divides the order of the group).
Proof
By [F1], has a factorization into distinct prime powers. Since is odd, every prime factor is odd. If there were only one distinct prime , then ; would make prime, while would make it a perfect power. Both contradict the hypotheses, so .
Under the CRT isomorphism [F2], a uniform unit corresponds to a uniform tuple in the product of the local unit groups: the map is a bijection and preserves equal weights. By [F3], the local components, and hence their orders and valuations , are independent. Each local unit group is finite, so only finitely many valuation values occur.
By [F8], is finite and positive. Since modulo , CRT and [F6] give for each . Let and . Since , the definition of gives for every , so . If , write and with odd; here . From , canceling the nonzero factor gives . Since is odd, it is coprime to , so Euclid's lemma gives . Also , so . Thus every , so every local component and therefore equals the identity by [F2,F6]. This contradicts the minimality of , since . Therefore .
Write . By independence [F3], the probability that all valuations agree is . For every possible , [F4] bounds each of by , so . Summing over the finite set of possible gives probability at most , since .
If the are not all equal, then ; choose indices with and . Write and with odd. Since , cancellation gives ; because is odd, it is coprime to , so Euclid's lemma gives . As , , hence . By [F6], . For the maximum index, because its two-adic valuation is while ; hence [F6] gives . Its square is because . By [F5], this local root is , while the component is . Thus the global square root is neither global sign, and [F5] gives proper gcd factors.
By step 2.2, the valuations differ with probability at least ; step 3.1 shows that every such outcome gives a proper factor. Since by step 1.1, this probability is at least .
Shor factoring with verified output and bounded outer retries
Definition
Inputs. A composite integer , encoded in binary, and a rational target failure probability with coprime integers . Use the modular-order-finding procedure on the earlier A page with its explicit reversible modular-multiplication circuit. Output is a verified proper divisor of or FAIL.
Arithmetic subroutines. For and exponent , CappedPower(c,e) returns : initialize ; while , replace by if is odd, then replace by and, if the new , replace by . For any integer and exponent , ModPower(c,e) returns : initialize ; while , replace by if is odd, then replace by and, if the new , replace by . In both routines, parity, quotient, product, comparison, and remainder operations are exact integer operations.
-
Set . If is even, set , check and , and return if both checks pass.
-
For each integer exponent , initialize and . While , set and . If , set . If , set . If , verify and ; return if both checks pass, and otherwise set . If the loop ends without a return, continue to the next exponent.
-
Initialize , , and . While , replace by . Continue to instruction 4 with this ; it is the least positive integer satisfying , equivalently .
-
For attempts , obtain a fresh independent sample by running Exact uniform sampling from the nonzero residue representatives on with a fresh independent countable fair-bit tape. Compute . If and , return . If , start the next attempt; the case is rejected as an invalid sample and also starts the next attempt.
-
When , run modular order finding on with target parameter , so its target failure is . Use fresh measurement randomness independent of the sampler tape and all previous attempts. If it returns
FAIL, start the next attempt. Otherwise let be its candidate. Reject the candidate unless , is even, and . Set , the standard representative of . Compute and . Return the first of these satisfying and ; if neither passes, start the next attempt. -
If all attempts finish without returning a divisor, return
FAIL.
The residue sampler's exact uniformity, almost-sure termination, and expected-bit bound are proved separately. The outer attempt count, root search, modular exponentiation, and divisor checks have the finite bounds stated above. Correctness, success probability, and costs are separate claims.
Remarks
The odd-composite branch reaches order finding only after the gcd test establishes , so the residue class of is a unit by For , is a unit if and only if . A returned candidate period is rechecked even though the order-finding contract also verifies candidates. Its fair-bit tapes use countable choice and dependent choice through the sampler's countable product model; the number-theoretic and output-verification branches use finite arguments. Order-finding success and cost are separate claims.
Shor factoring cost-accounting branches
Definition
Fix a promised input integer , set , and let an order-finding phase register have width and size . A work wire is an auxiliary circuit wire outside the stated input and output registers; its presence and use are charged as part of the supplied circuit. Classical bit transitions use the convention of Classical bit-operation cost. The cost report for Shor factoring keeps the following branches separate.
- Explicit reversible arithmetic. A supplied reversible circuit for multiplication by a fixed residue modulo is charged by its actual gate occurrences and work wires. Each use of that circuit is also counted in a separate modular-multiplier-call coordinate. The circuit, its inverse, and any controlled version must be supplied; this definition assigns none of them zero cost. It asserts no finite circuit-description generator or generation-time bound.
- Ideal exact-angle QFT. In this named ideal submodel, each Hadamard, exact controlled-phase rotation, and swap in the supplied -bit QFT circuit counts as one ideal gate. The standard exact cyclic QFT has Hadamards, controlled-phase rotations, and swaps, hence ideal gates. This submodel permits exact real angles as unit-cost gates. It supplies no finite gate alphabet, finite binary description, approximation, compiler, or uniform-family claim.
- Bare controlled-unitary access. If only a controlled call to is supplied, implementing the controlled power by repetition costs oracle calls. Across this is calls per phase-estimation sample. These oracle-query counts are separate from gate counts.
- Classical bit work. Integer inputs are binary, elementary arithmetic is charged in bit operations, and schoolbook multiplication of two -bit integers costs . A rejection sampler's random-bit cost is reported in expectation separately from deterministic bit operations.
The four coordinates used by the factoring cost theorem are ideal or explicit quantum gates, modular-multiplier calls, bare controlled-unitary oracle queries, and classical bit operations. An inapplicable branch is not reported as a zero-cost implementation.
Remarks
This is a cost convention for the stated algorithmic comparison. In particular, the ideal exact-angle QFT count is not a finite-alphabet or uniform-circuit theorem.
Even and perfect-power preprocessing returns a proper factor
Statement
For a promised composite , the even branch and the finite integer-root precheck in Shor factoring with verified output and bounded outer retries return a proper factor whenever they return. If is even, the even branch returns . If for integers and and is odd, the root-search branch is reached, detects an exact-power representation with and , and returns its base as a proper factor. Writing , its schoolbook bit cost is .
Facts & Assumptions
Given: A composite integer , , and the even/perfect-power preprocessing instructions in Shor factoring with verified output and bounded outer retries.
Divisibility means exactly when for an integer (Divisibility in : when for some integer ); integer powers are natural monoid powers with and (Powers : natural exponents in a monoid and integer exponents in a group, with ).
Integer order is translation invariant, products of positive integers are positive, and the natural embedding preserves order (The integers form a totally ordered ring, The integers form a commutative ring, The naturals embed in the integers).
The binary search and exponent range are those in Shor factoring with verified output and bounded outer retries; its capped repeated-squaring powers use integers at most . Schoolbook multiplication of two -bit integers costs bit operations (Shor factoring cost-accounting branches).
Proof
If is even, . Since , , so the returned integer is a proper factor.
Suppose the precheck finds with and . Then , so by [F1]. The power , so ; hence and its explicit divisibility verification returns a proper factor.
Conversely, suppose with and . If is even, step 1.1 shows that the earlier even branch returns , so the root search is not reached. Now suppose is odd. Then the root-search branch is reached, and , so and the loop includes this exponent. If the algorithm has not already returned on an earlier exact-power match in this root search, then for this fixed , if , because the factor and every summand are positive by [F2]. Hence is strictly increasing, so binary search on finds ; capping values above at preserves each comparison with . If the algorithm already returned on an earlier root-search match, that match was itself an exact-power representation of , and step 1.2 shows that its returned base is a proper factor. Thus the odd perfect-power input returns a proper factor through the root search, while the even case is handled by step 1.1.
There are at most exponents and at most binary-search comparisons per exponent because . Each comparison uses at most capped multiplications of -bit integers, hence bit operations by [F3]. The total is for , proving the claimed bound.
Rejection sampling is uniform, almost surely terminating, and has expected linear bit cost
Statement
For every , the procedure in Exact uniform sampling from the nonzero residue representatives halts almost surely and returns each with probability exactly . If , its expected random-bit use is at most and its expected total classical bit transitions are .
Facts & Assumptions
Given: , , , and the rejection procedure in Exact uniform sampling from the nonzero residue representatives.
Countable choice and dependent choice are assumed only to form the countable product of fair-bit probability spaces used by the random tape (The Axiom of Countable Choice (), The axiom of dependent choice: a relation in which every element is related to something admits an -indexed chain, Assuming countable and dependent choice, countable products of arbitrary probability spaces). The finite probability branches of the number-theoretic proofs do not use this axiom branch.
Each bit has probability for both values, finite blocks have their product law under the countable product measure, and disjoint blocks are independent (Assuming countable and dependent choice, countable products of arbitrary probability spaces, Finite probability spaces, outcome weights, events, and event probabilities, Coordinate random elements of a countable product are independent).
For a decreasing sequence of events in a probability space, the probability of the intersection is the limit of the probabilities (Continuity from above when one set has finite measure).
For a nonnegative random variable, expectation is the tail integral (Expectation of a nonnegative or integrable random variable, Layer-cake formulas for random variables).
The multitape bit-cost convention charges random-bit generation, binary arithmetic, comparisons and output writing (Classical bit-operation cost, Shor factoring cost-accounting branches).
Proof
A block is accepted with probability . By the definition of , , and either or ; hence . If , every block is accepted and each valid is output with probability . If , for a fixed valid the probability that the algorithm outputs on block is by [F1], and summing gives .
The events that the first blocks are all rejected decrease with and have probability by [F1]. Their intersection is the event that the algorithm never halts, and [F2] gives that event probability . Thus the procedure halts almost surely.
Let be the number of blocks read before the first acceptance. For integer , . The tail function is constant on each interval , so [F3] gives , with the case interpreted as . Computing as the binary length of takes transitions. Each block reads and stores bits in transitions; comparing that -bit integer with takes transitions, and incrementing an accepted value and writing the output use at most bits. Since , these operations also take transitions, so the nonrandom work per block is . By [F4], these transitions and the random-bit generations are charged. Thus expected random-bit use is at most and expected total bit transitions are .
Order-to-factor output correctness
Statement
For every promised composite , every non-FAIL output of Shor factoring with verified output and bounded outer retries is a proper divisor of . In its odd-unit branch, any candidate that passes the algorithm's checks and is even has ; with , if , both and are proper nontrivial divisors. No minimality of is needed for this output-correctness claim.
Facts & Assumptions
Given: The input/output instructions in Shor factoring with verified output and bounded outer retries, a promised composite , and an execution that returns rather than FAIL.
The even and perfect-power preprocessing return only a divisor satisfying (Even and perfect-power preprocessing returns a proper factor).
For a uniform residue , if it is a proper factor; if the gcd is one then is a unit (Random residue gcd branch for factoring, For , is a unit if and only if ).
For a unit and an accepted even exponent with , satisfies (Half an even order gives a square root of one).
Every odd composite has a factorization into distinct odd primes with (The fundamental theorem of arithmetic: every integer is a product of primes, and the factorisation is unique up to order — if with every and prime, then and for some , For and any injective list of primes containing every prime divisor of , one has ; the exponents are determined by , and for every prime outside the list). For this factorization, a square root other than the two global signs gives both gcds as proper nontrivial divisors (Mixed CRT signs yield proper gcd factors).
Proof
The even branch returns only after checking and . The perfect-power branch returns only after the exact checks and , and [F1] proves its candidate is proper.
In a random-residue branch, a returned gcd candidate is checked to satisfy and ; [F2] also shows that a nonunit gcd cannot equal because the sampled representative satisfies . Thus any returned candidate in this branch is proper.
The order-finding branch is reached only after the even and perfect-power branches, so is odd. It first verifies and . If is even it sets ; [F3] gives . If , [F4] gives a prime-power factorization and the CRT sign lemma shows that both computed gcds lie strictly between and and divide , so the explicit verification accepts a proper factor.
Every return branch is one of steps 1.1, 1.2 or 1.3, and each branch verifies the strict divisor conditions before returning. Therefore every non-FAIL output is a proper divisor.
Remarks
This theorem proves output correctness conditional on the outer algorithm's exact period and gcd checks. It does not rely on a candidate being the minimal order, and it makes no probability claim about whether the order-finding branch is reached.
Separate Shor factoring bit, gate, and query costs
Statement
Let , , and let be a reduced rational encoded in binary, with the bit length of . Let be the attempt cap in Shor factoring with verified output and bounded outer retries, and put . For the arithmetic, control, sampler and post-processing work after the declared circuits are supplied, under the explicit reversible-arithmetic branch and ideal exact-angle QFT branch of Shor factoring cost-accounting branches, the procedure uses
- quantum gates;
- controlled modular-multiplier calls and zero external black-box queries;
- expected classical bit operations, including sampler bits and exact computation of .
For the same order-finding control flow with only bare controlled access to , one phase-estimation sample costs controlled- queries, so the outer algorithm uses such queries. No polynomial-in- query bound, finite-alphabet compilation, uniform-family gate claim, or circuit-description generation-time bound is asserted.
Facts & Assumptions
Given: The algorithm Shor factoring with verified output and bounded outer retries on binary input , with its declared outer cap and phase width .
For , , and internal failure target , the order finder uses independent samples. Its cost theorem gives controlled modular-multiplier calls, gates and classical bit transitions in the explicit-arithmetic/ideal-QFT model; with bare controlled- access, one sample costs queries (Modular order finding with rational reconstruction, Separate order-finding query, gate, and bit costs).
A known controlled modular multiplication uses gates, and the repeated-squaring constants and inverses can be computed in classical bit transitions (Gate and bit cost of modular multiplication and powering).
The ideal exact-angle inverse QFT has gates, while the named cost convention keeps this ideal count separate from the explicit arithmetic circuits, multiplier calls, bare-unitary queries and classical bit operations; it asserts no finite gate alphabet or uniform family (Shor factoring cost-accounting branches).
The even/perfect-power preprocessing takes schoolbook bit operations (Even and perfect-power preprocessing returns a proper factor).
For , one rejection-sampler call halts almost surely, returns a uniform element of , and uses at most expected random bits and expected total bit transitions (Rejection sampling is uniform, almost surely terminating, and has expected linear bit cost).
Classical bit cost counts machine transitions, including random-bit generation, arithmetic, comparisons, preprocessing and output writing (Classical bit-operation cost).
The resource model records gate occurrences, work wires, oracle queries, description length, generator time, and classical bit costs as distinct coordinates; separate theorems must establish each bound (Circuit-family and computation cost model).
Proof
The Shor algorithm fixes , so [F1] gives multiplier calls, gates and classical bit transitions for each order-finding invocation. There are at most such invocations, so their totals are calls, gates and bit transitions. The definition of gives because is a positive constant.
In the bare controlled- branch, one phase sample applies controlled powers for . Repeating the bare call times implements the th power, so one sample uses queries. For fixed , [F1] gives samples per order call. At most calls therefore use queries.
The perfect-power check costs by [F4]. Each order call costs classical bit transitions by [F1]. The outer verification adds at most transitions per attempt: binary modular exponentiation uses products of -bit integers. Schoolbook multiplication takes transitions, and binary long division has at most quotient positions, each requiring an -bit comparison/subtraction, so product remainders also take transitions. The Euclidean gcd algorithm has remainder steps because in each pair of successive divisions the positive remainder at least halves; each division takes transitions by the same long-division count. Divisor comparisons and remainder checks fit this bound. By [F5], each sampler call uses expected total transitions. Thus all these per-attempt work is in total.
The exact cap is computed by increasing until . Since and , ; also . Hence . Throughout this loop, the exact powers have bits, and each of at most multiply/compare iterations costs schoolbook bit transitions. Computing therefore costs .
In the explicit-arithmetic branch, each multiplier call is charged to the supplied reversible circuit; it is not a black-box query. [F2] supplies its gate count and [F3] supplies the separate ideal QFT count. The resulting gate count is the bound in step 1.1; the distinct coordinates are those of [F7].
Combining steps 1.3 and 1.4 gives expected classical bit operations.
Remarks
The current cost-model definition and the QA08 arithmetic and order-finding cost theorems provide the stated separate resource coordinates. The supplied-circuit and ideal-QFT conventions above determine which bounds are asserted; they provide no circuit-description generation-time bound.
Bounded-error success of Shor factoring
Statement
For a promised composite and rational , the procedure Shor factoring with verified output and bounded outer retries returns a proper divisor with probability at least after its declared outer attempts. Its exact even and perfect-power preprocessing branches succeed with probability one.
Facts & Assumptions
Given: The algorithm Shor factoring with verified output and bounded outer retries on , with the least positive integer satisfying .
The even and perfect-power preprocessing branches return proper factors whenever they apply (Even and perfect-power preprocessing returns a proper factor).
A sampled nonunit residue immediately yields a proper gcd factor, and conditional on gcd one the residue is uniform in the unit group (Random residue gcd branch for factoring).
For an odd composite that is not a perfect power, the true-order reduction succeeds on a uniform unit with probability at least (Classical randomized order-to-factor success bound).
The rejection sampler halts almost surely and returns a uniform representative (Rejection sampling is uniform, almost surely terminating, and has expected linear bit cost).
Every returned output is a proper divisor (Order-to-factor output correctness).
The algorithm uses fresh independent sampler tapes and fresh order-finding randomness across attempts (Shor factoring with verified output and bounded outer retries). For each fixed unit input, order finding uses finitely many measurements of finite registers (Success probability and repetition for modular order finding). Finite terminal outcome laws can therefore be combined by the finite product law, whose coordinate events are independent (The finite product of finite probability spaces, Product weights normalize, and coordinate events are mutually independent).
In a finite probability space, conditional probability is when (Conditional probability for ).
Countable choice and dependent choice supply only the countable independent fair-bit tape used by [F4] (The Axiom of Countable Choice (), The axiom of dependent choice: a relation in which every element is related to something admits an -indexed chain, Assuming countable and dependent choice, countable products of arbitrary probability spaces).
The current body of Success probability and repetition for modular order finding states that for every fixed unit input and integer parameter , the exact-order output probability is at least . Setting gives at least for each fixed unit input. The actual algorithm and theorem bodies and the proof route supporting this statement were inspected; this records the current carrier, not independent acceptance.
Proof
If is even or a perfect power, preprocessing returns a proper factor by [F1], so the theorem holds with probability one. Otherwise is odd, composite, and not a perfect power, so [F3] applies.
By [F4], the sampler halts almost surely and has uniform finite output law. For each unit representative , let be the finite set of order-finding measurement transcripts and its probability mass function; for a nonunit use a singleton of mass one. One attempt has finite terminal outcome space with weights : the sampler marginal is [F4], the subsequent fresh measurement law is , and these weights sum to one. All conditioning here is on this finite space as in [F7]. Conditional on the unit event , [F2] makes uniform in the unit group. Let be the representatives whose true-order reduction succeeds, so [F3] gives . For each , [A2] gives exact-order probability at least ; summing its transcript weights gives . On that event the algorithm returns a proper factor. This uses a pointwise order-finding bound, without assuming independence between the unit and its measurement outcome.
Let be the probability that a sampled residue is a unit. The attempt succeeds with probability at least . Any output is correct by [F5]; a nonminimal or otherwise unsuccessful order candidate can only cause this attempt to continue.
Preassign independent terminal records with the finite product law . By the fresh randomness in [F6], this is the joint terminal law of the actual attempts; stopping at the first success simply leaves subsequent records unused. The event that any of these finitely many samplers does not halt has probability zero by [F4]. Let be the coordinate event that attempt returns no factor. Step 2.1 gives , and finite coordinate independence [F6] gives . Thus the probability of returning a proper factor is at least .
Remarks
The exact-order probability premise [A2] is taken from the current batch-32 carrier and checked against its stated fixed-unit hypotheses; the cited carrier remains a draft and this record is not independent acceptance. Countable choice and dependent choice are used only to supply the sampler's independent fair-bit tapes [A1].
5 · Examples, counterexamples and false statements
None yet.