HiddenLinearFunction

class HiddenLinearFunction(adjacency_matrix)[source]

Circuit to solve the hidden linear function problem.

The 2D Hidden Linear Function problem is determined by a 2D adjacency matrix A, where only elements that are nearest-neighbor on a grid have non-zero entries. Each row/column corresponds to one binary variable \(x_i\).

The hidden linear function problem is as follows:

Consider the quadratic form

\[q(x) = \sum_{i,j=1}^{n}{x_i x_j} ~(\mathrm{mod}~ 4)\]

and restrict \(q(x)\) onto the nullspace of A. This results in a linear function.

\[2 \sum_{i=1}^{n}{z_i x_i} ~(\mathrm{mod}~ 4) \forall x \in \mathrm{Ker}(A)\]

and the goal is to recover this linear function (equivalently a vector \([z_0, ..., z_{n-1}]\)). There can be multiple solutions.

In [1] it is shown that the present circuit solves this problem on a quantum computer in constant depth, whereas any corresponding solution on a classical computer would require circuits that grow logarithmically with \(n\). Thus this circuit is an example of quantum advantage with shallow circuits.

Reference Circuit:

Reference:

[1] S. Bravyi, D. Gosset, R. Koenig, Quantum Advantage with Shallow Circuits, 2017. arXiv:1704.00690

Create new HLF circuit.

Parameters

adjacency_matrix (Union[List[List[int]], ndarray]) – a symmetric n-by-n list of 0-1 lists. n will be the number of qubits.

Raises

CircuitError – If A is not symmetric.

Attributes

HiddenLinearFunction.ancillas

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

HiddenLinearFunction.clbits

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

HiddenLinearFunction.data

Return the circuit data (instructions and context).

HiddenLinearFunction.extension_lib

HiddenLinearFunction.global_phase

Return the global phase of the circuit in radians.

HiddenLinearFunction.header

HiddenLinearFunction.instances

HiddenLinearFunction.n_qubits

Deprecated, use num_qubits instead.

HiddenLinearFunction.num_ancillas

Return the number of ancilla qubits.

HiddenLinearFunction.num_clbits

Return number of classical bits.

HiddenLinearFunction.num_parameters

Convenience function to get the number of parameter objects in the circuit.

HiddenLinearFunction.num_qubits

Return number of qubits.

HiddenLinearFunction.parameters

Convenience function to get the parameters defined in the parameter table.

HiddenLinearFunction.prefix

HiddenLinearFunction.qubits

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

Methods

HiddenLinearFunction.AND(qr_variables, …)

Build a collective conjunction (AND) circuit in place using mct.

HiddenLinearFunction.OR(qr_variables, …[, …])

Build a collective disjunction (OR) circuit in place using mct.

HiddenLinearFunction.__getitem__(item)

Return indexed operation.

HiddenLinearFunction.__len__()

Return number of operations in circuit.

HiddenLinearFunction.add_register(*regs)

Add registers.

HiddenLinearFunction.append(instruction[, …])

Append one or more instructions to the end of the circuit, modifying the circuit in place.

HiddenLinearFunction.assign_parameters(…)

Assign parameters to new parameters or values.

HiddenLinearFunction.barrier(*qargs)

Apply Barrier.

HiddenLinearFunction.bind_parameters(value_dict)

Assign numeric parameters to values yielding a new circuit.

HiddenLinearFunction.cast(value, _type)

Best effort to cast value to type.

HiddenLinearFunction.cbit_argument_conversion(…)

Converts several classical bit representations (such as indexes, range, etc.) into a list of classical bits.

HiddenLinearFunction.ccx(control_qubit1, …)

Apply CCXGate.

HiddenLinearFunction.ch(control_qubit, …)

Apply CHGate.

HiddenLinearFunction.cls_instances()

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

HiddenLinearFunction.cls_prefix()

Return the prefix to use for auto naming.

HiddenLinearFunction.cnot(control_qubit, …)

Apply CXGate.

HiddenLinearFunction.combine(rhs)

Append rhs to self if self contains compatible registers.

HiddenLinearFunction.compose(other[, …])

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

HiddenLinearFunction.control([…])

Control this circuit on num_ctrl_qubits qubits.

HiddenLinearFunction.copy([name])

Copy the circuit.

HiddenLinearFunction.count_ops()

Count each operation kind in the circuit.

HiddenLinearFunction.cp(theta, …[, label, …])

Apply CPhaseGate.

HiddenLinearFunction.crx(theta, …[, …])

Apply CRXGate.

HiddenLinearFunction.cry(theta, …[, …])

Apply CRYGate.

HiddenLinearFunction.crz(theta, …[, …])

