+
    i-                         R t ^ RIHt ^ RIHt ^ RIHtHt ^ RIH	t	H
t
 ^ RIHtHt ^ RIHt ^ RIHt ^ RIHt ^ R	IHtHt ^ R
IHt R]R]3R ltR tRR ltR tRR ltR]3R ltR# )zJ
Module to evaluate the proposition with assumptions using SAT algorithm.
)S)Symbol)
NumberKindUndefinedKind)get_all_known_matrix_factsget_all_known_number_facts)global_assumptionsAppliedPredicate)class_fact_registry)oo)satisfiable)CNF
EncodedCNF)
MatrixKindTc                V   \         P                  ! V 4      p\         P                  ! V ( 4      p\         P                  ! V4      p\        4       pV'       d   VP                  V4      p\        WQVW4R7      pVP	                  V4       V'       d   VP	                  V4       \        WVV4      # )a  
Function to evaluate the proposition with assumptions using SAT algorithm.

This function extracts every fact relevant to the expressions composing
proposition and assumptions. For example, if a predicate containing
``Abs(x)`` is proposed, then ``Q.zero(Abs(x)) | Q.positive(Abs(x))``
will be found and passed to SAT solver because ``Q.nonnegative`` is
registered as a fact for ``Abs``.

Proposition is evaluated to ``True`` or ``False`` if the truth value can be
determined. If not, ``None`` is returned.

Parameters
==========

proposition : Any boolean expression.
    Proposition which will be evaluated to boolean value.

assumptions : Any boolean expression, optional.
    Local assumptions to evaluate the *proposition*.

context : AssumptionsContext, optional.
    Default assumptions to evaluate the *proposition*. By default,
    this is ``sympy.assumptions.global_assumptions`` variable.

use_known_facts : bool, optional.
    If ``True``, facts from ``sympy.assumptions.ask_generated``
    module are passed to SAT solver as well.

iterations : int, optional.
    Number of times that relevant facts are recursively extracted.
    Default is infinite times until no new fact is found.

Returns
=======

``True``, ``False``, or ``None``

Examples
========

>>> from sympy import Abs, Q
>>> from sympy.assumptions.satask import satask
>>> from sympy.abc import x
>>> satask(Q.zero(Abs(x)), Q.zero(x))
True

)use_known_facts
iterations)r   	from_propextendget_all_relevant_factsadd_from_cnfcheck_satisfiability)	propositionassumptionscontextr   r   props_propscontext_cnfsats	   &&&&&    V/var/www/html/photoedit/myenv/lib/python3.14/site-packages/sympy/assumptions/satask.pysataskr       s    d MM+&E]]K<(F--,K%K!((1
 ['@C[!%s33    c                 \   VP                  4       pVP                  4       pVP                  V 4       VP                  V4       \        V4      p\        V4      pV'       d   V'       d   R # V'       d   V'       g   R# V'       g   V'       d   R# V'       g   V'       g   \        R4      hR # R # )NTFzInconsistent assumptions)copyr   r   
ValueError)prop_propfactbasesat_true	sat_falsecan_be_truecan_be_falses   &&&    r   r   r   U   sz    }}HI$5!h'Ky)L|<<| 344	  ,;r!   Nc                   \        V 4      pV P                  4       p\        4       pV'       d   WQP                  4       ,          pV'       d   WRP                  4       ,          pV\        P                  \        P
                  0,
          pRpV\        4       8w  dP   \        4       pV F-  p\        V4      p	W,          \        4       8w  g   K%  Wy,          pK/  	  Ws,
          pW6,          pK^  YE Uu0 uF&  p\        V4      V,          \        4       8w  g   K$  VkK(  	  up,          p\        4       p
V FH  p\        V\        4      '       d   V
\        VP                  4      ,          p
K7  V
P                  V4       KJ  	  V
# u upi )a  
Extract every expression in the argument of predicates from *proposition*,
*assumptions* and *context*.

Parameters
==========

proposition : sympy.assumptions.cnf.CNF

assumptions : sympy.assumptions.cnf.CNF, optional.

context : sympy.assumptions.cnf.CNF, optional.
    CNF generated from assumptions context.

Examples
========

>>> from sympy import Q, Abs
>>> from sympy.assumptions.cnf import CNF
>>> from sympy.assumptions.satask import extract_predargs
>>> from sympy.abc import x, y
>>> props = CNF.from_prop(Q.zero(Abs(x*y)))
>>> assump = CNF.from_prop(Q.zero(x) & Q.zero(y))
>>> extract_predargs(props, assump)
{x, y, Abs(x*y)}

N)
find_symbolsall_predicatessetr   truefalse
isinstancer	   	argumentsadd)r   r   r   req_keyskeyslkeystmp_keystmplsymsexprskeys   &&&         r   extract_predargsr>   m   s&   8 K(H%%'DEE++--''))QVVQWW%%EH
ce
eA?DCE)  >E1a8!;su!DQQEEDEEc+,,S''EIIcN	 
 L Fs   -!E<E<c                    \        V \        4      '       d6   \        4       pV P                  4        F  pV\	        V4      ,          pK  	  V# V P                  \        4      # )zo
