
    cwi)                         S r SSKJr  SSK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Qr " S S	\5      r\ " S
 S5      5       r\ " S S5      5       r\ " S S5      5       rg)a  
Functions and classes to work with theory atoms.

Examples
--------
    >>> from clingo.control import Control
    >>>
    >>> ctl = Control()
    >>> ctl.add('base', [], """\
    ... #theory example {
    ...     t { };
    ...     &a/0 : t, head
    ... }.
    ... {c}.
    ... &a { t: c }.
    ... """)
    >>> ctl.ground([('base', [])])
    >>> atm = next(ctl.theory_atoms)
    >>> print(atm)
    &a{t: c}
    >>> elm = atm.elements[0]
    >>> print(elm)
    t: c
    )total_ordering)ListOptionalTuple   )_c_call_c_call2_lib_str_to_str)OrderedEnum)
TheoryAtomTheoryElement
TheoryTermTheoryTermTypec                       \ rS rSrSr\R                  r \R                  r	 \R                  r \R                  r \R                  r \R                   rSrg)r   #   z#
Enumeration of theory term types.
 N)__name__
__module____qualname____firstlineno____doc__r
    clingo_theory_term_type_functionFunctionclingo_theory_term_type_listr   clingo_theory_term_type_numberNumberclingo_theory_term_type_setSetclingo_theory_term_type_symbolSymbolclingo_theory_term_type_tupler   __static_attributes__r       M/home/james-whalen/.local/lib/python3.13/site-packages/clingo/theory_atoms.pyr   r   #   ss     44H ,,D 00F 
*
*C 00F ..Er%   r   c                       \ rS rSrSrS rS rS rS rS r	S r
\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   B   z
`TheoryTerm` objects represent theory terms.

Theory terms have a readable string representation, implement Python's rich
comparison operators, and can be used as dictionary keys.
c                     Xl         X l        g N_rep_idxselfrepidxs      r&   __init__TheoryTerm.__init__K       		r%   c                     U R                   $ r*   r-   r/   s    r&   __hash__TheoryTerm.__hash__O       yyr%   c                 4    U R                   UR                   :H  $ r*   r6   r/   others     r&   __eq__TheoryTerm.__eq__R       yyEJJ&&r%   c                 4    U R                   UR                   :  $ r*   r6   r<   s     r&   __lt__TheoryTerm.__lt__U       yy5::%%r%   c                 ~    [        [        R                  [        R                  U R                  U R
                  5      $ r*   )r   r
   'clingo_theory_atoms_term_to_string_size"clingo_theory_atoms_term_to_stringr,   r-   r7   s    r&   __str__TheoryTerm.__str__X   /    8833IIII	
 	
r%   c                 $    SU R                   < S3$ )NzTheoryTerm()r,   r7   s    r&   __repr__TheoryTerm.__repr__`       TYYM++r%   returnc                     [        SS[        R                  U R                  U R                  5      u  p[        U5       Vs/ s H  n[        U R                  X   5      PM     sn$ s  snf )zD
The arguments of the term (for functions, tuples, list, and sets).
clingo_id_t*size_t)r	   r
   "clingo_theory_atoms_term_argumentsr,   r-   ranger   )r/   argssizeis       r&   	argumentsTheoryTerm.argumentsc   sX    
 33IIII

 9>dD1
499dg.DDD   "A&c                 t    [        [        S[        R                  U R                  U R
                  5      5      $ )z3
The name of the term (for symbols and functions).
char*)r   r   r
   clingo_theory_atoms_term_namer,   r-   r7   s    r&   nameTheoryTerm.nameq   s-    
 GT??DIIV
 	
r%   c                 b    [        S[        R                  U R                  U R                  5      $ )z7
The numeric representation of the term (for numbers).
int)r   r
   clingo_theory_atoms_term_numberr,   r-   r7   s    r&   numberTheoryTerm.numberz   s(    
 477DII
 	
r%   c                 x    [        S[        R                  U R                  U R                  5      n[        U5      $ )z
The type of the theory term.
clingo_theory_term_type_t)r   r
   clingo_theory_atoms_term_typer,   r-   r   )r/   type_s     r&   typeTheoryTerm.type   s5    
 '..IIII	
 e$$r%   r-   r,   N)r   r   r   r   r   r2   r8   r>   rB   rH   rN   propertyr   rZ   strr`   rc   re   r   rk   r$   r   r%   r&   r   r   B   s    '&
, E4- E E 
c 
 
 
 
 
 
%n 
% 
%r%   r   c                       \ rS rSrSrS rS rS rS rS r	S r
\S	\\   4S
 j5       r\S	\4S j5       r\S	\\   4S j5       rSrg)r      z
Class to represent theory elements.

