+
    i                     h   R t ^ RIt^ RIHtHtHt ^ RIHt ^ RIH	t	 ^ RI
HtHtHtHt ^ RIHtHt ^ RIHtHtHtHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHt ^ RIH t H!t!H"t" ^ RI#H$t$ ^ RI%H&t&H't' ^ RI(H)t)H*t* ^ RI+H,t, R t-R t.R t/RR lt0R t1R t2R]Pf                  R3R lt4R t5RR lt6R t7. 3R lt8R# ) z<Tools for solving inequalities and systems of inequalities. N)continuous_domainperiodicityfunction_range)sympify)factor_terms)
RelationalLtGeEq)SymbolDummy)Interval	FiniteSetUnionIntersection)S)
expand_mul)Abs)And)PolyPolynomialErrorparallel_poly_from_expr)_nsort)solvifysolveset)siftiterable)
filldedentc           
     T   \        V \        4      '       g   \        R4      hV P                  4       P                  '       dx   \        V P                  4       ^ V4      pV\        P                  J d   \        P                  .# V\        P                  J d   \        P                  .# \        RV,          4      hV P                  RR7      . rCVR8X  d*   V F!  w  rV\        WU4      pVP                  V4       K#  	  V# VR8X  dV   \        P                  pV\        P                   ^3.,            F%  w  r\        WRR4      pVP                  V4       T	pK'  	  V# V P#                  4       ^ 8  d   ^p
MRp
RRrVR	8X  d   ^pM2VR
8X  d   RpM(VR8X  d   ^RrMVR8X  d   RRrM\        RV,          4      h\        P                   Rr\%        V4       F  w  rV^,          '       d5   W8X  d#   VP'                  ^ \        WV'       * V4      4       V
) Y'       * rp
KH  W8X  d+   V'       g#   VP'                  ^ \        WRV4      4       TRrKx  W8w  g   K  V'       g   K  VP'                  ^ \        W4      4       K  	  W8X  d-   VP'                  ^ \        \        P                  V	RV4      4       V# )a  Solve a polynomial inequality with rational coefficients.

Examples
========

>>> from sympy import solve_poly_inequality, Poly
>>> from sympy.abc import x

>>> solve_poly_inequality(Poly(x, x, domain='ZZ'), '==')
[{0}]

>>> solve_poly_inequality(Poly(x**2 - 1, x, domain='ZZ'), '!=')
[Interval.open(-oo, -1), Interval.open(-1, 1), Interval.open(1, oo)]

>>> solve_poly_inequality(Poly(x**2 - 1, x, domain='ZZ'), '==')
[{-1}, {1}]

See Also
========
solve_poly_inequalities
z8For efficiency reasons, `poly` should be a Poly instance%could not determine truth value of %sF)multiple==!=TN><>=<=z'%s' is not a valid relation)
isinstancer   
ValueErroras_expr	is_numberr   r   trueRealsfalseEmptySetNotImplementedError
real_rootsr   appendNegativeInfinityInfinityLCreversedinsert)polyreltreals	intervalsroot_intervalleftrightsigneq_signequal
right_openmultiplicitys   &&             z/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/sympy/solvers/inequalities.pysolve_poly_inequalityrH      sq   , dD!!FH 	H||~t||~q#.;GG9!''\JJ<%7!;= = 69
d{GD+HX& d _ 
!!!**a 111HET48HX&D 2X O 779q=DDu#:GCZGD[UD[U;cABBJJz"*5/Da?$$8DUJGI ,0%yZZ?5$$8DzBD(,d:_$$Q(<= #2 ?8A..tZHJ     c           
     b    \        V  UUu. uF  p\        V!   F  q"NK  	  K  	  upp!  # u uppi )au  Solve polynomial inequalities with rational coefficients.

Examples
========

>>> from sympy import Poly
>>> from sympy.solvers.inequalities import solve_poly_inequalities
>>> from sympy.abc import x
>>> solve_poly_inequalities(((
... Poly(x**2 - 3), ">"), (
... Poly(-x**2 + 1), ">")))
Union(Interval.open(-oo, -sqrt(3)), Interval.open(-1, 1), Interval.open(sqrt(3), oo))
)r   rH   )polyspss   &  rG   solve_poly_inequalitiesrN   q   s0     eGe-BA-F1-F1eGHHGs   +
c                   \         P                  pV  EF'  pV'       g   K  \        \         P                  \         P                  4      .pV F  w  w  rEp\        WE,          V4      p\        VR4      p. p	\        P                  ! Ws4       F=  w  rV
P                  V4      pV\         P                  Jg   K,  V	P                  V4       K?  	  T	p. p	V F;  pV F  pW,          pK  	  V\         P                  Jg   K*  V	P                  V4       K=  	  T	pV'       d   K   M	  V F  pVP                  V4      pK  	  EK*  	  V# )a  Solve a system of rational inequalities with rational coefficients.