Apply CRZGate.

HiddenLinearFunction.cswap(control_qubit, …)

Apply CSwapGate.

HiddenLinearFunction.csx(control_qubit, …)

Apply CSXGate.

HiddenLinearFunction.cu(theta, phi, lam, …)

Apply CUGate.

HiddenLinearFunction.cu1(theta, …[, …])

Apply CU1Gate.

HiddenLinearFunction.cu3(theta, phi, lam, …)

Apply CU3Gate.

HiddenLinearFunction.cx(control_qubit, …)

Apply CXGate.

HiddenLinearFunction.cy(control_qubit, …)

Apply CYGate.

HiddenLinearFunction.cz(control_qubit, …)

Apply CZGate.

HiddenLinearFunction.dcx(qubit1, qubit2)

Apply DCXGate.

HiddenLinearFunction.decompose()

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

HiddenLinearFunction.depth()

Return circuit depth (i.e., length of critical path).

HiddenLinearFunction.diag_gate(diag, qubit)

Deprecated version of QuantumCircuit.diagonal.

HiddenLinearFunction.diagonal(diag, qubit)

Attach a diagonal gate to a circuit.

HiddenLinearFunction.draw([output, scale, …])

Draw the quantum circuit.

HiddenLinearFunction.extend(rhs)

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

HiddenLinearFunction.fredkin(control_qubit, …)

Apply CSwapGate.

HiddenLinearFunction.from_qasm_file(path)

Take in a QASM file and generate a QuantumCircuit object.

HiddenLinearFunction.from_qasm_str(qasm_str)

Take in a QASM string and generate a QuantumCircuit object.

HiddenLinearFunction.h(qubit, *[, q])

Apply HGate.

HiddenLinearFunction.hamiltonian(operator, …)

Apply hamiltonian evolution to to qubits.

HiddenLinearFunction.has_register(register)

Test if this circuit has the register r.

HiddenLinearFunction.i(qubit, *[, q])

Apply IGate.

HiddenLinearFunction.id(qubit, *[, q])

Apply IGate.

HiddenLinearFunction.iden(qubit, *[, q])

Deprecated identity gate.

HiddenLinearFunction.initialize(params, qubits)

Apply initialize to circuit.

HiddenLinearFunction.inverse()

Invert (take adjoint of) this circuit.

HiddenLinearFunction.iso(isometry, q_input, …)

Attach an arbitrary isometry from m to n qubits to a circuit.

HiddenLinearFunction.isometry(isometry, …)

Attach an arbitrary isometry from m to n qubits to a circuit.

HiddenLinearFunction.iswap(qubit1, qubit2)

Apply iSwapGate.

HiddenLinearFunction.mcmt(gate, …[, …])

Apply a multi-control, multi-target using a generic gate.

HiddenLinearFunction.mcrx(theta, q_controls, …)

Apply Multiple-Controlled X rotation gate

HiddenLinearFunction.mcry(theta, q_controls, …)

Apply Multiple-Controlled Y rotation gate

HiddenLinearFunction.mcrz(lam, q_controls, …)

Apply Multiple-Controlled Z rotation gate

HiddenLinearFunction.mct(control_qubits, …)

Apply MCXGate.

HiddenLinearFunction.mcu1(lam, …)

Apply MCU1Gate.

HiddenLinearFunction.mcx(control_qubits, …)

Apply MCXGate.

HiddenLinearFunction.measure(qubit, cbit)

Measure quantum bit into classical bit (tuples).

HiddenLinearFunction.measure_active([inplace])

Adds measurement to all non-idle qubits.

HiddenLinearFunction.measure_all([inplace])

Adds measurement to all qubits.

HiddenLinearFunction.mirror()

DEPRECATED: use circuit.reverse_ops().

HiddenLinearFunction.ms(theta, qubits)

Apply MSGate.

HiddenLinearFunction.num_connected_components([…])

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

HiddenLinearFunction.num_nonlocal_gates()

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

HiddenLinearFunction.num_tensor_factors()

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

HiddenLinearFunction.num_unitary_factors()

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

HiddenLinearFunction.p(theta, qubit)

Apply PhaseGate.

HiddenLinearFunction.power(power[, matrix_power])

Raise this circuit to the power of power.

HiddenLinearFunction.qasm([formatted, filename])

Return OpenQASM string.

HiddenLinearFunction.qbit_argument_conversion(…)

Converts several qubit representations (such as indexes, range, etc.) into a list of qubits.

HiddenLinearFunction.r(theta, phi, qubit, *)

Apply RGate.

HiddenLinearFunction.rcccx(control_qubit1, …)

