Ë
    7^(hùS  ã                   ó~   — d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 ddl
mZ dd„Zd„ Z G d	„ d
«      Z G d„ d«      Zy)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                 ó²  — t        | t        «      st        «       }|j                  | «       |} dh| j                  v r|r	d„ dD «       S y|rt	        j
                  | «      \  }}nd}g }t        | j                  |z   | j                  t        «       | j                  |¬«      }|j                  «       }|rt        |«      S 	 t        |«      S # t        $ r Y yw xY w)a˜  
    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

    r   c              3   ó    K  — | ]  }|–— Œ y ­w©N© )Ú.0Úfs     úZ/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sympy/logic/algorithms/dpll2.pyú	<genexpr>z#dpll_satisfiable.<locals>.<genexpr>.   s   è ø€ Ò'˜!”AÑ'ùs   ‚©FFN)Ú
lra_theory)Ú
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
 Ã
	CÃCc              #   ó`   K  — d}	 	 t        | «      –— d}Œ# t        $ r |sd–— Y y Y y w xY w­w)NFT)r   r   )r&   Úsatisfiables     r   r   r   G   sD   è ø€ Ø€KðØÜ�v“,ÒØˆKð øô ò ÙØŒKñ ðüs   ‚.† —+¦.ª+«.c                   ó¢   — e Zd ZdZ	 	 	 dd„Zd„ Zd„ Zd„ Zed„ «       Z	d„ Z
d	„ Zd
„ Zd„ Z	 d„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy)r   z‚
    Class for representing a SAT solver capable of
     finding a model to a boolean theory in conjunctive
     normal form.
    Nc	                 ó  — || _         || _        d| _        g | _        g | _        || _        |€t        t        |«      «      | _        n|| _        | j                  |«       | j                  |«       d|k(  rU| j                  «        | j                  | _        | j                  | _        | j                   | _        | j$                  | _        nt(        ‚d|k(  rH| j*                  | _        | j.                  | _        | j                  j3                  | j4                  «       nd|k(  rd„ | _        d„ | _        nt(        ‚t7        d«      g| _        || j:                  _        d| _        d| _         tC        | jD                  «      | _#        || _$        y )NFÚvsidsÚsimpleÚnonec                  ó   — y r   r   )Úxs    r   ú<lambda>z$SATSolver.__init__.<locals>.<lambda>~   ó   � ó    c                   ó   — y r   r   r   r3   r   r1   z$SATSolver.__init__.<locals>.<lambda>   r2   r3   r   )%Ú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__zSATSolver.__init__Y   sb  € ð )ˆÔØ"ˆŒØ#ˆÔØ "ˆÔØ "ˆÔØ ˆŒàˆ?Ü¤¨	Ó 2Ó3ˆD�Là"ˆDŒ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                 ó‚   — t        t        «      | _        t        t        «      | _        dgt        |«      dz   z  | _        y)z+Set up the variable data structures needed.Fé   N)r   r   Ú	sentinelsÚintÚoccurrence_countrT   Úvariable_set)rW   r   s     r   r<   zSATSolver._initialize_variablesŽ   s3   € ä$¤SÓ)ˆŒÜ +¬CÓ 0ˆÔØ"˜G¤s¨9£~¸Ñ'9Ñ:ˆÕr3   c                 óž  — |D �cg c]  }t        |«      ‘Œ c}| _        t        | j                  «      D ]’  \  }}dt        |«      k(  r| j                  j                  |d   «       Œ3| j                  |d      j                  |«       | j                  |d      j                  |«       |D ]  }| j                  |xx   dz  cc<   Œ Œ” yc c}w )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.
        r[   r   éÿÿÿÿN)	r;   rU   Ú	enumeraterT   r8   rL   r\   Úaddr^   )rW   rU   ÚclauseÚiÚlits        r   r=   zSATSolver._initialize_clauses”   s¿   € ð 4;Ö;¨œ˜V�Ò;ˆŒä" 4§<¡<Ó0ò 	0‰IˆAˆvð ”C˜“KÒØ×%Ñ%×,Ñ,¨V°A©YÔ7Øà�N‰N˜6 !™9Ñ%×)Ñ)¨!Ô,Ø�N‰N˜6 "™:Ñ&×*Ñ*¨1Ô-àò 0�Ø×%Ñ% cÓ*¨aÑ/Ô*ñ0ñ	0ùò <s   …C
c              #   ó(  ‡K  — d}| j                  «        | j                  ry	 | j                  | j                  z  dk(  r| j                  D ]	  } |«        Œ |rd}| j
                  j                  }�n| j                  «       }| xj                  dz  c_        d|k(  �rÐ| j                  re| j                  D ]!  }| j                  j                  |«      Š‰€Œ! n | j                  j                  «       Š| j                  j                  «        ndŠ‰�‰d   r:| j                  D �ci c]!  }| j                  t        |«      dz
     |dkD  “Œ# c}–— nu| j                  ‰d   «       t!        ˆfd„| j
                  j                  D «       «      s9| j#                  «        t!        ˆfd„| j
                  j                  D «       «      sŒ9| j
                  j$                  r'| j#                  «        | j
                  j$                  rŒ't'        | j(                  «      dk(  ry| j
                  j                   }| j#                  «        | j(                  j+                  t-        |d¬«      «       d}�ŒL| j(                  j+                  t-        |«      «       | j/                  |«       | j                  «        | j                  rËd| _        | j
                  j$                  r@| j#                  «        dt'        | j(                  «      k(  ry| j
                  j$                  rŒ@| j1                  | j3                  «       «       | j
                  j                   }| j#                  «        | j(                  j+                  t-        |d¬«      «       d}�Œic c}w ­w)an  
        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}]

        FNTr   r[   c              3   ó.   •K  — | ]  }| ‰d    v –— Œ y­w)r[   Nr   )r   rf   Úress     €r   r   z(SATSolver._find_model.<locals>.<genexpr>ó   s   øè ø€ Ò%a¸ s d¨c°!©f¤nÑ%aùs   ƒ)Úflipped)Ú	_simplifyr7   rR   r:   r9   rP   Údecisionr@   r#   r5   Ú