Examples
========

>>> from sympy.abc import x
>>> from sympy import solve_rational_inequalities, Poly

>>> solve_rational_inequalities([[
... ((Poly(-x + 1), Poly(1, x)), '>='),
... ((Poly(-x + 1), Poly(1, x)), '<=')]])
{1}

>>> solve_rational_inequalities([[
... ((Poly(x), Poly(1, x)), '!='),
... ((Poly(-x + 1), Poly(1, x)), '>=')]])
Union(Interval.open(-oo, 0), Interval.Lopen(0, 1))

See Also
========
solve_poly_inequality
r!   )r   r/   r   r3   r4   rH   	itertoolsproduct	intersectr2   union)eqsresult_eqsglobal_intervalsnumerdenomr9   numer_intervalsdenom_intervalsr<   numer_intervalglobal_intervalr?   denom_intervals   &             rG   solve_rational_inequalitiesr_      s%   . ZZF$Q%7%7DE#'NUC3EKEO3E4@OI3<3D3D#47/)33OD1::-$$X.47  )I#3&5N#5O '6 #!**4$$_5 $4  )##7 $(: )H\\(+F )G L MrI   Tc                   Rp. p\         P                  pV  EF`  pV'       g   K  . p\         P                  pV EF  p	\        V	\        4      '       d   V	w  rM=V	P
                  '       d*   V	P                  V	P                  ,
          V	P                  rMRp
V	\         P                  J d#   \         P                  \         P                  RrpMVV	\         P                  J d#   \         P                  \         P                  RrpM V	P                  4       P                  4       w  r \        W3V4      w  w  rpTP$                  P&                  '       g"   TP)                  4       TP)                  4       Rr<pTP$                  P+                  4       pTP,                  '       g?   TP.                  '       g-   Y,          p	\1        T	^ T
4      p	T\3        YRR7      ,          pEK  TP5                  Y3T
34       EK  	  V'       dt   V\7        V.4      ,          p\7        V UUUUu. uF:  q F2  w  w  pppVP9                  V4      '       g   K"  VVP:                  3R3NK4  	  K<  	  upppp.4      pVV,          pWX,          pEKc  	  V'       g   V'       d   VP=                  4       pV'       d   VP?                  V4      pV#   \          d    \!        \#        R4      4      hi ; iu uppppi )a  Reduce a system of rational inequalities with rational coefficients.

Examples
========

>>> from sympy import Symbol
>>> from sympy.solvers.inequalities import reduce_rational_inequalities

>>> x = Symbol('x', real=True)

>>> reduce_rational_inequalities([[x**2 <= 0]], x)
Eq(x, 0)

>>> reduce_rational_inequalities([[x + 2 > 0]], x)
-2 < x
>>> reduce_rational_inequalities([[(x + 2, ">")]], x)
-2 < x
>>> reduce_rational_inequalities([[x + 2]], x)
Eq(x, -2)

This function find the non-infinite solution set so if the unknown symbol
is declared as extended real rather than real then the result may include
finiteness conditions:

>>> y = Symbol('y', extended_real=True)
>>> reduce_rational_inequalities([[y + 2 > 0]], y)
(-2 < y) & (y < oo)
Tr!   z
                    only polynomials and rational functions are
                    supported in this context.
                    F)
