Approximate quantum counting estimates the number of satisfying assignments of a Boolean function, using a quantum oracle and quantum measurement. Controlled repetitions of a Grover search algorithm iteration let quantum interference reveal the count. For one input bit, a Hadamard test can give Pauli Z gate expectation value : with the complemented phase oracle and , use to obtain . Repeated preparations estimate this expectation value; one binary measurement result does not distinguish all three counts .
For even positive , share the maximally entangled state . Each party applies a phase oracle from its input binary string, producing . Its overlap with is the displayed expression because the Hamming distance counts exactly the negative signs. Under the promise , the output either equals or is orthogonal to it. Sending one subsystem lets the receiver distinguish the cases with the projective measurement . The transmitted system needs qubits, including when is not a power of two.
An unrestricted Boolean function on inputs cannot be classified as constant or nonconstant with certainty using a single phase oracle query, even with quantum ancillas. Write a purified query input as with and . The zero constant function leaves it unchanged; the function supported only at produces a vector with inner product with it. Perfect discrimination of pure states requires orthogonality, forcing for all and thus , a contradiction. This is an exact quantum query complexity obstruction for all nonconstant inputs, rather than the restricted promise used by the Deutsch-Jozsa algorithm.
Start from , negate amplitudes at marked indices, and apply . If the marked fraction is , the oracle-state mean amplitude is . Inversion about the mean therefore gives amplitudes on unmarked indices and on marked ones. The marked success probability is . At it is exactly one: unmarked amplitudes vanish and each marked amplitude is . The output is uniform among the marked indices. This is an exact special case of Grover's algorithm, using one phase oracle call under the stated promise.
Let be the two output counts. Choose a known preparation unitary F with . The Deutsch-Jozsa algorithm applies the supplied phase oracle and then , declaring constant exactly for outcome 0. Its amplitude on that outcome is
This is the Deutsch-Jozsa test with an arbitrary uniform-state unitary. For , the usual preparation is ; the argument itself needs only a uniform preparation on the stated N-dimensional space.
For an actually constant-up-to-k function, the two counts are and , so the outcome-0 probability is . The error is returning the other label. Therefore
Here the possible count k is nonnegative, and the supplied bound implies . The error is consequently at most ; at it vanishes. This is the error conditional on the stated constant-up-to-k case, not an average over unspecified prior probabilities. For comparison, the printed balanced-up-to-k definition has count difference , so its outcome-0 probability would be , not the expression for the constant-up-to-k case. No change to that promise definition is made.
One Grover iteration returns a marked label with certainty. Prepare ; apply the supplied phase oracle to negate amplitudes on the marked inputs; apply the Grover diffusion operator ; and measure in the computational basis. If F prepares from , the reflection is , requiring no further oracle query.
After the oracle the amplitudes are on the unmarked labels and on the marked labels. Their average is
The reflection performs inversion about the mean, . It therefore sends every unmarked amplitude to zero and every marked amplitude to . The resulting normalized state is
Each marked label has Born rule probability , every unmarked label has probability zero, and the marked probabilities sum to . This is one-step exact Grover search with a quarter of the inputs marked, using one reduced-oracle query. The positive integer N must be divisible by four; a qubit implementation may take , but the stated reflection proof does not assume that register convention.
Use the Bernstein-Vazirani algorithm: initialize n qubits in , apply , query the supplied phase oracle once, apply again, and measure all n computational bits. Immediately after the query the state is
where the dot product in the exponent is taken modulo two. The Walsh-Hadamard transform gives amplitude
Every factor is one if and zero otherwise. Thus the final state is exactly , and the measurement outputs a with certainty after one oracle query. This is the character cancellation behind Bernstein-Vazirani phase kickback; because access here is already to the reduced phase oracle, no extra target ancilla or conversion from a bit-flip oracle is required.
The phase oracle multiplies an unmarked basis vector by and a marked one by . Thus the state after the oracle is
Its squared norm is . All computational outcomes would still have probability if measured at this point: the oracle has changed the relative phase, not the magnitudes of the amplitudes. The following reflection converts that phase information into a changed probability distribution through quantum interference.
The algorithm returns a uniformly random marked input with certainty. The Born rule applied to the final state gives, for each individual basis label ,
Summing over the marked inputs gives . The outcome is a marked input label, not merely the bit indicating whether some marked input exists. There is one use of the supplied phase oracle, together with the specified preparation, reflection and measurement.
The exact success relies on the marked fraction . More generally, the mean amplitude immediately after the oracle is . Inversion about the mean sends an unmarked amplitude to and a marked amplitude to . Thus a single iteration has marked success probability . At the unmarked amplitudes vanish and the marked amplitudes become , giving the one-step exact Grover search with a quarter of the inputs marked. No claim of one-query certainty for an arbitrary marked fraction is needed.
Figure 1.
Original amplitude and Born-probability illustration for eight inputs with two marked. The oracle's relative minus signs become exact concentration on the marked inputs after one reflection.
Details.
Use the entanglement-assisted promised equality protocol. Alice applies the phase oracle on , and Bob applies on . These are unitary operators because their diagonal entries have modulus one. After Alice sends to Bob, the joint pure state is
Let be the original maximally entangled state. If is the Hamming distance, then
Bob performs the projective measurement with projectors and . Under the promise,
He declares equal strings for the first outcome and distance for the other. This is exact because the promised outputs occupy orthogonal subspaces. A basic measurement also suffices: extend to an orthonormal basis and group all its other outcomes together. Alice transmits one -dimensional system, realizable using qubits; need not be a power of two.
We prove the one-query constancy obstruction for phase oracles while allowing arbitrary quantum ancillas. By purification of a density operator, the quantum state immediately before the sole query can be taken as
The ancilla vectors need not be normalized or orthogonal. Classical randomness and earlier quantum measurements can be included in additional ancillas; allowing access to these systems only gives the proposed algorithm more power.
For the zero constant function, the phase oracle is , leaving unchanged. For each , consider the Boolean function that is one at and zero elsewhere. Since , it is nonconstant, and its phase oracle produces
Any later fixed unitary transformation preserves these inner products. An arbitrary final quantum measurement cannot distinguish the constant output from each nonconstant output with certainty unless they are orthogonal, by perfect discrimination of pure states requires orthogonality. Explicitly, an accepting POVM effect would satisfy and , forcing .
Therefore exact classification requires for every . Summing gives
which contradicts . Thus one query cannot decide constancy with certainty. The other constant function gives , differing only by a global phase, so it does not change the argument. For comparison, permits ; the impossibility arises from demanding the test work for every nonconstant Boolean function.
For one input bit, a Boolean function is specified by the pair , and counts its satisfying assignments. In the ordered computational basis , the supplied phase oracle convention gives
Here is exclusive or: the oracle changes the sign of the inputs with . With the identity matrix and the Pauli Z gate, all four cases are
The two middle cases are balanced Boolean functions; the others are constant functions. The specified zero-state sign change and the Hadamard gate are
Use the top qubit as the first tensor product factor. Write the controlled unitary gate as . Reading the bracketed quantum circuit from left to right, its four operations are , , , . Thus the target operation in its control-one branch is
where the rightmost matrix acts first. The control-zero branch is the identity operator. The Hadamard conjugation of a controlled gate identity gives
Indeed, on control zero the replacement applies to the target, while on control one both sides apply . By linearity, the identity holds on every quantum superposition and therefore in every repetition of the bracket. This replaces the two internal controlled Hadamard gates as a pair.
The global phase of a controlled quantum gate must be preserved: , whereas . Consequently the minus signs in and the special phase oracles cannot be discarded as an unobservable global phase of the complete quantum circuit.
For brackets the control-zero branch still does nothing, and the control-one branch applies to the target. Immediately before the final two Hadamard gates, the quantum state is
For the constant function with , the phase oracle is , so . Since is an eigenstate of the Pauli X gate with eigenvalue , for every integer . The final two Hadamard gates therefore give
In particular, the first qubit always ends in .
For the constant function with , and , so . Thus the target remains in , and the top qubit before its final Hadamard gate is . The sign is a relative quantum phase between the control branches. The Hadamard gate converts it into the integer parity of :
The first qubit is therefore for even and for odd , including all requested .