assert_litÚcheckÚreset_boundsr   ÚabsrH   ÚanyÚ_undorj   rT   rO   rL   rN   Ú_assign_literalrI   rK   )rW   Úflip_varÚfuncrf   Úenc_varÚflip_litri   s         @r   r   zSATSolver._find_model«   s
  øè ø€ ð8 ˆð 	�‰ÔØ×ÒØð à×!Ñ! D§M¡MÑ1°QÒ6Ø ×1Ñ1ò �DÙ•Fðñ à �Ø×)Ñ)×2Ñ2’ð ×)Ñ)Ó+�Ø×"Ò" aÑ'Õ"ð ˜“8ð —x’xØ'+×'8Ñ'8ò &˜GØ"&§(¡(×"5Ñ"5°gÓ">˜CØ"™Ù %ð&ð #Ÿh™hŸn™nÓ.˜ØŸ™×-Ñ-Õ/à"˜Ø�{ c¨!¢fà7;×7HÑ7HöJØ03ð  $Ÿ|™|¬C°«H°q©LÑ9Ø$'¨!¡Gñ ,ò Jó Jð ×7Ñ7¸¸A¹Ô?ô #&Ó%aÀ×@SÑ@S×@`Ñ@`Ô%aÔ"aØ ŸJ™JœLô #&Ó%aÀ×@SÑ@S×@`Ñ@`Ô%aÕ"að ×-Ñ-×5Ò5ØŸ
™
œð ×-Ñ-×5Ó5ä˜4Ÿ;™;Ó'¨1Ò,ØØ $× 3Ñ 3× <Ñ <Ð<�HØ—J‘J”LØ—K‘K×&Ñ&¤u¨X¸tÔ'DÔEØ#�HÙð —‘×"Ñ"¤5¨£:Ô.ð × Ñ  Ô%ð �N‰NÔð ×"Ò"à&+�Ô#ð ×)Ñ)×1Ò1Ø—J‘J”Lð œC §¡Ó,Ò,Øð ×)Ñ)×1Ó1ð ×'Ñ'¨×(=Ñ(=Ó(?Ô@ð !×/Ñ/×8Ñ8Ð8�Ø—
‘
”Ø—‘×"Ñ"¤5¨¸4Ô#@ÔAØ�ñ] ùò<Jùs.   ƒCNÃANÄ'&NÅA:NÇ<NÈDNÌA5Nc                 ó    — | j                   d   S )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}

        ra   )rO   ©rW   s    r   rP   zSATSolver._current_level"  s   € ð& �{‰{˜2‰Ðr3   c                 óL   — | j                   |   D ]  }|| j                  v sŒ y y)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   Úclsrf   s      r   Ú_clause_satzSATSolver._clause_sat7  s2   € ð$ —<‘< Ñ$ò 	ˆCØ�d×'Ñ'Ò'Ùð	ð r3   c                 ó$   — || j                   |   v S )a©  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   rf   r|   s      r   Ú_is_sentinelzSATSolver._is_sentinelN  s   € ð" �d—n‘n SÑ)Ð)Ð)r3   c                 óŒ  — | j                   j                  |«       | j                  j                   j                  |«       d| j                  t	        |«      <   | j                  |«       t        | j                  |    «      }|D ]½  }| j                  |«      rŒd}| j                  |   D ]w  }|| k7  sŒ
