§
    ¹³Ùg-T  ã                  óR  — d Z ddlmZ g d¢ZddlZddlmZmZmZm	Z	m
Z
mZmZ ddlmZmZ dd	lmZ ej        rddlZd6d„Zd7d„Zd8d9d„Zd:d„Zd;d„Zd;d„Zd<d„Zd=d!„Zd>d"„Zd>d#„Zd>d$„Zd=d%„Zd>d&„Zd>d'„Z d=d(„Z!d>d)„Z"d>d*„Z#d=d+„Z$d>d,„Z%d>d-„Z&d>d.„Z'd>d/„Z(d?d0„Z)d8d@d1„Z*d8d@d2„Z+dAd5„Z,dS )BzvUser-space constructor functions for the expression tree, which do some of the inference and
lifting boilerplate work.é    )Úannotations)ÚliftÚbit_notÚ	logic_notÚbit_andÚbit_orÚbit_xorÚ	logic_andÚlogic_orÚequalÚ	not_equalÚlessÚ
less_equalÚgreaterÚgreater_equalÚlift_legacy_conditionNé   )ÚExprÚVarÚValueÚUnaryÚBinaryÚCastÚIndexé   )ÚCastKindÚ	cast_kind)ÚtypesÚexprr   Útypeú
types.TypeÚreturnc                ó@  — t          | j        |¦  «        }|t          j        u r| S |t          j        u rt          | |d¬¦  «        S |t          j        u rt          | |d¬¦  «        S |t          j        u rt          d| › d|› d�¦  «        ‚t          d| › d|› d�¦  «        ‚)	z‡Coerce ``expr`` to ``type`` by inserting a suitable :class:`Cast` node, if the cast is
    lossless.  Otherwise, raise a ``TypeError``.T©ÚimplicitFúcannot cast 'ú' to 'z' without loss of precisionzno cast is defined to take 'ú')	r   r    r   ÚEQUALÚIMPLICITr   ÚLOSSLESSÚ	DANGEROUSÚ	TypeError)r   r    Úkinds      ú`/granary/edev/quantum/lib/python3.11/site-packages/qiskit/circuit/classical/expr/constructors.pyÚ_coerce_losslessr0   0   s¿   € õ �T”Y Ñ%Ô%€DØ�xŒ~ÐÐØˆØ�xÔ Ð Ð Ý�D˜$¨Ð.Ñ.Ô.Ð.Ø�xÔ Ð Ð Ý�D˜$¨Ð/Ñ/Ô/Ð/Ø�xÔ!Ð!Ð!ÝÐU¨ÐUÐU°DÐUÐUÐUÑVÔVÐVÝ
ÐF°4ÐFÐF¸tÐFÐFÐFÑ
GÔ
GÐGó    Ú	conditionúCtuple[qiskit.circuit.Clbit | qiskit.circuit.ClassicalRegister, int]c               ód  — ddl m} | \  }}t          ||¦  «        rSt          j        ¦   «         }|rt          ||¦  «        n-t          t          j        j        t          ||¦  «        |¦  «        S t          |t          j	        |j
        ¬¦  «        ¦  «        }|                     ¦   «         |j
        k    r7t          |t          j	        |                     ¦   «         ¬¦  «        d¬¦  «        }t          ||j        ¦  «        }t          t          j        j        ||t          j        ¦   «         ¦  «        S )a  Lift a legacy two-tuple equality condition into a new-style :class:`Expr`.

    Examples:
        Taking an old-style conditional instruction and getting an :class:`Expr` from its
        condition::

            from qiskit.circuit import ClassicalRegister
            from qiskit.circuit.library import HGate
            from qiskit.circuit.classical import expr

            cr = ClassicalRegister(2)
            instr = HGate().c_if(cr, 3)

            lifted = expr.lift_legacy_condition(instr.condition)
    r   )ÚClbit©ÚwidthTr$   )Úqiskit.circuitr5   Ú
isinstancer   ÚBoolr   r   ÚOpÚ	LOGIC_NOTÚUintÚsizeÚ
bit_lengthr   r   r    r   r)   )r2   r5   ÚtargetÚvalueÚbool_ÚleftÚrights          r/   r   r   ?   s  € ð$ %Ð$Ð$Ð$Ð$Ð$à�M€FˆEÝ�&˜%Ñ Ô ð eÝ”
‘”ˆØ%*Ðd�s�6˜5Ñ!Ô!Ð!µµe´hÔ6HÍ#ÈfÐV[ÑJ\ÔJ\Ð^cÑ0dÔ0dÐdÝˆv•u”z¨¬Ð4Ñ4Ô4Ñ5Ô5€DØ×ÒÑÔ˜FœKÒ'Ð'Ý�D�%œ*¨5×+;Ò+;Ñ+=Ô+=Ð>Ñ>Ô>ÈÐNÑNÔNˆÝ�%˜œÑ#Ô#€EÝ•&”)”/ 4¨µ´
±´Ñ=Ô=Ð=r1   útypes.Type | NonerA   ú
typing.Anyc          	     ó¢  — t          | t          ¦  «        r|�t          d¦  «        ‚| S ddlm}m} | du s| du st          | |¦  «        r*t          j        ¦   «         }| du s| du rt          nt          }n t          | |¦  «        r"t          j
        | j        ¬¦  «        }t          }nnt          | t          ¦  «        rF| dk     rt          d¦  «        ‚t          j
        |                      ¦   «         pd	¬¦  «        }t          }nt          d
| › d�¦  «        ‚|€|}t          j        ||¦  «        r || |¦  «        S t          d|› d| › d|› d�¦  «        ‚)aV  Lift the given Python ``value`` to a :class:`~.expr.Value` or :class:`~.expr.Var`.

    If an explicit ``type`` is given, the typing in the output will reflect that.

    Examples:
        Lifting simple circuit objects to be :class:`~.expr.Var` instances::

            >>> from qiskit.circuit import Clbit, ClassicalRegister
            >>> from qiskit.circuit.classical import expr
            >>> expr.lift(Clbit())
            Var(<clbit>, Bool())
            >>> expr.lift(ClassicalRegister(3, "c"))
            Var(ClassicalRegister(3, "c"), Uint(3))

        The type of the return value can be influenced, if the given value could be interpreted
        losslessly as the given type (use :func:`cast` to perform a full set of casting
        operations, include lossy ones)::

            >>> from qiskit.circuit import ClassicalRegister
            >>> from qiskit.circuit.classical import expr, types
            >>> expr.lift(ClassicalRegister(3, "c"), types.Uint(5))
            Var(ClassicalRegister(3, "c"), Uint(5))
            >>> expr.lift(5, types.Uint(4))
            Value(5, Uint(4))
    Nz3use 'cast' to cast existing expressions, not 'lift'r   )r5   ÚClassicalRegisterTFr6   z!cannot represent a negative valuer   zfailed to infer a type for 'r(   zthe explicit type 'z$' is not suitable for representing 'z''; it must be non-strict supertype of ')r9   r   Ú
ValueErrorr8   r5   rH   r   r:   r   r   r=   r>   Úintr?   r-   Úis_supertype)rA   r    r5   rH   ÚinferredÚconstructors         r/   r   r   ^   sŸ  € õ4 �%�ÑÔð ØÐÝÐRÑSÔSÐSØˆØ7Ð7Ð7Ð7Ð7Ð7Ð7Ð7ð �€}€}˜ ˜˜­*°U¸EÑ*BÔ*B˜Ý”:‘<”<ˆØ$¨˜}˜}°¸°°•e�eÅCˆˆÝ	�EÐ,Ñ	-Ô	-ð 	AÝ”: E¤JÐ/Ñ/Ô/ˆÝˆˆÝ	�E�3Ñ	Ô	ð AØ�1Š9ˆ9ÝÐ@ÑAÔAÐAÝ”: E×$4Ò$4Ñ$6Ô$6Ð$;¸!Ð<Ñ<Ô<ˆÝˆˆåÐ?°uÐ?Ð?Ð?Ñ@Ô@Ð@Ø€|ØˆÝÔ˜$ Ñ)Ô)ð (Øˆ{˜5 $Ñ'Ô'Ð'Ý
ð	<˜dð 	<ð 	<Èð 	<ð 	<Ø08ð	<ð 	<ð 	<ñô ð r1   Úoperandc               ó®   — t          | ¦  «        } t          | j        |¦  «        t          j        u rt          d| › d|› d�¦  «        ‚t          | |¦  «        S )a¸  Create an explicit cast from the given value to the given type.

    Examples:
        Add an explicit cast node that explicitly casts a higher precision type to a lower precision
        one::

            >>> from qiskit.circuit.classical import expr, types
            >>> value = expr.value(5, types.Uint(32))
            >>> expr.cast(value, types.Uint(8))
            Cast(Value(5, types.Uint(32)), types.Uint(8), implicit=False)
    r&   r'   r(   )r   r   r    r   ÚNONEr-   r   )rN   r    s     r/   ÚcastrQ   –   sZ   € õ �7‰mŒm€GÝ�”˜tÑ$Ô$­¬Ð5Ð5ÝÐ>¨Ð>Ð>°tÐ>Ð>Ð>Ñ?Ô?Ð?Ý�˜ÑÔÐr1   c               ó  — t          | ¦  «        } | j        j        t          j        t          j        fvr*t          dt          j        j	        › d| j        › d�¦  «        ‚t          t          j        j	        | | j        ¦  «        S )añ  Create a bitwise 'not' expression node from the given value, resolving any implicit casts and
    lifting the value into a :class:`Value` node if required.

    Examples:
        Bitwise negation of a :class:`.ClassicalRegister`::

            >>> from qiskit.circuit import ClassicalRegister
            >>> from qiskit.circuit.classical import expr
            >>> expr.bit_not(ClassicalRegister(3, "c"))
            Unary(Unary.Op.BIT_NOT, Var(ClassicalRegister(3, 'c'), Uint(3)), Uint(3))
    zcannot apply 'z' to type 'r(   )
r   r    r.   r   r:   r=   r-   r   r;   ÚBIT_NOT©rN   s    r/   r   r   ¨   sj   € õ �7‰mŒm€GØ„|Ô¥¤­U¬ZÐ 8Ð8Ð8ÝÐU­¬Ô)9ÐUÐUÀgÄlÐUÐUÐUÑVÔVÐVÝ•”Ô! 7¨G¬LÑ9Ô9Ð9r1   c               ó¨   — t          t          | ¦  «        t          j        ¦   «         ¦  «        } t	          t          j        j        | | j        ¦  «        S )a  Create a logical 'not' expression node from the given value, resolving any implicit casts and
    lifting the value into a :class:`Value` node if required.

    Examples:
        Logical negation of a :class:`.ClassicalRegister`::

            >>> from qiskit.circuit import ClassicalRegister
            >>> from qiskit.circuit.classical import expr
            >>> expr.logic_not(ClassicalRegister(3, "c"))
            Unary(Unary.Op.LOGIC_NOT, Cast(Var(ClassicalRegister(3, 'c'), Uint(3)), Bool(), implicit=True), Bool())
    )r0   r   r   r:   r   r;   r<   r    rT   s    r/   r   r   º   s8   € õ �t G™}œ}­e¬j©l¬lÑ;Ô;€GÝ•”Ô# W¨g¬lÑ;Ô;Ð;r1   rC   rD   útuple[Expr, Expr]c                óè  — t          | t          ¦  «        ot          | t          ¦  «         }t          |t          ¦  «        ot          |t          ¦  «         }|s"|s t          | ¦  «        } t          |¦  «        }�nu|s…t          |¦  «        }|j        j        t          j        u rN|                      ¦   «         |j        j	        k    rt          d| › d|› d�¦  «        ‚t          | |j        ¦  «        } nþt          | ¦  «        } nî|s…t          | ¦  «        } | j        j        t          j        u rN|                     ¦   «         | j        j	        k    rt          d|› d| › d�¦  «        ‚t          || j        ¦  «        }nwt          |¦  «        }ngt          j        t          |                      ¦   «         |                     ¦   «         d¦  «        ¦  «        }t          | |¦  «        } t          ||¦  «        }| |fS )z„Lift two binary operands simultaneously, inferring the widths of integer literals in either
    position to match the other operand.zinteger literal 'z#' is wider than the other operand 'r(   r   )r9   rJ   Úboolr   r    r.   r   r=   r?   r7   r-   r   Úmax)rC   rD   Úleft_intÚ	right_intÚuints        r/   Ú_lift_binary_operandsr]   Í   sÛ  € õ ˜$¥Ñ$Ô$ÐC­Z¸½dÑ-CÔ-CÐ)C€HÝ˜5¥#Ñ&Ô&ÐF­z¸%ÅÑ/FÔ/FÐ+F€IØð #˜	ð #Ý�D‰zŒzˆÝ�U‘”ˆ‰Øð #Ý�U‘”ˆØŒ:Œ?�eœjÐ(Ð(Ø�ŠÑ Ô  5¤:Ô#3Ò3Ð3ÝØY¨ÐYÐYÐQVÐYÐYÐYñô ð õ ˜˜uœzÑ*Ô*ˆDˆDå˜‘:”:ˆDˆDØð #Ý�D‰zŒzˆØŒ9Œ>�UœZÐ'Ð'Ø×ÒÑ!Ô! D¤I¤OÒ3Ð3ÝØY¨ÐYÐYÐRVÐYÐYÐYñô ð õ ˜% ¤Ñ+Ô+ˆEˆEå˜‘K”KˆEˆEõ Œz�#˜dŸošoÑ/Ô/°×1AÒ1AÑ1CÔ1CÀQÑGÔGÑHÔHˆÝ�T˜4Ñ Ô ˆÝ�e˜TÑ"Ô"ˆØ�ˆ;Ðr1   Úopú	Binary.Opc           	     óò  — t          ||¦  «        \  }}|j        j        |j        j        cxu rt          j        u rn nt          j        ¦   «         }n•|j        j        t          j        u rZ|j        j        t          j        u rB|j        |j        k    r*t          d|j        j        › d|j        j        › d�¦  «        ‚|j        }n#t          d| › d|j        › d|j        › d�¦  «        ‚t          | |||¦  «        S )Nz[binary bitwise operations are defined between unsigned integers of the same width, but got z and ú.úinvalid types for 'ú': 'ú' and 'r(   )	r]   r    r.   r   r:   r=   r-   r7   r   ©r^   rC   rD   r    s       r/   Ú_binary_bitwiserf   ñ   s  € Ý'¨¨eÑ4Ô4�K€Dˆ%à„y„~˜œœÐ6Ð6Ð6Ð6­E¬JÐ6Ð6Ð6Ð6Ð6ÝŒz‰|Œ|ˆˆØ	ŒŒ�5œ:Ð	%Ð	%¨%¬*¬/½U¼ZÐ*GÐ*GØŒ9˜œ
Ò"Ð"ÝðFØ œIœOðFð FØ27´*Ô2BðFð Fð Fñô ð ð ŒyˆˆåÐU¨bÐUÐU°d´iÐUÐUÈÌ
ÐUÐUÐUÑVÔVÐVÝ�"�d˜E 4Ñ(Ô(Ð(r1   c               óB   — t          t          j        j        | |¦  «        S )a  Create a bitwise 'and' expression node from the given value, resolving any implicit casts and
    lifting the values into :class:`Value` nodes if required.

    Examples:
        Bitwise 'and' of a classical register and an integer literal::

            >>> from qiskit.circuit import ClassicalRegister
            >>> from qiskit.circuit.classical import expr
            >>> expr.bit_and(ClassicalRegister(3, "c"), 0b111)
            Binary(Binary.Op.BIT_AND, Var(ClassicalRegister(3, 'c'), Uint(3)), Value(7, Uint(3)), Uint(3))
        )rf   r   r;   ÚBIT_AND©rC   rD   s     r/   r   r     ó   € õ  �6œ9Ô,¨d°EÑ:Ô:Ð:r1   c               óB   — t          t          j        j        | |¦  «        S )a  Create a bitwise 'or' expression node from the given value, resolving any implicit casts and
    lifting the values into :class:`Value` nodes if required.

    Examples:
        Bitwise 'or' of a classical register and an integer literal::

            >>> from qiskit.circuit import ClassicalRegister
            >>> from qiskit.circuit.classical import expr
            >>> expr.bit_or(ClassicalRegister(3, "c"), 0b101)
            Binary(Binary.Op.BIT_OR, Var(ClassicalRegister(3, 'c'), Uint(3)), Value(5, Uint(3)), Uint(3))
    )rf   r   r;   ÚBIT_ORri   s     r/   r   r     s   € õ  �6œ9Ô+¨T°5Ñ9Ô9Ð9r1   c               óB   — t          t          j        j        | |¦  «        S )a*  Create a bitwise 'exclusive or' expression node from the given value, resolving any implicit
    casts and lifting the values into :class:`Value` nodes if required.

    Examples:
        Bitwise 'exclusive or' of a classical register and an integer literal::

            >>> from qiskit.circuit import ClassicalRegister
            >>> from qiskit.circuit.classical import expr
            >>> expr.bit_xor(ClassicalRegister(3, "c"), 0b101)
            Binary(Binary.Op.BIT_XOR, Var(ClassicalRegister(3, 'c'), Uint(3)), Value(5, Uint(3)), Uint(3))
    )rf   r   r;   ÚBIT_XORri   s     r/   r	   r	   (  rj   r1   c                óÀ   — t          j        ¦   «         }t          t          |¦  «        |¦  «        }t          t          |¦  «        |¦  «        }t	          | |||¦  «        S ©N)r   r:   r0   r   r   )r^   rC   rD   rB   s       r/   Ú_binary_logicalrq   ;  sK   € ÝŒJ‰LŒL€EÝ�D ™JœJ¨Ñ.Ô.€DÝ�T %™[œ[¨%Ñ0Ô0€EÝ�"�d˜E 5Ñ)Ô)Ð)r1   c               óB   — t          t          j        j        | |¦  «        S )aÜ  Create a logical 'and' expression node from the given value, resolving any implicit casts and
    lifting the values into :class:`Value` nodes if required.

    Examples:
        Logical 'and' of two classical bits::

            >>> from qiskit.circuit import Clbit
            >>> from qiskit.circuit.classical import expr
            >>> expr.logical_and(Clbit(), Clbit())
            Binary(Binary.Op.LOGIC_AND, Var(<clbit 0>, Bool()), Var(<clbit 1>, Bool()), Bool())
    )rq   r   r;   Ú	LOGIC_ANDri   s     r/   r
   r
   B  s   € õ �6œ9Ô.°°eÑ<Ô<Ð<r1   c               óB   — t          t          j        j        | |¦  «        S )a×  Create a logical 'or' expression node from the given value, resolving any implicit casts and
    lifting the values into :class:`Value` nodes if required.

    Examples:
        Logical 'or' of two classical bits

            >>> from qiskit.circuit import Clbit
            >>> from qiskit.circuit.classical import expr
            >>> expr.logical_and(Clbit(), Clbit())
            Binary(Binary.Op.LOGIC_OR, Var(<clbit 0>, Bool()), Var(<clbit 1>, Bool()), Bool())
    )rq   r   r;   ÚLOGIC_ORri   s     r/   r   r   Q  s   € õ �6œ9Ô-¨t°UÑ;Ô;Ð;r1   c           	     óZ  — t          ||¦  «        \  }}|j        j        |j        j        ur#t          d| › d|j        › d|j        › d�¦  «        ‚t	          j        |j        |j        ¦  «        }t          | t          ||¦  «        t          ||¦  «        t	          j        ¦   «         ¦  «        S ©Nrb   rc   rd   r(   )	r]   r    r.   r-   r   r   r   r0   r:   re   s       r/   Ú_equal_likerx   `  sŸ   € Ý'¨¨eÑ4Ô4�K€Dˆ%Ø„y„~˜UœZœ_Ð,Ð,ÝÐU¨bÐUÐU°d´iÐUÐUÈÌ
