§
    º³ÙgÊ  ã                   óŠ   — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ dd	lmZ d
Z G d„ de¦  «        ZdS )zHCancel the redundant (self-adjoint) gates through commutation relations.é    )ÚTransformationPass)ÚStandardGateCommutations)ÚU1Gate)Ú	PhaseGate)ÚRZGate)Úcommutation_cancellation)ÚCommutationChecker)Útrivial_recursegñhãˆµøä>c                   ó:   ‡ — e Zd ZdZdˆ fd„	Zed„ ¦   «         Zˆ xZS )ÚCommutativeCancellationa  Cancel the redundant (self-adjoint) gates through commutation relations.

    Pass for cancelling self-inverse gates/rotations. The cancellation utilizes
    the commutation relations in the circuit. Gates considered include::

        H, X, Y, Z, CX, CY, CZ
    Nc                 óª  •— t          ¦   «                              ¦   «          |rt          |¦  «        | _        nt          ¦   «         | _        || _        |�t          |j        ¦  «        | _        t          t          t          dœ| _	        h d£| _
        ddh| _        h d£| _        t          t          | j        | j
        z  | j        z  ¬¦  «        | _        dS )a@  
        CommutativeCancellation initializer.

        Args:
            basis_gates (list[str]): Basis gates to consider, e.g.
                ``['u3', 'cx']``. For the effects of this pass, the basis is
                the set intersection between the ``basis_gates`` parameter
                and the gates in the dag.
            target (Target): The :class:`~.Target` representing the target backend, if both
                ``basis_gates`` and ``target`` are specified then this argument will take
                precedence and ``basis_gates`` will be ignored.
        N)ÚrzÚpÚu1>   r   ÚsÚtÚzr   r   ÚxÚrx>   ÚhÚyÚcxÚcyÚcz)Úgates)ÚsuperÚ__init__ÚsetÚbasisÚtargetÚoperation_namesr   r   r   Ú
_var_z_mapÚ_z_rotationsÚ_x_rotationsÚ_gatesr	   r   Ú_commutation_checker)ÚselfÚbasis_gatesr    Ú	__class__s      €út/granary/edev/quantum/lib/python3.11/site-packages/qiskit/transpiler/passes/optimization/commutative_cancellation.pyr   z CommutativeCancellation.__init__%   sÌ   ø€ õ 	‰Œ×ÒÑÔÐØð 	Ý˜[Ñ)Ô)ˆDŒJˆJå™œˆDŒJØˆŒØÐÝ˜VÔ3Ñ4Ô4ˆDŒJå!'­i½vÐFÐFˆŒà<Ð<Ð<ˆÔØ  $˜KˆÔØ2Ð2Ð2ˆŒõ %7Ý$¨D¬K¸$Ô:KÑ,KÈdÔN_Ñ,_ð%
ñ %
ô %
ˆÔ!Ð!Ð!ó    c                 óF   — t          j        || j        | j        ¦  «         |S )zºRun the CommutativeCancellation pass on `dag`.

        Args:
            dag (DAGCircuit): the DAG to be optimized.

        Returns:
            DAGCircuit: the optimized DAG.
        )r   Úcancel_commutationsr&   r   )r'   Údags     r*   ÚrunzCommutativeCancellation.runG   s%   € õ 	!Ô4°S¸$Ô:SÐUYÔU_Ñ`Ô`Ð`Øˆ
r+   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r
   r/   Ú__classcell__)r)   s   @r*   r   r      sc   ø€ € € € € ðð ð 
ð  
ð  
ð  
ð  
ð  
ðD ð
ð 
ñ „_ð
ð 
ð 
ð 
ð 
r+   r   N)r3   Úqiskit.transpiler.basepassesr   Ú"qiskit.circuit.commutation_libraryr   Ú(qiskit.circuit.library.standard_gates.u1r   Ú'qiskit.circuit.library.standard_gates.pr   Ú(qiskit.circuit.library.standard_gates.rzr   Úqiskit._accelerater   Ú&qiskit._accelerate.commutation_checkerr	   Ú+qiskit.transpiler.passes.utils.control_flowr
   Ú_CUTOFF_PRECISIONr   © r+   r*   ú<module>r?      sÙ   ðð OÐ NØ ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø GÐ GÐ GÐ GÐ GÐ Gà ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø =Ð =Ð =Ð =Ð =Ð =Ø ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø EÐ EÐ EÐ EÐ EÐ Eà GÐ GÐ GÐ GÐ GÐ GàÐ ð6ð 6ð 6ð 6ð 6Ð0ñ 6ô 6ð 6ð 6ð 6r+   