mimiqcircuits.decomposition.rules.to_z_rotation

Rewrite rule for converting X and Y rotations to Z rotations.

Classes

ToZRotationRewrite()

Rewrite rule that turns GateRX and GateRY into GateRZ and Cliffords.

class ToZRotationRewrite[source]

Bases: RewriteRule

Rewrite rule that turns GateRX and GateRY into GateRZ and Cliffords.

Use it for gate sets whose only parametric rotation is GateRZ. The rewrite is exact, keeps the angle as it is (symbolic angles included), and listed in circuit order is:

  • GateRX(theta) to H, RZ(theta), H;

  • GateRY(theta) to S†, H, RZ(theta), H, S.

Examples

>>> from mimiqcircuits import *
>>> from symengine import pi
>>> rule = ToZRotationRewrite()
>>> # an X rotation is a Z rotation conjugated by Hadamard gates
>>> rule.decompose_step(GateRX(pi/3), [0], [], [])
1-qubit circuit with 3 instructions:
├── H @ q[0]
├── RZ((1/3)*pi) @ q[0]
└── H @ q[0]
matches(op)[source]

Check whether an operation is an X or Y rotation.

Parameters:

op (Operation) – The operation to check.

Returns:

True for GateRX and GateRY.

Return type:

bool

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

Rewrite an X or Y rotation as a Z rotation between Cliffords.

Parameters:
  • op (Operation) – The GateRX or GateRY to rewrite.

  • qubits (Sequence[int]) – Qubit index the rotation acts on.

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

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

Returns:

A new Circuit with the rewrite.

Raises:

DecompositionError – If op is not a GateRX or GateRY.

Return type:

Circuit