ÐUÐUÐUÑVÔVÐVÝŒ=˜œ E¤JÑ/Ô/€DÝ�"Õ& t¨TÑ2Ô2Õ4DÀUÈDÑ4QÔ4QÕSXÔS]ÑS_ÔS_Ñ`Ô`Ð`r1   c               óB   — t          t          j        j        | |¦  «        S )a  Create an 'equal' expression node from the given value, resolving any implicit casts and
    lifting the values into :class:`Value` nodes if required.

    Examples:
        Equality between a classical register and an integer::

            >>> from qiskit.circuit import ClassicalRegister
            >>> from qiskit.circuit.classical import expr
            >>> expr.equal(ClassicalRegister(3, "c"), 7)
            Binary(Binary.Op.EQUAL, Var(ClassicalRegister(3, "c"), Uint(3)), Value(7, Uint(3)), Uint(3))
    )rx   r   r;   r)   ri   s     r/   r   r   h  s   € õ •v”y”¨¨eÑ4Ô4Ð4r1   c               óB   — t          t          j        j        | |¦  «        S )a  Create a 'not equal' expression node from the given value, resolving any implicit casts and
    lifting the values into :class:`Value` nodes if required.

    Examples:
        Inequality between a classical register and an integer::

            >>> from qiskit.circuit import ClassicalRegister
            >>> from qiskit.circuit.classical import expr
            >>> expr.not_equal(ClassicalRegister(3, "c"), 7)
            Binary(Binary.Op.NOT_EQUAL, Var(ClassicalRegister(3, "c"), Uint(3)), Value(7, Uint(3)), Uint(3))
    )rx   r   r;   Ú	NOT_EQUALri   s     r/   r   r   z  s   € õ •v”yÔ*¨D°%Ñ8Ô8Ð8r1   c           	     óŠ  — t          ||¦  «        \  }}|j        j        |j        j        us|j        j        t          j        u r#t          d| › d|j        › d|j        › d�¦  «        ‚t          j        |j        |j        ¦  «        }t          | t          ||¦  «        t          ||¦  «        t          j        ¦   «         ¦  «        S rw   )	r]   r    r.   r   r:   r-   r   r   r0   re   s       r/   Ú_binary_relationr}   Œ  s¯   € Ý'¨¨eÑ4Ô4�K€Dˆ%Ø„y„~˜UœZœ_Ð,Ð,°´	´Å%Ä*Ð0LÐ0LÝÐU¨bÐUÐU°d´iÐUÐUÈÌ
