Blog

# Circuit of the month Dec 21: creating sophisticated oracles

18
December
,
2021

Oracles are a very important component of quantum computing algorithms. An oracle is essentially a "black box" function that is used as input to another algorithm. For instance, in a Grover search, the oracle identifies which values match the search and which values do not match the search.

Creating a simple oracle is a relatively simple matter. For instance, consider the oracle that is part of the Grover circuit below, part of the Qiskit textbook

The task if this particular oracle is to mark states |101> and |110> so that they be amplified by the next part of the circuit.

But what happens when you want to write a more sophisticated oracle? For instance, assume that you have three quantum variables, a, b and c. Each variable is not a single qubit but a register that is comprised of several qubits. Let's assume that a is 2 qubits wide, b is also 2 qubits wide and c is 3 qubits wide. Our oracle is designed to identify combinations of a, b and c such that (using the Python notation):

a+ b + (c & 15) % 8 ^ 3 & a ^ 10 == 4

This oracle is more complex and depending on the user preferences, it might look something like this:

You can see the high-level functionality and then some higher level detail in some of the individual blocks.

Such an oracle would take a long time to create.

Unless you are using the Classiq platform. Here's the code that creates this oracle on Classiq:

{
"qubit_count": 40,
"max_depth": 1000,
"logic_flow": [
{
"function": "Arithmetic",
"function_params": {
"expression": "(a + b + (c & 15)) % 8 ^ 3 & a ^ 10 == 4",
"definitions": {"a": {"size": 2}, "b": {"size":2}, "c": {"size":3}},
"method": "pebble",
"qubit_count": 30
},
]
}


In addition to the obvious degrees of freedom in writing a different arithmetic expression or changing the width of each variable, one could control the desired number of qubits, the method of creating the oracle, and many additional parameters.

Here's how the full circuit looks like. Hover above the colored blocks below and click on the "+" signs on the blocks below to expand and keep expanding the circuit to your heart's content

Complex oracle, created on Dec 17, 2021 using the Classiq quantum algorithm design platform

There was some error with the script

Oracles are a very important component of quantum computing algorithms. An oracle is essentially a "black box" function that is used as input to another algorithm. For instance, in a Grover search, the oracle identifies which values match the search and which values do not match the search.

Creating a simple oracle is a relatively simple matter. For instance, consider the oracle that is part of the Grover circuit below, part of the Qiskit textbook

The task if this particular oracle is to mark states |101> and |110> so that they be amplified by the next part of the circuit.

But what happens when you want to write a more sophisticated oracle? For instance, assume that you have three quantum variables, a, b and c. Each variable is not a single qubit but a register that is comprised of several qubits. Let's assume that a is 2 qubits wide, b is also 2 qubits wide and c is 3 qubits wide. Our oracle is designed to identify combinations of a, b and c such that (using the Python notation):

a+ b + (c & 15) % 8 ^ 3 & a ^ 10 == 4

This oracle is more complex and depending on the user preferences, it might look something like this:

You can see the high-level functionality and then some higher level detail in some of the individual blocks.

Such an oracle would take a long time to create.

Unless you are using the Classiq platform. Here's the code that creates this oracle on Classiq:

{
"qubit_count": 40,
"max_depth": 1000,
"logic_flow": [
{
"function": "Arithmetic",
"function_params": {
"expression": "(a + b + (c & 15)) % 8 ^ 3 & a ^ 10 == 4",
"definitions": {"a": {"size": 2}, "b": {"size":2}, "c": {"size":3}},
"method": "pebble",
"qubit_count": 30
},
]
}


In addition to the obvious degrees of freedom in writing a different arithmetic expression or changing the width of each variable, one could control the desired number of qubits, the method of creating the oracle, and many additional parameters.

Here's how the full circuit looks like. Hover above the colored blocks below and click on the "+" signs on the blocks below to expand and keep expanding the circuit to your heart's content

Complex oracle, created on Dec 17, 2021 using the Classiq quantum algorithm design platform

There was some error with the script

## About "The Qubit Guy's Podcast"

Hosted by The Qubit Guy (Yuval Boger, our Chief Marketing Officer), the podcast hosts thought leaders in quantum computing to discuss business and technical questions that impact the quantum computing ecosystem. Our guests provide interesting insights about quantum computer software and algorithm, quantum computer hardware, key applications for quantum computing, market studies of the quantum industry and more.