U
    —9%e%  ã                   @   s   d dl mZ ddd„ZdS )é    )Ú
EncodedCNFFc                    s¶   t ˆ tƒstƒ }| ˆ ¡ |‰ ddlm} dhˆ jkrL|rHdd„ dD ƒS dS |ˆ jƒ}ˆrv| dd„ t| ¡ ƒD ƒ¡ | 	¡ s‚dS |sœ‡ fd	d
„| 
¡ D ƒS ‡ ‡fdd„}||ƒS d S )Nr   )Ú	Minisat22c                 s   s   | ]
}|V  qd S )N© )Ú.0Úfr   r   úg/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/sympy/logic/algorithms/minisat22_wrapper.pyÚ	<genexpr>   s     z(minisat22_satisfiable.<locals>.<genexpr>)FFc                 S   s   g | ]}|d   ‘qS )é   r   ©r   Úir   r   r   Ú
<listcomp>   s     z)minisat22_satisfiable.<locals>.<listcomp>c                    s$   i | ]}ˆ j t|ƒd   |dk“qS ©r	   r   ©ÚsymbolsÚabs©r   Zlit©Úexprr   r   Ú
<dictcomp>   s      z)minisat22_satisfiable.<locals>.<dictcomp>c                 3   sn   d}|   ¡ r\|  ¡ }‡ fdd„|D ƒV  ˆrB|  dd„ |D ƒ¡ n|  dd„ |D ƒ¡ d}q|sfdV  t‚d S )NFc                    s$   i | ]}ˆ j t|ƒd   |dk“qS r   r   r   r   r   r   r   #   s      z7minisat22_satisfiable.<locals>._gen.<locals>.<dictcomp>c                 S   s   g | ]}|d kr| ‘qS )r   r   r
   r   r   r   r   %   s      z7minisat22_satisfiable.<locals>._gen.<locals>.<listcomp>c                 S   s   g | ]
}| ‘qS r   r   r
   r   r   r   r   '   s     T)ÚsolveÚ	get_modelZ
add_clauseÚStopIteration)ÚresultsZsatisfiableZsol©r   Úminimalr   r   Ú_gen   s    z#minisat22_satisfiable.<locals>._gen)Ú
isinstancer   Zadd_propZpysat.solversr   ÚdataZ
set_phasesÚrangeZnof_varsr   r   )r   Z
all_modelsr   Úexprsr   Úrr   r   r   r   Úminisat22_satisfiable   s$    


r!   N)FF)Zsympy.assumptions.cnfr   r!   r   r   r   r   Ú<module>   s   