ÐUÐUÐUÑVÔVÐVÝŒ=˜œ E¤JÑ/Ô/€DÝ�"Õ& t¨TÑ2Ô2Õ4DÀUÈDÑ4QÔ4QÕSXÔS]ÑS_ÔS_Ñ`Ô`Ð`r1   c               óB   — t          t          j        j        | |¦  «        S )a  Create a 'less than' expression node from the given value, resolving any implicit casts and
    lifting the values into :class:`Value` nodes if required.

    Examples:
        Query if a classical register is less than an integer::

            >>> from qiskit.circuit import ClassicalRegister
            >>> from qiskit.circuit.classical import expr
            >>> expr.less(ClassicalRegister(3, "c"), 5)
            Binary(Binary.Op.LESS, Var(ClassicalRegister(3, "c"), Uint(3)), Value(5, Uint(3)), Uint(3))
    )r}   r   r;   ÚLESSri   s     r/   r   r   ”  s   € õ �FœIœN¨D°%Ñ8Ô8Ð8r1   c               óB   — t          t          j        j        | |¦  «        S )aN  Create a 'less than or equal to' expression node from the given value, resolving any implicit
    casts and lifting the values into :class:`Value` nodes if required.

    Examples:
        Query if a classical register is less than or equal to another::

            >>> from qiskit.circuit import ClassicalRegister
            >>> from qiskit.circuit.classical import expr
            >>> expr.less(ClassicalRegister(3, "a"), ClassicalRegister(3, "b"))
            Binary(Binary.Op.LESS_EQUAL, Var(ClassicalRegister(3, "a"), Uint(3)), Var(ClassicalRegister(3, "b"), Uint(3)), Uint(3))
    )r}   r   r;   Ú