relational) r   r/   r-   r(   tupleis_Relationallhsrhsrel_opr,   ZeroOner.   togetheras_numer_denomr   r   r   domainis_Exactto_exact	get_exactis_ZZis_QQr   solve_univariate_inequalityr2   r_   hasoneevalfas_relational)exprsgenra   exactrT   solution_exprsrV   _solexprr9   rX   rY   optrk   indr>   excludes   &&&                 rG   reduce_rational_inequalitiesr      s]   : E
CzzHwwD$&& 	c%%% $488 3T[[#Cqvv~$%FFAEE4cc$%EE155$cc#}}==?&=NC')# ::&&&&+nn&68H%eZZ))+FLLLFLLL{!$3/3D%PPe^S12G J /77D14AA&1a!QUU3Z 5GaZ4F01 5G4A 3B CGGODa d X>>#))#.OA # %j 2 '  (4As   "J7#KK7 Kc                >  a VP                   RJ d   \        \        R4      4      hV3R loRRRR/p. pS! V 4       FT  w  rWP                  4       9  d   \	        V ^ V4      p M\	        V ) ^ W1,          4      p VP                  V .V,           4       KV  	  \        WB4      # )a]  Reduce an inequality with nested absolute values.

Examples
========

>>> from sympy import reduce_abs_inequality, Abs, Symbol
>>> x = Symbol('x', real=True)

>>> reduce_abs_inequality(Abs(x - 5) - 3, '<', x)
(2 < x) & (x < 8)

>>> reduce_abs_inequality(Abs(x + 2)*3 - 13, '<', x)
(-19/3 < x) & (x < 7/3)

See Also
========

reduce_abs_inequalities
Fzs
            Cannot solve inequalities with absolute values containing
            non-real variables.
            c                 6  <a . pV P                   '       g   V P                  '       dv   V P                  pV P                   FW  pS	! V4      pV'       g   TpK  \        P
                  ! W4       U UUUu. uF  w  w  rw  rgV! W4      WW,           3NK  	  pppp pKY  	  V# V P                  '       dW   V P                  oSP                  '       g   \        R 4      hVP                  V3R lS	! V P                  4       4       4       V# \        V \        4      '       dq   S	! V P                  ^ ,          4      pV FO  w  rVP                  W\        V ^ 4      .,           34       VP                  V ) V\!        V ^ 4      .,           34       KQ  	  V# V . 3.pV# u upppp i )z'Only Integer Powers are allowed on Abs.c              3   >   <"   T F  w  rVS,          V3x  K  	  R # 5iN ).0r|   condsr   s   &  rG   	<genexpr>Areduce_abs_inequality.<locals>._bottom_up_scan.<locals>.<genexpr>L  s     X=Wkd$'5)=Ws   )is_Addis_MulfuncargsrP   rQ   is_Powexp
is_Integerr)   extendbaser(   r   r2   r	   r   )
r|   rv   opargrz   r   _expr_condsr   _bottom_up_scans
   &       @rG   r   .reduce_abs_inequality.<locals>._bottom_up_scan9  sa   ;;;$+++Byy(-"E &--e<>< Db=DRaSXbou~><  >E !.  [[[A<<< !JKKLLX_TYY=WXX  c""$TYYq\2F%tbqk]%:;<teUbqk]%:;<  &  BZLE#>s   3 Fr$   r#   r&   r%   )is_extended_real	TypeErrorr   keysr   r2   r   )r|   r9   rw   mappinginequalitiesr   r   s   &&&   @rG   reduce_abs_inequalityr     s    ( u$
 $   	
> Ct$GL&t,lln$tQ,DteQ5DTFUN+ - (::rI   c                \    \        V  UUu. uF  w  r#\        W#V4      NK  	  upp!  # u uppi )a  Reduce a system of inequalities with nested absolute values.

Examples
========

>>> from sympy import reduce_abs_inequalities, Abs, Symbol
>>> x = Symbol('x', extended_real=True)

>>> reduce_abs_inequalities([(Abs(3*x - 5) - 7, '<'),
... (Abs(x + 25) - 13, '>')], x)
(-2/3 < x) & (x < 4) & (((-oo < x) & (x < -38)) | ((-12 < x) & (x < oo)))

>>> reduce_abs_inequalities([(Abs(x - 4) + Abs(3*x - 5) - 7, '<')], x)
(1/2 < x) & (x < 4)

See Also
========

reduce_abs_inequality
)r   r   )rv   rw   r|   r9   s   &&  rG   reduce_abs_inequalitiesr   f  s:    * !ID (37! " " !s   (
Fc                $  a aa) ^ RI Hp VP                  \        P                  4      RJ d   \        \        R4      4      hV\        P                  Jd:   \        S SRVR7      P                  V4      pV'       d   VP                  S4      pV#  SpTpSP                  RJ d,   \        P                  pV'       g   V# VP                  V4      # SP                  f"   \        RRR7      o S P                  VS/4      o RpS \        P                  J d   TpEM!S \        P                   J d   \        P                  pEMS P"                  S P$                  ,
          p	\'        V	S4      p
V
\        P(                  8X  d\   \+        V	4      p	S P-                  V	^ 4      pV\        P                  J d   TpEMQV\        P                   J d   \        P                  pEM+V
Ee'   \/        V	SV4      pS P0                  pVR9   dY   S P-                  VP2                  ^ 4      '       d   TpMS P-                  VP4                  ^ 4      '       g   \        P                  pM^VR9   dX   S P-                  VP4                  ^ 4      '       d   TpM2S P-                  VP2                  ^ 4      '       g   \        P                  pVP4                  VP2                  rW,
          \        P6                  J d    \9        ^ V
RR4      P;                  V4      pTpVEf3   V	P=                  4       w  pp SVP>                  9  d!   \A        V	P>                  4      ^8  d   \B        h\E        V	SV4      pVf   \B        h \+        T	4      o)T)T T3R lp. pT! S S4       F  pTPK                  \E        TST4      4       K!  	  T'       g   \M        S)ST4      pRS P0                  9   ;'       d    S P0                  R8g  p \O        TPP                  \S        TP4                  TP2                  4      ,
          4      p\S        TT,           \U        T4      ,           !  P                  \9        TP4                  TP2                  TP4                  T9  TP2                  T9  4      4      p\V        ;QJ d    R T 4       F  '       d   K   RM	  RM! R T 4       4      '       d   \Y        TRR7      ^ ,          pMG\[        TR 4      pTR,          '       d   \
        h TR,          p\A        T4      ^8  d   \]        T4      p\        P                  pS)P_                  \        P`                  4      ;p\        P(                  8w  Ed   Rp\S        4       p \c        TST4      p\e        T\8        4      '       gK   T FB  pTT9  g   K  T! T4      '       g   K  TP                  '       g   K0  T\S        T4      ,          pKD  	  EM2TP4                  TP2                  p!p \Y        T\S        T!4      ,           4       F  pT! T 4      p"T T!8w  d   T! T4      p#\g        T T4      p$T$T9  d   T$P                  '       d   T! T$4      '       d   T"'       d   T#'       d   T\9        T T4      ,          pMlT"'       d    T\8        Ph                  ! T T4      ,          pMET#'       d    T\8        Pj                  ! T T4      ,          pMT\8        Pl                  ! T T4      ,          pTp K  	  T F  p%T\S        T%4      ,          pK  	   T\        P                  J d.   \C        \        RS PG                  ST4      : RT: R24      4      hTP;                  T4      p\        P                  .p&TP4                  p T T9   d;   T! T 4      '       d-   T Pn                  '       d   T&Pq                  \S        T 4      4       T F  p'T'p!T! \g        T T!4      4      '       d   T&Pq                  \9        T T!RR4      4       T'T9   d   TPs                  T'4       MET'T9   d   TPs                  T'4       T! T'4      p(MTp(T('       d   T&Pq                  \S        T'4      4       T!p K  	  TP2                  p!T!T9   d;   T! T!4      '       d-   T!Pn                  '       d   T&Pq                  \S        T!4      4       T! \g        T T!4      4      '       d'   T&Pq                  \8        Pl                  ! T T!4      4       T\        P(                  8w  d   X'       d   TP;                  T4      pM$\u        \w        T&!  TT4      PG                  ST4      pV'       g   V# VP                  V4      #   \         d    \        \        R	4      4      hi ; i  \B        \
        3 d6    \        \        R
S PG                  S\I        R4      4      ,          4      4      hi ; i  \         d    \
        hi ; i  \
         d    \        R4      hi ; i  \         d    \        P                  pRp ELi ; i)a  Solves a real univariate inequality.

Parameters
==========

expr : Relational
    The target inequality
gen : Symbol
    The variable for which the inequality is solved
relational : bool
    A Relational type output is expected or not
domain : Set
    The domain over which the equation is solved
continuous: bool
    True if expr is known to be continuous over the given domain
    (and so continuous_domain() does not need to be called on it)

Raises
======

NotImplementedError
    The solution of the inequality cannot be determined due to limitation
    in :func:`sympy.solvers.solveset.solvify`.

Notes
=====

Currently, we cannot solve all the inequalities due to limitations in
:func:`sympy.solvers.solveset.solvify`. Also, the solution returned for trigonometric inequalities
are restricted in its periodic interval.

See Also
========

sympy.solvers.solveset.solvify: solver returning solveset solutions with solve's output API

Examples
========

>>> from sympy import solve_univariate_inequality, Symbol, sin, Interval, S
>>> x = Symbol('x')

>>> solve_univariate_inequality(x**2 >= 4, x)
((2 <= x) & (x < oo)) | ((-oo < x) & (x <= -2))

>>> solve_univariate_inequality(x**2 >= 4, x, relational=False)
Union(Interval(-oo, -2), Interval(2, oo))

>>> domain = Interval(0, S.Infinity)
>>> solve_univariate_inequality(x**2 >= 4, x, False, domain)
Interval(2, oo)

>>> solve_univariate_inequality(sin(x) > 0, x, relational=False)
Interval.open(0, pi)

denomsFz|
        Inequalities in the complex domain are
        not supported. Try the real domain by
        setting domain=S.Reals)ra   
