�
��g# � � � d Z ddlmZmZmZmZmZ ddlmZ ddl m
Z
ddlmZ d� Z
dd �Zd
� Zdd�Zdd�Z G d
� d� � Z G d� de� � ZdS )z Inference in propositional logic� )�And�Not� conjuncts�to_cnf�BooleanFunction)�ordered)�sympify)�
import_modulec � � | du s| du r| S | j r| S | j rt | j d � � S t d� � �)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 �e/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/sympy/logic/inference.pyr r s[ � � �$���'�U�*�*��� � � @��� �� @��g�l�1�o�.�.�.��>�?�?�?� NFc � � |r|�|dk rt d|� d�� � �d}|�|dk r+t d� � }|�d}n|dk rt d� � �d}|dk rt d� � }|�d}|d k rt d � � }|�d}|d
k rddlm} || � � S |dk rddlm} || ||�
� � S |dk rddlm} | | |� � S |dk rddlm }
|
| ||� � S |d k rddl
m} || |� � S t �)a�
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
N�dpll2z2Currently only dpll2 can handle using lra theory. z is not handled.�pycosatzpycosat 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�%9��m�R[�m�m�m�n�n�n�� ���I��2�2�� �*�*����!�I�I��I�%�%�!�"A�B�B�B� �I��+����g�&�&���=��I��$���
�4�
�
��
�:��I��F���@�@�@�@�@�@����%�%�%� �g� � �A�A�A�A�A�A����j��P�P�P�P� �i� � �N�N�N�N�N�N�"�"�4��4�4�4� �k� !� !�R�R�R�R�R�R�$�$�T�:�w�?�?�?� �d� � �D�D�D�D�D�D��~�d�J�/�/�/�
�r c �<