LESS_EQUALri   s     r/   r   r   ¦  s   € õ �FœIÔ0°$¸Ñ>Ô>Ð>r1   c               óB   — t          t          j        j        | |¦  «        S )a  Create a 'greater than' expression node from the given value, resolving any implicit casts
    and lifting the values into :class:`Value` nodes if required.

    Examples:
        Query if a classical register is greater than an integer::

            >>> from qiskit.circuit import ClassicalRegister
            >>> from qiskit.circuit.classical import expr
            >>> expr.less(ClassicalRegister(3, "c"), 5)
            Binary(Binary.Op.GREATER, Var(ClassicalRegister(3, "c"), Uint(3)), Value(5, Uint(3)), Uint(3))
    )r}   r   r;   ÚGREATERri   s     r/   r   r   ¸  s   € õ �FœIÔ-¨t°UÑ;Ô;Ð;r1   c               óB   — t          t          j        j        | |¦  «        S )aW  Create a 'greater than or equal to' expression node from the given value, resolving any
    implicit casts and lifting the values into :class:`Value` nodes if required.

    Examples:
        Query if a classical register is greater than or equal to another::

            >>> from qiskit.circuit import ClassicalRegister
            >>> from qiskit.circuit.classical import expr
            >>> expr.less(ClassicalRegister(3, "a"), ClassicalRegister(3, "b"))
            Binary(Binary.Op.GREATER_EQUAL, Var(ClassicalRegister(3, "a"), Uint(3)), Var(ClassicalRegister(3, "b"), Uint(3)), Uint(3))
    )r}   r   r;   ÚGREATER_EQUALri   s     r/   r   r   Ê  s   € õ �FœIÔ3°T¸5ÑAÔAÐAr1   c           	     óÀ  — |�&|j         t          j        urt          d|› d�¦  «        ‚t	          |t
          ¦  «        r|�t          ||¦  «        n|}nt          ||¦  «        }t          |¦  «        }|j        j         t          j        k    s|j        j         t          j        k    r#t          d| › d|j        › d|j        › d�¦  «        ‚t          | |||j        ¦  «        S )Nztype 'z&' is not a valid bitshift operand typerb   rc   rd   r(   )
