# How does ControlledOnInt in Q# make it Grovers Oracle?

I have an example with 6 qubits for names and 6 for telephones. I encoded their relation like this:

(ControlledOnInt(1, SetRegisterToInt(6, _)))(rnames, rtels);
(ControlledOnInt(3, SetRegisterToInt(2, _)))(rnames, rtels);


So there are only 2 registers states(tel->name) in a BD with 64 possible states.

When I ask the BD for a name from a telephone it works ok, 6 => 2 and 2 => 3 because only in these 2 values (6 and 2) the marked qbit entangled with telephones is One.

So the important part is the oracle made with ControlledOnInt, and I need to know how does it, because I have my own Grovers in c++ and I want to know the details to make it, and also to learn what gates it uses and how it multiply the matrices.

Thanks

• I mean what I need to know is which gates are used to transfrom telephone 6 in name 2 and T 2 in name 6 that are valid for both?. I supoposse there will be a comparation first to know if T is 2 or 6 and later convert their bits with CNOT? – Luis ALberto Jul 5 '19 at 12:57
• The questions seem very broad. Are you asking about your implementation of Grover's applied to a $6$-qubit database of names/telephone numbers? What is a BD? What do you mean by 6=>2 and 2=>3? "I have my own Grovers in c++ and I want to know the details to make it" - so did you implement Grover's algorithm, or not? "And also to learn what gate it uses" - gates for Grover's algorithm? Or your implementation? "how it multiple the matrices" - how what multiplies which matrices? – Mark S Jul 5 '19 at 13:51

ControlledOnInt is a library function which applies a specified operation (in this case SetRegisterToInt) to the target register only if the control register is in a state that encodes the given integer. Internally it does the following:
• applies normally controlled version of the operation (apply operation if all control qubits are in $$|1\rangle$$ state) to the control and target registers;