pytket.tableau

Python API module for interfacing with tket c++ implemented functions and modules. Exports classes and tools for binary tableau representations of Clifford unitaries/states.

class pytket.tableau.UnitaryRevTableau

Equivalent to the UnitaryTableau, except that the rows indicate the action at the input corresponding to either an X or a Z on a single output.

__init__(self, nqb: int) None
__init__(self, xx: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], xz: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], xph: numpy.ndarray[dtype=bool, shape=(*), order='C'], zx: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], zz: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], zph: numpy.ndarray[dtype=bool, shape=(*), order='C']) None
__init__(self, arg: pytket.circuit.Circuit, /) None

Overloaded function.

  1. __init__(self, nqb: int) -> None

Constructs a UnitaryRevTableau representing the identity operation over some number of qubits. Qubits will be indexed sequentially in the default register.

Parameters:

nqb – The number of qubits in the unitary.

  1. __init__(self, xx: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], xz: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], xph: numpy.ndarray[dtype=bool, shape=(*), order='C'], zx: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], zz: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], zph: numpy.ndarray[dtype=bool, shape=(*), order='C']) -> None

Constructs a UnitaryRevTableau from the binary tables of its components.

Parameters:
  • xx – The X component of the X rows.

  • xz – The Z component of the X rows.

  • xph – The phases of the X rows.

  • zx – The X component of the Z rows.

  • zz – The Z component of the Z rows.

  • zph – The phases of the Z rows.

  1. __init__(self, arg: pytket.circuit.Circuit, /) -> None

Constructs a UnitaryRevTableau from a unitary Circuit. Throws an exception if the input contains non-unitary operations.

Parameters:

circ – The unitary circuit to convert to a tableau.

apply_gate_at_end(self, type: pytket.circuit.OpType, qbs: collections.abc.Sequence[pytket.unit_id.Qubit]) None

Update the tableau according to adding a Clifford gate after the current unitary, i.e. updates \(U\) to \(GU\) for a gate \(G\).

Parameters:
  • type – The OpType of the gate to add. Must be an unparameterised Clifford gate type.

  • qbs – The qubits to apply the gate to. Length must match the arity of the given gate type.

apply_gate_at_front(self, type: pytket.circuit.OpType, qbs: collections.abc.Sequence[pytket.unit_id.Qubit]) None

Update the tableau according to adding a Clifford gate before the current unitary, i.e. updates \(U\) to \(UG\) for a gate \(G\).

Parameters:
  • type – The OpType of the gate to add. Must be an unparameterised Clifford gate type.

  • qbs – The qubits to apply the gate to. Length must match the arity of the given gate type.

get_row_product(self, paulis: pytket.pauli.QubitPauliTensor) pytket.pauli.QubitPauliTensor

Combine rows to yield the effect of a given Pauli string.

Parameters:

paulis – The Pauli string \(P\) to consider at the output.

Returns:

The Pauli string \(Q\) such that \(UQ=PU\).

get_xrow(self, qb: pytket.unit_id.Qubit) pytket.pauli.QubitPauliTensor

Read off an X row as a Pauli string.

Parameters:

qb – The qubits whose X row to read off.

Returns:

The Pauli string \(P\) such that \(UP=X_{qb}U\).

get_zrow(self, qb: pytket.unit_id.Qubit) pytket.pauli.QubitPauliTensor

Read off an Z row as a Pauli string.

Parameters:

qb – The qubits whose Z row to read off.

Returns:

The Pauli string \(P\) such that \(UP=Z_{qb}U\).

to_circuit(self) pytket.circuit.Circuit

Synthesises a unitary Circuit realising the same unitary as the tableau. Uses the method from Aaronson & Gottesman: “Improved Simulation of Stabilizer Circuits”, Theorem 8. This is not optimised for gate count, so is not recommended for performance-sensitive usage.

class pytket.tableau.UnitaryTableau

Stabilizer tableau for a unitary in the style of Aaronson&Gottesman “Improved Simulation of Stabilizer Circuits”: rows indicate the action at the output corresponding to either an X or a Z on a single input.

__init__(self, nqb: int) None
__init__(self, xx: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], xz: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], xph: numpy.ndarray[dtype=bool, shape=(*), order='C'], zx: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], zz: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], zph: numpy.ndarray[dtype=bool, shape=(*), order='C']) None
__init__(self, arg: pytket.circuit.Circuit, /) None

Overloaded function.

  1. __init__(self, nqb: int) -> None

