mqt.qecc.circuit_synthesis.operations

Tableau operations used during elimination.

Classes

TableauOperation

Represents an operation performed during tableau elimination.

Transvection

Class representing a transvection operation on a stabilizer tableau.

SingleQubitClifford

Class representing a single-qubit Clifford operation on a stabilizer tableau.

PauliOperation

Class representing a Pauli operation on a stabilizer tableau.

CNOT

Class representing a CNOT operation on a stabilizer tableau.

Swap

Class representing a SWAP operation on a stabilizer tableau.

Module Contents

class TableauOperation[source]

Bases: abc.ABC

Represents an operation performed during tableau elimination.

apply(tableau: mqt.qecc.circuit_synthesis.types.BinaryMatrix, inplace: bool = False) → mqt.qecc.circuit_synthesis.types.BinaryMatrix[source]

Apply the operation to the given stabilizer tableau.

Parameters:
  • tableau – The stabilizer tableau to apply the operation to.

  • inplace – If True, modifies the tableau in place. If False, returns a new tableau.

abstractmethod append_to_circuit(circuit: stim.Circuit) → None[source]

Append the operation to a Stim circuit.

Parameters:

circuit – The Stim circuit to append the operation to.

to_stim_circuit() → stim.Circuit[source]

Convert the operation to a Stim circuit representation.

Returns:

The Stim circuit representing the operation.

Return type:

stim.Circuit

abstractmethod qubits() → set[int][source]

Get the set of qubits involved in the operation.

Returns:

The set of qubit indices involved in the operation.

Return type:

set[int]

abstractmethod apply_stabilizer_tableau(tableau: PauliTableau, inplace: bool = False) → PauliTableau[source]

Apply the operation to a stabilizer tableau.

Parameters:
  • tableau – The stabilizer tableau to apply the operation to.

  • inplace – If True, modifies the tableau in place. If False, returns a new tableau.

Returns:

The resulting stabilizer tableau after applying the operation.

Return type:

PauliTableau

abstractmethod apply_check_matrix(check_matrix: CheckMatrix, inplace: bool = False) → CheckMatrix[source]

Apply the operation to a CSS check matrix.

Parameters:
  • check_matrix – The CSS check matrix to apply the operation to.

  • inplace – If True, modifies the check matrix in place. If False, returns a new check matrix.

Returns:

The resulting CSS check matrix after applying the operation.

Return type:

CheckMatrix

class Transvection(v: TV2, i: int, j: int)[source]

Bases: TableauOperation

Class representing a transvection operation on a stabilizer tableau.

apply_stabilizer_tableau_inplace(tableau: PauliTableau) → None[source]

Apply the transvection operation to a stabilizer tableau.

apply_stabilizer_tableau(tableau: PauliTableau, inplace: bool = False) → PauliTableau[source]

Apply the transvection operation to a stabilizer tableau.

apply_check_matrix(check_matrix: CheckMatrix, inplace: bool = False) → CheckMatrix[source]

Apply the transvection operation to a CSS check matrix.

Parameters:
  • check_matrix – The CSS check matrix to apply the operation to.

  • inplace – If True, modifies the check matrix in place. If False, returns a new check matrix.

Returns:

The resulting CSS check matrix after applying the operation.

Return type:

CheckMatrix

static all_two_qubit_transvections() → list[TV2][source]

Get all 9 possible two-qubit transvections.

The 9 distinct 2-qubit transvections √(P_i P_j) (P∈{X,Y,Z} non-trivial) correspond to choosing (x,z) in {(1,0),(0,1),(1,1)} for each of the two qubits.

Returns:

List of all 9 transvection vectors as tuples (xi, xj, zi, zj).

append_to_circuit(circuit: stim.Circuit) → None[source]

Append the operation to a Stim circuit.

Parameters:

circuit – The Stim circuit to append the operation to.

qubits() → set[int][source]

Get the set of qubits involved in the operation.

Returns:

The set of qubit indices involved in the operation.

Return type:

set[int]

class SingleQubitClifford(qubit: int, clifford: str)[source]

Bases: TableauOperation

Class representing a single-qubit Clifford operation on a stabilizer tableau.

apply_stabilizer_tableau(tableau: PauliTableau, inplace: bool = False) → PauliTableau[source]

Apply the single-qubit Clifford operation to a stabilizer tableau.

Parameters:
  • tableau – The stabilizer tableau to apply the operation to.

  • inplace – If True, modifies the tableau in place. If False, returns a new tableau.

Returns:

The resulting stabilizer tableau after applying the operation.

Return type:

PauliTableau

apply_check_matrix(check_matrix: CheckMatrix, inplace: bool = False) → CheckMatrix[source]

Apply the single-qubit Clifford operation to a CSS check matrix.

Parameters:
  • check_matrix – The CSS check matrix to apply the operation to.

  • inplace – If True, modifies the check matrix in place. If False, returns a new check matrix.

Returns:

The resulting CSS check matrix after applying the operation.

Return type:

CheckMatrix

apply_inverse(tableau: mqt.qecc.circuit_synthesis.types.BinaryMatrix, inplace: bool = False) → mqt.qecc.circuit_synthesis.types.BinaryMatrix[source]

Apply the inverse of the single-qubit Clifford operation to the given stabilizer tableau.

Parameters:
  • tableau – The stabilizer tableau to apply the operation to.

  • inplace – Whether to modify the tableau in place.

Returns:

The resulting stabilizer tableau after applying the inverse operation.

Return type:

BinaryMatrix

inverse() → SingleQubitClifford[source]