Find every :obj:`~.Symbol` in *pred*.

Parameters
==========

pred : sympy.assumptions.cnf.CNF, or any Expr.

)r2   r   r/   r.   r-   atomsr   )predsymbolsas   &  r   r-   r-      sM     $%$$&A|A&G '::fr!   c                h   V'       g   \        4       p\        4       pV  F  p\        V4       Fu  p\         P                  ! V4      pVP	                  V4      pVP                  4        F7  p\        V\        4      '       g   K  V\        VP                  4      ,          pK9  	  Kw  	  K  	  W ,
          V3# )a^  
Extract relevant facts from the items in *exprs*. Facts are defined in
``assumptions.sathandlers`` module.

This function is recursively called by ``get_all_relevant_facts()``.

Parameters
==========

exprs : set
    Expressions whose relevant facts are searched.

relevant_facts : sympy.assumptions.cnf.CNF, optional.
    Pre-discovered relevant facts.

Returns
=======

exprs : set
    Candidates for next relevant fact searching.

relevant_facts : sympy.assumptions.cnf.CNF
    Updated relevant facts.

Examples
========

Here, we will see how facts relevant to ``Abs(x*y)`` are recursively
extracted. On the first run, set containing the expression is passed
without pre-discovered relevant facts. The result is a set containing
candidates for next run, and ``CNF()`` instance containing facts
which are relevant to ``Abs`` and its argument.

>>> from sympy import Abs
>>> from sympy.assumptions.satask import get_relevant_clsfacts
>>> from sympy.abc import x, y
>>> exprs = {Abs(x*y)}
>>> exprs, facts = get_relevant_clsfacts(exprs)
>>> exprs
{x*y}
>>> facts.clauses #doctest: +SKIP
{frozenset({Literal(Q.odd(Abs(x*y)), False), Literal(Q.odd(x*y), True)}),
frozenset({Literal(Q.zero(Abs(x*y)), False), Literal(Q.zero(x*y), True)}),
frozenset({Literal(Q.even(Abs(x*y)), False), Literal(Q.even(x*y), True)}),
frozenset({Literal(Q.zero(Abs(x*y)), True), Literal(Q.zero(x*y), False)}),
frozenset({Literal(Q.even(Abs(x*y)), False),
            Literal(Q.odd(Abs(x*y)), False),
            Literal(Q.odd(x*y), True)}),
frozenset({Literal(Q.even(Abs(x*y)), False),
            Literal(Q.even(x*y), True),
            Literal(Q.odd(Abs(x*y)), False)}),
frozenset({Literal(Q.positive(Abs(x*y)), False),
            Literal(Q.zero(Abs(x*y)), False)})}

We pass the first run's results to the second run, and get the expressions
for next run and updated facts.

>>> exprs, facts = get_relevant_clsfacts(exprs, relevant_facts=facts)
>>> exprs
{x, y}

On final run, no more candidate is returned thus we know that all
relevant facts are successfully retrieved.

>>> exprs, facts = get_relevant_clsfacts(exprs, relevant_facts=facts)
>>> exprs
set()

)	r   r/   r
   to_CNF_andr.   r2   r	   r3   )r<   relevant_factsnewexprsexprfactnewfactr=   s   &&     r   get_relevant_clsfactsrL      s    L uH'-Djj&G+009N--/c#344CMM 22H 0 .  ^++r!   c                *  a ^ p\        4       p\        4       p V^ 8X  d   \        WV4      pVX,          p\        W4      w  rV^,          pWT8  d   MV'       d   KD   V'       Ed   \        4       p	\        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   V	P                  \        4       4       \        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   V	P                  \        4       4       \        4       p
