# FourierChecking¶

class FourierChecking(f, g)[source]

Fourier checking circuit.

The circuit for the Fourier checking algorithm, introduced in [1], involves a layer of Hadamards, the function $$f$$, another layer of Hadamards, the function $$g$$, followed by a final layer of Hadamards. The functions $$f$$ and $$g$$ are classical functions realized as phase oracles (diagonal operators with {-1, 1} on the diagonal).

The probability of observing the all-zeros string is $$p(f,g)$$. The algorithm solves the promise Fourier checking problem, which decides if f is correlated with the Fourier transform of g, by testing if $$p(f,g) <= 0.01$$ or $$p(f,g) >= 0.05$$, promised that one or the other of these is true.

The functions $$f$$ and $$g$$ are currently implemented from their truth tables but could be represented concisely and implemented efficiently for special classes of functions.

Fourier checking is a special case of $$k$$-fold forrelation [2].

Reference:

[1] S. Aaronson, BQP and the Polynomial Hierarchy, 2009 (Section 3.2). arXiv:0910.4698

[2] S. Aaronson, A. Ambainis, Forrelation: a problem that optimally separates quantum from classical computing, 2014. arXiv:1411.5729

Create Fourier checking circuit.

Parameters
• f (List[int]) – truth table for f, length 2**n list of {1,-1}.

• g (List[int]) – truth table for g, length 2**n list of {1,-1}.

Raises

CircuitError – if the inputs f and g are not valid.

Reference Circuit:

Attributes

 FourierChecking.clbits Returns a list of classical bits in the order that the registers were added. FourierChecking.data Return the circuit data (instructions and context). FourierChecking.extension_lib FourierChecking.header FourierChecking.instances FourierChecking.n_qubits Deprecated, use num_qubits instead. FourierChecking.num_clbits Return number of classical bits. FourierChecking.num_parameters Convenience function to get the number of parameter objects in the circuit. FourierChecking.num_qubits Return number of qubits. FourierChecking.parameters Convenience function to get the parameters defined in the parameter table. FourierChecking.prefix FourierChecking.qubits Returns a list of quantum bits in the order that the registers were added.

