+
    
þÎjùS  ã                   ó‚   € R t ^ RIHt ^ RIHtHt ^ RIHt ^ RIH	t	 ^ RI
Ht RR ltR t ! R R	4      t ! R
 R4      tR# )z«Implementation of DPLL algorithm

Features:
  - Clause learning
  - Watch literal scheme
  - VSIDS heuristic

References:
  - https://en.wikipedia.org/wiki/DPLL_algorithm
)Údefaultdict)ÚheappushÚheappop)Úordered)Ú
EncodedCNF)Ú	LRASolverc                óø  € \        V \        4      '       g   \        4       pVP                  V 4       Tp ^ 0V P                  9   d   V'       d
   R R 4       # R# V'       d   \        P
                  ! V 4      w  rEMRp. p\        V P                  V,           V P                  \        4       V P                  VR7      pVP                  4       pV'       d   \        V4      #  \        V4      #   \         d     R# i ; i)ah  
Check satisfiability of a propositional sentence.
It returns a model rather than True when it succeeds.
Returns a generator of all models if all_models is True.

Examples
========

>>> from sympy.abc import A, B
>>> from sympy.logic.algorithms.dpll2 import dpll_satisfiable
>>> dpll_satisfiable(A & ~B)
{A: True, B: False}
>>> dpll_satisfiable(A & ~A)
False

c              3   ó$   "  € T F  qx € K  	  R # 5i©N© )Ú.0Úfs   & ÚR/opt/data/home/.local/lib/python3.14/site-packages/sympy/logic/algorithms/dpll2.pyÚ	<genexpr>Ú#dpll_satisfiable.<locals>.<genexpr>.   s   é € Ð'™w˜!”A›wùs   ‚FN)Ú
lra_theory©F)Ú
isinstancer   Úadd_propÚdatar   Úfrom_encoded_cnfÚ	SATSolverÚ	variablesÚsetÚsymbolsÚ_find_modelÚ_all_modelsÚnextÚStopIteration)ÚexprÚ
all_modelsÚuse_lra_theoryÚexprsÚlraÚimmediate_conflictsÚsolverÚmodelss   &&&     r   Údpll_satisfiabler'      sÒ   € ô" �dœJ×'Ò'Ü“ˆØ�‰�tÔØˆð 	
€sˆd�i‰iÔßÙ'™wÓ'Ð'ÙçÜ#,×#=Ò#=¸dÓ#CÑ ˆÐ àˆØ ÐÜ�t—y‘yÐ#6Õ6¸¿¹ÌËÈtÏ|É|ÐhkÔl€FØ×ÑÓ!€FçÜ˜6Ó"Ð"ðÜ�F‹|ÐøÜô Úðús   Ã
C* Ã*C9Ã8C9c              #   óv   "  € R p  \        V 4      x € RpK    \         d    T'       g   R x €  R#  R# i ; i5i)FTN)r   r   )r&   Úsatisfiables   & r   r   r   G   s<   é € Ø€KðØÜ�v“,ÒØŠKøÜô ßØ�Kò ðüs   ‚9† ˜6«6¯9µ6¶9c                   ó²   a € ] tR t^Rt o RtRR ltR tR tR t]	R 4       t
R tR	 tR
 tR t R tR tR tR tR tR tR tR tR tR tR tR tRtV tR# )r   zr
Class for representing a SAT solver capable of
 finding a model to a boolean theory in conjunctive
 normal form.
