+
    i                         R t ^ RIHt ^ RIHt ^ RIHtHtHtH	t	 ^ RI
Ht ^ RIHtHtHtHtHtHt ^ RIHtHt RR.t ! R	 R]4      t ! R
 R]4      tR# )z
General binary relations.
)Optional)S)AppliedPredicateask	PredicateQ)BooleanKind)EqNeGtLtGeLe)	conjunctsNotBinaryRelationAppliedBinaryRelationc                   n   a  ] tR t^t o RtRtRtR t]R 4       t	]R 4       t
R tR
R ltV 3R ltR	tV tR# )r   a  
Base class for all binary relational predicates.

Explanation
===========

Binary relation takes two arguments and returns ``AppliedBinaryRelation``
instance. To evaluate it to boolean value, use :obj:`~.ask()` or
:obj:`~.refine()` function.

You can add support for new types by registering the handler to dispatcher.
See :obj:`~.Predicate()` for more information about predicate dispatching.

Examples
========

Applying and evaluating to boolean value:

>>> from sympy import Q, ask, sin, cos
>>> from sympy.abc import x
>>> Q.eq(sin(x)**2+cos(x)**2, 1)
Q.eq(sin(x)**2 + cos(x)**2, 1)
>>> ask(_)
True

You can define a new binary relation by subclassing and dispatching.
Here, we define a relation $R$ such that $x R y$ returns true if
$x = y + 1$.

>>> from sympy import ask, Number, Q
>>> from sympy.assumptions import BinaryRelation
>>> class MyRel(BinaryRelation):
...     name = "R"
...     is_reflexive = False
>>> Q.R = MyRel()
>>> @Q.R.register(Number, Number)
... def _(n1, n2, assumptions):
...     return ask(Q.zero(n1 - n2 - 1), assumptions)
>>> Q.R(2, 1)
Q.R(2, 1)

Now, we can use ``ask()`` to evaluate it to boolean value.

>>> ask(Q.R(2, 1))
True
>>> ask(Q.R(1, 2))
False

``Q.R`` returns ``False`` with minimum cost if two arguments have same
structure because it is antireflexive relation [1] by
``is_reflexive = False``.

>>> ask(Q.R(x, x))
False

References
==========

