guppyalgos.primitives.gate_decompositions.and_op

Quantum AND gate implementations.

Functions

index_and(target_q, control_q0, ...)

Perform an AND operation on indexed control qubits and store the result.

temp_and_comp_index(control_q0, ...)

Compute a temporary AND operation and return the target qubit.

temp_and_compute(q0, q1, t_qubit)

Temporary AND computation acting on 0 state target.

temp_and_t_state_compute(q0, q1, t_qubit)

Temporary AND computation acting on T state target.

temp_and_uncomp_index(target_q, control_q0, ...)

Uncompute a temporary AND operation and discard the target qubit.

temp_and_uncompute(q_0, q_1, target_q)

Uncompute the logical AND operation.

guppyalgos.primitives.gate_decompositions.and_op.index_and(target_q, control_q0, control_0_ind, control_q1, control_1_ind, and_operation)

Perform an AND operation on indexed control qubits and store the result.

Parameters:
  • target_q (qubit) – The target qubit to store the result.

  • control_q0 (qubit) – The first control qubit.

  • control_0_ind (bool) – Indicator for the first control qubit.

  • control_q1 (qubit) – The second control qubit.

  • control_1_ind (bool) – Indicator for the second control qubit.

  • and_operation (Callable[[qubit, qubit, qubit], None]) – The AND operation to apply.

guppyalgos.primitives.gate_decompositions.and_op.temp_and_comp_index(control_q0, control_0_ind, control_q1, control_1_ind, and_operation)

Compute a temporary AND operation and return the target qubit.

This function allocates a new qubit to store the result of the AND operation. The allocated qubit is in the \(\ket{0}\) state. The returned qubit can be later uncomputed using the index_uncomp_temp_and function and discarded as a work qubit.

It is compatible with any AND operation that matches the signature of the compute_temp_and function in this module.

Parameters:
  • control_q0 (qubit) – The first control qubit.

  • control_0_ind (bool) – Indicator for the first control qubit.

  • control_q1 (qubit) – The second control qubit.

  • control_1_ind (bool) – Indicator for the second control qubit.

  • and_operation (Callable[[qubit, qubit, qubit], None]) – The AND operation to apply.

Returns:

The target qubit storing the result.

Return type:

qubit

guppyalgos.primitives.gate_decompositions.and_op.temp_and_compute(q0, q1, t_qubit)

Temporary AND computation acting on 0 state target.

Following the construction in https://arxiv.org/abs/1805.03662 which uses 4 T-gates.

Parameters:
  • q0 (qubit) – The first input qubit.

  • q1 (qubit) – The second input qubit.

  • t_qubit (qubit) – The target qubit to store the result. Begins in \(\ket{0}\)

guppyalgos.primitives.gate_decompositions.and_op.temp_and_t_state_compute(q0, q1, t_qubit)

Temporary AND computation acting on T state target.

Following the construction in https://arxiv.org/abs/1805.03662 which uses 3 T-gates and 1 incoming \(|T>\) state.

Parameters:
  • q0 (qubit) – The first input qubit.

  • q1 (qubit) – The second input qubit.

  • t_qubit (qubit) – The target qubit to store the result. Must be in the \(|T>\) state.

guppyalgos.primitives.gate_decompositions.and_op.temp_and_uncomp_index(target_q, control_q0, control_0_ind, control_q1, control_1_ind, and_operation)

Uncompute a temporary AND operation and discard the target qubit.

The target qubit must be the one returned by the index_comp_temp_and function. This function uncomputes the AND operation and then discards the target qubit as a work qubit.

It is compatible with any AND operation that matches the signature of the

compute_temp_and function in this module.

Parameters:
  • target_q (qubit @ owned) – The target qubit storing the result.

  • control_q0 (qubit) – The first control qubit.

  • control_0_ind (bool) – Indicator for the first control qubit.

  • control_q1 (qubit) – The second control qubit.

  • control_1_ind (bool) – Indicator for the second control qubit.

  • and_operation (Callable[[qubit, qubit, qubit], None]) – The AND operation to apply.

guppyalgos.primitives.gate_decompositions.and_op.temp_and_uncompute(q_0, q_1, target_q)

Uncompute the logical AND operation.

This function reverses the effects of the logical AND operation applied to the input qubits and the target qubit. It is equivalent to measurement based uncomputation as described in Fig 4. https://arxiv.org/pdf/1805.03662. The qubit must be discarded after use.

Parameters:
  • q_0 (qubit) – The first input qubit.

  • q_1 (qubit) – The second input qubit.

  • target_q (qubit) – The auxiliary qubit used in computation.