r.   r   r=   r-   r9   r   r0   r   r    r   re   s       r/   Ú_shift_liker‡   Ü  sß   € ð Ð˜DœI­U¬ZÐ7Ð7ÝÐM ÐMÐMÐMÑNÔNÐNÝ�$�ÑÔð  Ø/3Ð/?Õ  dÑ+Ô+Ð+ÀTˆˆå�D˜$ÑÔˆÝ�‰KŒK€EØ„y„~�œÒ#Ð# u¤z¤½%¼*Ò'DÐ'DÝÐU¨bÐUÐU°d´iÐUÐUÈÌ
ÐUÐUÐUÑVÔVÐVÝ�"�d˜E 4¤9Ñ-Ô-Ð-r1   c               óD   — t          t          j        j        | ||¦  «        S )aM  Create a 'bitshift left' expression node from the given two values, resolving any implicit
    casts and lifting the values into :class:`Value` nodes if required.

    If ``type`` is given, the ``left`` operand will be coerced to it (if possible).

    Examples:
        Shift the value of a standalone variable left by some amount::

            >>> from qiskit.circuit.classical import expr, types
            >>> a = expr.Var.new("a", types.Uint(8))
            >>> expr.shift_left(a, 4)
            Binary(Binary.Op.SHIFT_LEFT, Var(<UUID>, Uint(8), name='a'), Value(4, Uint(3)), Uint(8))

        Shift an integer literal by a variable amount, coercing the type of the literal::

            >>> expr.shift_left(3, a, types.Uint(16))
            Binary(Binary.Op.SHIFT_LEFT, Value(3, Uint(16)), Var(<UUID>, Uint(8), name='a'), Uint(16))
    )r‡   r   r;   Ú