| j                  ||«      r|}Œ| j                  t	        |«         rŒ8| j                  |    j                  |«       | j                  |   j                  |«       d} n |sŒ£| j                  j                  |«       Œ¿ y)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   rc   rP   r_   rp   rB   r;   r\   r}   rU   r   Úremover8   rL   )rW   rf   Úsentinel_listr|   Úother_sentinelÚnewlits         r   rs   zSATSolver._assign_literala  s&  € ð> 	×Ñ×Ñ˜cÔ"Ø×Ñ×(Ñ(×,Ñ,¨SÔ1Ø&*ˆ×Ñœ#˜c›(Ñ#Ø×Ñ˜sÔ#ä˜TŸ^™^¨S¨DÑ1Ó2ˆà ò 	AˆCØ×#Ñ# CÕ(Ø!%�Ø"Ÿl™l¨3Ñ/ò "�FØ # “~Ø×,Ñ,¨V°SÔ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°Õ@ñ	Ar3   c                 óö   — | j                   j                  D ]F  }| j                  j                  |«       | j                  |«       d| j                  t        |«      <   ŒH | j                  j                  «        y)ag  
        _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_   rp   rO   Úpop©rW   rf   s     r   rr   zSATSolver._undo˜  se   € ð, ×&Ñ&×3Ñ3ò 	0ˆCØ×Ñ×$Ñ$ SÔ)Ø×Ñ Ô$Ø*/ˆD×Ñœc #›hÒ'ð	0ð 	�‰�‰Õr3   c                 ód   — d}|r,d}|| j                  «       z  }|| j                  «       z  }|rŒ+yy)ad  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   rk   zSATSolver._simplify¾  s:   € ð. ˆÙØˆGØ�t—‘Ó(Ñ(ˆGØ�t×)Ñ)Ó+Ñ+ˆGô r3   c                 óú   — t        | j                  «      dkD  }| j                  rV| j                  j                  «       }| | j                  v rd| _        g | _        y| j                  |«       | j                  rŒV|S )z/Perform unit propagation on the current theory.r   TF)rT   r8   r†   r5   r7   rs   )rW   ÚresultÚnext_lits      r   r‰   zSATSolver._unit_propÛ  sw   € ä�T×*Ñ*Ó+¨aÑ/ˆØ×#Ò#Ø×,Ñ,×0Ñ0Ó2ˆHØˆy˜D×-Ñ-Ñ-Ø&*�Ô#Ø(*�Ô%Øà×$Ñ$ XÔ.ð ×#Ó#ð ˆr3   c                  ó   — y)z2Look for pure literals and assign them when found.Fr   ry   s    r   rŠ   zSATSolver._pure_literalé  s   € àr3   c                 óœ  — g | _         i | _        t        dt        | j                  «      «      D ]œ  }t        | j                  |    «      | j                  |<   t        | j                  |     «      | j                  | <   t        | j                   | j                  |   |f«       t        | j                   | j                  |    | f«       Œž y)z>Initialize the data structures needed for the VSIDS heuristic.r[   N)Úlit_heapÚ