Nc	                ó  € W0n         WPn        R V n        . V n        . V n        Wpn        Vf   \        \        V4      4      V n        MW@n        V P                  V4       V P                  V4       RV8X  dV   V P                  4        V P                  V n        V P                  V n        V P                   V n        V P$                  V n        M\(        hRV8X  dI   V P*                  V n        V P.                  V n        V P                  P3                  V P4                  4       MRV8X  d   R V n        R V n        M\(        h\7        ^ 4      .V n        W0P:                  n        ^ V n        ^ V n         \C        V PD                  4      V n#        W€n$        R# )FNÚvsidsÚsimpleÚnonec                 ó   € R # r
   r   )Úxs   &r   Ú<lambda>Ú$SATSolver.__init__.<locals>.<lambda>~   s   € ±ó    c                  ó   € R # r
   r   r   r3   r   r1   r2      s   € ©Dr3   )%Úvar_settingsÚ	heuristicÚis_unsatisfiedÚ_unit_prop_queueÚupdate_functionsÚINTERVALÚlistr   r   Ú_initialize_variablesÚ_initialize_clausesÚ_vsids_initÚ_vsids_calculateÚheur_calculateÚ_vsids_lit_assignedÚheur_lit_assignedÚ_vsids_lit_unsetÚheur_lit_unsetÚ_vsids_clause_addedÚheur_clause_addedÚNotImplementedErrorÚ_simple_add_learned_clauseÚadd_learned_clauseÚ_simple_compute_conflictÚcompute_conflictÚappendÚ_simple_clean_clausesÚLevelÚlevelsÚ_current_levelÚvarsettingsÚnum_decisionsÚnum_learned_clausesÚlenÚclausesÚoriginal_num_clausesr#   )	ÚselfrU   r   r5   r   r6   Úclause_learningr:   r   s	   &&&&&&&&&r   Ú__init__ÚSATSolver.__init__Y   sV  € ð )ÔØ"ŒØ#ˆÔØ "ˆÔØ "ˆÔØ ŒàŠ?Ü¤¨	Ó 2Ó3ˆD�Là"ŒLà×"Ñ" 9Ô-Ø× Ñ  Ô)à�iÔØ×ÑÔØ"&×"7Ñ"7ˆDÔØ%)×%=Ñ%=ˆDÔ"Ø"&×"7Ñ"7ˆDÔØ%)×%=Ñ%=ˆDÕ"ô &Ð%à�Ô&Ø&*×&EÑ&EˆDÔ#Ø$(×$AÑ$AˆDÔ!Ø×!Ñ!×(Ñ(¨×)CÑ)CÕDØ�Ô&Ù&4ˆDÔ#Ù$0ˆDÕ!ä%Ð%ô ˜Q“x�jˆŒØ*6×ÑÔ'ð ˆÔØ#$ˆÔ Ü$'¨¯©Ó$5ˆÔ!àŽr3   c                ó”   € \        \        4      V n        \        \        4      V n        R.\        V4      ^,           ,          V n        R# )z+Set up the variable data structures needed.FN)r   r   Ú	sentinelsÚintÚoccurrence_countrT   Úvariable_set)rW   r   s   &&r   r<   ÚSATSolver._initialize_variablesŽ   s3   € ä$¤SÓ)ˆŒÜ +¬CÓ 0ˆÔØ"˜G¤s¨9£~¸Õ'9Õ:ˆÖr3   c                óè  € V Uu. uF  p\        V4      NK  	  upV n        \        V P                  4       F³  w  r2^\        V4      8X  d%   V P                  P                  V^ ,          4       K9  V P                  V^ ,          ,          P                  V4       V P                  VR,          ,          P                  V4       V F"  pV P                  V;;,          ^,          uu&   K$  	  Kµ  	  R# u upi )a  Set up the clause data structures needed.

