ó
    ‰*£h#  ã                   óœ   • S r SSKJrJrJrJrJr  SSKJr  SSK	J
r
  SSKJr  S rSS jrS	 rSS
 jrSS jr " S S5      r " S S\5      rg)z Inference in propositional logicé    )ÚAndÚNotÚ	conjunctsÚto_cnfÚBooleanFunction)Úordered)Úsympify)Úimport_modulec                 ó¨   • U SL d  U SL a  U $ U R                   (       a  U $ U R                  (       a  [        U R                  S   5      $ [	        S5      e)zË
The symbol in this literal (without the negation).

Examples
========

>>> from sympy.abc import A
>>> from sympy.logic.inference import literal_symbol
>>> literal_symbol(A)
A
>>> literal_symbol(~A)
A

TFr   z#Argument must be a boolean literal.)Ú	is_SymbolÚis_NotÚliteral_symbolÚargsÚ
ValueError)Úliterals    ÚR/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sympy/logic/inference.pyr   r   	   sK   € ð  �$‚˜' UÒ*ØˆØ	×	×	ØˆØ	��Ü˜gŸl™l¨1™oÓ.Ð.äÐ>Ó?Ð?ó    Nc                 óÊ  • U(       a  Ub  US:w  a  [        SU S35      eSnUb  US:X  a$  [        S5      nUb  SnOUS:X  a  [        S5      eSnUS:X  a  [        S5      nUc  SnUS:X  a  [        S5      nUc  SnUS	:X  a  S
SKJn  U" U 5      $ US:X  a  S
SKJn  U" XUS9$ US:X  a  S
SKJn	  U	" X5      $ US:X  a  S
SKJ	n
  U
" XU5      $ US:X  a  S
SK
Jn  U" X5      $ [        e)aJ  
Check satisfiability of a propositional sentence.
Returns a model when it succeeds.
Returns {true: true} for trivially true expressions.

On setting all_models to True, if given expr is satisfiable then
returns a generator of models. However, if expr is unsatisfiable
then returns a generator containing the single element False.

Examples
========

>>> from sympy.abc import A, B
>>> from sympy.logic.inference import satisfiable
>>> satisfiable(A & ~B)
{A: True, B: False}
>>> satisfiable(A & ~A)
False
>>> satisfiable(True)
{True: True}
>>> next(satisfiable(A & ~A, all_models=True))
False
>>> models = satisfiable((A >> B) & B, all_models=True)
>>> next(models)
{A: False, B: True}
>>> next(models)
{A: True, B: True}
>>> def use_models(models):
...     for model in models:
...         if model:
...             # Do something with the model.
...             print(model)
...         else:
...             # Given expr is unsatisfiable.
...             print("UNSAT")
>>> use_models(satisfiable(A >> ~A, all_models=True))
{A: False}
>>> use_models(satisfiable(A ^ A, all_models=True))
UNSAT

Údpll2z2Currently only dpll2 can handle using lra theory. z is not handled.Úpycosatzpycosat module is not presentÚ	minisat22ÚpysatÚz3Údpllr   )Údpll_satisfiable)Úuse_lra_theory)Úpycosat_satisfiable)Úminisat22_satisfiable)Úz3_satisfiable)r   r
   ÚImportErrorÚsympy.logic.algorithms.dpllr   Úsympy.logic.algorithms.dpll2Ú&sympy.logic.algorithms.pycosat_wrapperr   Ú(sympy.logic.algorithms.minisat22_wrapperr   Ú!sympy.logic.algorithms.z3_wrapperr   ÚNotImplementedError)ÚexprÚ	algorithmÚ