V
P                  V	4       R oV3R lp. p. p\        V
P                  4      p\        V4       FL  w  r_YP                   Uu. uF  pV! V4      NK  	  up,          pW! V
P                  W^,          4      ,          pKN  	  \        \        \!        V\#        ^\        V4      ^,           4      4      4      4      p\        VV4      pM
\        4       pVP%                  V4       V# u upi )a  
Extract all relevant facts from *proposition* and *assumptions*.

This function extracts the facts by recursively calling
``get_relevant_clsfacts()``. Extracted facts are converted to
``EncodedCNF`` and returned.

Parameters
==========

proposition : sympy.assumptions.cnf.CNF
    CNF generated from proposition expression.

assumptions : sympy.assumptions.cnf.CNF
    CNF generated from assumption expression.

context : sympy.assumptions.cnf.CNF
    CNF generated from assumptions context.

use_known_facts : bool, optional.
    If ``True``, facts from ``sympy.assumptions.ask_generated``
    module are encoded as well.

iterations : int, optional.
    Number of times that relevant facts are recursively extracted.
    Default is infinite times until no new fact is found.

Returns
=======

sympy.assumptions.cnf.EncodedCNF

Examples
========

>>> from sympy import Q
>>> from sympy.assumptions.cnf import CNF
>>> from sympy.assumptions.satask import get_all_relevant_facts
>>> from sympy.abc import x, y
>>> props = CNF.from_prop(Q.nonzero(x*y))
>>> assump = CNF.from_prop(Q.nonzero(x))
>>> context = CNF.from_prop(Q.nonzero(y))
>>> get_all_relevant_facts(props, assump, context) #doctest: +SKIP
<sympy.assumptions.cnf.EncodedCNF at 0x7f09faa6ccd0>

Tc              3   X   "   T F   qP                   \        \        4      8H  x  K"  	  R # 5iN)kindr   r   .0rI   s   & r   	<genexpr>)get_all_relevant_facts.<locals>.<genexpr>R  s     IytyyJz22ys   (*Fc              3   |   "   T F2  qP                   \        8H  ;'       g    VP                   \        8H  x  K4  	  R # 5irO   )rP   r   r   rQ   s   & r   rS   rT   U  s-     aW`tj(IIdii=.HIW`s   <<c                 0    V ^ 8  d	   W,           # W,
          # )     )litdeltas   &&r   translate_literal1get_all_relevant_facts.<locals>.translate_literal[  s    Qw{"{"r!   c                 l   < V  UUu. uF  q" Uu0 uF  pS! W14      kK  	  upNK  	  upp# u upi u uppi rO   rX   )datarZ   clauseir[   s   &&  r   translate_data.get_all_relevant_facts.<locals>.translate_dataa  s5    PTUPTf&A&Q&q0&APTUUAUs   0+00)r   r/   r>   rL   anyadd_clausesr   r   r   from_cnflenrB   	enumerater^   dictlistzipranger   )r   r   r   r   r   r`   rG   	all_exprsr<   known_facts_CNF
kf_encodedra   r^   rB   n_litrI   rA   encodingctxr[   s   &&&&&              @r   r   r     s   h 	
AUNI
6$[wGEU	 5e L	Q?u%3IyI333IyIII''(B(DE3aW`a333aW`aaa''(B(DE\
O,	#	VJ&&' +GA/A/AB/AtT
/ABBGN:??AI>>D , S%3w<>*BCDEx(l^$J Cs   1H)NNrO   )__doc__sympy.core.singletonr   sympy.core.symbolr   sympy.core.kindr   r   sympy.assumptions.ask_generatedr   r   sympy.assumptions.assumer   r	   sympy.assumptions.sathandlersr
   
sympy.corer   sympy.logic.inferencer   sympy.assumptions.cnfr   r   sympy.matrices.kindr   r    r   r>   r-   rL   r   rX   r!   r   <module>r}      sb    # $ 5 b I =  - 1 * %)2DA4H507r$R,l dr!   