SHIFT_LEFT©rC   rD   r    s      r/   Ú
shift_leftr‹   ë  s   € õ2 •v”yÔ+¨T°5¸$Ñ?Ô?Ð?r1   c               óD   — t          t          j        j        | ||¦  «        S )au  Create a 'bitshift right' expression node from the given values, resolving any implicit casts
    and lifting the values into :class:`Value` nodes if required.

    If ``type`` is given, the ``left`` operand will be coerced to it (if possible).

    Examples:
        Shift the value of a classical register right by some amount::

            >>> from qiskit.circuit import ClassicalRegister
            >>> from qiskit.circuit.classical import expr
            >>> expr.shift_right(ClassicalRegister(8, "a"), 4)
            Binary(Binary.Op.SHIFT_RIGHT, Var(ClassicalRegister(8, "a"), Uint(8)), Value(4, Uint(3)), Uint(8))
    )r‡   r   r;   ÚSHIFT_RIGHTrŠ   s      r/   Úshift_rightrŽ     s   € õ" •v”yÔ,¨d°E¸4Ñ@Ô@Ð@r1   r@   Úindexc               ó"  — t          | ¦  «        t          |¦  «        }} | j        j        t          j        us|j        j        t          j        ur t          d| j        › d|j        › d�¦  «        ‚t          | |t          j        ¦   «         ¦  «        S )a.  Index into the ``target`` with the given integer ``index``, lifting the values into
    :class:`Value` nodes if required.

    This can be used as the target of a :class:`.Store`, if the ``target`` is itself an lvalue.

    Examples:
        Index into a classical register with a literal::

            >>> from qiskit.circuit import ClassicalRegister
            >>> from qiskit.circuit.classical import expr
            >>> expr.index(ClassicalRegister(8, "a"), 3)
            Index(Var(ClassicalRegister(8, "a"), Uint(8)), Value(3, Uint(2)), Bool())
    zinvalid types for indexing: 'rd   r(   )r   r    r.   r   r=   r-   r   r:   )r@   r�   s     r/   r�   r�     sy   € õ ˜‘L”L¥$ u¡+¤+ˆE€FØ„{Ô�uœzÐ)Ð)¨U¬Z¬_ÅEÄJÐ-NÐ-NÝÐY¸¼ÐYÐYÈEÌJÐYÐYÐYÑZÔZÐZÝ�˜¥¤
