
    cwi<p                     H   S r SSKJr  SSKJrJrJrJrJ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S	KJrJr  / S
Qr " S S\\   5      r " S S\\   5      r " S S\5      r " S S\5      r " S S5      r " S S5      r " S S\S9r \RB                  " \" S5      SS9S 5       r"\RB                  " \" S5      SS9S 5       r#\RB                  " \" S5      S S9S! 5       r$\RB                  " \" S5      S"S9S# 5       r%\RB                  " \" S5      S$S9S% 5       r&g&)'aC  
Functions and classes to implement custom propagators.

```python
>>> from clingo.symbol import Function
>>> from clingo.propagator import Propagator
>>> from clingo.control import Control
>>>
>>> class AIFFB(Propagator):
...     # add watches for atoms `a` and `b`
...     def init(self, init):
...         # get program literals for atoms `a` and `b`
...         plit_a = init.symbolic_atoms[Function("a")].literal
...         plit_b = init.symbolic_atoms[Function("b")].literal
...         # get solver literals for program literals `a` and `b`
...         self.slit_a = init.solver_literal(plit_a)
...         self.slit_b = init.solver_literal(plit_b)
...         # add watches for solver literals `a` and `b`
...         init.add_watch(self.slit_a)
...         init.add_watch(self.slit_b)
...     # propagate solver literals `a` and `b`
...     def propagate(self, ctl, changes):
...         # if `a` is true imply `b`
...         if self.slit_a in changes:
...             ctl.add_clause([-self.slit_a, self.slit_b])
...         # if `b` is true imply `a`
...         if self.slit_b in changes:
...             ctl.add_clause([-self.slit_b, self.slit_a])
...
>>> ctl = Control(["0"])
>>> ctl.register_propagator(AIFFB())
>>> ctl.add("base", [], "1 { a; b }.")
>>> ctl.ground([("base", [])])
>>> print(ctl.solve(on_model=print))
a b
SAT
```
    )ABCMeta)IterableIteratorOptionalSequenceTuple   )_c_call_cb_error_handler_ffi_handle_error_lib)OrderedEnum)SymbolicAtoms)
TheoryAtom)SliceSlicedSequence)
AssignmentPropagateControlPropagateInit
PropagatorPropagatorCheckModePropagatorUndoModeTrailc                   T    \ rS rSrSrS rS rS rS rS\	S\	4S	 jr
S\	S\	4S
 jrSrg)r   <   a  
Class to access literals assigned by the solver in chronological order.