continuousNrw   Textended_realz
                When gen is real, the relational has a complex part
                which leads to an invalid comparison like I < 0.
                z
                    The inequality, %s, cannot be solved using
                    solve_univariate_inequality.
                    xc                   < SP                  S\        V 4      4      p SP                  V^ 4      pV\        P                  \        P
                  39   d   V# VP                  RJ d   \        P
                  # VP                  ^4      pVP                  '       d   SP                  V^ 4      # \        RV,          4      h  \         d    \        P
                  p Li ; i)    Fz!relationship did not evaluate: %s)subsr   r   r   r   r.   r,   r   r   is_comparabler0   )r   vr
expanded_er|   rw   s   &  rG   valid*solve_univariate_inequality.<locals>.valid  s     OOCA7 		!QA ))H%%.77NAA#yyA.-;a?A A !  A s   B> >CC=r"   c              3   8   "   T F  qP                   x  K  	  R # 5ir   )r+   )r   r   s   & rG   r   .solve_univariate_inequality.<locals>.<genexpr>@  s     <Oq{{Os   )	separatedc                     V P                   # r   r   )r   s   &rG   <lambda>-solve_univariate_inequality.<locals>.<lambda>C  s
    Q=O=OrI   z'sorting of these roots is not supportedz
                        zZ contains imaginary parts which cannot be
                        made 0 for any value of zm satisfying the
                        inequality, leading to relations like I < 0.
                        )r$   r&   )r#   r%   )<sympy.solvers.solversr   	is_subsetr   r-   r0   r   rq   intersectionru   r   r/   r   xreplacer   r,   r.   rd   re   r   rg   r   r   r   rf   supinfr4   r   rR   rj   free_symbolslenr)   r   r   r   r   r   setboundaryr   listallr   r   sortedcoeffImaginaryUnitr   r(   _ptRopenLopenopen	is_finiter2   remover   r   )*r|   rw   ra   rk   r   r   rv_gen_domaineperiodconstfranger9   r   r   r   r   solnsr   singularities	include_xdiscontinuitiescritical_pointsr;   sifted	make_realcoeffIcheckim_solazstartendvalid_startvalid_zptrM   sol_setsr   _validr   s*   ff&&&                                    @rG   rq   rq     s)   r - E)!* ." ## $ 	$ 
