mqt.qecc.circuit_synthesis.exact.gate_operations¶
Gate operation abstractions for exact synthesis encoding.
Classes¶
Abstract base class for gate operations in symbolic encoding. |
|
Hadamard gate operation. |
|
S (phase) gate operation. |
|
√X gate (SX = HSH) operation. |
|
CNOT gate operation. |
|
CZ gate operation. |
|
Identity (no-op) gate operation. |
|
Registry of available gate operations for synthesis. |
Functions¶
|
Get the standard Clifford gate set {H, S, CX, ID}. |
|
Get the Clifford gate set {H, SX, CX, ID}. |
|
Get the extended Clifford gate set {H, S, CX, CZ, ID}. |
|
Get the full extended Clifford gate set {H, S, SX, CX, CZ, ID}. |
|
Get the standard CSS gate set {CX, ID}. |
Module Contents¶
- class SymbolicGateOperation[source]¶
Bases:
abc.ABCAbstract base class for gate operations in symbolic encoding.
- Class attributes (must be set on every concrete subclass):
IS_TWO_QUBIT: True for two-qubit gates (CX, CZ, …). IS_SYMMETRIC: True when the gate treats both qubits symmetrically so
that only unordered pairs need to be enumerated (e.g. CZ). Ignored for single-qubit gates.
- IS_SELF_INVERSE: True when applying the gate twice yields the identity
in the binary stabilizer tableau (ignoring global phases). This holds for H, CX, CZ, and also for S and SX: although S and SX have order 4 as unitaries, their binary tableau actions square to the identity (S: z↦x⊕z twice gives z; SX: x↦x⊕z twice gives x). Used by symmetry-breaking to prune adjacent identical gates.
- classmethod from_qubits(q1: int, q2: int, /) SymbolicGateOperation[source]¶
- Abstractmethod:
Instantiate the gate from up to two qubit indices.
Single-qubit gates use q1 and ignore q2. Two-qubit gates use both. This uniform interface allows extraction code to create gate instances without knowing the concrete arity.
- Parameters:
q1 – First (or only) qubit index.
q2 – Second qubit index (ignored for single-qubit gates).
- Returns:
A concrete gate instance.
- abstractmethod clifford_tableau_effect(tableau_x_curr: numpy.typing.NDArray[object_], tableau_z_curr: numpy.typing.NDArray[object_], tableau_x_next: numpy.typing.NDArray[object_], tableau_z_next: numpy.typing.NDArray[object_]) z3.BoolRef[source]¶
Return the constraint relating the next Clifford tableau to the current one.
The returned expression fixes only the columns this gate acts on; the caller guards it with the gate-selection condition, e.g.
solver.add(Implies(selected, effect)). This is the single place a gate’s tableau action is defined — encoders and tests both consume it, so adding a new gate means implementing only this class.- Parameters:
tableau_x_curr – Current X part of tableau.
tableau_z_curr – Current Z part of tableau.
tableau_x_next – Next X part of tableau.
tableau_z_next – Next Z part of tableau.
- Returns:
A Boolean expression constraining
tableau_*_nextgiventableau_*_curr.
- abstractmethod css_matrix_effect(matrix_curr: numpy.typing.NDArray[object_], matrix_next: numpy.typing.NDArray[object_]) z3.BoolRef[source]¶
Return the constraint relating the next CSS check matrix to the current one.
- Parameters:
matrix_curr – Current CSS matrix.
matrix_next – Next CSS matrix.
- Returns:
A Boolean expression constraining
matrix_nextgivenmatrix_curr.
- abstractmethod to_stim_gate() tuple[str, list[int]][source]¶
Convert to Stim gate representation.
- Returns:
Tuple of (gate_name, qubit_targets).
- class HGate(qubit: int)[source]¶
Bases:
SymbolicGateOperationHadamard gate operation.
- classmethod from_qubits(q1: int, _q2: int) HGate[source]¶
Instantiate H gate from qubit indices (_q2 ignored).
- clifford_tableau_effect(tableau_x_curr: numpy.typing.NDArray[object_], tableau_z_curr: numpy.typing.NDArray[object_], tableau_x_next: numpy.typing.NDArray[object_], tableau_z_next: numpy.typing.NDArray[object_]) z3.BoolRef[source]¶
H gate: swap X and Z columns of the target qubit.
- class SGate(qubit: int)[source]¶
Bases:
SymbolicGateOperationS (phase) gate operation.
- classmethod from_qubits(q1: int, _q2: int) SGate[source]¶
Instantiate S gate from qubit indices (_q2 ignored).
- clifford_tableau_effect(tableau_x_curr: numpy.typing.NDArray[object_], tableau_z_curr: numpy.typing.NDArray[object_], tableau_x_next: numpy.typing.NDArray[object_], tableau_z_next: numpy.typing.NDArray[object_]) z3.BoolRef[source]¶
S gate: Z <- Z ⊕ X on the target qubit.
- class SqrtXGate(qubit: int)[source]¶
Bases:
SymbolicGateOperation√X gate (SX = HSH) operation.
Binary tableau action: X_out = X ⊕ Z, Z_out = Z. Self-inverse in the binary tableau: (SX)^2 = X as a unitary, but the binary tableau action squares to the identity (x⊕z)⊕z = x.
- classmethod from_qubits(q1: int, _q2: int) SqrtXGate[source]¶
Instantiate SX gate from qubit indices (_q2 ignored).
- clifford_tableau_effect(tableau_x_curr: numpy.typing.NDArray[object_], tableau_z_curr: numpy.typing.NDArray[object_], tableau_x_next: numpy.typing.NDArray[object_], tableau_z_next: numpy.typing.NDArray[object_]) z3.BoolRef[source]¶
SX gate: X_out = X ⊕ Z, Z_out = Z on the target qubit.
- class CNOTGate(control: int, target: int)[source]¶
Bases:
SymbolicGateOperationCNOT gate operation.
- classmethod from_qubits(q1: int, q2: int) CNOTGate[source]¶
Instantiate CNOT gate from qubit indices.
- clifford_tableau_effect(tableau_x_curr: numpy.typing.NDArray[object_], tableau_z_curr: numpy.typing.NDArray[object_], tableau_x_next: numpy.typing.NDArray[object_], tableau_z_next: numpy.typing.NDArray[object_]) z3.BoolRef[source]¶
CNOT gate: X[:,t] <- X[:,t] ⊕ X[:,c], Z[:,c] <- Z[:,c] ⊕ Z[:,t].
- class CZGate(qubit1: int, qubit2: int)[source]¶
Bases:
SymbolicGateOperationCZ gate operation.
- clifford_tableau_effect(tableau_x_curr: numpy.typing.NDArray[object_], tableau_z_curr: numpy.typing.NDArray[object_], tableau_x_next: numpy.typing.NDArray[object_], tableau_z_next: numpy.typing.NDArray[object_]) z3.BoolRef[source]¶
CZ gate: Z[:,i] ^= X[:,j], Z[:,j] ^= X[:,i], X columns unchanged.
- class IdentityGate(qubit: int)[source]¶
Bases:
SymbolicGateOperationIdentity (no-op) gate operation.
- classmethod from_qubits(q1: int, _q2: int) IdentityGate[source]¶
Instantiate identity gate from qubit indices (_q2 ignored).
- clifford_tableau_effect(tableau_x_curr: numpy.typing.NDArray[object_], tableau_z_curr: numpy.typing.NDArray[object_], tableau_x_next: numpy.typing.NDArray[object_], tableau_z_next: numpy.typing.NDArray[object_]) z3.BoolRef[source]¶
Identity: preserve the target qubit’s columns.
- class GateRegistry[source]¶
Registry of available gate operations for synthesis.
- register_clifford_gate(name: str, gate_class: type[SymbolicGateOperation]) None[source]¶
Register a gate for Clifford synthesis.
- Parameters:
name – Gate identifier (e.g., ‘H’, ‘S’, ‘CX’).
gate_class – Gate operation class.
- register_css_gate(name: str, gate_class: type[SymbolicGateOperation]) None[source]¶
Register a gate for CSS synthesis.
- Parameters:
name – Gate identifier (e.g., ‘CX’).
gate_class – Gate operation class.
- get_clifford_gates() dict[str, type[SymbolicGateOperation]][source]¶
Get all registered Clifford gates.
- Returns:
Dictionary mapping gate names to gate classes.
- get_standard_clifford_gate_set() dict[str, type[SymbolicGateOperation]][source]¶
Get the standard Clifford gate set {H, S, CX, ID}.
- Returns:
Dictionary mapping gate names to gate classes.
- get_clifford_sx_gate_set() dict[str, type[SymbolicGateOperation]][source]¶
Get the Clifford gate set {H, SX, CX, ID}.
Replaces S with the √X (SX = HSH) gate.
- Returns:
Dictionary mapping gate names to gate classes.
- get_clifford_cz_gate_set() dict[str, type[SymbolicGateOperation]][source]¶
Get the extended Clifford gate set {H, S, CX, CZ, ID}.
- Returns:
Dictionary mapping gate names to gate classes.