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.ancillas

Returns a list of ancilla bits in the order that the registers were added.

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.global_phase

Return the global phase of the circuit in radians.

FourierChecking.header

FourierChecking.instances

FourierChecking.n_qubits

Deprecated, use num_qubits instead.

FourierChecking.num_ancillas

Return the number of ancilla qubits.

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.

FourierChecking.__getitem__(item)

Return indexed operation.

FourierChecking.__len__()

Return number of operations in circuit.

FourierChecking.add_register(*regs)

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.

FourierChecking.barrier(*qargs)

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.

FourierChecking.cbit_argument_conversion(…)

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.

FourierChecking.cls_instances()

Return the current number of instances of this class, useful for auto naming.

FourierChecking.cls_prefix()

Return the prefix to use for auto naming.

FourierChecking.cnot(control_qubit, …[, …])

Apply CXGate.

FourierChecking.combine(rhs)

Append rhs to self if self contains compatible registers.

FourierChecking.compose(other[, qubits, …])

Compose circuit with other circuit or instruction, optionally permuting wires.

FourierChecking.control([num_ctrl_qubits, …])

Control this circuit on num_ctrl_qubits qubits.

FourierChecking.copy([name])

Copy the circuit.

FourierChecking.count_ops()

Count each operation kind in the circuit.

FourierChecking.cp(theta, control_qubit, …)

Apply CPhaseGate.

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.csx(control_qubit, target_qubit)

Apply CSXGate.

FourierChecking.cu(theta, phi, lam, gamma, …)

Apply CUGate.

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.

FourierChecking.decompose()

Call a decomposition pass on this circuit, to decompose one level (shallow decompose).

FourierChecking.depth()

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.

FourierChecking.extend(rhs)

Append QuantumCircuit to the right hand side if it contains compatible registers.

FourierChecking.fredkin(control_qubit, …)

Apply CSwapGate.

FourierChecking.from_qasm_file(path)

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.

FourierChecking.inverse()

Invert (take adjoint of) 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.

FourierChecking.mirror()

DEPRECATED: use circuit.reverse_ops().

FourierChecking.ms(theta, qubits)

Apply MSGate.

FourierChecking.num_connected_components([…])

How many non-entangled subcircuits can the circuit be factored to.

FourierChecking.num_nonlocal_gates()

Return number of non-local gates (i.e.

FourierChecking.num_tensor_factors()

Computes the number of tensor factors in the unitary (quantum) part of the circuit only.

FourierChecking.num_unitary_factors()

Computes the number of tensor factors in the unitary (quantum) part of the circuit only.

FourierChecking.p(theta, qubit)

Apply PhaseGate.

FourierChecking.power(power[, matrix_power])

Raise this circuit to the power of power.

FourierChecking.qasm([formatted, filename])

Return OpenQASM string.

FourierChecking.qbit_argument_conversion(…)

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.

FourierChecking.remove_final_measurements([…])

Removes final measurement on all qubits if they are present.

FourierChecking.repeat(reps)

Repeat this circuit reps times.

FourierChecking.reset(qubit)

Reset q.

FourierChecking.reverse_bits()

Return a circuit with the opposite order of wires.

FourierChecking.reverse_ops()

Reverse the circuit by reversing the order of instructions.

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.

FourierChecking.size()

Returns total number of gate operations in circuit.

FourierChecking.snapshot(label[, …])

Take a statevector snapshot of the internal simulator representation.

FourierChecking.snapshot_density_matrix(label)

Take a density matrix snapshot of simulator state.

FourierChecking.snapshot_expectation_value(…)

Take a snapshot of expectation value <O> of an Operator.

FourierChecking.snapshot_probabilities(…)

Take a probability snapshot of the simulator state.

FourierChecking.snapshot_stabilizer(label)

Take a stabilizer snapshot of the simulator state.

FourierChecking.snapshot_statevector(label)

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.sx(qubit)

Apply SXGate.

FourierChecking.sxdg(qubit)

Apply SXdgGate.

FourierChecking.t(qubit, *[, q])

Apply TGate.

FourierChecking.tdg(qubit, *[, q])

Apply TdgGate.

FourierChecking.to_gate([parameter_map, label])

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.u(theta, phi, lam, qubit)

Apply UGate.

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.

FourierChecking.width()

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.

FourierChecking.__getitem__(item)

Return indexed operation.

FourierChecking.__len__()

Return number of operations in circuit.