Literals in the trail are ordered by decision levels, where the first
literal with a larger level than the previous literals is a decision; the
following literals with same level are implied by this decision literal.
Each decision level up to and including the current decision level has a
valid offset in the trail.
c                     Xl         g N_repselfreps     K/home/james-whalen/.local/lib/python3.13/site-packages/clingo/propagator.py__init__Trail.__init__G       	    c                 L    [        S[        R                  U R                  5      $ )Nuint32_t)r
   r   clingo_assignment_trail_sizer    r"   s    r$   __len__Trail.__len__J   s    z4#D#DdiiPPr(   c                 
   [        U[        5      (       a  [        U [        U5      5      $ US:  a  U[	        U 5      -  nUS:  d  U[	        U 5      :  a  [        S5      e[        S[        R                  U R                  U5      $ Nr   zinvalid indexclingo_literal_t)

isinstanceslicer   r   len
IndexErrorr
   r   clingo_assignment_trail_atr    r"   slcs     r$   __getitem__Trail.__getitem__M   sr    c5!!!$c
3373t9C7cSY&_-- ? ?C
 	
r(   c              #      #    [        [        U 5      5       H+  n[        S[        R                  U R
                  U5      v   M-     g 7fNr1   )ranger4   r
   r   r6   r    r"   is     r$   __iter__Trail.__iter__X   s9     s4y!A"D$C$CTYYPQ  "   AAlevelreturnc                 N    [        S[        R                  U R                  U5      $ )z
Returns the offset of the decision literal with the given decision
level in the trail.

Parameters
----------
level
    The decision level.
r*   )r
   r   clingo_assignment_trail_beginr    r"   rC   s     r$   beginTrail.begin^   s      z4#E#EtyyRWXXr(   c                 N    [        S[        R                  U R                  U5      $ )z
Returns the offset following the last literal with the given decision
literal in the trail.

Parameters
----------
level
    The decision level.
r*   )r
   r   clingo_assignment_trail_endr    rG   s     r$   end	Trail.endj   s      z4#C#CTYYPUVVr(   r   N)__name__
__module____qualname____firstlineno____doc__r%   r-   r9   r@   intrH   rL   __static_attributes__ r(   r$   r   r   <   sH    Q	

Y3 
Y3 
Y
W 
W 
Wr(   r   c                   :   \ rS rSrSrS rS rS rS rS\	S\	4S	 jr
S
\	S\4S jrS
\	S\4S jrS
\	S\4S jrS
\	S\4S jrS
\	S\4S jrS
\	S\	4S jrS\\   4S jr\S\	4S j5       r\S\4S j5       r\S\4S j5       r\S\	4S j5       r\S\4S j5       rSrg)r   w   aR  
Class to inspect the (parital) assignment of an associated solver.

Assigns truth values to solver literals.  Each solver literal is either
true, false, or undefined, represented by the Python constants `True`,
`False`, or `None`, respectively.

This class implements `Sequence[int]` to access the (positive)
literals in the assignment.
c                     Xl         g r   r   r!   s     r$   r%   Assignment.__init__   r'   r(   c                 B    [         R                  " U R                  5      $ r   )r   clingo_assignment_sizer    r,   s    r$   r-   Assignment.__len__   s    **49955r(   c                 
   [        U[        5      (       a  [        U [        U5      5      $ US:  a  U[	        U 5      -  nUS:  d  U[	        U 5      :  a  [        S5      e[        S[        R                  U R                  U5      $ r0   )
r2   r3   r   r   r4   r5   r
   r   clingo_assignment_atr    r7   s     r$   r9   Assignment.__getitem__   so    c5!!!$c
3373t9C7cSY&_--)4+D+DdiiQTUUr(   c              #      #    [        [        U 5      5       H+  n[        S[        R                  U R
                  U5      v   M-     g 7fr<   )r=   r4   r
   r   r^   r    r>   s     r$   r@   Assignment.__iter__   s5     s4y!A,d.G.GTUVV "rB   rC   rD   c                 N    [        S[        R                  U R                  U5      $ )zf
Return the decision literal of the given level.

Parameters
----------
level
    The decision level.
r1   )r
   r   clingo_assignment_decisionr    rG   s     r$   decisionAssignment.decision   s$      ? ?E
 	
r(   literalc                 D    [         R                  " U R                  U5      $ )zp
Determine if the given literal is valid in this solver.

Parameters
----------
literal
    The solver literal.
)r   clingo_assignment_has_literalr    r"   rf   s     r$   has_literalAssignment.has_literal   s     11$))WEEr(   c                 N    [        S[        R                  U R                  U5      $ )z[
Determine if the literal is false.

Parameters
----------
literal
    The solver literal.
bool)r
   r   clingo_assignment_is_falser    ri   s     r$   is_falseAssignment.is_false        vt>>		7SSr(   c                 N    [        S[        R                  U R                  U5      $ )zo
Determine if the literal is assigned on the top level.

Parameters
----------
literal
    The solver literal.
rm   )r
   r   clingo_assignment_is_fixedr    ri   s     r$   is_fixedAssignment.is_fixed   rq   r(   c                 N    [        S[        R                  U R                  U5      $ )zZ
Determine if the literal is true.

Parameters
----------
literal
    The solver literal.
rm   )r
   r   clingo_assignment_is_truer    ri   s     r$   is_trueAssignment.is_true   s     vt==tyy'RRr(   c                 t    [        S[        R                  U R                  U5      nU[        R                  :H  $ )zZ
Determine if the literal is free.

Parameters
----------
literal
    The solver literal.
clingo_truth_value_t)r
   r   clingo_assignment_truth_valuer    clingo_truth_value_freer"   rf   values      r$   is_freeAssignment.is_free   s7     "..II	
 4444r(   c                 N    [        S[        R                  U R                  U5      $ )z
The decision level of the given literal.

Parameters
----------
literal
    The solver literal.

Notes
-----
Note that the returned value is only meaningful if the literal is
assigned - i.e., `value(lit) is not None`.
r*   )r
   r   clingo_assignment_levelr    ri   s     r$   rC   Assignment.level   s     z4#?#?GTTr(   c                     [        S[        R                  U R                  U5      nU[        R                  :X  a  gU[        R
                  :X  a  gU[        R                  :X  d   eg)z{
Get the truth value of the given literal or `None` if it has none.

Parameters
----------
literal
    The solver literal.
r{   TFN)r
   r   r|   r    clingo_truth_value_trueclingo_truth_value_falser}   r~   s      r$   r   Assignment.value   s_     "..II	
 D000D11144444r(   c                 B    [         R                  " U R                  5      $ )z
The current decision level.
)r    clingo_assignment_decision_levelr    r,   s    r$   decision_levelAssignment.decision_level  s    
 44TYY??r(   c                 B    [         R                  " U R                  5      $ )z(
True if the assignment is conflicting.
)r   clingo_assignment_has_conflictr    r,   s    r$   has_conflictAssignment.has_conflict  s    
 22499==r(   c                 B    [         R                  " U R                  5      $ )z"
Whether the assignment is total.
)r   clingo_assignment_is_totalr    r,   s    r$   is_totalAssignment.is_total  s    
 ..tyy99r(   c                 B    [         R                  " U R                  5      $ )z
The current root level.
)r   clingo_assignment_root_levelr    r,   s    r$   
root_levelAssignment.root_level  s    
 00;;r(   c                 ,    [        U R                  5      $ )z!
The trail of assigned literals.
)r   r    r,   s    r$   trailAssignment.trail"  s    
 TYYr(   r   N)rN   rO   rP   rQ   rR   r%   r-   r9   r@   rS   rd   rm   rj   ro   rt   rx   r   rC   r   r   propertyr   r   r   r   r   r   rT   rU   r(   r$   r   r   w   sK   	6VW
c 
c 
	F3 	F4 	F	T 	T 	T	T 	T 	T	Ss 	St 	S5s 5t 5"US US U  , @ @ @ >d > > :$ : : <C < <  u    r(   r   c                   ~    \ rS rSrSr\R                  r \R                  r	 \R                  r \R                  rSrg)r   i*  
Enumeration of supported check modes for propagators.

Note that total checks are subject to the lock when a model is found. This
means that information from previously found models can be used to discard
assignments in check calls.
rU   N)rN   rO   rP   rQ   rR   r   !clingo_propagator_check_mode_bothBoth%clingo_propagator_check_mode_fixpointFixpoint!clingo_propagator_check_mode_noneOff"clingo_propagator_check_mode_totalTotalrT   rU   r(   r$   r   r   *  sO     11D 99H 
0
0C 33Er(   r   c                   J    \ rS rSrSr\R                  r \R                  r	Sr
g)r   iE  r   rU   N)rN   rO   rP   rQ   rR   r   #clingo_propagator_undo_mode_defaultDefault"clingo_propagator_undo_mode_alwaysAlwaysrT   rU   r(   r$   r   r   E  s+     66G 44Fr(   r   c                      \ rS rSrSrS rS\\   S\4S jr	S#S\S\4S jjr
S$S	\S
\S\SS4S jjrS%S	\S\\   SS4S jjrS%S	\S\\   SS4S jjrS	\SS4S jr  S&S	\S\\\\4      S\S\S\S\4S jjrS\4S jrS	\S\4S jr\S\4S j5       r\S\4S j5       r\R2                  S\SS4S j5       r\S\4S j5       r\R2                  S\SS4S j5       r\S\4S j5       r\S\4S  j5       r\S\\    4S! j5       r!S"r"g)'r   iX  zJ
Object that is used to initialize a propagator before each solving step.
c                     Xl         g r   r   r!   s     r$   r%   PropagateInit.__init__]  r'   r(   clauserD   c           	      b    [        S[        R                  U R                  U[	        U5      5      $ )ae  
Statically adds the given clause to the problem.

Parameters
----------
clause
    The clause over solver literals to add.

Returns
-------
Returns false if the program becomes unsatisfiable.

Notes
-----
If this function returns false, initialization should be stopped and no
further functions of the `PropagateInit` and related objects should be
called.
rm   )r
   r    clingo_propagate_init_add_clauser    r4   )r"   r   s     r$   
add_clausePropagateInit.add_clause`  s.    & 11IIK
 	
r(   freezec                 N    [        S[        R                  U R                  U5      $ )a  
Statically adds a literal to the solver.

To be able to use the variable in clauses during propagation or add
watches to it, it has to be frozen. Otherwise, it might be removed
during preprocessing.

Parameters
----------
freeze
    Whether to freeze the variable.

Returns
-------
Returns the added literal.

Notes
-----
If literals are added to the solver, subsequent calls to `add_clause` and
`propagate` are expensive. It is best to add literals in batches.
r1   )r
   r   !clingo_propagate_init_add_literalr    )r"   r   s     r$   add_literalPropagateInit.add_literal{  s'    , 22II	
 	
r(   rf   weightpriorityNc                 Z    [        [        R                  " U R                  XU5      5        g)z
Extends the solver's minimize constraint with the given weighted
literal.

Parameters
----------
literal
    The literal to add.
weight
    The weight of the literal.
priority
    The priority of the literal.
N)r   r   "clingo_propagate_init_add_minimizer    )r"   rf   r   r   s       r$   add_minimizePropagateInit.add_minimize  s%     	33		7H	
r(   	thread_idc                     Uc+  [        [        R                  " U R                  U5      5        g[        [        R                  " U R                  X5      5        g)z
Add a watch for the solver literal in the given phase.

Parameters
----------
literal
    The solver literal to watch.
thread_id
    The id of the thread to watch the literal. If the is `None` then
    all active threads will watch the literal.
N)r   r   clingo_propagate_init_add_watchr    )clingo_propagate_init_add_watch_to_threadr"   rf   r   s      r$   	add_watchPropagateInit.add_watch  sB     $>>tyy'RS>>IIwr(   c                     Uc+  [        [        R                  " U R                  U5      5        g[        [        R                  " U R                  X5      5        g)a  
Remove the watch for the solver literal in the given phase.

Parameters
----------
literal
    The solver literal to remove the watch from.
thread_id
    The id of the thread from which to remove the watch. If the is `None`, then
    the watch is removed from all active threads.
N)r   r   "clingo_propagate_init_remove_watchr    .clingo_propagate_init_remove_watch_from_threadr   s      r$   remove_watchPropagateInit.remove_watch  sB     $AA$))WUVCCIIwr(   c                 X    [        [        R                  " U R                  U5      5        g)a  
Freeze the given solver literal.

Any solver literal that is not frozen is subject to simplification and
might be removed in a preprocessing step after propagator
initialization. A propagator should freeze all literals over which it
might add clauses during propagation. Note that any watched literal is
automatically frozen and that it does not matter which phase of the
literal is frozen.

Parameters
----------
literal
    The solver literal to freeze.
N)r   r   $clingo_propagate_init_freeze_literalr    ri   s     r$   freeze_literalPropagateInit.freeze_literal  s      	d??		7STr(   literalsboundtype_compare_equalc                 j    [        S[        R                  U R                  UU[	        U5      UUU5	      $ )a  
Statically adds a constraint of form

    literal <=> { l=w | (l, w) in literals } >= bound

to the solver.

- If `type_ < 0`, then `<=>` is a left implication.
- If `type_ > 0`, then `<=>` is a right implication.
- Otherwise, `<=>` is an equivalence.

Parameters
----------
literal
    The literal associated with the constraint.
literals
    The weighted literals of the constraint.
bound
    The bound of the constraint.
type_
    Add a weight constraint of the given type_.
compare_equal
    A Boolean indicating whether to compare equal or less than equal.

Returns
-------
Returns false if the program became unsatisfiable.

Notes
-----
If this function returns false, initialization should be stopped and no further
functions of the `PropagateInit` and related objects should be called.
rm   )r
   r   +clingo_propagate_init_add_weight_constraintr    r4   )r"   rf   r   r   r   r   s         r$   add_weight_constraint#PropagateInit.add_weight_constraint  s;    R <<IIM

 
	
r(   c                 L    [        S[        R                  U R                  5      $ )a|  
Propagates consequences of the underlying problem excluding registered
propagators.

Returns
-------
Returns false if the program becomes unsatisfiable.

Notes
-----
This function has no effect if SAT-preprocessing is enabled.

If this function returns false, initialization should be stopped and no
further functions of the `PropagateInit` and related objects should be
called.
rm   )r
   r   clingo_propagate_init_propagater    r,   s    r$   	propagatePropagateInit.propagate  s    " vtCCTYYOOr(   c                 N    [        S[        R                  U R                  U5      $ )z
Maps the given program literal or condition id to its solver literal.

Parameters
----------
literal
    A program literal or condition id.

Returns
-------
A solver literal.
r1   )r
   r   $clingo_propagate_init_solver_literalr    ri   s     r$   solver_literalPropagateInit.solver_literal0  s'     55II	
 	
r(   c                 T    [        [        R                  " U R                  5      5      $ )z9
`Assignment` object capturing the top level assignment.
)r   r    clingo_propagate_init_assignmentr    r,   s    r$   
assignmentPropagateInit.assignmentD  s    
 $??		JKKr(   c                 T    [        [        R                  " U R                  5      5      $ )zD
`PropagatorCheckMode` controlling when to call `Propagator.check`.
)r   r   $clingo_propagate_init_get_check_moder    r,   s    r$   
check_modePropagateInit.check_modeK  s    
 #4#L#LTYY#WXXr(   modec                 Z    [         R                  " U R                  UR                  5        g r   )r   $clingo_propagate_init_set_check_moder    r   r"   r   s     r$   r   r   R  s    11$))TZZHr(   c                 T    [        [        R                  " U R                  5      5      $ )zB
`PropagatorUndoMode` controlling when to call `Propagator.undo`.
)r   r   #clingo_propagate_init_get_undo_moder    r,   s    r$   	undo_modePropagateInit.undo_modeV  s    
 "$"J"J499"UVVr(   c                 Z    [         R                  " U R                  UR                  5        g r   )r   #clingo_propagate_init_set_undo_moder    r   r   s     r$   r   r   ]  s    00DJJGr(   c                 B    [         R                  " U R                  5      $ )zD
The number of solver threads used in the corresponding solve call.
)r   'clingo_propagate_init_number_of_threadsr    r,   s    r$   number_of_threadsPropagateInit.number_of_threadsa  s    
 ;;DIIFFr(   c                 b    [        S[        R                  U R                  5      n[	        U5      $ )z:
The symbolic atoms captured by a `SymbolicAtoms` object.
zclingo_symbolic_atoms_t*)r
   r   $clingo_propagate_init_symbolic_atomsr    r   )r"   atomss     r$   symbolic_atomsPropagateInit.symbolic_atomsh  s.    
 &55II

 U##r(   c              #      #    [        S[        R                  U R                  5      n[        S[        R                  U5      n[        U5       H  n[        X5      v   M     g7f)z$
An iterator over all theory atoms.
zclingo_theory_atoms_t*size_tN)r
   r   "clingo_propagate_init_theory_atomsr    clingo_theory_atoms_sizer=   r   )r"   r   sizeidxs       r$   theory_atomsPropagateInit.theory_atomst  sQ     
 $d&M&Mtyy
 x!>!>F;CU(( s   A!A#r   )T)r   r   )r   F)#rN   rO   rP   rQ   rR   r%   r   rS   rm   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   setterr   r   r   r   r   r   r   r   rT   rU   r(   r$   r   r   X  s.   
# 
4 
6
$ 
# 
:
C 
 
 
D 
( # $ *C HSM T *Uc Ud U. #3
3
 5c?+3
 	3

 3
 3
 
3
jP4 P&
c 
c 
( LJ L L Y/ Y Y I2 It I I W- W W H0 HT H H G3 G G 	$ 	$ 	$ 
)hz2 
) 
)r(   r   c            	           \ rS rSrSrS r SS\\   S\S\S\4S jjr	S\4S	 jr
 SS\\   S\S\S\4S
 jjrS\SS4S jrS\S\4S jrS\4S jrS\SS4S jr\S\4S j5       r\S\4S j5       rSrg)r   i  z?
This object can be used to add clauses and to propagate them.
c                     Xl         g r   r   r!   s     r$   r%   PropagateControl.__init__  r'   r(   r   taglockrD   c           	          SnU(       a  U[         R                  -  nU(       a  U[         R                  -  n[        S[         R                  U R
                  U[        U5      U5      $ )ag  
Add the given clause to the solver.

Parameters
----------
clause
    List of solver literals forming the clause.
tag
    If true, the clause applies only in the current solving step.
lock
    If true, exclude clause from the solver's regular clause deletion
    policy.

Returns
-------
This method returns false if the current propagation must be stopped.
r   rm   )r   clingo_clause_type_volatileclingo_clause_type_staticr
   #clingo_propagate_control_add_clauser    r4   )r"   r   r  r  r   s        r$   r   PropagateControl.add_clause  s\    ( T555ET333E44IIK
 	
r(   c                 L    [        S[        R                  U R                  5      $ )a%  
Adds a new positive volatile literal to the underlying solver thread.

The literal is only valid within the current solving step and solver
thread. All volatile literals and clauses involving a volatile literal
are deleted after the current search.

Returns
-------
The added solver literal.
r1   )r
   r   $clingo_propagate_control_add_literalr    r,   s    r$   r   PropagateControl.add_literal  s"      I I499
 	
r(   c                 R    U R                  U Vs/ s H  oD* PM     snX#5      $ s  snf )zG
Equivalent to `self.add_clause([-lit for lit in clause], tag, lock)`.
)r   )r"   r   r  r  lits        r$   
add_nogoodPropagateControl.add_nogood  s'     77CC7s   $rf   Nc                 X    [        [        R                  " U R                  U5      5        g)z
Add a watch for the solver literal in the given phase.

Parameters
----------
literal
    The target solver literal.

Notes
-----
Unlike `PropagateInit.add_watch` this does not add a watch to all
solver threads but just the current one.
N)r   r   "clingo_propagate_control_add_watchr    ri   s     r$   r   PropagateControl.add_watch  s     	d==diiQRr(   c                 D    [         R                  " U R                  U5      $ )z
Check whether a literal is watched in the current solver thread.

Parameters
----------
literal
    The target solver literal.

Returns
-------
Whether the literal is watched.
)r   "clingo_propagate_control_has_watchr    ri   s     r$   	has_watchPropagateControl.has_watch  s     66tyy'JJr(   c                 L    [        S[        R                  U R                  5      $ )z
Propagate literals implied by added clauses.

Returns
-------
This method returns false if the current propagation must be stopped.
rm   )r
   r   "clingo_propagate_control_propagater    r,   s    r$   r   PropagateControl.propagate  s     vtFF		RRr(   c                 F    [         R                  " U R                  U5        g)zx
Removes the watch (if any) for the given solver literal.

Parameters
----------
literal
    The target solver literal.
N)r   %clingo_propagate_control_remove_watchr    ri   s     r$   r   PropagateControl.remove_watch  s     	22499gFr(   c                 T    [        [        R                  " U R                  5      5      $ )zT
`Assignment` object capturing the partial assignment of the current solver thread.
)r   r   #clingo_propagate_control_assignmentr    r,   s    r$   r   PropagateControl.assignment  s    
 $BB499MNNr(   c                 B    [         R                  " U R                  5      $ )z.
The numeric id of the current solver thread.
)r   "clingo_propagate_control_thread_idr    r,   s    r$   r   PropagateControl.thread_id  s    
 66tyyAAr(   r   )FF)rN   rO   rP   rQ   rR   r%   r   rS   rm   r   r   r   r  r   r  r   r   r   r   r   r   rT   rU   r(   r$   r   r     s
    FK 
sm 
*. 
>B 
	 
D
S 
" FKDsmD*.D>BD	DS S S K K KS4 S	GC 	GD 	G OJ O O B3 B Br(   r   c                       \ rS rSrSrS\SS4S jrS\S\\	   SS4S	 jr
S
\	S\S\\	   SS4S jrS\SS4S jrS
\	S\S\	S\	4S jrSrg)r   i  z
Propagator interface for custom constraints.

See Also
--------
clingo.control.Control.register_propagator

Notes
-----
Not all functions of the `Propagator` interface have to be implemented and
can be omitted if not needed.
initrD   Nc                     g)a  
This function is called once before each solving step.

It is used to map relevant program literals to solver literals, add
watches for solver literals, and initialize the data structures used
during propagation.

Parameters
----------
init
    Object to initialize the propagator.

Notes
-----
This is the last point to access theory atoms.  Once the search has
started, they are no longer accessible.
NrU   )r"   r(  s     r$   r(  Propagator.init      r(   controlchangesc                     g)a  
Can be used to propagate solver literals given a partial assignment.

Parameters
----------
control
    Object to control propagation.
changes
    List of watched solver literals assigned to true.

Notes
-----
Called during propagation with a non-empty list of watched solver
literals that have been assigned to true since the last call to either
propagate, undo, (or the start of the search) - the change set. Only
watched solver literals are contained in the change set. Each literal
in the change set is true w.r.t. the current Assignment.
`PropagateControl.add_clause` can be used to add clauses. If a clause
is unit resulting, it can be propagated using
`PropagateControl.propagate`. If either of the two methods returns
False, the propagate function must return immediately.

    c = ...
    if not control.add_clause(c) or not control.propagate(c):
        return

Note that this function can be called from different solving threads.
Each thread has its own assignment and id, which can be obtained using
`PropagateControl.thread_id`.
NrU   )r"   r,  r-  s      r$   r   Propagator.propagate(  r+  r(   r   r   c                     g)a   
Called whenever a solver with the given id undos assignments to watched
solver literals.

Parameters
----------
thread_id
    The solver thread id.
assignment
    Object for inspecting the partial assignment of the solver.
changes
    The list of watched solver literals whose assignment is undone.

Notes
-----
This function is meant to update assignment dependent state in a
propagator but not to modify the current state of the solver.
Furthermore, errors raised in the function lead to program termination.
NrU   )r"   r   r   r-  s       r$   undoPropagator.undoH  r+  r(   c                     g)aZ  
This function is similar to propagate but is called without a change
set on propagation fixpoints.

When exactly this function is called, can be configured using the @ref
PropagateInit.check_mode property.

Parameters
----------
control
    Object to control propagation.

Notes
-----
This function is called even if no watches have been added.
NrU   )r"   r,  s     r$   checkPropagator.check_  r+  r(   fallbackc                     U$ )u  
This function allows a propagator to implement domain-specific
heuristics.

It is called whenever propagation reaches a fixed point.

Parameters
----------
thread_id
    The solver thread id.
assignment
    Object for inspecting the partial assignment of the solver.
fallback
    The literal choosen by the solver's heuristic.

Returns
-------
Тhe next solver literal to make true.

Notes
-----
This function should return a free solver literal that is to be
assigned true. In case multiple propagators are registered, this
function can return 0 to let a propagator registered later make a
decision. If all propagators return 0, then the fallback literal is
used.
rU   )r"   r   r   r6  s       r$   decidePropagator.decideq  s	    : r(   rU   )rN   rO   rP   rQ   rR   r   r(  r   r   rS   r   r   r1  r4  r8  rT   rU   r(   r$   r   r     s     4 &!1 HSM d @*4?G}	.- $ $  s s r(   r   )	metaclassdatapyclingo_propagator_init)onerrornamec                 x    [         R                  " U5      R                  nUR                  [	        U 5      5        gNT)r   from_handler;  r(  r   )r(  r;  
propagators      r$   _pyclingo_propagator_initrC    s,    !!$',,JOOM$'(r(   pyclingo_propagator_propagatec                     [         R                  " U5      R                  n[        U5       Vs/ s H  oQU   PM	     nnUR	                  [        U 5      U5        gs  snf r@  )r   rA  r;  r=   r   r   )r,  r-  r   r;  rB  r?   
py_changess          r$   _pyclingo_propagator_propagaterG    sR     !!$',,J&+Dk2k!*kJ2)'2J? 3s   Apyclingo_propagator_undoc                     [         R                  " U5      R                  n[        U5       Vs/ s H  oQU   PM	     nn[	        U 5      nUR                  UR                  UR                  U5        g s  snf r   )r   rA  r;  r=   r   r1  r   r   )r,  r-  r   r;  rB  r?   rF  ctls           r$   _pyclingo_propagator_undorK    sY    !!$',,J&+Dk2k!*kJ2
7
#COOCMM3>>:> 3s   A1pyclingo_propagator_checkc                 x    [         R                  " U5      R                  nUR                  [	        U 5      5        gr@  )r   rA  r;  r4  r   )r,  r;  rB  s      r$   _pyclingo_propagator_checkrN    s/    !!$',,J%g./r(   pyclingo_propagator_decidec                     [         R                  " U5      R                  nUR                  U [	        U5      U5      US'   g)Nr   T)r   rA  r;  r8  r   )r   r   r6  r;  rd   rB  s         r$   _pyclingo_propagator_deciderQ    s8    !!$',,J##Iz*/ExPHQKr(   N)'rR   abcr   typingr   r   r   r   r   	_internalr
   r   r   r   r   corer   r   r   r   r   utilr   r   __all__rS   r   r   r   r   r   r   r   
def_externrC  rG  rK  rN  rQ  rU   r(   r$   <module>rY     s\  %N  @ @ L L  ) $ '8WHSM 8Wvp # p f+ 6 &g) g)T	BB BBJG7 GT *629ST U f%,K *629ST? U? *629TU V *629UV Wr(   