Get the inverse of the single-qubit Clifford operation.

Returns:

The inverse single-qubit Clifford operation.

Return type:

SingleQubitClifford

static available_cliffords() → list[str][source]

Get the list of available single-qubit Clifford operations.

Returns:

H, S, SDAG, HS, SH, HSH, SDAGH, HSDAG, HSDAGH, I.

Return type:

List of Clifford operation names

append_to_circuit(circuit: stim.Circuit) → None[source]

Append the operation to a Stim circuit.

Parameters:

circuit – The Stim circuit to append the operation to.

qubits() → set[int][source]

Get the set of qubits involved in the operation.

Returns:

The set of qubit indices involved in the operation.

Return type:

set[int]

static from_symplectic_block(block: numpy.typing.NDArray[numpy.int8], qubit: int) → SingleQubitClifford[source]

Create a SingleQubitClifford from a symplectic block.

Parameters:
  • block – A 2x2 symplectic block representing the single-qubit Clifford operation.

  • qubit – The index of the qubit.

Returns:

A single-qubit Clifford operation.

class PauliOperation(qubit: int, pauli: str)[source]

Bases: TableauOperation

Class representing a Pauli operation on a stabilizer tableau.

apply_check_matrix(check_matrix: CheckMatrix, inplace: bool = False) → CheckMatrix[source]

Apply the Pauli operation to a CSS check matrix.

Parameters:
  • check_matrix – The CSS check matrix to apply the operation to.

  • inplace – If True, modifies the check matrix in place. If False, returns a new check matrix.

Returns:

The resulting CSS check matrix after applying the operation.

Return type:

CheckMatrix

apply_stabilizer_tableau(tableau: PauliTableau, inplace: bool = False) → PauliTableau[source]

Apply the Pauli operation to a stabilizer tableau.

Parameters:
  • tableau – The stabilizer tableau to apply the operation to.

  • inplace – If True, modifies the tableau in place. If False, returns a new tableau.

Returns:

The resulting stabilizer tableau after applying the operation.

Return type:

PauliTableau

append_to_circuit(circuit: stim.Circuit) → None[source]

Append the operation to a Stim circuit.

Parameters:

circuit – The Stim circuit to append the operation to.

qubits() → set[int][source]

Get the set of qubits involved in the operation.

Returns:

The set of qubit indices involved in the operation.

Return type:

set[int]

class CNOT(control: int, target: int)[source]

Bases: TableauOperation

Class representing a CNOT operation on a stabilizer tableau.

apply(tableau: mqt.qecc.circuit_synthesis.types.BinaryMatrix, inplace: bool = False) → mqt.qecc.circuit_synthesis.types.BinaryMatrix[source]

Apply the CNOT operation to the given stabilizer tableau.

Parameters:
  • tableau – The stabilizer tableau to apply the operation to.

  • inplace – If True, modifies the tablau in place. If False, returns a new tableau.

apply_stabilizer_tableau(tableau: PauliTableau, inplace: bool = False) → PauliTableau[source]

Apply the CNOT operation to a stabilizer tableau.

Parameters:
  • tableau – The stabilizer tableau to apply the operation to.

  • inplace – If True, modifies the tableau in place. If False, returns a new tableau.

Returns:

The resulting stabilizer tableau after applying the operation.

Return type:

PauliTableau

apply_check_matrix(check_matrix: CheckMatrix, inplace: bool = False) → CheckMatrix[source]

Apply the operation to a CSS check matrix.

Parameters:
  • check_matrix – The CSS check matrix to apply the operation to.

  • inplace – If True, modifies the check matrix in place. If False, returns a new check matrix.

Returns:

The resulting CSS check matrix after applying the operation.

append_to_circuit(circuit: stim.Circuit) → None[source]

Append the operation to a Stim circuit.

Parameters:

circuit – The Stim circuit to append the operation to.

qubits() → set[int][source]

Get the set of qubits involved in the operation.

Returns:

The set of qubit indices involved in the operation.

Return type:

set[int]

class Swap(qubit_a: int, qubit_b: int)[source]

Bases: TableauOperation

Class representing a SWAP operation on a stabilizer tableau.

apply(tableau: mqt.qecc.circuit_synthesis.types.BinaryMatrix, inplace: bool = False) → mqt.qecc.circuit_synthesis.types.BinaryMatrix[source]

Apply the SWAP operation to the given stabilizer tableau.

Parameters:
  • tableau – The stabilizer tableau to apply the operation to.

  • inplace – If True, modifies the tableau in place. If False, returns a new tableau.

apply_stabilizer_tableau(tableau: PauliTableau, inplace: bool = False) → PauliTableau[source]

Apply the SWAP operation to a stabilizer tableau.

Parameters:
  • tableau – The stabilizer tableau to apply the operation to.

  • inplace – If True, modifies the tableau in place. If False, returns a new tableau.

Returns:

The resulting stabilizer tableau after applying the operation.

Return type:

PauliTableau

apply_check_matrix(check_matrix: CheckMatrix, inplace: bool = False) → CheckMatrix[source]

Apply the operation to a CSS check matrix.

Parameters:
  • check_matrix – The CSS check matrix to apply the operation to.

  • inplace – If True, modifies the check matrix in place. If False, returns a new check matrix.

append_to_circuit(circuit: stim.Circuit) → None[source]

Append the operation to a Stim circuit.

Parameters:

circuit – The Stim circuit to append the operation to.

qubits() → set[int][source]

Get the set of qubits involved in the operation.

Returns:

The set of qubit indices involved in the operation.