
    cwi                        S r SSKrSSKJr  SSKJr  SSKJrJrJ	r	J
r
JrJrJrJrJr  \R                   S:  a  SSKJr  SS	KJrJrJrJrJrJrJrJr  SS
K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&J'r'  SSK(J)r)J*r*J+r+  SSK,J-r-  SSK.J/r/  SSK0J1r1  SS/r2 " S S\5      r3 " S S5      r4\Rj                  " \" S5      SS9S 5       r6\Rj                  " \" S5      SS9S 5       r7 " S S5      r8g)a  
This module contains the `clingo.control.Control` class responsible for
controling grounding and solving.

Examples
--------
The following example shows the basic ground solve process:

    >>> from clingo.symbol import Number
    >>> from clingo.control import Control
    >>>
    >>> ctl = Control()
    >>> ctl.add("q.")
    >>>
    >>> ctl.ground()
    >>> print(ctl.solve(on_model=print))
    q
    SAT

The following example shows basic (multishot) grounding and solving:

    >>> from clingo.symbol import Number
    >>> from clingo.control import Control
    >>>
    >>> ctl = Control()
    >>> ctl.add("a", [], "q.")
    >>> ctl.add("b", ["t"], "q(t).")
    >>>
    >>> ctl.ground([("a", [])])
    >>> print(ctl.solve(on_model=print))
    q
    SAT
    >>> ctl.ground([("b", [Number(1)]), ("b", [Number(2)])])
    >>> print(ctl.solve(on_model=print))
    q q(1) q(2)
    SAT
    >>> ctl.ground([("b", [Number(3)])])
    >>> print(ctl.solve(on_model=print))
    q q(1) q(2) q(3)
    SAT
    N)abc)IntEnum)	AnyCallableIteratorOptionalSequenceTupleUnioncastoverload      )Literal   )_c_call_cb_error_handler_CBData_Error_ffi_handle_error_lib_overwritten)BackendObserver)Configuration)Logger)
Propagator)ModelSolveHandleSolveResult)StatisticsMap_mutable_statistics_statistics)Symbol)SymbolicAtoms)
TheoryAtomControlBackendTypec                   d    \ rS rSrSr\R                  r \R                  r	 \R                  rSrg)r*   T   z$
Enumeration of available backends.
 N)__name__