¡¤Ñ-Ô-Ð-r1   )r   r   r    r!   r"   r   )r2   r3   r"   r   rp   )r    rE   rA   rF   r"   r   )rN   rF   r    r!   r"   r   )rN   rF   r"   r   )rC   rF   rD   rF   r"   rV   )r^   r_   rC   rF   rD   rF   r"   r   )rC   rF   rD   rF   r"   r   )
r^   r_   rC   rF   rD   rF   r    rE   r"   r   )r    rE   rC   rF   rD   rF   r"   r   )r@   rF   r�   rF   r"   r   )-Ú__doc__Ú
__future__r   Ú__all__Útypingr   r   r   r   r   r   r   r   r   r   r   Ú ÚTYPE_CHECKINGÚqiskitr0   r   r   rQ   r   r   r]   rf   r   r   r	   rq   r
   r   rx   r   r   r}   r   r   r   r   r‡   r‹   rŽ   r�   © r1   r/   ú<module>r™      sð  ððð ð
 #Ð "Ð "Ð "Ð "Ð "ðð ð €ð$ €€€à >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø Ð Ð Ð Ð Ð à	Ôð Ø€M€M€MðHð Hð Hð Hð>ð >ð >ð >ð>5ð 5ð 5ð 5ð 5ðpð ð ð ð$:ð :ð :ð :ð$<ð <ð <ð <ð&!ð !ð !ð !ðH)ð )ð )ð )ð";ð ;ð ;ð ;ð&:ð :ð :ð :ð&;ð ;ð ;ð ;ð&*ð *ð *ð *ð=ð =ð =ð =ð<ð <ð <ð <ðað að að að5ð 5ð 5ð 5ð$9ð 9ð 9ð 9ð$að að að að9ð 9ð 9ð 9ð$?ð ?ð ?ð ?ð$<ð <ð <ð <ð$Bð Bð Bð Bð$.ð .ð .ð .ð@ð @ð @ð @ð @ð8Að Að Að Að Að(.ð .ð .ð .ð .ð .r1   