mimiqcircuits.decomposition.rules.special_angle

Special angle rewrite rule for Clifford+T decomposition.

Classes

SpecialAngleRewrite([only_cliffords])

Rewrite rule for decomposing rotations with special angles to Clifford+T.

class mimiqcircuits.decomposition.rules.special_angle.SpecialAngleRewrite(only_cliffords=False)[source]

Bases: RewriteRule

Rewrite rule for decomposing rotations with special angles to Clifford+T.

Decomposes single-qubit rotations whose angle is a multiple of pi/4 into explicit Clifford or Clifford+T gates.

This rule only matches rotations with angles k*pi/4 (or k*pi/2 in Clifford-only mode). Generic rotations with arbitrary angles are not matched.

Parameters:

only_cliffords (bool) – If True, only match angles k*pi/2 (Clifford gates only). If False (default), match angles k*pi/4 (Clifford+T).

Supported operations:
  • GateRX(theta) where theta = k*pi/4

  • GateRY(theta) where theta = k*pi/4

  • GateRZ(lambda) where lambda = k*pi/4

Example

>>> from mimiqcircuits import GateRZ
>>> from mimiqcircuits.decomposition import SpecialAngleRewrite
>>> from symengine import pi
>>> rule = SpecialAngleRewrite()
>>> rule.matches(GateRZ(pi/4))  # True, decomposes to T
True
>>> rule.matches(GateRZ(0.123))  # False, not a special angle
False
only_cliffords: bool
matches(op)[source]

Check if this rule can decompose the operation.

Parameters:

op (Operation) – The operation to check.

Returns:

True if the operation is a rotation with a special angle.

Return type:

bool

decompose_step(op, qubits, bits, zvars)[source]

Decompose the rotation to Clifford+T gates.

Parameters:
  • op (Operation) – The rotation operation to decompose.

  • qubits (Sequence[int]) – Qubit indices for the operation.

  • bits (Sequence[int]) – Classical bit indices (unused).

  • zvars (Sequence[int]) – Z-variable indices (unused).

Returns:

A Circuit containing the decomposed instructions.

Raises:

DecompositionError – If the operation cannot be decomposed.

Return type:

Circuit

__init__(only_cliffords=False)