.. [1] https://en.wikipedia.org/wiki/Reflexive_relation
Nc                r    \        V4      ^8X  g   \        R\        V4      ,          4      h\        V .VO5!  # )   z0Binary relation takes two arguments, but got %s.)len
ValueErrorr   )selfargss   &*ځ/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/sympy/assumptions/relation/binrel.py__call__BinaryRelation.__call__P   s5    4yA~ORUVZR[[\\$T1D11    c                .    V P                   '       d   V # R # N)is_symmetricr   s   &r   reversedBinaryRelation.reversedU   s    Kr   c                    R # r    r!   s   &r   negatedBinaryRelation.negated[   s    r   c                    V\         P                  J g   V\         P                  J d   R # V P                  pVf    R # V'       d	   W8X  d   R# V'       g	   W8X  d   R# R # )NTF)r   NaNis_reflexive)r   lhsrhs	reflexives   &&& r   _compare_reflexive!BinaryRelation._compare_reflexive_   sN     !%%<3!%%<%%	
 	 CJ
r   c                `   V P                   ! V!  pVe   V# Vw  rEV P                  WEVR7      pVe   V# V P                  '       di   \        V4      \        V4      3pV P                  P                  ! V!  V P                  P                  ! \        V4      !  Jd   V P                  WTVR7      pV# )N)assumptions)r.   handlerr*   typedispatchr"   )r   r   r1   retr+   r,   typess   &&&    r   evalBinaryRelation.evalq   s    %%t,?J ll3l=?J #YS	*E||$$e,DLL4I4I8TY?4[[ll3lE
r   c                R   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   # )r   r*   r    )r   bool)format__classdict__s   "r   __annotate__BinaryRelation.__annotate__   s+     | 4.'} ~ 4.' r   r%   )T)__name__
__module____qualname____firstlineno____doc__r*   r    r   propertyr"   r&   r.   r7   __annotate_func____static_attributes____classdictcell__r<   s   @r   r   r      sV     ;z $(L#'L2
  
  $E  r   c                      a  ] tR t^t o Rt]R 4       t]R 4       t]R 4       t]R 4       t	]R 4       t
R tR tR	tV tR
# )r   zX
The class of expressions resulting from applying ``BinaryRelation``
to the arguments.

c                (    V P                   ^ ,          # )z#The left-hand side of the relation.	argumentsr!   s   &r   r+   AppliedBinaryRelation.lhs        ~~a  r   c                (    V P                   ^,          # )z$The right-hand side of the relation.rK   r!   s   &r   r,   AppliedBinaryRelation.rhs   rN   r   c                t    V P                   P                  pVf   V # V! V P                  V P                  4      # )z5
Try to return the relationship with sides reversed.
)functionr"   r,   r+   r   revfuncs   & r   r"   AppliedBinaryRelation.reversed   s2    
 --((?Ktxx**r   c                   V P                   P                  pVf   V # \        ;QJ d&    R V P                   4       F  '       g   K   RM	  RM! R V P                   4       4      '       g    V! V P                  ) V P
                  ) 4      # V # )z5
Try to return the relationship with signs reversed.
c              3   D   "   T F  qP                   \        J x  K  	  R # 5ir   )kindr   ).0sides   & r   	<genexpr>5AppliedBinaryRelation.reversedsign.<locals>.<genexpr>   s     G99+s    TF)rR   r"   anyrL   r+   r,   rS   s   & r   reversedsign"AppliedBinaryRelation.reversedsign   sd    
 --((?KsGGsssGGGGDHH9txxi00r   c                p    V P                   P                  pVf   \        V RR7      # V! V P                  !  # )NFevaluate)rR   r&   r   rL   )r   neg_rels   & r   r&   AppliedBinaryRelation.negated   s2    --''?te,,''r   c                  a \        4       o\        \        P                  \        \        P
                  \        \        P                  \        \        P                  \        \        P                  \        \        P                  /p\        V4       FV  pVP                  V9   d2   SP!                  V\#        V4      ,          ! VP$                  !  4       KE  SP!                  V4       KX  	  \&        ;QJ d*    V3R  lW P(                  3 4       F  '       g   K   RM	  RM! V3R  lW P(                  3 4       4      '       d   R# V P*                  V P(                  P*                  \-        V RR7      \-        V P(                  RR7      3p\&        ;QJ d    V3R lV 4       F  '       g   K   RM	  RM! V3R lV 4       4      '       d   R# V P.                  P1                  V P2                  V4      pVe   V# \4        ;QJ d    . R V P2                   4       F  NK  	  5M! R V P2                   4       4      pV P.                  P1                  Wa4      # )c              3   ,   <"   T F	  qS9   x  K  	  R # 5ir   r%   rY   relconj_assumpss   & r   r[   2AppliedBinaryRelation._eval_ask.<locals>.<genexpr>   s     D.Csl".C   TFra   c              3   ,   <"   T F	  qS9   x  K  	  R # 5ir   r%   rg   s   & r   r[   rj      s     7hsl"hrk   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir   )simplify)rY   as   & r   r[   rj      s     :>aZZ\\>s   )setr	   r   eqr
   ner   gtr   ltr   ger   ler   funcaddr3   r   r]   r"   r&   r   rR   r7   rL   tuple)r   r1   binrelpredsro   neg_relsr5   r   ri   s   &&     @r   	_eval_askAppliedBinaryRelation._eval_ask   su   u144QTT2qttRr144QTTR;'Avv$  T!W!5qvv!>?  #	 ( 3Dt]].CD333Dt]].CDDDLL$--"7"7TE9R.037h73337h777 mm  =?J u:4>>:uu:4>>::}}!!$44r   c                H    \        V 4      pVf   \        RV ,          4      hV# )Nz"Cannot determine truth value of %s)r   	TypeError)r   r5   s   & r   __bool__AppliedBinaryRelation.__bool__   s&    $i;@4GHH
r   r%   N)r?   r@   rA   rB   rC   rD   r+   r,   r"   r^   r&   r|   r   rF   rG   rH   s   @r   r   r      s}      ! ! ! ! + + 	 	 ( (56 r   N)rC   typingr   sympy.core.singletonr   sympy.assumptionsr   r   r   r   sympy.core.kindr   sympy.core.relationalr	   r
   r   r   r   r   sympy.logic.boolalgr   r   __all__r   r   r%   r   r   <module>r      sM     " A A ' 8 8 .4
5uY upM, Mr   