# 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:

$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  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:

 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. Return indexed operation. Return number of operations in circuit. Add registers. HiddenLinearFunction.append(instruction[, …]) Append one or more instructions to the end of the circuit, modifying the circuit in place. Assign parameters to new parameters or values. 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. 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. Return the current number of instances of this class, useful for auto naming. Return the prefix to use for auto naming. HiddenLinearFunction.cnot(control_qubit, …) Apply CXGate. Append rhs to self if self contains compatible registers. HiddenLinearFunction.compose(other[, …]) Compose circuit with other circuit or instruction, optionally permuting wires. Control this circuit on num_ctrl_qubits qubits. Copy the circuit. 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. Call a decomposition pass on this circuit, to decompose one level (shallow decompose). 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. Append QuantumCircuit to the right hand side if it contains compatible registers. HiddenLinearFunction.fredkin(control_qubit, …) Apply CSwapGate. Take in a QASM file and generate a QuantumCircuit object. 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. 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. 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. Apply MCU1Gate. HiddenLinearFunction.mcx(control_qubits, …) Apply MCXGate. HiddenLinearFunction.measure(qubit, cbit) Measure quantum bit into classical bit (tuples). Adds measurement to all non-idle qubits. HiddenLinearFunction.measure_all([inplace]) Adds measurement to all qubits. DEPRECATED: use circuit.reverse_ops(). HiddenLinearFunction.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. 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. 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. Removes final measurement on all qubits if they are present. Repeat this circuit reps times. Reset q. Return a circuit with the opposite order of wires. 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. Returns total number of gate operations in circuit. HiddenLinearFunction.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. HiddenLinearFunction.squ(unitary_matrix, qubit) Decompose an arbitrary 2*2 unitary into three rotation gates. HiddenLinearFunction.swap(qubit1, qubit2) Apply SwapGate. Apply SXGate. Apply SXdgGate. HiddenLinearFunction.t(qubit, *[, q]) Apply TGate. HiddenLinearFunction.tdg(qubit, *[, q]) Apply TdgGate. Create a Gate out of this circuit. 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. 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. Return indexed operation. Return number of operations in circuit.