# Implementing a multioutput quantum oracle on Qiskit

A quantum boolean oracle is an operator that should work as follows: $$\sum_x U_f |x, 0> = \sum_x |x, f(x)>$$.

Now, suppose that I have two input qubits and two output qubits and I want to implement the following $$f(x)$$:

• f(00) = 00
• f(01) = 10
• f(10) = 11
• f(11) = 01

The above function is just an example (I'm looking for a more general answer). How can I implement something like that in Qiskit? I saw TruthTable Method, but it seems to work correctly only in the case of one output qubit.

Generally speaking (also in classical compuatation) , output with more than 1 bit, is implemented by seperate function for each bit. Same fir qubits which are acting like bits, but in superpositions of different states in the same time.

So in this case, all you have to do, is to create 2 ancilla qubits instead of 1, each one with its relevant oracle.

The first oracle:

f(00) = 0

f(01) = 1

f(10) = 1

f(11) = 0

The second:

f(00) = 0

f(01) = 0

f(10) = 1

f(11) = 1

• I don't think this is a good advice. Can you point to some example of classical computation where we implement these kind of functions bitwise? I can think of many of cases where we don't do this. (i.e. boolean circuits for sum, multiplication, whatever..)
– asdf
Sep 5, 2022 at 10:39
• Actually you gave example to the cases that are doing it, for example full adder of few bits geeksforgeeks.org/4-bit-binary-adder-subtractor Sep 6, 2022 at 4:36
• The output may also depend on another output, but yet, calculated seperatly Sep 6, 2022 at 4:37
• Oh, I see what you mean now! Tnx! But that actually does not lead to many optimization to the circuit, no?
– asdf
Sep 6, 2022 at 14:11
• I order to make optimization you can use things like Karnoo maps, seperatly to each output, in the classical case. Sep 7, 2022 at 11:55