For each clause, the following changes are made:
- Unit clauses are queued for propagation right away.
- Non-unit clauses have their first and last literals set as sentinels.
- The number of clauses a literal appears in is computed.
Néÿÿÿÿ)	r;   rU   Ú	enumeraterT   r8   rL   r\   Úaddr^   )rW   rU   ÚclauseÚiÚlits   &&   r   r=   ÚSATSolver._initialize_clauses”   s·   € ñ 4;Ó;±7¨œ˜Vž±7Ñ;ˆŒä" 4§<¡<Ö0‰IˆAð ”C˜“KÔØ×%Ñ%×,Ñ,¨V°A­YÔ7Ùà�N‰N˜6 !�9Õ%×)Ñ)¨!Ô,Ø�N‰N˜6 "�:Õ&×*Ñ*¨1Ô-ã�Ø×%Ñ% c×*¨aÕ/Õ*ó ó 1ùò <s   …C/c              #  ó¾  a"  € RpV P                  4        V P                  '       d   R#  V P                  V P                  ,          ^ 8X  d   V P                   F
  pV! 4        K  	  V'       d   RpV P
                  P                  pEMWV P                  4       pV ;P                  ^,          un        ^ V8X  Ed   V P                  '       dj   V P                   F$  pV P                  P                  V4      oSf   K$   M	  V P                  P                  4       oV P                  P                  4        MRoSe   S^ ,          '       dE   V P                   Uu/ uF*  pV P                  \        V4      ^,
          ,          V^ 8„  bK,  	  upx € M’V P                  S^,          4       \         ;QJ d3    V3R lV P
                  P                   4       F  '       g   K   RM(	  RM$! V3R lV P
                  P                   4       4      '       g   V P#                  4        Kz  V P
                  P$                  '       d   V P#                  4        K.  \'        V P(                  4      ^8X  d   R# V P
                  P                  ) pV P#                  4        V P(                  P+                  \-        VRR7      4       RpEK’  V P(                  P+                  \-        V4      4       V P/                  V4       V P                  4        V P                  '       g   EKì  RV n        V P
                  P$                  '       d/   V P#                  4        ^\'        V P(                  4      8X  g   KH  R# V P1                  V P3                  4       4       V P
                  P                  ) pV P#                  4        V P(                  P+                  \-        VRR7      4       RpEK®  u upi 5i)aÞ  
Main DPLL loop. Returns a generator of models.

Variables are chosen successively, and assigned to be either
True or False. If a solution is not found with this setting,
the opposite is chosen and the search continues. The solver
halts when every variable has a setting.

Examples
========

>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())
>>> list(l._find_model())
[{1: True, 2: False, 3: False}, {1: True, 2: True, 3: True}]

>>> from sympy.abc import A, B, C
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set(), [A, B, C])
>>> list(l._find_model())
[{A: True, B: False, C: False}, {A: True, B: True, C: True}]

FNTc              3   ó<   <"  € T F  q) S^,          9   x € K  	  R# 5i)é   Nr   )r   rg   Úress   & €r   r   Ú(SATSolver._find_model.<locals>.<genexpr>ó   s   øé € Ð%aÑ@`¸ d¨c°!­f¦nÓ@`ùs   ƒ)Úflipped)Ú	_simplifyr7   rR   r:   r9   rP   Údecisionr@   r#   r5   Ú
assert_litÚcheckÚreset_boundsr   ÚabsrH   ÚanyÚ_undorn   rT   rO   rL   rN   Ú_assign_literalrI   rK   )rW   Úflip_varÚfuncrg   Úenc_varÚflip_litrl   s   &     @r   r   ÚSATSolver._find_model«   sî  øé € ð8 ˆð 	�‰ÔØ××ÐÙð à×!Ñ! D§M¡MÕ1°QÔ6Ø ×1Ô1�DÙ–Fñ 2÷ à �Ø×)Ñ)×2Ñ2’ð ×)Ñ)Ó+�Ø×"Ò" aÕ'Õ"ð ˜•8ð —x—x�xØ'+×'8Ô'8˜GØ"&§(¡(×"5Ñ"5°gÓ">˜CØ"œÙ %ñ (9ð #Ÿh™hŸn™nÓ.˜ØŸ™×-Ñ-Õ/à"˜Ø’{ c¨!§f¤fà7;×7HÒ7HóJÙ7H°ð  $Ÿ|™|¬C°«H°q­LÕ9Ø$'¨!¡Gò ,Ù7HñJó Jð ×7Ñ7¸¸A½Ô?÷ #&£#Ô%aÀ×@SÑ@S×@`Ò@`Ó%a§#§#¢#Ô%aÀ×@SÑ@S×@`Ò@`Ó%a×"aÒ"aØ ŸJ™JžLà×-Ñ-×5×5Ð5ØŸ
™
žÜ˜4Ÿ;™;Ó'¨1Ô,ÙØ $× 3Ñ 3× <Ñ <Ð<�HØ—J‘J”LØ—K‘K×&Ñ&¤u¨X¸tÔ'DÔEØ#�HÚð —‘×"Ñ"¤5¨£:Ô.ð × Ñ  Ô%ð �N‰NÔð ×"×"Ó"à&+�Ô#ð ×)Ñ)×1×1Ð1Ø—J‘J”Lð œC §¡Ó,Ö,Ùð ×'Ñ'¨×(=Ñ(=Ó(?Ô@ð !×/Ñ/×8Ñ8Ð8�Ø—
‘
”Ø—‘×"Ñ"¤5¨¸4Ô#@ÔAØ“ùòaJùsX   ƒA+OÁ/AOÃ+OÃ<AOÅ
OÅ0OÆ(OÆ1(OÇ1OÈ-OÈ<COÌ"OÌ9'OÍ%A8Oc                ó(   € V P                   R,          # )a<  The current decision level data structure

Examples
========

>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{1}, {2}], {1, 2}, set())
>>> next(l._find_model())
{1: True, 2: True}
>>> l._current_level.decision
0
>>> l._current_level.flipped
False
>>> l._current_level.var_settings
{1, 2}

rb   )rO   ©rW   s   &r   rP   ÚSATSolver._current_level"  s   € ð& �{‰{˜2�Ðr3   c                ó`   € V P                   V,           F  pW P                  9   g   K   R# 	  R# )a:  Check if a clause is satisfied by the current variable setting.