Theory elements have a readable string representation, implement Python's rich
comparison operators, and can be used as dictionary keys.
c                     Xl         X l        g r*   r+   r.   s      r&   r2   TheoryElement.__init__   r4   r%   c                     U R                   $ r*   r6   r7   s    r&   r8   TheoryElement.__hash__   r:   r%   c                 4    U R                   UR                   :H  $ r*   r6   r<   s     r&   r>   TheoryElement.__eq__   r@   r%   c                 4    U R                   UR                   :  $ r*   r6   r<   s     r&   rB   TheoryElement.__lt__   rD   r%   c                 ~    [        [        R                  [        R                  U R                  U R
                  5      $ r*   )r   r
   *clingo_theory_atoms_element_to_string_size%clingo_theory_atoms_element_to_stringr,   r-   r7   s    r&   rH   TheoryElement.__str__   s/    ;;66IIII	
 	
r%   c                 $    SU R                   < S3$ )NzTheoryElement(rL   rM   r7   s    r&   rN   TheoryElement.__repr__   s    		}A..r%   rQ   c                     [        SS[        R                  U R                  U R                  5      u  p[        U5       Vs/ s H  o1U   PM	     sn$ s  snf )zE
The condition of the element in form of a list of program literals.
zclingo_literal_t*rT   )r	   r
   %clingo_theory_atoms_element_conditionr,   r-   rV   )r/   condrX   rY   s       r&   	conditionTheoryElement.condition   sM    
 66IIII

 "'t-AQ---s   Ac                 b    [        S[        R                  U R                  U R                  5      $ )z
Each condition has an id, which is a temporary program literal. This id
can be passed to `clingo.propagator.PropagateInit.solver_literal` to
obtain a corresponding solver literal.
clingo_literal_t)r   r
   (clingo_theory_atoms_element_condition_idr,   r-   r7   s    r&   condition_idTheoryElement.condition_id   s+     99IIII	
 	
r%   c                     [        SS[        R                  U R                  U R                  5      u  p[        U5       Vs/ s H  n[        U R                  X   5      PM     sn$ s  snf )z
The tuple of the element.
rS   rT   )r	   r
   !clingo_theory_atoms_element_tupler,   r-   rV   r   )r/   termsrX   rY   s       r&   r   TheoryElement.terms   sX    
 22IIII
 :?tEA
499eh/EEEr\   rm   N)r   r   r   r   r   r2   r8   r>   rB   rH   rN   rn   r   rc   r   r   r   r   r$   r   r%   r&   r   r      s    '&
/ .49 . . 
c 
 
 FtJ' F Fr%   r   c                       \ rS rSrSrS rS rS rS rS r	S r
\S	\\   4S
 j5       r\S	\\\\4      4S j5       r\S	\4S j5       r\S	\4S j5       rSrg)r      z
Class to represent theory atoms.

Theory atoms have a readable string representation, implement Python's rich
comparison operators, and can be used as dictionary keys.
c                     Xl         X l        g r*   r+   r.   s      r&   r2   TheoryAtom.__init__   r4   r%   c                     U R                   $ r*   r6   r7   s    r&   r8   TheoryAtom.__hash__   r:   r%   c                 4    U R                   UR                   :H  $ r*   r6   r<   s     r&   r>   TheoryAtom.__eq__   r@   r%   c                 4    U R                   UR                   :  $ r*   r6   r<   s     r&   rB   TheoryAtom.__lt__   rD   r%   c                 ~    [        [        R                  [        R                  U R                  U R
                  5      $ r*   )r   r
   'clingo_theory_atoms_atom_to_string_size"clingo_theory_atoms_atom_to_stringr,   r-   r7   s    r&   rH   TheoryAtom.__str__   rJ   r%   c                 $    SU R                   < S3$ )NzTheoryAtom(rL   rM   r7   s    r&   rN   TheoryAtom.__repr__   rP   r%   rQ   c                     [        SS[        R                  U R                  U R                  5      u  p[        U5       Vs/ s H  n[        U R                  X   5      PM     sn$ s  snf )z
The elements of the atom.
rS   rT   )r	   r
   !clingo_theory_atoms_atom_elementsr,   r-   rV   r   )r/   elemsrX   rY   s       r&   elementsTheoryAtom.elements   sY    
 22IIII
 =B$KHKqdii2KHHHr\   c                    [        S[        R                  U R                  U R                  5      (       d  g[        SS[        R                  U R                  U R                  5      u  p[        U5      [        U R                  U5      4$ )z9
The guard of the atom or None if the atom has no guard.
boolNr^   clingo_id_t)	r   r
   "clingo_theory_atoms_atom_has_guardr,   r-   r	   clingo_theory_atoms_atom_guardr   r   )r/   connterms      r&   guardTheoryAtom.guard  sr    
 D;;TYY		
 
 //IIII

 z$))T:;;r%   c                 b    [        S[        R                  U R                  U R                  5      $ )z/
The program literal associated with the atom.
r   )r   r
    clingo_theory_atoms_atom_literalr,   r-   r7   s    r&   literalTheoryAtom.literal   s+    
 11IIII	
 	
r%   c                     [        S[        R                  U R                  U R                  5      n[        U R                  U5      $ )z
The term of the atom.
r   )r   r
   clingo_theory_atoms_atom_termr,   r-   r   )r/   r   s     r&   r   TheoryAtom.term,  s8    
 4==tyy$))
 $))T**r%   rm   N)r   r   r   r   r   r2   r8   r>   rB   rH   rN   rn   r   r   r   r   r   ro   r   r   rc   r   r   r$   r   r%   r&   r   r      s    '&
, I$}- I I <xc:o 67 < <& 	
 	
 	
 +j + +r%   r   N)r   	functoolsr   typingr   r   r   	_internalr   r	   r
   r   r   corer   __all__r   r   r   r   r   r%   r&   <module>r      s   2 % ( ( = = 
I[ > K% K% K%\ HF HF HFV V+ V+ V+r%   