Let be a rank- projector with . No unitary operator can map every pure state whose probability equals to a state with the same fixed smaller probability. Average over good and bad basis vectors and both signs. The average density operator is the maximally mixed state, so every unitary preserves its average probability. This contradicts a strictly smaller probability for all states in the ensemble. A preparation tailored to one known starting state is a different resource and is used in exact amplitude amplification.
The amplitude amplification theorem concerns a known preparation quantum circuit and a good-subspace projector . Write , with . Let and . Then
The reflection operators preserve the two-dimensional good-bad plane and rotate it by , so iterations amplify a small known success probability to a constant close to one. Each iteration uses one good-subspace phase test and one use each of , together with a known reflection. Amplitude amplification provides a quadratic improvement in the number of repetitions of a successful preparation. The query cost of the preparation and its inverse must be included when they themselves use the input oracle. Exact amplitude amplification uses additional known-overlap preparation or phase matching to avoid integer-iteration overshoot.
Let be the orthogonal projection onto the good vector subspace , and let the normalized input be . Set with , and define
Assuming coherent access to the two reflections, the amplitude amplification theorem states that
preserves the plane spanned by and acts as a rotation, giving
Hence the good-outcome probability is . When is known, choose the nearest nonnegative integer to . The resulting angle is within of , so the good probability is at least . For small this is close to one and requires iterations. Exact success occurs when . Known also allows exact amplitude amplification by ancilla qubit dilution or selective phase adjustment when ordinary integer iterations would overshoot.
If has a known coherent preparation, its reflection is implemented with , and a zero-state phase flip. A coherent membership test supplies the reflection about . Merely possessing an unknown copy of does not automatically supply its reflection. For the state is already good; for this two-reflection construction cannot generate a good component. These cases delimit the theorem's algorithmic assumptions.
Write , and . The easy starting state is uniform over all -bit labels, so its good fraction is , not . For distinct primes one has . If both primes are odd, and , giving . If one prime is two, the other is an odd prime ; since has bits, , and .
The uniform coprime state for a semiprime can now be prepared by one exact Grover rotation. Set
Prepare
Use the good subspace spanned by with and . Its squared overlap with is exactly . The Euclidean algorithm supplies a reversible computation of the membership predicate, including the range check; condition a sign flip on membership and the extra qubit being one, then uncompute the workspace. This implements .
The starting-state reflection uses the inverse of its known preparation and a reflection on the all-zero state. Applying once invokes exact amplitude amplification at , and gives
The extra qubit factors off, and the arithmetic workspace is returned to zero. Although the stated range includes , that label is not coprime to itself, so the predicate is equivalent and avoids admitting labels outside the intended range.
The supplied determine in polynomial time; no factoring procedure is needed. Binary arithmetic, range comparison, the reversible greatest common divisor, the two starting-state reflections and the controlled sign flip all have polynomial-size circuits. Thus the construction takes polynomial time in in the ideal model allowing the specified one-qubit state preparation. Exactness uses the rotation with known amplitudes ; with a fixed finite approximate gate library one obtains arbitrary accuracy with precision overhead, rather than an automatic promise of exact state preparation. In the ideal model the preparation succeeds with certainty, without rejection sampling. If desired, the extra can be reset by a Pauli X gate.
If some integer obeys , ordinary amplitude amplification already gives exactly. For a general known , use exact amplitude amplification. Choose so that
and put . Append an ancilla and coherently arrange that its designated good value has amplitude conditional on the original register being good. With the enlarged good subspace defined by
the starting state's total good amplitude is .
Apply the amplitude amplification theorem times to this enlarged problem. Its final good amplitude is
The Boolean quantum oracle implements the reflection by phase kickback, and the known state-preparation circuit implements the reflection about the starting state by prepare--reflect--unprepare. A final computational-basis measurement therefore yields an with with certainty.
Attach a quantum ancilla prepared with amplitude
on ; this is possible because . Mark a state as good only when both the original success qubit and this ancilla equal one. The enlarged state's good probability is , so its good amplitude is . One amplitude amplification iteration rotates the angle from to . It therefore prepares exactly, after which the flag and ancillary qubits may be discarded. This is an instance of exact amplitude amplification.
Choose an integer large enough that
Prepare an ancillary qubit in and declare only to be good. The initial good amplitude of
is . Applying amplitude amplification iterations gives good amplitude
The final state is therefore up to a global phase. Discarding the ancilla prepares exactly; this is exact amplitude amplification.
For a semiprime with distinct known primes, this quantum state is uniform over the reduced residue classes. With binary digits in , its fraction among all computational labels is . An ancilla qubit whose one probability is dilutes the joint good probability to exactly . A reversible range-and-greatest common divisor predicate marks the good labels with ancilla qubit one, and a single exact amplitude amplification iteration produces . Known prime factors provide the cardinality; the membership test itself needs only . Polynomial gate complexity presumes ideal one-qubit rotations at the specified amplitudes.