Apply RC3XGate.

HiddenLinearFunction.rccx(control_qubit1, …)

Apply RCCXGate.

HiddenLinearFunction.remove_final_measurements([…])

Removes final measurement on all qubits if they are present.

HiddenLinearFunction.repeat(reps)

Repeat this circuit reps times.

HiddenLinearFunction.reset(qubit)

Reset q.

HiddenLinearFunction.reverse_bits()

Return a circuit with the opposite order of wires.

HiddenLinearFunction.reverse_ops()

Reverse the circuit by reversing the order of instructions.

HiddenLinearFunction.rx(theta, qubit, *[, …])

Apply RXGate.

HiddenLinearFunction.rxx(theta, qubit1, qubit2)

Apply RXXGate.

HiddenLinearFunction.ry(theta, qubit, *[, …])

Apply RYGate.

HiddenLinearFunction.ryy(theta, qubit1, qubit2)

Apply RYYGate.

HiddenLinearFunction.rz(phi, qubit, *[, q])

Apply RZGate.

HiddenLinearFunction.rzx(theta, qubit1, qubit2)

Apply RZXGate.

HiddenLinearFunction.rzz(theta, qubit1, qubit2)

Apply RZZGate.

HiddenLinearFunction.s(qubit, *[, q])

Apply SGate.

HiddenLinearFunction.sdg(qubit, *[, q])

Apply SdgGate.

HiddenLinearFunction.size()

Returns total number of gate operations in circuit.

HiddenLinearFunction.snapshot(label[, …])

Take a statevector snapshot of the internal simulator representation.

HiddenLinearFunction.snapshot_density_matrix(label)

Take a density matrix snapshot of simulator state.

HiddenLinearFunction.snapshot_expectation_value(…)

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

HiddenLinearFunction.snapshot_probabilities(…)

Take a probability snapshot of the simulator state.

HiddenLinearFunction.snapshot_stabilizer(label)

Take a stabilizer snapshot of the simulator state.

HiddenLinearFunction.snapshot_statevector(label)

Take a statevector snapshot of the simulator state.

HiddenLinearFunction.squ(unitary_matrix, qubit)

Decompose an arbitrary 2*2 unitary into three rotation gates.

HiddenLinearFunction.swap(qubit1, qubit2)

Apply SwapGate.

HiddenLinearFunction.sx(qubit)

Apply SXGate.

HiddenLinearFunction.sxdg(qubit)

Apply SXdgGate.

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

Apply TGate.

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

Apply TdgGate.

HiddenLinearFunction.to_gate([…])

Create a Gate out of this circuit.

HiddenLinearFunction.to_instruction([…])

Create an Instruction out of this circuit.

HiddenLinearFunction.toffoli(control_qubit1, …)

Apply CCXGate.

HiddenLinearFunction.u(theta, phi, lam, qubit)

Apply UGate.

HiddenLinearFunction.u1(theta, qubit, *[, q])

Apply U1Gate.

HiddenLinearFunction.u2(phi, lam, qubit, *)

Apply U2Gate.

HiddenLinearFunction.u3(theta, phi, lam, …)

Apply U3Gate.

HiddenLinearFunction.uc(gate_list, …[, …])

Attach a uniformly controlled gates (also called multiplexed gates) to a circuit.

HiddenLinearFunction.ucg(angle_list, …[, …])

Deprecated version of uc.

HiddenLinearFunction.ucrx(angle_list, …)

Attach a uniformly controlled (also called multiplexed) Rx rotation gate to a circuit.

HiddenLinearFunction.ucry(angle_list, …)

Attach a uniformly controlled (also called multiplexed) Ry rotation gate to a circuit.

HiddenLinearFunction.ucrz(angle_list, …)

Attach a uniformly controlled (also called multiplexed gates) Rz rotation gate to a circuit.

HiddenLinearFunction.ucx(angle_list, …)

Deprecated version of ucrx.

HiddenLinearFunction.ucy(angle_list, …)

Deprecated version of ucry.

HiddenLinearFunction.ucz(angle_list, …)

Deprecated version of ucrz.

HiddenLinearFunction.unitary(obj, qubits[, …])

Apply unitary gate to q.

HiddenLinearFunction.width()

Return number of qubits plus clbits in circuit.

HiddenLinearFunction.x(qubit, *[, label, …])

Apply XGate.

HiddenLinearFunction.y(qubit, *[, q])

Apply YGate.

HiddenLinearFunction.z(qubit, *[, q])

Apply ZGate.

HiddenLinearFunction.__getitem__(item)

Return indexed operation.

HiddenLinearFunction.__len__()

Return number of operations in circuit.