Methods

 FourierChecking.AND(qr_variables, qb_target, …) Build a collective conjunction (AND) circuit in place using mct. FourierChecking.OR(qr_variables, qb_target, …) Build a collective disjunction (OR) circuit in place using mct. Return indexed operation. Return number of operations in circuit. Add registers. FourierChecking.append(instruction[, qargs, …]) Append one or more instructions to the end of the circuit, modifying the circuit in place. FourierChecking.assign_parameters(param_dict) Assign parameters to new parameters or values. Apply Barrier. FourierChecking.bind_parameters(value_dict) Assign numeric parameters to values yielding a new circuit. FourierChecking.cast(value, _type) Best effort to cast value to type. Converts several classical bit representations (such as indexes, range, etc.) into a list of classical bits. FourierChecking.ccx(control_qubit1, …[, …]) Apply CCXGate. FourierChecking.ch(control_qubit, …[, …]) Apply CHGate. Return the current number of instances of this class, useful for auto naming. Return the prefix to use for auto naming. FourierChecking.cnot(control_qubit, …[, …]) Apply CXGate. Append rhs to self if self contains compatible registers. FourierChecking.compose(other[, qubits, …]) Compose circuit with other circuit or instruction, optionally permuting wires. FourierChecking.copy([name]) Copy the circuit. Count each operation kind in the circuit. FourierChecking.crx(theta, control_qubit, …) Apply CRXGate. FourierChecking.cry(theta, control_qubit, …) Apply CRYGate. FourierChecking.crz(theta, control_qubit, …) Apply CRZGate. FourierChecking.cswap(control_qubit, …[, …]) Apply CSwapGate. FourierChecking.cu1(theta, control_qubit, …) Apply CU1Gate. FourierChecking.cu3(theta, phi, lam, …[, …]) Apply CU3Gate. FourierChecking.cx(control_qubit, …[, …]) Apply CXGate. FourierChecking.cy(control_qubit, …[, …]) Apply CYGate. FourierChecking.cz(control_qubit, …[, …]) Apply CZGate. FourierChecking.dcx(qubit1, qubit2) Apply DCXGate. Call a decomposition pass on this circuit, to decompose one level (shallow decompose). Return circuit depth (i.e., length of critical path). FourierChecking.diag_gate(diag, qubit) Deprecated version of QuantumCircuit.diagonal. FourierChecking.diagonal(diag, qubit) Attach a diagonal gate to a circuit. FourierChecking.draw([output, scale, …]) Draw the quantum circuit. Append QuantumCircuit to the right hand side if it contains compatible registers. FourierChecking.fredkin(control_qubit, …) Apply CSwapGate. Take in a QASM file and generate a QuantumCircuit object. FourierChecking.from_qasm_str(qasm_str) Take in a QASM string and generate a QuantumCircuit object. FourierChecking.h(qubit, *[, q]) Apply HGate. FourierChecking.hamiltonian(operator, time, …) Apply hamiltonian evolution to to qubits. FourierChecking.has_register(register) Test if this circuit has the register r. FourierChecking.i(qubit, *[, q]) Apply IGate. FourierChecking.id(qubit, *[, q]) Apply IGate. FourierChecking.iden(qubit, *[, q]) Deprecated identity gate. FourierChecking.initialize(params, qubits) Apply initialize to circuit. Invert this circuit. FourierChecking.iso(isometry, q_input, …) Attach an arbitrary isometry from m to n qubits to a circuit. FourierChecking.isometry(isometry, q_input, …) Attach an arbitrary isometry from m to n qubits to a circuit. FourierChecking.iswap(qubit1, qubit2) Apply iSwapGate. FourierChecking.mcmt(gate, control_qubits, …) Apply a multi-control, multi-target using a generic gate. FourierChecking.mcrx(theta, q_controls, q_target) Apply Multiple-Controlled X rotation gate FourierChecking.mcry(theta, q_controls, …) Apply Multiple-Controlled Y rotation gate FourierChecking.mcrz(lam, q_controls, q_target) Apply Multiple-Controlled Z rotation gate FourierChecking.mct(control_qubits, target_qubit) Apply MCXGate. FourierChecking.mcu1(lam, control_qubits, …) Apply MCU1Gate. FourierChecking.mcx(control_qubits, target_qubit) Apply MCXGate. FourierChecking.measure(qubit, cbit) Measure quantum bit into classical bit (tuples). FourierChecking.measure_active([inplace]) Adds measurement to all non-idle qubits. FourierChecking.measure_all([inplace]) Adds measurement to all qubits. Mirror the circuit by reversing the instructions. FourierChecking.ms(theta, qubits) Apply MSGate. How many non-entangled subcircuits can the circuit be factored to. Return number of non-local gates (i.e. Computes the number of tensor factors in the unitary (quantum) part of the circuit only. Computes the number of tensor factors in the unitary (quantum) part of the circuit only. FourierChecking.qasm([formatted, filename]) Return OpenQASM string. Converts several qubit representations (such as indexes, range, etc.) into a list of qubits. FourierChecking.r(theta, phi, qubit, *[, q]) Apply RGate. FourierChecking.rcccx(control_qubit1, …) Apply RC3XGate. FourierChecking.rccx(control_qubit1, …) Apply RCCXGate. Removes final measurement on all qubits if they are present. Reset q. FourierChecking.rx(theta, qubit, *[, label, q]) Apply RXGate. FourierChecking.rxx(theta, qubit1, qubit2) Apply RXXGate. FourierChecking.ry(theta, qubit, *[, label, q]) Apply RYGate. FourierChecking.ryy(theta, qubit1, qubit2) Apply RYYGate. FourierChecking.rz(phi, qubit, *[, q]) Apply RZGate. FourierChecking.rzx(theta, qubit1, qubit2) Apply RZXGate. FourierChecking.rzz(theta, qubit1, qubit2) Apply RZZGate. FourierChecking.s(qubit, *[, q]) Apply SGate. FourierChecking.sdg(qubit, *[, q]) Apply SdgGate. Returns total number of gate operations in circuit. FourierChecking.snapshot(label[, …]) Take a statevector snapshot of the internal simulator representation. Take a density matrix snapshot of simulator state. Take a snapshot of expectation value of an Operator. Take a probability snapshot of the simulator state. Take a stabilizer snapshot of the simulator state. Take a statevector snapshot of the simulator state. FourierChecking.squ(unitary_matrix, qubit[, …]) Decompose an arbitrary 2*2 unitary into three rotation gates. FourierChecking.swap(qubit1, qubit2) Apply SwapGate. FourierChecking.t(qubit, *[, q]) Apply TGate. FourierChecking.tdg(qubit, *[, q]) Apply TdgGate. FourierChecking.to_gate([parameter_map]) Create a Gate out of this circuit. FourierChecking.to_instruction([parameter_map]) Create an Instruction out of this circuit. FourierChecking.toffoli(control_qubit1, …) Apply CCXGate. FourierChecking.u1(theta, qubit, *[, q]) Apply U1Gate. FourierChecking.u2(phi, lam, qubit, *[, q]) Apply U2Gate. FourierChecking.u3(theta, phi, lam, qubit, *) Apply U3Gate. FourierChecking.uc(gate_list, q_controls, …) Attach a uniformly controlled gates (also called multiplexed gates) to a circuit. FourierChecking.ucg(angle_list, q_controls, …) Deprecated version of uc. FourierChecking.ucrx(angle_list, q_controls, …) Attach a uniformly controlled (also called multiplexed) Rx rotation gate to a circuit. FourierChecking.ucry(angle_list, q_controls, …) Attach a uniformly controlled (also called multiplexed) Ry rotation gate to a circuit. FourierChecking.ucrz(angle_list, q_controls, …) Attach a uniformly controlled (also called multiplexed gates) Rz rotation gate to a circuit. FourierChecking.ucx(angle_list, q_controls, …) Deprecated version of ucrx. FourierChecking.ucy(angle_list, q_controls, …) Deprecated version of ucry. FourierChecking.ucz(angle_list, q_controls, …) Deprecated version of ucrz. FourierChecking.unitary(obj, qubits[, label]) Apply unitary gate to q. Return number of qubits plus clbits in circuit. FourierChecking.x(qubit, *[, label, …]) Apply XGate. FourierChecking.y(qubit, *[, q]) Apply YGate. FourierChecking.z(qubit, *[, q]) Apply ZGate. Return indexed operation. Return number of operations in circuit.