My question is related to a similar question which did not get a satisfactory answer. Since it was asked in 2020 and was somewhat general, I hope to ask a similar question in 2022 with a concrete piece of code that I would like to get help with.
A quantum oracle $O_f$ is an operation that is usually used by higher-level quantum algorithms like Grover's quantum search, DJ algorithm, etc.
$O_f$ is usually defined in terms of a classical binary function $f:\{0,1\}^n \rightarrow \{0,1\}^m$. So, implementation of an oracle $O_f$ boils down to implementing $f(x)$ as a quantum circuit. I suppose the resulting circuit does not have any quantum effects because we just map a classical circuit to a quantum circuit.
Since $f(x)$ is entirely classical computation, I would like to know if there are compilers that take high-level description of $f(x)$ in terms of the standard programming constructs if, for, while and produce a quantum circuit $O_f$?
For example, I'm interested in getting a quantum circuit for the following function $f:\{0,1\}^n \rightarrow \{0,1\}$ that performs the primality test:
def primality_test(num):
for i in range(2, int(sqrt(num))+1):
if num % i == 0: #if remainder is zero, `num` is not prime
return 0
return 1
I will appreciate any links to compilers or libraries that can do the conversion.