Constructs a UnitaryTableau representing the identity operation over some number of qubits. Qubits will be indexed sequentially in the default register.

Parameters:

nqb – The number of qubits in the unitary.

  1. __init__(self, xx: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], xz: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], xph: numpy.ndarray[dtype=bool, shape=(*), order='C'], zx: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], zz: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], zph: numpy.ndarray[dtype=bool, shape=(*), order='C']) -> None

Constructs a UnitaryTableau from the binary tables of its components.

Parameters:
  • xx – The X component of the X rows.

  • xz – The Z component of the X rows.

  • xph – The phases of the X rows.

  • zx – The X component of the Z rows.

  • zz – The Z component of the Z rows.

  • zph – The phases of the Z rows.

  1. __init__(self, arg: pytket.circuit.Circuit, /) -> None

Constructs a UnitaryTableau from a unitary Circuit. Throws an exception if the input contains non-unitary operations.

Parameters:

circ – The unitary circuit to convert to a tableau.

apply_gate_at_end(self, type: pytket.circuit.OpType, qbs: collections.abc.Sequence[pytket.unit_id.Qubit]) None

Update the tableau according to adding a Clifford gate after the current unitary, i.e. updates \(U\) to \(GU\) for a gate \(G\).

Parameters:
  • type – The OpType of the gate to add. Must be an unparameterised Clifford gate type.

  • qbs – The qubits to apply the gate to. Length must match the arity of the given gate type.

apply_gate_at_front(self, type: pytket.circuit.OpType, qbs: collections.abc.Sequence[pytket.unit_id.Qubit]) None

Update the tableau according to adding a Clifford gate before the current unitary, i.e. updates \(U\) to \(UG\) for a gate \(G\).

Parameters:
  • type – The OpType of the gate to add. Must be an unparameterised Clifford gate type.

  • qbs – The qubits to apply the gate to. Length must match the arity of the given gate type.

get_row_product(self, paulis: pytket.pauli.QubitPauliTensor) pytket.pauli.QubitPauliTensor

Combine rows to yield the effect of a given Pauli string.

Parameters:

paulis – The Pauli string \(P\) to consider at the input.

Returns:

The Pauli string \(Q\) such that \(QU=UP\).

get_xrow(self, qb: pytket.unit_id.Qubit) pytket.pauli.QubitPauliTensor

Read off an X row as a Pauli string.

Parameters:

qb – The qubits whose X row to read off.

Returns:

The Pauli string \(P\) such that \(PU=UX_{qb}\).

get_zrow(self, qb: pytket.unit_id.Qubit) pytket.pauli.QubitPauliTensor

Read off an Z row as a Pauli string.

Parameters:

qb – The qubits whose Z row to read off.

Returns:

The Pauli string \(P\) such that \(PU=UZ_{qb}\).

to_circuit(self) pytket.circuit.Circuit

Synthesises a unitary Circuit realising the same unitary as the tableau. Uses the method from Aaronson & Gottesman: “Improved Simulation of Stabilizer Circuits”, Theorem 8. This is not optimised for gate count, so is not recommended for performance-sensitive usage.

class pytket.tableau.UnitaryTableauBox

A Clifford unitary specified by its actions on Paulis.

__init__(self, tab: pytket.tableau.UnitaryTableau) None
__init__(self, xx: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], xz: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], xph: numpy.ndarray[dtype=bool, shape=(*), order='C'], zx: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], zz: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], zph: numpy.ndarray[dtype=bool, shape=(*), order='C']) None

Overloaded function.

  1. __init__(self, tab: pytket.tableau.UnitaryTableau) -> None

Construct from a given tableau.

Parameters:

tab – The UnitaryTableau representing the desired unitary.

  1. __init__(self, xx: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], xz: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], xph: numpy.ndarray[dtype=bool, shape=(*), order='C'], zx: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], zz: numpy.ndarray[dtype=bool, shape=(*, *), order='F'], zph: numpy.ndarray[dtype=bool, shape=(*), order='C']) -> None

Construct the tableau from the binary tables of its components.

Parameters:
  • xx – The X component of the X rows.

  • xz – The Z component of the X rows.

  • xph – The phases of the X rows.

  • zx – The X component of the Z rows.

  • zz – The Z component of the Z rows.

  • zph – The phases of the Z rows.

get_circuit(self) pytket.circuit.Circuit
Returns:

The Circuit described by the box.

get_tableau(self) pytket.tableau.UnitaryTableau
Returns:

The tableau representing the unitary operation.