Let the known phase gate on the answer register be
where the comparison uses ordinary integers, not modular arithmetic. A reversible circuit computes the predicate, applies a Pauli Z gate to its flag, then performs uncomputation.
The compute-phase-uncompute construction now gives
Use modular-oracle inversion by negation to realize the last operation with one further query. Exactly two oracle queries implement , returning the answer register and comparison workspace to their initial states.
Applying the two modular-addition quantum oracles consecutively adds to the answer register. Thus
Let . Applying , then , then gives
Therefore
using one query and two unitary operators independent of . This is modular-oracle inversion by negation.