Examples
========

>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{1}, {-1}], {1}, set())
>>> try:
...     next(l._find_model())
... except StopIteration:
...     pass
>>> l._clause_sat(0)
False
>>> l._clause_sat(1)
True

TF)rU   r5   ©rW   Úclsrg   s   && r   Ú_clause_satÚSATSolver._clause_sat7  s.   € ð$ —<‘< ×$Ð$ˆCØ×'Ñ'Ö'Úñ %ñ r3   c                ó,   € W P                   V,          9   # )aI  Check if a literal is a sentinel of a given clause.

Examples
========

>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())
>>> next(l._find_model())
{1: True, 2: False, 3: False}
>>> l._is_sentinel(2, 3)
True
>>> l._is_sentinel(-3, 1)
False

)r\   )rW   rg   r‚   s   &&&r   Ú_is_sentinelÚSATSolver._is_sentinelN  s   € ð" —n‘n SÕ)Ñ)Ð)r3   c                óö  € V P                   P                  V4       V P                  P                   P                  V4       RV P                  \	        V4      &   V P                  V4       \        V P                  V) ,          4      pV Fì  pV P                  V4      '       d   K  RpV P                  V,           F’  pWQ) 8w  g   K  V P                  WS4      '       d   TpK'  V P                  \	        V4      ,          '       d   KK  V P                  V) ,          P                  V4       V P                  V,          P                  V4       Rp M	  V'       g   KÑ  V P                  P                  V4       Kî  	  R# )a  Make a literal assignment.

The literal assignment must be recorded as part of the current
decision level. Additionally, if the literal is marked as a
sentinel of any clause, then a new sentinel must be chosen. If
this is not possible, then unit propagation is triggered and
another literal is added to the queue to be set in the future.

Examples
========

>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())
>>> next(l._find_model())
{1: True, 2: False, 3: False}
>>> l.var_settings
{-3, -2, 1}

>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())
>>> l._assign_literal(-1)
>>> try:
...     next(l._find_model())
... except StopIteration:
...     pass
>>> l.var_settings
{-1}