lit_scoresÚrangerT   r_   Úfloatr^   r   )rW   Úvars     r   r>   zSATSolver._vsids_initð  sµ   € àˆŒØˆŒä˜œC × 1Ñ 1Ó2Ó3ò 	Cˆ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ñ		Cr3   c                 óp   — | j                   j                  «       D ]  }| j                   |xx   dz  cc<   Œ y)aË  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_decayzSATSolver._vsids_decayû  s4   € ð* —?‘?×'Ñ'Ó)ò 	(ˆCØ�O‰O˜CÓ  CÑ'Ô ñ	(r3   c                 ób  — t        | j                  «      dk(  ry| j                  t        | j                  d   d   «         rWt	        | j                  «       t        | j                  «      dk(  ry| j                  t        | j                  d   d   «         rŒWt	        | j                  «      d   S )aá  
            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)]

        r   r[   )rT   r‘   r_   rp   r   ry   s    r   r?   zSATSolver._vsids_calculate  s”   € ô* ˆt�}‰}Ó Ò"Øð ×Ñ¤ D§M¡M°!Ñ$4°QÑ$7Ó 8Ò9Ü�D—M‘MÔ"Ü�4—=‘=Ó! QÒ&Øð ×Ñ¤ D§M¡M°!Ñ$4°QÑ$7Ó 8Ó9ô
 �t—}‘}Ó% aÑ(Ð(r3   c                  ó   — y)z;Handle the assignment of a literal for the VSIDS heuristic.Nr   r‡   s     r   rA   zSATSolver._vsids_lit_assigned3  ó   € àr3   c                 ó²   — t        |«      }t        | j                  | j                  |   |f«       t        | j                  | j                  |    | f«       y)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)rp   r   r‘   r’   )rW   rf   r•   s      r   rC   zSATSolver._vsids_lit_unset7  sI   € ô& �#‹hˆÜ�—‘ §¡°Ñ!5°sÐ ;Ô<Ü�—‘ §¡°#°Ñ!6¸¸Ð =Õ>r3   c                 ój   — | xj                   dz  c_         |D ]  }| j                  |xx   dz  cc<   Œ y)aD  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}

        r[   N)rS   r’   r{   s      r   rE   zSATSolver._vsids_clause_addedN  s8   € ð. 	× Ò  AÑ%Õ Øò 	&ˆCØ�O‰O˜CÓ  AÑ%Ô ñ	&r3   c                 óF  — t        | j                  «      }| j                  j                  |«       |D ]  }| j                  |xx   dz  cc<   Œ | j                  |d      j                  |«       | j                  |d      j                  |«       | j                  |«       y)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}}

        r[   r   ra   N)rT   rU   rL   r^   r\   rc   rF   )rW   r|   Úcls_numrf   s       r   rH   z$SATSolver._simple_add_learned_clausel  s�   € ô2 �d—l‘lÓ#ˆØ�‰×Ñ˜CÔ àò 	,ˆCØ×!Ñ! #Ó&¨!Ñ+Ô&ð	,ð 	�‰�s˜1‘vÑ×"Ñ" 7Ô+Ø�‰�s˜2‘wÑ×#Ñ# GÔ,à×Ñ˜sÕ#r3   c                 ó\   — | j                   dd D �cg c]  }|j                   ‘Œ c}S c c}w )a«   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]

        r[   N)rO   rl   )rW   Úlevels     r   rJ   z"SATSolver._simple_compute_conflict�  s)   € ð  04¯{©{¸1¸2¨Ö? e�%—.‘.Ò!Ò?Ð?ùÒ?s   ’)c                  ó   — y)zClean up learned clauses.Nr   ry   s    r   rM   zSATSolver._simple_clean_clauses¢  r›   r3   )Nr,   r.   iô  N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rY   r<   r=   r   ÚpropertyrP   r}   r   rs   rr   rk   r‰   rŠ   r>   r˜   r?   rA   rC   rE   rH   rJ   rM   r   r3   r   r   r   R   s›   „ ñð BFØDGØ"ó3òj;ò0ò.r ðn ñó ðò(ò.*ò&5AònðBò
,ò:òò	Cò(ò0)ò@ò?ò.&ò<"$òH@ó$r3   r   c                   ó   — e Zd ZdZdd„Zy)rN   z‚
    Represents a single level in the DPLL algorithm, and contains
    enough information for a sound backtracking procedure.
    c                 ó>   — || _         t        «       | _        || _        y r   )rl   r   r5   rj   )rW   rl   rj   s      r   rY   zLevel.__init__­  s   € Ø ˆŒÜ›EˆÔØˆ�r3   Nr   )r£   r¤   r¥   r¦   rY   r   r3   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   