__module____qualname____firstlineno____doc__r   clingo_backend_type_aspifAspifclingo_backend_type_smodelsSmodelsclingo_backend_type_reifyReify__static_attributes__r-       H/home/james-whalen/.local/lib/python3.13/site-packages/clingo/control.pyr*   r*   T   s=     **E ..G **Er:   c                   2    \ rS rSrS rS rS rS rS rSr	g)	_SolveEventHandlerg   c                 4    Xl         X l        X0l        X@l        g N)	_on_model	_on_unsat_on_statistics
_on_finish)selfon_modelon_unsaton_statistics	on_finishs        r;   __init___SolveEventHandler.__init__i   s    !!+#r:   c                     S nU R                   b  U R                  [        U5      5      n[        U=(       d    US L 5      $ r@   )rA   r    bool)rE   mrets      r;   rF   _SolveEventHandler.on_modelo   s7    >>%..q*CC&3$;''r:   c                 B    U R                   b  U R                  U5        g g r@   )rB   )rE   lowers     r;   rG   _SolveEventHandler.on_unsatu   s    >>%NN5! &r:   c                 T    U R                   b  U R                  [        U5      5        g g r@   )rD   r"   )rE   ress     r;   rI   _SolveEventHandler.on_finishy   s"    ??&OOK,- 'r:   c                 h    U R                   b%  U R                  [        U5      [        U5      5        g g r@   )rC   r$   )rE   stepaccus      r;   rH    _SolveEventHandler.on_statistics}   s/    * 3D 9;Nt;TU +r:   )rD   rA   rC   rB   N)
r.   r/   r0   r1   rJ   rF   rG   rI   rH   r9   r-   r:   r;   r=   r=   g   s    $(".Vr:   r=   datapyclingo_solve_event_callback)onerrornamec                    [         R                  " U5      R                  nU [        R                  :X  a)  UR                  [         R                  " SU5      S   5        U [        R                  :X  a)  UR                  [         R                  " SU5      5      US'   U [        R                  :X  a  [         R                  " SU5      n[         R                  " SUS   5      n[        [         R                  " SUS   5      5      nUR                  [        U5       Vs/ s H  oU   PM	     sn5        U [        R                  :X  a/  [         R                  " SU5      n	UR                  U	S   U	S   5        g	s  snf )
z 
Low-level solve event handler.
zclingo_solve_result_bitset_t*r   zclingo_model_t*zvoid**zint64_t*size_tr   zclingo_statistics_t**T)r   from_handler[   r   clingo_solve_event_type_finishrI   r   clingo_solve_event_type_modelrF   clingo_solve_event_type_unsatintrG   range"clingo_solve_event_type_statisticsrH   )
type_eventr[   goonhandlerc_argsc_lowersizeip_statss
             r;   _pyclingo_solve_event_callbackrq      s"    t$))G333$))$CUKANO222""499->#FGQ2228U+))Jq	2499Xvay12eDk:k!*k:;777))3U;gaj'!*5 ;s   E4pyclingo_ground_callbackc                 P   [         R                  " U5      R                  n[         R                  " U5      R	                  5       n[        Uc  [        R                  S   OUU5      n	/ n
[        U5       H  nU
R                  [        X+   5      5        M!     U	" U
6 n[        U[        R                  5      (       a  [        U5      OU/n[         R                  " S[!        U5      5      n[#        U5       H  u  pUR$                  X'   M     ['        U" U[!        U5      U5      5        g)z
Low-level ground callback.
__main__clingo_symbol_t[]T)r   ra   r[   stringdecodegetattrsysmodulesrf   appendr&   
isinstancer   Iterablelistnewlen	enumerate_repr   )locationr^   	argumentsarguments_sizer[   symbol_callbacksymbol_callback_datacontextpy_namefunargsro   rO   symbols	c_symbolssyms                   r;   _pyclingo_ground_callbackr      s     t$))Gkk$&&(G
W_#++j)'7
SCD>"F9<() # t*C%c3<<88d3iseG,c'l;IG$xx	 %/)S\;OPQr:   c                   F	   \ rS rSrSr/ SS4S\\   S\\   S\	4S jjr
S	 r\S
\S\\   S\SS4S j5       r\S\SS4S j5       rSUS jrS\SS4S jrS
\S\\   S\SS4S jrS\\\	4   S\	4S jrSUS jrS\\\\	4      S\SS4S jrS\\\\	4      SS4S jrS\\\\	4      SS4S jrSUS jrS\\\	4   S\\   SS4S jrS\4S jrSUS  jrS
\S\\   4S! jr  SVS"\\\\\   4      S#\SS4S$ jjr SUS% jr!S&\SS4S' jr"S(\\   SS4S) jr#SWS+\$S,\SS4S- jjr%   SXS.\&S/\S,\S0\S1\SS4S2 jjr'S3\(SS4S4 jr)S\\\	4   SS4S5 jr*\+RX                  S6:  Ga^  \       SYS*S*S7.S8\\\\\4   \	4      S9\\-\./\\   4      S:\\-\\	   /S4      S;\\-\/\//S4      S<\\-\0/S4      S=\\-\\	   /S4      S>\\-\./S4      S?\1S*   S@\1S*   S\04SA jjj5       r2\      SZS*SB.S8\\\\\4   \	4      S9\\-\./\\   4      S:\\-\\	   /S4      S;\\-\/\//S4      S<\\-\0/S4      S=\\-\\	   /S4      S?\1SC   S@\S\34SD jjj5       r2\      SZS*SE.S8\\\\\4   \	4      S9\\-\./\\   4      S:\\-\\	   /S4      S;\\-\/\//S4      S<\\-\0/S4      S=\\-\\	   /S4      S?\S@\1SC   S\34SF jjj5       r2Op\       SYS8\\\\\4   \	4      S9\\-\./\\   4      S:\\-\\	   /S4      S;\\-\/\//S4      S<\\-\0/S4      S=\\-\\	   /S4      S>\\-\./S4      S\04SG jj5       r2\         S[S8\\\\\4   \	4      S9\\-\./\\   4      S:\\-\\	   /S4      S;\\-\/\//S4      S<\\-\0/S4      S=\\-\\	   /S4      S>\\-\./S4      S?\S@\S\\3\04   4SH jj5       r2         S[S8\\\\\4   \	4      S9\\-\./\\   4      S:\\-\\	   /S4      S;\\-\/\//S4      S<\\-\0/S4      S=\\-\\	   /S4      S>\\-\./S4      S?\S@\S\\3\04   4SI jjr2\4S\54SJ j5       r6\4S\4SK j5       r7\7Rp                  SL\SS4SM j5       r7\4S\4SN j5       r9\9Rp                  SL\SS4SO j5       r9\4S\4SP j5       r:\4S\;4SQ j5       r<\4S\=4SR j5       r>\4S\?\@   4SS j5       rASTrBg)\r)      a  
Control object for the grounding/solving process.

Parameters
----------
arguments
    Arguments to the grounder and solver.
logger
    Function to intercept messages normally printed to standard error.
message_limit
    The maximum number of messages passed to the logger.

Notes
-----
Note that only gringo options (without `--text`) and clasp's search options
are supported. Furthermore, you must not call any functions of a `Control`
object while a solve call is active.
N   r   loggermessage_limitc           	         SU l         / U l        [        U[        R                  5      (       Ga  UbB  [
        R                  " U5      n[        R                  nU R                  R                  U5        O [
        R                  n[
        R                  n/ n[
        R                  " S[        U5      5      n[        U5       H@  u  pUR                  [
        R                  " SU	R                  5       5      5        US   Xx'   MB     [        S[        R                   U[        U5      UUU5      U l        SU l         OXl        S U l        S U l        SU l        [+        5       U l        g )NFchar*[]char[]zclingo_control_t *Tg      )_free_memr|   r   r	   r   
new_handler   pyclingo_logger_callbackr{   NULLr   r   r   encoder   clingo_control_newr   _handlerr%   _statistics_callr   _error)
rE   r   r   r   c_handlec_cbc_memrl   ro   args
             r;   rJ   Control.__init__   s    
	i..!??6244		  *99yyEXXiY8F#I.TXXh

=>!"I	 /  $''IDI DJ!I $hr:   c                 h    U R                   (       a!  [        R                  " U R                  5        g g r@   )r   r   clingo_control_freer   rE   s    r;   __del__Control.__del__   s     ::$$TYY/ r:   r^   
parametersprogramreturnc                     g)a$  
Extend the logic program with the given non-ground logic program in string form.

Parameters
----------
name
    The name of program block to add.
parameters
    The parameters of the program block to add.
program
    The non-ground program in string form.

See Also
--------
Control.ground
Nr-   )rE   r^   r   r   s       r;   addControl.add       r:   c                     g)z
Extend the logic program with the given non-ground logic program in string form.

Parameters
----------
name
    The name of program block to add.

Notes
-----
This function is equivalent to calling `add("base", [], program)`.
Nr-   rE   r   s     r;   r   r     r   r:   c                     [        U5      [        U5      -   nUS:X  a  U R                  " U0 UD6  gU R                  " U0 UD6  g)a  
Extend the logic program with the given non-ground logic program in string form.

This function provides two overloads:

```python
def add(self, name: str, parameters: Sequence[str], program: str) -> None:
    ...

def add(self, program: str) -> None:
    return self.add("base", [], program)
```

Parameters
----------
name
    The name of program block to add.
parameters
    The parameters of the program block to add.
program
    The non-ground program in string form.

See Also
--------
Control.ground
r   N)r   _add1_add2)rE   r   kwargsns       r;   r   r   !  s?    6 IF#6JJ''JJ''r:   c                 *    U R                  S/ U5        g )Nbase)r   r   s     r;   r   Control._add1B  s    

62w'r:   c           
         / n[         R                  " S[        U5      5      n[        U5       H@  u  pgUR	                  [         R                  " SUR                  5       5      5        US   XV'   MB     [        [        R                  " U R                  UR                  5       U[        U5      UR                  5       5      5        g )Nr   r   r   )
r   r   r   r   r{   r   r   r   clingo_control_addr   )rE   r^   r   r   r   c_paramsro   params           r;   r   Control._add2E  s    88Is:7!*-HALL(ELLN;<)HK . 	##		4;;=(C
OW^^EU	
r:   litc                 p    [        U[        5      (       a  U$ U R                  U   nUc  S$ UR                  $ )Nr   )r|   re   symbolic_atomsliteral)rE   r   satoms      r;   _program_atomControl._program_atomQ  s7    c3J##C(Mq4u}}4r:   c                 V    [        [        R                  " U R                  5      5        g)z
Remove all minimize constraints from the program.

This function removes all minimize constraints that were previously added to the program.
N)r   r   clingo_control_remove_minimizer   r   s    r;   remove_minimizeControl.remove_minimizeW  s     	d99$))DEr:   atomsr{   c           	          [         R                  " S[        U5      5      n[        U5       H  u  pEU R	                  U5      X4'   M     [        [        R                  " U R                  U[        U5      U5      5        g )Nzclingo_atom_t[])	r   r   r   r   r   r   r   clingo_control_update_projectr   )rE   r   r{   p_projro   r   s         r;   _update_projectControl._update_project_  sb     +SZ8&FA**3/FI ' 	..tyy&#e*fU	
r:   c                 $    U R                  USS9  g)a0  
Add atoms to project on to the program.

Parameters
----------
atoms
    List of atoms or program literals (see `clingo.symbolic_atoms.SymbolicAtom.literal`) to project on.

Notes
-----
The function extends the set of atoms to project on with the given atoms.

See Also
--------
Control.replace_project
Tr{   Nr   rE   r   s     r;   add_projectControl.add_projectj  s    " 	U40r:   c                 $    U R                  USS9  g)aJ  
Set atoms to project on.

Parameters
----------
atoms
   List of atoms or program literals (see `clingo.symbolic_atoms.SymbolicAtom.literal`) to project on.

Notes
-----
The function sets the atoms to project on to the given atoms thereby replacing any previously added project
statements.

See Also
--------
Control.add_project
Fr   Nr   r   s     r;   replace_projectControl.replace_project}  s    $ 	U51r:   c                 $    U R                  / SS9  g)zE
Remove all projection atoms.

See Also
--------
Control.add_project
Fr   Nr   r   s    r;   remove_projectControl.remove_project  s     	R.r:   externaltruthc                     Uc  [         R                  nO(U(       a  [         R                  nO[         R                  n[	        [         R
                  " U R                  U R                  U5      U5      5        g)a>  
Assign a truth value to an external atom.

Parameters
----------
external
    A symbol or program literal representing the external atom.
truth
    A Boolean fixes the external to the respective truth value; and
    None leaves its truth value open.

See Also
--------
Control.release_external, clingo.solving.SolveControl.symbolic_atoms,
clingo.symbolic_atoms.SymbolicAtom.is_external

Notes
-----
The truth value of an external atom can be changed before each solve
call. An atom is treated as external if it has been declared using an
`#external` directive, and has not been released by calling
`Control.release_external` or defined in a logic program with some
rule. If the given atom is not external, then the function has no
effect.

For convenience, the truth assigned to atoms over negative program
literals is inverted.
N)r   clingo_external_type_freeclingo_external_type_trueclingo_external_type_falser   clingo_control_assign_externalr   r   )rE   r   r   vals       r;   assign_externalControl.assign_external  sZ    @ =00C00C11C//		4--h7	
r:   c                 t    [        [        S[        R                  U R                  5      U R
                  5      $ )zy
Returns a `Backend` object providing a low level interface to extend a
logic program.

See Also
--------
clingo.backend
zclingo_backend_t*)r   r   r   clingo_control_backendr   r   r   s    r;   backendControl.backend  s/     ')D)DdiiPKK
 	
r:   c                 V    [        [        R                  " U R                  5      5        g)a;  
Cleanup the domain used for grounding by incorporating information from
the solver.

This function cleans up the domain used for grounding.  This is done by
first simplifying the current program representation (falsifying
released external atoms).  Afterwards, the top-level implications are
used to either remove atoms from the domain or mark them as facts.

See Also
--------
Control.enable_cleanup

Notes
-----
Any atoms falsified are completely removed from the logic program.
Hence, a definition for such an atom in a successive step introduces a
fresh atom.

With the current implementation, the function only has an effect if
called after solving and before any function is called that starts a
new step.

Typically, it is not necessary to call this function manually because
automatic cleanups are enabled by default.
N)r   r   clingo_control_cleanupr   r   s    r;   cleanupControl.cleanup  s    6 	d11$))<=r:   c           	          [        S[        R                  U R                  UR	                  5       5      (       d  g[        [        S[        R                  U R                  UR	                  5       5      5      $ )z
Return the symbol for a constant definition of form:

    #const name = symbol.

Parameters
----------
name
    The name of the constant to retrieve.

Returns
-------
The function returns `None` if no matching constant definition exists.
rM   Nclingo_symbol_t)r   r   clingo_control_has_constr   r   r&   clingo_control_get_const)rE   r^   s     r;   	get_constControl.get_const  sY     vt<<diiWW!--			
 	
r:   partsr   c           
      b   U R                   R                  5         [        X R                   5      nU(       a  [        R                  " U5      O[        R
                  nU(       a  [        R                  O[        R
                  n/ n[        R                  " S[        U5      5      n[        X5       H  u  pUR                  [        R                  " SUS   R                  5       5      5        US   U	l        UR                  [        R                  " S[        US   5      5      5        US   U	l        [        US   5       H  u  pUR                   U	R                  U
'   M      [        US   5      U	l        M     [%        [        R&                  " U R                   U[        U5      XT5      U5        g)a  
Ground the given list of program parts specified by tuples of names and
arguments.

Parameters
----------
parts
    List of tuples of program names and program arguments to ground.
context
    A context object whose methods are called during grounding using
    the `@`-syntax (if omitted, those from the main module are used).

Notes
-----
Note that parts of a logic program without an explicit `#program`
specification are by default put into a program called `base` without
arguments.
zclingo_part_t[]r   r   r   ru   r   N)r   clearr   r   r   r   r   rr   r   r   zipr{   r   r^   paramsr   r   rn   r   clingo_control_ground)rE   r   r   r[   c_datar   r   c_partspartc_partro   r   s               r;   groundControl.ground  s-   0 	w,*1&tyy07t,,TYY((,c%j9/LDLL(DGNN,<=>)FKLL"5s47|DE!"IFM#DG,#&88a  -d1g,FK 0 	&&tyy'3u:tT	
r:   c                 D    [         R                  " U R                  5        g)a!  
Interrupt the active solve call.

Notes
-----
This function is thread-safe and can be called from a signal handler. If no
search is active, the subsequent call to `Control.solve` is interrupted. The
result of the `Control.solve` method can be used to query if the search was
interrupted.
N)r   clingo_control_interruptr   r   s    r;   	interruptControl.interrupt:  s     	%%dii0r:   pathc                 t    [        [        R                  " U R                  UR	                  5       5      5        g)z
Extend the logic program with a (non-ground) logic program in a file.

Parameters
----------
path
    The path of the file to load.
N)r   r   clingo_control_loadr   r   )rE   r  s     r;   loadControl.loadG  s#     	d..tyy$++-HIr:   filesc           	      N   / n[         R                  " S[        U5      5      n[        U5       H@  u  pEUR	                  [         R                  " SUR                  5       5      5        US   X4'   MB     [        [        R                  " U R                  U[        U5      5      5        g)a  
Extend the logic program with a program in aspif format.

This function should be called on an empty control object. If more than
one file is given, they are merged into one file. Only the first one
should have a preamble.

Parameters
----------
files
    A list of files to load.
r   r   r   N)
r   r   r   r   r{   r   r   r   clingo_control_load_aspifr   )rE   r  r   c_filesro   r  s         r;   
load_aspifControl.load_aspifR  sw     ((9c%j1 'GALL(DKKM:;rGJ ( 	d44TYYUTUr:   Fobserverreplacec                    [         R                  " S[        [        US5      (       a  [        R
                  O[         R                  [        [        US5      (       a  [        R                  O[         R                  [        [        US5      (       a  [        R                  O[         R                  [        [        US5      (       a  [        R                  O[         R                  [        [        US5      (       a  [        R                  O[         R                  [        [        US5      (       a  [        R                  O[         R                  [        [        US5      (       a  [        R                  O[         R                  [        [        US	5      (       a  [        R                  O[         R                  [        [        US
5      (       a  [        R                  O[         R                  [        [        US5      (       a  [        R                  O[         R                  [        [        US5      (       a  [        R                   O[         R                  [        [        US5      (       a  [        R"                  O[         R                  [        [        US5      (       a  [        R$                  O[         R                  [        [        US5      (       a  [        R&                  O[         R                  [        [        US5      (       a  [        R(                  O[         R                  [        [        US5      (       a  [        R*                  O[         R                  [        [        US5      (       a  [        R,                  O[         R                  [        [        US5      (       a  [        R.                  O[         R                  [        [        US5      (       a  [        R0                  O[         R                  45      n[         R2                  " [5        XR6                  5      5      nU R8                  R;                  U5        [=        [        R>                  " U R@                  X2U5      5        g)aw  
Registers the given observer to inspect the produced grounding.

Parameters
----------
observer
    The observer to register. See below for a description of the required
    interface.
replace
    If set to true, the output is just passed to the observer and no longer to
    the underlying solver (or any previously registered observers).

See Also
--------
clingo.backend
z!clingo_ground_program_observer_t*init_program
begin_stepend_stepruleweight_ruleminimizeprojectoutput_atomoutput_termr   assume	heuristic	acyc_edgetheory_term_numbertheory_term_stringtheory_term_compoundtheory_elementtheory_atomtheory_atom_with_guardN)!r   r   r   r   r   pyclingo_observer_init_programr   pyclingo_observer_begin_steppyclingo_observer_end_steppyclingo_observer_rulepyclingo_observer_weight_rulepyclingo_observer_minimizepyclingo_observer_projectpyclingo_observer_output_atompyclingo_observer_output_termpyclingo_observer_externalpyclingo_observer_assumepyclingo_observer_heuristicpyclingo_observer_acyc_edge$pyclingo_observer_theory_term_number$pyclingo_observer_theory_term_string&pyclingo_observer_theory_term_compound pyclingo_observer_theory_elementpyclingo_observer_theory_atom(pyclingo_observer_theory_atom_with_guardr   r   r   r   r{   r    clingo_control_register_observerr   )rE   r  r  
c_observerr   s        r;   register_observerControl.register_observerf  s   $ XX/ $HhGG 77 $HhEE 55 $Hh
CC 33 $Hh?? // $HhFF 66 $Hh
CC 33 $Hh	BB 22 $HhFF 66 $HhFF 66 $Hh
CC 33 $HhAA 11 $HhDD 44 $HhDD 44 $Hh8LMM == $Hh8LMM == $Hh8NOO ?? $Hh8HII 99 $HhFF 66 $Hh8PQQ AA}`c

H ;;!?@		 11		:	
r:   typefile
reify_sccsreify_stepsc                     UR                   nU(       a  U[        R                  -  nU(       a  U[        R                  -  n[	        [        R
                  " U R                  XbR                  5       U5      5        g)a  
Registers a backend of the given type.

This function is similar to register_observer but instead registers a predefined backend.

Parameters
----------
type
    The type of backend to register.
file:
    The path of the file to write to.
replace
    If set to true, the output is just passed to the backend and no longer to
    the underlying solver (or any previously registered backends/observers).
reify_sccs
    Whether to reify sccs.
reify_steps
    Whether to reify steps.

See Also
--------
clingo.backend
N)valuer   clingo_backend_type_reify_sccsclingo_backend_type_reify_stepsr   clingo_control_register_backendr   r   )rE   r?  r@  r  rA  rB  bitsets          r;   register_backendControl.register_backend  sZ    > dAAAFdBBBF00		6;;='	
r:   
propagatorc                 "   [         R                  " S[        [        US5      (       a  [        R
                  O[         R                  [        [        US5      (       a  [        R                  O[         R                  [        [        US5      (       a  [        R                  O[         R                  [        [        US5      (       a  [        R                  O[         R                  [        [        US5      (       a  [        R                  O[         R                  45      n[         R                  " [        XR                  5      5      nU R                  R                  U5        [!        [        R"                  " U R$                  X#S5      5        g)	z
Registers the given propagator with all solvers.

Parameters
----------
propagator
    The propagator to register.

See Also
--------
clingo.propagator
zclingo_propagator_t*init	propagateundocheckdecideFN)r   r   r   r   r   pyclingo_propagator_initr   pyclingo_propagator_propagatepyclingo_propagator_undopyclingo_propagator_checkpyclingo_propagator_decider   r   r   r   r{   r   "clingo_control_register_propagatorr   )rE   rK  c_propagatorr   s       r;   register_propagatorControl.register_propagator  s    xx" $J
FCC 11 $J
KHH 66 $J
FCC 11 $J
GDD 22 $J
HEE 331
< [[!AB		 33		<	
r:   c                 v    [        [        R                  " U R                  U R	                  U5      5      5        g)a  
Release an external atom represented by the given symbol or program
literal.

This function causes the corresponding atom to become permanently false
if there is no definition for the atom in the program. Otherwise, the
function has no effect.

Parameters
----------
external
    The symbolic atom or program atom to release.

Notes
-----
If the program literal is negative, the corresponding atom is released.

Examples
--------
The following example shows the effect of assigning and releasing and external
atom.

    >>> from clingo.symbol import Function
    >>> from clingo.control import Control
    >>>
    >>> ctl = Control()
    >>> ctl.add("base", [], "a. #external b.")
    >>> ctl.ground([("base", [])])
    >>> ctl.assign_external(Function("b"), True)
    >>> print(ctl.solve(on_model=print))
    b a
    SAT
    >>> ctl.release_external(Function("b"))
    >>> print(ctl.solve(on_model=print))
    a
    SAT
N)r   r   clingo_control_release_externalr   r   )rE   r   s     r;   release_externalControl.release_externalB  s/    L 	00		4--h7	
r:   r   )yield_async_assumptionsrF   rG   rH   rI   on_coreon_lastr_  r`  c                    g r@   r-   
rE   ra  rF   rG   rH   rI   rb  rc  r_  r`  s
             r;   solveControl.solver  s     r:   )r`  Tc                    g r@   r-   	rE   ra  rF   rG   rH   rI   rb  r_  r`  s	            r;   rf  rg         r:   )r_  c                    g r@   r-   ri  s	            r;   rf  rg    rj  r:   c                     g r@   r-   )rE   ra  rF   rG   rH   rI   rb  rc  s           r;   rf  rg    s     r:   c
                     g r@   r-   re  s
             r;   rf  rg    s     +.r:   c
                 (   U R                   R                  5         [        X#XE5      n
[        XR                   5      n[        R
                  " U5      U l        [        R                  nU(       a  Sn[        R                  " S[        U5      5      n[        U5       Hc  u  p[        U[        5      (       a  XU'   M   Uc  U R                  nU R                  US      nUc  SOUR                  nUS   (       a  UOU* X'   Me     SnU(       a  U[        R                   -  nU	(       a  U[        R"                  -  n[%        ['        S[        R(                  U R*                  UU[        U5      [        R,                  U R                  US9	U5      nU(       dm  U	(       df  U   UR/                  5       nUb'  UR0                  (       a  U" UR3                  5       5        Ub  UR5                  5       nUb  U" U5        UsSSS5        $ U$ ! , (       d  f       U$ = f)a	  
Starts a search.

Parameters
----------
assumptions
    List of (atom, boolean) tuples or program literals (see
    `clingo.symbolic_atoms.SymbolicAtom.literal`) that serve as
    assumptions for the solve call, e.g., solving under assumptions
    `[(Function("a"), True)]` only admits answer sets that contain atom `a`.
on_model
    Optional callback for intercepting models.
    A `clingo.solving.Model` object is passed to the callback. The
    search can be interrupted from the model callback by returning
    False.
on_unsat
    Optional callback to intercept lower bounds during optimization.
on_statistics
    Optional callback to update statistics.
    The step and accumulated statistics are passed as arguments.
on_finish
    Optional callback called once search has finished.
    A `clingo.solving.SolveResult` also indicating whether the solve
    call has been interrupted is passed to the callback.
on_core
    Optional callback called with the assumptions that made a problem
    unsatisfiable.
on_last
    Optional callback for getting the last model computed for a satisfiable problem.
    A `clingo.solving.Model` object is passed to the callback.
yield_
    The resulting `clingo.solving.SolveHandle` is iterable yielding
    `clingo.solving.Model` objects.
async_
    The solve call and the method `clingo.solving.SolveHandle.resume`
    of the returned handle are non-blocking.

Returns
-------
The return value depends on the parameters. If either `yield_` or
`async_` is true, then a handle is returned. Otherwise, a
`clingo.solving.SolveResult` is returned.

See Also
--------
clingo.solving

Notes
-----
If neither `yield_` nor `async_` is set, the function returns a
`clingo.solving.SolveResult` right away.

In gringo or in clingo with lparse or text output enabled, this
function just grounds and returns a `clingo.solving.SolveResult` where
`clingo.solving.SolveResult.unknown` is true.

If this function is used in embedded Python code, you might want to start
clingo using the `--outf=3` option to disable all output from clingo.

Asynchronous solving is only available in clingo with thread support
enabled. Furthermore, the on_model and on_finish callbacks are called
from another thread. To ensure that the methods can be called, make
sure to not use any functions that block Python's GIL indefinitely.

This function as well as blocking functions on the
`clingo.solving.SolveHandle` release the GIL but are not thread-safe.
Nzclingo_literal_t[]r   r   r   zclingo_solve_handle_t*)rk   )r   r   r=   r   r   r   r   r   r   r   r   r|   re   r   r   r   clingo_solve_mode_yieldclingo_solve_mode_asyncr!   r   clingo_control_solver   r\   getunsatisfiablecorelast)rE   ra  rF   rG   rH   rI   rb  rc  r_  r`  rk   r[   p_assr   ro   r   atomslitmodehandlerO   rN   s                         r;   rf  rg    s   ` 	$XRw,-		EHH13{3CDE#K0c3''"!H} $ 3 3..s1v6D!%24<<D'*1vtD5EH 1 D000DD000D())		K 22
 
 fjjl&3+<+<FKKM*&A}
    s   AH
Hc                     [        S[        R                  U R                  5      n[        S[        R                  U5      n[        X5      $ )z%
Object to change the configuration.
zclingo_configuration_t*clingo_id_t)r   r   clingo_control_configurationr   clingo_configuration_rootr   )rE   confkeys      r;   configurationControl.configurationC  s@    
 %t'H'H$))
 mT%C%CTJT''r:   c                 B    [         R                  " U R                  5      $ )z9
Whether to enable automatic calls to `Control.cleanup`.
)r   !clingo_control_get_enable_cleanupr   r   s    r;   enable_cleanupControl.enable_cleanupN  s    
 55dii@@r:   rD  c                 X    [        [        R                  " U R                  U5      5        g r@   )r   r   !clingo_control_set_enable_cleanupr   rE   rD  s     r;   r  r  U  s    d<<TYYNOr:   c                 B    [         R                  " U R                  5      $ )a5  
Whether to discard or keep learnt information from enumeration modes.

If the enumeration assumption is enabled, then all information learnt from
clasp's various enumeration modes is removed after a solve call. This includes
enumeration of cautious or brave consequences, enumeration of answer sets with
or without projection, or finding optimal models; as well as clauses added with
`clingo.solving.SolveControl.add_clause`.

Notes
-----
Initially the enumeration assumption is enabled.

In general, the enumeration assumption should be enabled whenever there are
multiple calls to solve. Otherwise, the behavior of the solver will be
unpredictable because there are no guarantees which information exactly is
kept. There might be small speed benefits when disabling the enumeration
assumption for single shot solving.
)r   0clingo_control_get_enable_enumeration_assumptionr   r   s    r;   enable_enumeration_assumption%Control.enable_enumeration_assumptionY  s    * DDTYYOOr:   c                 X    [        [        R                  " U R                  U5      5        g r@   )r   r   0clingo_control_set_enable_enumeration_assumptionr   r  s     r;   r  r  p  s    AA$))US	
r:   c                 B    [         R                  " U R                  5      $ )a  
Whether the internal program representation is conflicting.

If this (read-only) property is true, solve calls return immediately with an
unsatisfiable solve result.

Notes
-----
Conflicts first have to be detected, e.g., initial unit propagation results in
an empty clause, or later if an empty clause is resolved during solving. Hence,
the property might be false even if the problem is unsatisfiable.
)r   clingo_control_is_conflictingr   r   s    r;   is_conflictingControl.is_conflictingv  s     11$))<<r:   c                 L   [        S[        R                  U R                  5      n[        R
                  " S5      n[        U[        R                  U5      n[        U[        R                  XSR                  5       5      n[        U[        R                  XSR                  5       5      n[        S[        R                  X5      nU R                  b  X`R                  :w  a  SU l
        U R                  c  X`l        [        X5      U l
        [        [        U R                  5      $ )a  
A `dict` containing solve statistics of the last solve call.

See Also
--------
clingo.statistics

Notes
-----
The statistics correspond to the `--stats` output of clingo. The detail of the
statistics depends on what level is requested on the command line. Furthermore,
there are some functions like `Control.release_external` that start a new
solving step resetting the current step statistics. It is best to access the
statistics right after solving.

This property is only available in clingo.
zclingo_statistics_t*z	uint64_t*summarycalldoubleN)r   r   clingo_control_statisticsr   r   r   clingo_statistics_rootclingo_statistics_map_atr   clingo_statistics_value_getr%   r   r   dict)rE   statsp_keykey_rootkey_summarykey_callr  s          r;   
statisticsControl.statistics  s    & "D$B$BDII
 %5$"="=uE400%9CSCSCU
 400%fmmo
 x!A!A5S'D4I4I,I#D#$(!*5;DD$**++r:   c                 ^    [        [        S[        R                  U R                  5      5      $ )zS
An object to inspect the symbolic atoms.

See Also
--------
clingo.symbolic_atoms
zclingo_symbolic_atoms_t*)r'   r   r   clingo_control_symbolic_atomsr   r   s    r;   r   Control.symbolic_atoms  s,     *22		
 	
r:   c              #      #    [        S[        R                  U R                  5      n[        S[        R                  U5      n[        U5       H  n[        X5      v   M     g7f)zX
An iterator over the theory atoms in a program.

See Also
--------
clingo.theory_atoms
zclingo_theory_atoms_t*r`   N)r   r   clingo_control_theory_atomsr   clingo_theory_atoms_sizerf   r(   )rE   r   rn   idxs       r;   theory_atomsControl.theory_atoms  sQ      $d&F&F		
 x!>!>F;CU(( s   A!A#)r   r   r   r   r   r%   r   )r   N)))r   r-   N)F)FFF)r-   NNNNNN)r-   NNNNN)	r-   NNNNNNFF)Cr.   r/   r0   r1   r2   r	   strr   r   re   rJ   r   r   r   r   r   r   r&   r   r   rM   r   r   r   r   r   r   r   r   r   r
   r   r  r  r  r  r   r=  r*   rI  r   rY  r]  ry   version_infor   r    r#   r"   r   rf  r!   propertyr   r  r  setterr  r  r  r  r'   r   r   r(   r  r9   r-   r:   r;   r)   r)      s
   * $&#'	&C=&  & 	&P0  #    $ 3 4  (B(S (T (

# 

8C= 

3 

4 

5vs{!3 5 5F	
eFCK01	
;?	
		
1%*<!= 1$ 1&2XeFCK.@%A 2d 2(/*
fck**
3;D>*
	*
X
 
>:
c 
hv&6 
: 9H+
c8F#3345+
 +
 
	+
Z1	J 	J 	JV V$ V(|
( |
T |
d |
D  !(
(
 (
 	(

 (
 (
 
(
T2
j 2
T 2
h*
vs{); *
 *
\ 6!	 FHDHBF AEAE9=	 &+%*	!%fdl(;S(@"AB	 x$(?@A	 x#(=>?		
 $-7=>	  +)< =>	 h'<=>	 hw}56	 EN	 EN	 	 
	 
 FHDHBF AEAE	 !	!%fdl(;S(@"AB	 x$(?@A	 x#(=>?		
 $-7=>	  +)< =>	 h'<=>	 DM	 	 	 
	 
 FHDHBF AEAE	 !	!%fdl(;S(@"AB	 x$(?@A	 x#(=>?		
 $-7=>	  +)< =>	 h'<=>	 	 DM	 	 
	" 
 FHDHBF AEAE9=	!%fdl(;S(@"AB	 x$(?@A	 x#(=>?		
 $-7=>	  +)< =>	 h'<=>	 hw}56	 	 
	  BD@D>BRV=A=A59.eE&$,$7$<=>. 8UGXd^$;<=. 8Xc]OT$9:;	.
  -)G)M NO. Hk]D%89:. (HSM?D#89:. (E7D=12. . . 
{K'	(. . BD@D>BRV=A=A59BeE&$,$7$<=>B 8UGXd^$;<=B 8Xc]OT$9:;	B
  -)G)M NOB Hk]D%89:B (HSM?D#89:B (E7D=12B B B 
{K'	(BH (} ( ( A A A PD PT P P Pt P P, #))
4 
D 
 *

 = = = ',D ', ',R 
 
 
  )hz2 ) )r:   )9r2   ry   collectionsr   enumr   typingr   r   r   r   r	   r
   r   r   r   r  r   	_internalr   r   r   r   r   r   r   r   r   r   r   r  r   rt  r   rK  r   solvingr    r!   r"   r  r#   r$   r%   symbolr&   r   r'   r  r(   __all__r*   r=   
def_externrq   r   r)   r-   r:   r;   <module>r     s   (T   
 
 
 v	 	 	 ' (  " 4 4 G G  ) $m
$' &V V6 f%,K0 *629ST UBQ) Q)r:   