TN)r5   rd   rP   r_   rt   rB   r;   r\   rƒ   rU   r†   Úremover8   rL   )rW   rg   Úsentinel_listr‚   Úother_sentinelÚnewlits   &&    r   rw   ÚSATSolver._assign_literala  s$  € ð> 	×Ñ×Ñ˜cÔ"Ø×Ñ×(Ñ(×,Ñ,¨SÔ1Ø&*ˆ×Ñœ#˜c›(Ñ#Ø×Ñ˜sÔ#ä˜TŸ^™^¨S¨DÕ1Ó2ˆã ˆCØ×#Ñ# C×(Ô(Ø!%�Ø"Ÿl™l¨3×/Ð/�FØ –~Ø×,Ñ,¨V×9Ò9Ø-3šNØ!%×!2Ñ!2´3°v³;×!?Ö!?Ø ŸN™N¨C¨4Õ0×7Ñ7¸Ô<Ø ŸN™N¨6Õ2×6Ñ6°sÔ;Ø-1˜NÙ!ñ 0÷ "‘>Ø×)Ñ)×0Ñ0°Ö@ó !r3   c                óü   € V P                   P                   FG  pV P                  P                  V4       V P                  V4       RV P                  \        V4      &   KI  	  V P                  P                  4        R# )aç  
_undo the changes of the most recent decision level.

Examples
========

>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())
>>> next(l._find_model())
{1: True, 2: False, 3: False}
>>> level = l._current_level
>>> level.decision, level.var_settings, level.flipped
(-3, {-3, -2}, False)
>>> l._undo()
>>> level = l._current_level
>>> level.decision, level.var_settings, level.flipped
(0, {1}, False)

