# Grover Operator¶

The grover operator is a unitary used in amplitude estimation and amplitude amplification algorithms.[1]

The grover operator can be given as:

$Q = Q(A,\chi) = -AS_0A^{-1}S_\chi$

where $$A$$ is state preparation operator,

$A|0 \rangle= |\psi \rangle$

$$S_x$$ marks good states,

and $$S_0$$, called diffuser, flips around the zero state,

$S_0 = I - 2|0\rangle\langle0|$

By default, the state preparation used is the uniform superposition by applying hadamard on all inputs.

$A = H^{\bigotimes n}$

## Syntax¶

Function: GroverOperator

Parameters:

-

oracle: ArithmeticOracle

{
"function": "GroverOperator",
"function_params": {
"oracle": {
"expression": "(a + b + (c & 6)) % 4 | 4 & c  == 4",
"definitions": {
"a": {
"size": 2
},
"b": {
"size": 2
},
"c": {
"size": 3
}
},
"uncomputation_method": "optimized",
"qubit_count": 16
},
"state_preparation": null
}
}


### Example 1:¶

from classiq import Model, RegisterUserInput
from classiq.builtin_functions import ArithmeticOracle, GroverOperator

oracle_params = ArithmeticOracle(
expression="(a + b + (c & 6)) % 4 | 4 & c  == 4",
definitions=dict(
a=RegisterUserInput(size=2),
b=RegisterUserInput(size=2),
c=RegisterUserInput(size=3),
),
uncomputation_method="optimized",
qubit_count=16,
)
grover_params = GroverOperator(oracle=oracle_params)

model = Model()
model.GroverOperator(grover_params)

circuit = model.synthesize()


The example above generates grover operator for a specific oracle. The functional blocks include an arithmetic oracle, state preparation, a diffuser and finally the global phase.

An explanation of execution of a Grover Operator can be found in the Amplitude Amplification section.

## Grover in the IDE¶

In the screenshot below the IDE view when the Grover option is selected form the application suite is shown.

Details on executing a Grover model with Amplitude Amplification can be found in the Amplitude Amplification section.

## References¶

[1]G. Brassard, P. Hoyer, M. Mosca, and A. Tapp, “Quantum Amplitude Amplification and Estimation,” arXiv:quant-ph/0005055, vol. 305, pp. 53–74, 2002, doi: 10.1090/conm/305/05215.