qww	(ce
<<HL<P 	!!#&B	
 DG
u$ZZ#r?)9)9$)??				%E.	==$-D 
Bqvv~	ZZ HHtxxQ$QVV1AIIaOE!''!ZZ#AsF3F++Ck!99VZZ++B6::q11B#99VZZ++B6::q11Bzz6::yAJJ&!!VUD9CCGL :##%DAq8ann,Q^^1Dq1H$$  3/=$$ ! $AJA6 MD#&$$WQV%<= '*:sFCt{{*BBt{{d/BIU"%foofjj&**5'6 #7 #,em.Cd#G% /% #''3|VZZJJf,fjj.FH(I   3<O<333<O<<<"?dCAFE!/3OPFd|| 212 &tu:>$*5ME I$**1??;;F"" f5A%a22!"A 5%((qGYGYGY &)A, 6 "# &'UUAEEs!')C.(H!IA*/,K$|*/(%(]#%]#:r?R?R?RW\]_W`W`'2w(.(5!2D(D)4(.(..2J(J)0(.(..2J(J(.(--q2I(I$%E "J "/A"il2F "/ QZZ'$Z !%		#t 4d	1< &= > > &//7	

|HJJE5<<EOOO	% 01UC))OOHUCt$DE%!((+O+'..q1!&q!* 	!5# & **Cf}s	#/S_%%eS 9:E**73!H%	7<<@DdO   2;R%5%5d%;;_  	J (   	p  34 8 ** 6 ))C566 +7 8 88@ % 2112& U)*STTUD " "WWF!E"s   *e Ae6  B?g "g =g "g 5$f? +,g. g. ,g.  g. A1g. 
g. g.  g. (g. &g. +Ag.  e36Af<?gg g+.hhc                   V P                   '       g$   VP                   '       g   W,           ^,          pV# V P                   '       d%   VP                   '       d   \        P                  pV# V P                   '       d   V P                  e!   VP                   '       d   VP                  f   \	        R4      hVP                   '       d   VP
                  '       g%   V P                   '       d   V P                  '       d   YrVP                   '       dU   V P                  '       d   V ^,          pV# V P
                  '       d   V \        P                  ,          pV# V ^,           p V# V P                   '       dR   VP                  '       d   V\        P                  ,          pV# VP
                  '       d   V^,          pV# V^,
          pX# )z$Return a point between start and endz,cannot proceed with unsigned infinite values)is_infiniter   rg   is_extended_positiver)   is_extended_negativeHalf)r   r   r   s   && rG   r   r     sn   S___k1_6 I5 
			sVV2 I/ %"<"<"DC$<$<$DKLLOOO 8 8 8!!!e&@&@&@3 ???)))1W I +++166\ I QY I '''Z
 I	 )))U I 1WIrI   c                *	   ^ RI Hp WP                  9  d   V # V P                  V8X  d   V P                  p V P
                  V8X  d   WP                  P                  9  d   V # R pRp\        P                  pV P
                  V P                  ,
          p \        Wq4      pVP                  4       ^ 8X  d"   V P                  VP                  4       ^ 4      pM#V'       g   VP                  4       ^8  d   \        h. pVEf   XP                  4       p^ pVP)                  VRR7      w  rW,          pW,          p\+        V4      pVP)                  VRR7      w  ppVP,                  R8w  g6   VP.                  VP0                  u;8X  d    f'   M M#V P2                  R9  d   Tp\        P4                  pVV,          pVP0                  '       d   V P                  W4      pMV P                  P                  W4      pV! V P
                  4      V! V P                  4      ,          pV! V4      pVV,
           F~  p\7        \9        V^ 4      WR7      p\;        V\8        4      '       g   K2  VP
                  V8X  g   KE  V! WQVP                  4      \        P                   J g   Kl  VP=                  V( 4       K  	  V) V3 F\  pV! WQV4      \        P                   J g   K   V! WV4      \        P                   Jg   K=  TP=                  VVJ d   VV8  MVV8  4       K^  	  VP=                  V4       \'        V!  #   \        \        3 EdM    T'       Eg5    \        T ..T4      pM  \         d    \        Y4      p Mi ; iT! YT4      p	T	\        P                   J d0   T! YQT4      \        P"                  J d   TP%                  Y8  R4      pT! YT) 4      p