all_modelsÚminimalr   r   r   r   r   r   r   r   s               r   Úsatisfiabler+   #   s  € öT ØÑ  Y°'Ó%9ÜÐQÐR[ÐQ\Ð\lÐmÓnÐnØˆ	àÑ˜I¨Ó2Ü 	Ó*ˆØÑØ!‰Ià˜IÓ%Ü!Ð"AÓBÐBð  ˆIà�+ÓÜ˜gÓ&ˆØ‰=ØˆIà�$ƒÜ˜4Ó ˆØ‰:ØˆIà�FÓÝ@Ù Ó%Ð%Ø	�gÓ	ÝAÙ ÀÑPÐPØ	�iÓ	ÝNÙ" 4Ó4Ð4Ø	�kÓ	!ÝRÙ$ T°wÓ?Ð?Ø	�dÓ	ÝDÙ˜dÓ/Ð/ä
Ðr   c                 ó4   • [        [        U 5      5      (       + $ )a@  
Check validity of a propositional sentence.
A valid propositional sentence is True under every assignment.

Examples
========

>>> from sympy.abc import A, B
>>> from sympy.logic.inference import valid
>>> valid(A | ~A)
True
>>> valid(A | B)
False

References
==========

.. [1] https://en.wikipedia.org/wiki/Validity

)r+   r   )r'   s    r   Úvalidr-   z   s   € ô* œ3˜t›9Ó%Ô%Ð%r   c                 óþ  ^^^• SSK Jm  SmUUU4S jmU T;   a  U $ [        U 5      n T" U 5      (       d  [        SU -  5      eU(       d  0 nUR	                  5        VVs0 s H  u  p4UT;   d  M  X4_M     nnnU R                  U5      nUT;   a  [        U5      $ U(       aX  [        R                  UR                  5       S5      n[        XQ5      (       a  [        U5      (       a  g g[        U5      (       d  ggs  snnf )	a³  
Returns whether the given assignment is a model or not.

If the assignment does not specify the value for every proposition,
this may return None to indicate 'not obvious'.

Parameters
==========

model : dict, optional, default: {}
    Mapping of symbols to boolean values to indicate assignment.
deep: boolean, optional, default: False
    Gives the value of the expression under partial assignments
    correctly. May still return None to indicate 'not obvious'.


Examples
========

>>> from sympy.abc import A, B
>>> from sympy.logic.inference import pl_true
>>> pl_true( A & B, {A: True, B: True})
True
>>> pl_true(A & B, {A: False})
False
>>> pl_true(A & B, {A: True})
>>> pl_true(A & B, {A: True}, deep=True)
>>> pl_true(A >> (B >> A))
>>> pl_true(A >> (B >> A), deep=True)
True
>>> pl_true(A & ~A)
>>> pl_true(A & ~A, deep=True)
False
>>> pl_true(A & B & (~A | ~B), {A: True})
>>> pl_true(A & B & (~A | ~B), {A: True}, deep=True)
False