FN)rP   r5   r‰   rD   r_   rt   rO   Úpop©rW   rg   s   & r   rv   ÚSATSolver._undo˜  s`   € ð, ×&Ñ&×3Ô3ˆCØ×Ñ×$Ñ$ SÔ)Ø×Ñ Ô$Ø*/ˆD×Ñœc #›hÓ'ñ 4ð 	�‰�‰Ör3   c                óz   € RpV'       d1   RpWP                  4       ,          pWP                  4       ,          pK8  R# )aä  Iterate over the various forms of propagation to simplify the theory.

Examples
========

>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())
>>> l.variable_set
[False, False, False, False]
>>> l.sentinels
{-3: {0, 2}, -2: {3, 4}, 2: {0, 3}, 3: {2, 4}}

>>> l._simplify()

>>> l.variable_set
[False, True, False, False]
>>> l.sentinels
{-3: {0, 2}, -2: {3, 4}, -1: set(), 2: {0, 3},
...3: {2, 4}}

TFN)Ú
_unit_propÚ_pure_literal)rW   Úchangeds   & r   ro   ÚSATSolver._simplify¾  s6   € ð. ˆßØˆGØ—‘Ó(Õ(ˆGØ×)Ñ)Ó+Õ+ŠGñ r3   c                óø   € \        V P                  4      ^ 8„  pV P                  '       dP   V P                  P                  4       pV) V P                  9   d   RV n        . V n        R# V P                  V4       Ka  V# )z/Perform unit propagation on the current theory.TF)rT   r8   r�   r5   r7   rw   )rW   ÚresultÚnext_lits   &  r   r“   ÚSATSolver._unit_propÛ  sm   € ä�T×*Ñ*Ó+¨aÑ/ˆØ×#×#Ð#Ø×,Ñ,×0Ñ0Ó2ˆHØˆy˜D×-Ñ-Ô-Ø&*�Ô#Ø(*�Ô%Ùà×$Ñ$ XÖ.àˆr3   c                ó   € R# )z2Look for pure literals and assign them when found.Fr   r~   s   &r   r”   ÚSATSolver._pure_literalé  s   € ár3   c                óÂ  € . V n         / V n        \        ^\        V P                  4      4       F­  p\        V P                  V,          ) 4      V P                  V&   \        V P                  V) ,          ) 4      V P                  V) &   \        V P                   V P                  V,          V34       \        V P                   V P                  V) ,          V) 34       K¯  	  R# )z>Initialize the data structures needed for the VSIDS heuristic.N)Úlit_heapÚ
lit_scoresÚrangerT   r_   Úfloatr^   r   )rW   Úvars   & r   r>   ÚSATSolver._vsids_initð  s®   € àˆŒØˆŒä˜œC × 1Ñ 1Ó2Ö3ˆCÜ#(¨$×*?Ñ*?ÀÕ*DÐ)DÓ#EˆD�O‰O˜CÑ Ü$)¨4×+@Ñ+@À#ÀÕ+FÐ*FÓ$GˆD�O‰O˜S˜DÑ!Ü�T—]‘] T§_¡_°SÕ%9¸3Ð$?Ô@Ü�T—]‘] T§_¡_°c°TÕ%:¸S¸DÐ$AÖBó	 4r3   c                ó†   € V P                   P                  4        F"  pV P                   V;;,          R,          uu&   K$  	  R# )as  Decay the VSIDS scores for every literal.

Examples
========

>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())

>>> l.lit_scores
{-3: -2.0, -2: -2.0, -1: 0.0, 1: 0.0, 2: -2.0, 3: -2.0}

>>> l._vsids_decay()

>>> l.lit_scores
{-3: -1.0, -2: -1.0, -1: 0.0, 1: 0.0, 2: -1.0, 3: -1.0}

g       @N)rŸ   Úkeysr�   s   & r   Ú_vsids_decayÚSATSolver._vsids_decayû  s/   € ð* —?‘?×'Ñ'Ö)ˆCØ�O‰O˜C×  CÕ'Õ ó *r3   c                óL  € \        V P                  4      ^ 8X  d   ^ # V P                  \        V P                  ^ ,          ^,          4      ,          '       d4   \	        V P                  4       \        V P                  4      ^ 8X  g   Kk  ^ # \	        V P                  4      ^,          # )ay  
    VSIDS Heuristic Calculation

Examples
========

>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())

>>> l.lit_heap
[(-2.0, -3), (-2.0, 2), (-2.0, -2), (0.0, 1), (-2.0, 3), (0.0, -1)]

>>> l._vsids_calculate()
-3

>>> l.lit_heap
[(-2.0, -2), (-2.0, 2), (0.0, -1), (0.0, 1), (-2.0, 3)]

)rT   rž   r_   rt   r   r~   s   &r   r?   ÚSATSolver._vsids_calculate  sr   € ô* ˆt�}‰}Ó Ô"Ùð ×Ñ¤ D§M¡M°!Õ$4°QÕ$7Ó 8×9Ô9Ü�D—M‘MÔ"Ü�4—=‘=Ó! QÖ&Ùä�t—}‘}Ó% aÕ(Ð(r3   c                ó   € R# )z;Handle the assignment of a literal for the VSIDS heuristic.Nr   r�   s   &&r   rA   ÚSATSolver._vsids_lit_assigned3  ó   € ár3   c                óÄ   € \        V4      p\        V P                  V P                  V,          V34       \        V P                  V P                  V) ,          V) 34       R# )a¶  Handle the unsetting of a literal for the VSIDS heuristic.

Examples
========

>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())
>>> l.lit_heap
[(-2.0, -3), (-2.0, 2), (-2.0, -2), (0.0, 1), (-2.0, 3), (0.0, -1)]

>>> l._vsids_lit_unset(2)

>>> l.lit_heap
[(-2.0, -3), (-2.0, -2), (-2.0, -2), (-2.0, 2), (-2.0, 3), (0.0, -1),
...(-2.0, 2), (0.0, 1)]

N)rt   r   rž   rŸ   )rW   rg   r¢   s   && r   rC   ÚSATSolver._vsids_lit_unset7  sI   € ô& �#‹hˆÜ�—‘ §¡°Õ!5°sÐ ;Ô<Ü�—‘ §¡°#°Õ!6¸¸Ð =Ö>r3   c                óˆ   € V ;P                   ^,          un         V F"  pV P                  V;;,          ^,          uu&   K$  	  R# )aÌ  Handle the addition of a new clause for the VSIDS heuristic.

Examples
========

>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())

>>> l.num_learned_clauses
0
>>> l.lit_scores
{-3: -2.0, -2: -2.0, -1: 0.0, 1: 0.0, 2: -2.0, 3: -2.0}

>>> l._vsids_clause_added({2, -3})

>>> l.num_learned_clauses
1
>>> l.lit_scores
{-3: -1.0, -2: -2.0, -1: 0.0, 1: 0.0, 2: -1.0, 3: -2.0}

N)rS   rŸ   r�   s   && r   rE   ÚSATSolver._vsids_clause_addedN  s3   € ð. 	× Ò  AÕ%Õ ÛˆCØ�O‰O˜C×  AÕ%Õ ó r3   c                ó|  € \        V P                  4      pV P                  P                  V4       V F"  pV P                  V;;,          ^,          uu&   K$  	  V P                  V^ ,          ,          P                  V4       V P                  VR,          ,          P                  V4       V P                  V4       R# )aú  Add a new clause to the theory.

Examples
========

>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())

>>> l.num_learned_clauses
0
>>> l.clauses
[[2, -3], [1], [3, -3], [2, -2], [3, -2]]
>>> l.sentinels
{-3: {0, 2}, -2: {3, 4}, 2: {0, 3}, 3: {2, 4}}

>>> l._simple_add_learned_clause([3])

>>> l.clauses
[[2, -3], [1], [3, -3], [2, -2], [3, -2], [3]]
>>> l.sentinels
{-3: {0, 2}, -2: {3, 4}, 2: {0, 3}, 3: {2, 4, 5}}

Nrb   )rT   rU   rL   r^   r\   rd   rF   )rW   r‚   Úcls_numrg   s   &&  r   rH   Ú$SATSolver._simple_add_learned_clausel  sŠ   € ô2 �d—l‘lÓ#ˆØ�‰×Ñ˜CÔ ãˆCØ×!Ñ! #×&¨!Õ+Õ&ñ ð 	�‰�s˜1•vÕ×"Ñ" 7Ô+Ø�‰�s˜2•wÕ×#Ñ# GÔ,à×Ñ˜sÖ#r3   c                óf   € V P                   R,           Uu. uF  qP                  ) NK  	  up# u upi )aR  Build a clause representing the fact that at least one decision made
so far is wrong.

Examples
========

>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())
>>> next(l._find_model())
{1: True, 2: False, 3: False}
>>> l._simple_compute_conflict()
[3]

:rk   NN)rO   rp   )rW   Úlevels   & r   rJ   Ú"SATSolver._simple_compute_conflict�  s)   € ð  04¯{©{¸2®Ó?© e—.‘.Ó!©Ñ?Ð?ùÒ?s   –.c                ó   € R# )zClean up learned clauses.Nr   r~   s   &r   rM   ÚSATSolver._simple_clean_clauses¢  r¬   r3   )r:   r8   rI   rU   rK   r@   rF   rB   rD   r6   r7   rO   rž   rŸ   r#   rR   rS   r^   rV   r\   r   r9   r5   r_   )Nr,   r.   iô  N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rY   r<   r=   r   ÚpropertyrP   rƒ   r†   rw   rv   ro   r“   r”   r>   r¦   r?   rA   rC   rE   rH   rJ   rM   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   r   r   R   s–   ø‡ € ñô3òj;ò0ò.r ðn ñó ðò(ò.*ò&5AònðBò
,ò:òò	Cò(ò0)ò@ò?ò.&ò<"$òH@÷$ð r3   r   c                   ó.   a € ] tR tRt o RtRR ltRtV tR# )rN   i§  zv
Represents a single level in the DPLL algorithm, and contains
enough information for a sound backtracking procedure.
c                ó<   € Wn         \        4       V n        W n        R # r
   )rp   r   r5   rn   )rW   rp   rn   s   &&&r   rY   ÚLevel.__init__­  s   € Ø ŒÜ›EˆÔØŽr3   )rp   rn   r5   Nr   )r¹   rº   r»   r¼   r½   rY   r¿   rÀ   rÁ   s   @r   rN   rN   §  s   ø‡ € ñ÷
ò r3   rN   N)FF)r½   Úcollectionsr   Úheapqr   r   Úsympy.core.sortingr   Úsympy.assumptions.cnfr   Ú!sympy.logic.algorithms.lra_theoryr   r'   r   r   rN   r   r3   r   Ú<module>rË      s=   ðñ	õ $ß #å &Ý ,å 7ô*òd÷R	ñ R	÷j	ó 	r3   