T
\        P                   J dH   T! YQT) 4      \        P"                  J d,   TP%                  T) T8  R4      pTP%                  Y) 8  R4      pT\        P                   J dA   T	\        P                   J d   Y8*  MY8  pT
\        P                   Jd   \'        T) T8  T4      p EL\        T4      p ELi ; i)	a  Return the inequality with s isolated on the left, if possible.
If the relationship is non-linear, a solution involving And or Or
may be returned. False or True are returned if the relationship
is never True or always True, respectively.

If `linear` is True (default is False) an `s`-dependent expression
will be isolated on the left, if possible
but it will not be solved for `s` unless the expression is linear
in `s`. Furthermore, only "safe" operations which do not change the
sense of the relationship are applied: no division by an unsigned
value is attempted unless the relationship involves Eq or Ne and
no division by a value not known to be nonzero is ever attempted.

Examples
========

>>> from sympy import Eq, Symbol
>>> from sympy.solvers.inequalities import _solve_inequality as f
>>> from sympy.abc import x, y

For linear expressions, the symbol can be isolated:

>>> f(x - 2 < 0, x)
x < 2
>>> f(-x - 6 < x, x)
x > -3

Sometimes nonlinear relationships will be False

>>> f(x**2 + 4 < 0, x)
False

Or they may involve more than one region of values:

>>> f(x**2 - 4 < 0, x)
(-2 < x) & (x < 2)

To restrict the solution to a relational, set linear=True
and only the x-dependent portion will be isolated on the left:

>>> f(x**2 - 4 < 0, x, linear=True)
x**2 < 4

Division of only nonzero quantities is allowed, so x cannot
be isolated by dividing by y:

>>> y.is_nonzero is None  # it is unknown whether it is 0 or not
True
>>> f(x*y < 1, x)
x*y < 1

And while an equality (or inequality) still holds after dividing by a
non-zero quantity

>>> nz = Symbol('nz', nonzero=True)
>>> f(Eq(x*nz, 1), x)
Eq(x, 1/nz)

the sign must be known for other inequalities involving > or <:

>>> f(x*nz <= 1, x)
nz*x <= 1
>>> p = Symbol('p', positive=True)
>>> f(x*p <= 1, x)
x <= 1/p

When there are denominators in the original expression that
are removed by expansion, conditions for them will be returned
as part of the result:

>>> f(x < x*(2/x - 1), x)
(x < 1) & Ne(x, 0)
r   c                      V P                  W4      pV\        P                  J d   V# VR9  d   R# V#   \         d    \        P                  u # i ; i)TNTF)r   r   NaNr   )ierM   r~   r   s   &&& rG   classify#_solve_inequality.<locals>.classify  sL    	AAEEz-'H 	55L	s   &4 4 4 AANT)as_AddF)linear)r"   r!   )r   r   r   re   r6   rd   r   r4   r   degreer   r*   r0   r   r   rq   r,   r.   r   r   as_independentr   is_zerois_negativeis_positiverf   rh   _solve_inequalityr
   r(   r2   )r   rM   r   r   r   r   oor|   rL   okoooknoor   r   re   baxefr   beginning_denomscurrent_denomsr   cr~   s   &&&                    rG   r   r     s   T -		vv{[[	vv{q 3 33	 
B	
B66BFF?DM88:?a(BAHHJN%%0 E	zIIK
   4 0	!_  5 11II&!%&		-AAq===B!!!)B ""&&>F266N:!N22A!"Q(A=A!R  QUUaZB155)QVV3LL!$ 3 #rA"aff,RA&aff4a2gQU1q59 
 
LL;A 01 v81B4&!<" 8078 B2&Dqvv~(2""5"@WWQVT*RRC(ERRC(AGG3WWbS1Wd+WWQWd+QVV|"&!&&.agqv&bS1Wb)BT
A+sJ   A L4 L4 L4 4RMRM85R7M88DRRRc           
      N  a / / r2. pV  EF  pVP                   VP                  rvVP                  \        4      p\	        V4      ^8X  d   VP                  4       oMoVP                  V,          p	\	        V	4      ^8X  d9   V	P                  4       oVP                  \        \        V^ V4      S4      4       K  \        \        R4      4      hVP                  S4      '       d%   VP                  S. 4      P                  Wg34       K  VP                  V3R l4      p
V
'       d`   \        ;QJ d    R V
 4       F  '       d   K   RM	  RM! R V
 4       4      '       d&   VP                  S. 4      P                  Wg34       EKw  VP                  \        \        V^ V4      S4      4       EK  	  VP!                  4        UUu. uF  w  r\#        V.V4      NK  	  pppVP!                  4        UUu. uF  w  r\%        W4      NK  	  ppp\'        W,           V,           !  # u uppi u uppi )   zZ
                    inequality has more than one symbol of interest.
                    c                    < V P                  S4      ;'       dD    V P                  ;'       g0    V P                  ;'       d    V P                  P                  '       * # r   )rr   is_Functionr   r   r   )urw   s   &rG   r   &_reduce_inequalities.<locals>.<lambda>  sH    c
 D DBB!B!B!%%2B2B.BDrI   c              3   B   "   T F  p\        V\        4      x  K  	  R # 5ir   )r(   r   r   r~   s   & rG   r   '_reduce_inequalities.<locals>.<genexpr>  s     !Ij*Q"4"4js   FT)rd   rf   atomsr   r   popr   r2   r   r   r0   r   is_polynomial
setdefaultfindr   itemsr   r   r   )r   symbols	poly_partabs_partother
inequalityr|   r9   genscommon
componentsrw   rv   poly_reducedabs_reduceds   &&         `   rG   _reduce_inequalitiesr   t  s    bxE"
NNJ$5$5c
 zz&!t9>((*C&&0F6{ajjl.z$3/GMN)* 6 +   c""  b)00$= $D EJ cc!Ij!Iccc!Ij!III##C,33TK@.z$3/GMN? #B R[Q`Q`QbcQb:30%#>QbLcIQIYZIY:3*56IYKZ+e355 dZs   >H,H!c           	     "   \        V 4      '       g   V .p V  Uu. uF  p\        V4      NK  	  p p\        4       P                  ! V  Uu. uF  q"P                  NK  	  up!  p\        V4      '       g   V.p\        V4      ;'       g    TV,          p\
        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   \        \        R4      4      hV Uu/ uF*  q"P                  e   K  V\        VP                  RR7      bK,  	  ppV  Uu. uF  q"P                  V4      NK  	  p pV Uu0 uF  q"P                  V4      kK  	  pp. pV  F  p\        V\        4      '       dK   VP                  VP                  P!                  4       VP"                  P!                  4       ,
          ^ 4      pMVR9  d   \%        V^ 4      pVR8X  d   K  VR8X  d   \&        P(                  u # VP                  P*                  '       d   \-        RV,          4      hVP/                  V4       K  	  Tp ?\1        W4      pTP                  VP3                  4        UUu/ uF  w  rxWbK	  	  upp4      # u upi u upi u upi u upi u upi u uppi )a!  Reduce a system of inequalities with rational coefficients.

Examples
========

>>> from sympy.abc import x, y
>>> from sympy import reduce_inequalities

>>> reduce_inequalities(0 <= x + 3, [])
(-3 <= x) & (x < oo)

>>> reduce_inequalities(0 <= x + y*2 - 1, [x])
(x < oo) & (x >= 1 - 2*y)
c              3   <   "   T F  qP                   R J x  K  	  R# 5i)FNr   r  s   & rG   r   &reduce_inequalities.<locals>.<genexpr>  s     
81&s   TFzP
            inequalities cannot contain symbols that are not real.
            r   r   r   )r   r   r   rS   r   anyr   r   r   r   namer   r(   r   r   rd   r*   re   r
   r   r.   r+   r0   r2   r   r  )	r   r  r~   r  recastkeepr   kr   s	   &&       rG   reduce_inequalitiesr)    s    L!!$~(451GAJL55;;>A>?DG)7|##tt+G
s
8
8sss
8
888
 $   	 5A++ 3aqvvT22  50<=1JJv&L=+237azz&!7G3 Da$$quu}}8!<Am#1aA9%Z77N55???%7!;= =A  L 
l	4B ;;8899Q 6>5=30 9s)   I2I7"I<6I<J7JJ
)T)F)9__doc__rP   sympy.calculus.utilr   r   r   
sympy.corer   sympy.core.exprtoolsr   sympy.core.relationalr   r   r	   r
   sympy.core.symbolr   r   sympy.sets.setsr   r   r   r   sympy.core.singletonr   sympy.core.functionr   $sympy.functions.elementary.complexesr   sympy.logicr   sympy.polysr   r   r   sympy.polys.polyutilsr   sympy.solvers.solvesetr   r   sympy.utilities.iterablesr   r   sympy.utilities.miscr   rH   rN   r_   r   r   r   r-   rq   r   r   r   r)  r   rI   rG   <module>r:     s    B    - 8 8 + D D " * 4  F F ( 4 4 +XvI"?DXvD;N"2 7;177W\ d<N	BjZ*6Z /1 9:rI   