r   )ÚSymbol)TFc                 óž   >• [        U T5      (       d  U T;   a  g[        U [        5      (       d  g[        U4S jU R                   5       5      $ )NTFc              3   ó4   >#   • U  H  nT" U5      v •  M     g 7f©N© )Ú.0ÚargÚ	_validates     €r   Ú	<genexpr>Ú-pl_true.<locals>._validate.<locals>.<genexpr>Ã   s   øé € Ð7ªY c‘9˜S—>�>ªYùs   ƒ)Ú
isinstancer   Úallr   )r'   r/   r6   Úbooleans    €€€r   r6   Úpl_true.<locals>._validate¾   s>   ø€ Ü�d˜F×#Ñ# t¨w£ØÜ˜$¤×0Ñ0ØÜÔ7¨T¯YªYÓ7Ó7Ð7r   z$%s is not a valid boolean expressionTFN)Úsympy.core.symbolr/   r	   r   ÚitemsÚsubsÚboolÚdictÚfromkeysÚatomsÚpl_truer-   r+   )	r'   ÚmodelÚdeepÚkÚvÚresultr/   r6   r;   s	         @@@r   rD   rD   ’   sä   ú€ õP )à€G÷8ð ˆwƒØˆÜ�4‹=€DÙ�T�?‰?ÜÐ?À$ÑFÓGÐGÞØˆØ#Ÿk™kœmÔ<šm‘d�a¨q°G©|‹TˆQŠT™m€EÑ<Ø�Y‰Y�uÓ€FØ�ÓÜ�F‹|ÐÞÜ—‘˜fŸl™l›n¨dÓ3ˆÜ�6×!Ñ!Ü�V�}‰}Øð ð
 ô ˜v×&Ñ&ØØùó =s   ÁC9Á.C9c                 óŒ   • U(       a  [        U5      nO/ nUR                  [        U 5      5        [        [	        U6 5      (       + $ )a°  
Check whether the given expr_set entail an expr.
If formula_set is empty then it returns the validity of expr.

Examples
========

>>> from sympy.abc import A, B, C
>>> from sympy.logic.inference import entails
>>> entails(A, [A >> B, B >> C])
False
>>> entails(C, [A >> B, B >> C, A])
True
>>> entails(A >> B)
False
>>> entails(A >> (B >> A))
True

References
==========

.. [1] https://en.wikipedia.org/wiki/Logical_consequence

)ÚlistÚappendr   r+   r   )r'   Úformula_sets     r   ÚentailsrN   Û   s;   € ö2 Ü˜;Ó'‰àˆØ×Ñ”s˜4“yÔ!Üœ3 Ð,Ó-Ô-Ð-r   c                   óD   • \ rS rSrSrS
S jrS rS rS r\	S 5       r
S	rg)ÚKBéü   z"Base class for all knowledge basesNc                 óT   • [        5       U l        U(       a  U R                  U5        g g r2   )ÚsetÚclauses_Útell©ÚselfÚsentences     r   Ú__init__ÚKB.__init__þ   s   € Ü›ˆŒÞØ�I‰I�hÕð r   c                 ó   • [         er2   ©r&   rV   s     r   rU   ÚKB.tell  ó   € Ü!Ð!r   c                 ó   • [         er2   r\   ©rW   Úquerys     r   ÚaskÚKB.ask  r^   r   c                 ó   • [         er2   r\   rV   s     r   ÚretractÚ
KB.retract	  r^   r   c                 ó>   • [        [        U R                  5      5      $ r2   )rK   r   rT   )rW   s    r   ÚclausesÚ
KB.clauses  s   € ä”G˜DŸM™MÓ*Ó+Ð+r   )rT   r2   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rY   rU   rb   re   Úpropertyrh   Ú__static_attributes__r3   r   r   rP   rP   ü   s-   † Ù,ô ò
"ò"ò"ð ñ,ó ó,r   rP   c                   ó*   • \ rS rSrSrS rS rS rSrg)ÚPropKBi  z=A KB for Propositional Logic.  Inefficient, with no indexing.c                 óp   • [        [        U5      5       H  nU R                  R                  U5        M      g)zùAdd the sentence's clauses to the KB

Examples
========

>>> from sympy.logic.inference import PropKB
>>> from sympy.abc import x, y
>>> l = PropKB()
>>> l.clauses
[]

>>> l.tell(x | y)
>>> l.clauses
[x | y]

>>> l.tell(y)
>>> l.clauses
[y, x | y]

N)r   r   rT   Úadd©rW   rX   Úcs      r   rU   ÚPropKB.tell  s*   € ô* œ6 (Ó+Ö,ˆAØ�M‰M×Ñ˜aÖ ò -r   c                 ó,   • [        XR                  5      $ )zàChecks if the query is true given the set of clauses.

Examples
========

>>> from sympy.logic.inference import PropKB
>>> from sympy.abc import x, y
>>> l = PropKB()
>>> l.tell(x & ~y)
>>> l.ask(x)
True
>>> l.ask(y)
False

)rN   rT   r`   s     r   rb   Ú
PropKB.ask,  s   € ô  �uŸm™mÓ,Ð,r   c                 óp   • [        [        U5      5       H  nU R                  R                  U5        M      g)zýRemove the sentence's clauses from the KB

Examples
========

>>> from sympy.logic.inference import PropKB
>>> from sympy.abc import x, y
>>> l = PropKB()
>>> l.clauses
[]

>>> l.tell(x | y)
>>> l.clauses
[x | y]

>>> l.retract(x | y)
>>> l.clauses
[]

N)r   r   rT   Údiscardru   s      r   re   ÚPropKB.retract>  s*   € ô* œ6 (Ó+Ö,ˆAØ�M‰M×!Ñ! !Ö$ò -r   r3   N)	rj   rk   rl   rm   rn   rU   rb   re   rp   r3   r   r   rr   rr     s   † ÙGò!ò0-õ$%r   rr   )NFFF)NFr2   )rn   Úsympy.logic.boolalgr   r   r   r   r   Úsympy.core.sortingr   Úsympy.core.sympifyr	   Úsympy.external.importtoolsr
   r   r+   r-   rD   rN   rP   rr   r3   r   r   Ú<module>r�      sN   ðÙ &ç LÕ LÝ &Ý &Ý 4ò@ô4Tòn&ô0FôR.÷B,ñ ,ô*C%ˆRõ C%r   