
    cwid                         S 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/r " S S5      r " S	 S\\   5      rg
)a&  
Functions and classes to work with symbolic atoms.

Examples
--------

    >>> from clingo.symbol import Function, Number
    >>> from clingo.control import Control
    >>> ctl = Control()
    >>> ctl.add('base', [], """\
    ... p(1).
    ... { p(3) }.
    ... #external p(1..3).
    ...
    ... q(X) :- p(X).
    ... """)
    >>> ctl.ground([("base", [])])
    >>> len(ctl.symbolic_atoms)
    6
    >>> ctl.symbolic_atoms[Function("p", [Number(2)])] is not None
    True
    >>> ctl.symbolic_atoms[Function("p", [Number(4)])] is None
    True
    >>> ctl.symbolic_atoms.signatures
    [('p', 1, True), ('q', 1, True)]
    >>> [(str(x.symbol), x.is_fact, x.is_external)
    ...  for x in ctl.symbolic_atoms.by_signature("p", 1)]
    [('p(1)', True, False), ('p(3)', False, False), ('p(2)', False, True)]
    )
CollectionIteratorListOptionalTuple   )_c_call_ffi_handle_error_lib_to_str)SymbolSymbolicAtomSymbolicAtomsc            	           \ rS rSrSrS rSS\S\S\S\4S j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rg)r   '   zH
Captures a symbolic atom and provides properties to inspect its state.
c                     Xl         X l        g N)_rep_it)selfrepits      O/home/james-whalen/.local/lib/python3.13/site-packages/clingo/symbolic_atoms.py__init__SymbolicAtom.__init__,   s    	    namearitypositivereturnc                 :    U R                   R                  XU5      $ )a)  
Check if the atom matches the given signature.

Parameters
----------
name
    The name of the function.

arity
    The arity of the function.

positive
    Whether to match positive or negative signatures.

Returns
-------
Whether the atom matches.

See Also
--------
clingo.symbol.Symbol.match
)symbolmatch)r   r   r   r    s       r   r$   SymbolicAtom.match0   s    . {{  h77r   c                 b    [        S[        R                  U R                  U R                  5      $ )z'
Whether the atom is an external atom.
bool)r	   r   !clingo_symbolic_atoms_is_externalr   r   r   s    r   is_externalSymbolicAtom.is_externalI   s(    
 D::DIItxx
 	
r   c                 b    [        S[        R                  U R                  U R                  5      $ )z
Whether the atom is a fact.
r'   )r	   r   clingo_symbolic_atoms_is_factr   r   r)   s    r   is_factSymbolicAtom.is_factR   s#    
 vtAA499dhhWWr   c                 b    [        S[        R                  U R                  U R                  5      $ )z/
The program literal associated with the atom.
clingo_literal_t)r	   r   clingo_symbolic_atoms_literalr   r   r)   s    r   literalSymbolicAtom.literalY   s(    
  B BDIItxx
 	
r   c                 t    [        [        S[        R                  U R                  U R
                  5      5      $ )z5
The representation of the atom in form of a symbol.
clingo_symbol_t)r   r	   r   clingo_symbolic_atoms_symbolr   r   r)   s    r   r#   SymbolicAtom.symbolb   s3    
 !11			
 	
r   )r   r   NT)__name__
__module____qualname____firstlineno____doc__r   strintr'   r$   propertyr*   r.   r3   r   r#   __static_attributes__ r   r   r   r   '   s    8# 8c 8T 8T 82 
T 
 
 X X X 
 
 
 
 
 
r   c            
           \ rS rSrSrS rS\\   4S jrS\\   4S jr	S\
4S jrS\S\\   4S	 jrS\4S
 jr SS\S\S\
S\\   4S jjr\S\\\\\
4      4S j5       rSrg)r   q   zH
This class provides read-only access to the atom base of the grounder.
c                     Xl         g r   r   )r   r   s     r   r   SymbolicAtoms.__init__v   s    	r   r!   c              #     #    [         R                  " S5      n[         R                  " S5      n[        [        R                  " U R
                  X5      5        [        U[        R                  U R
                  US   5      (       az  [        U R
                  US   5      v   [        [        R                  " U R
                  US   U5      5        [        U[        R                  U R
                  US   5      (       a  My  g g 7f)Nz clingo_symbolic_atom_iterator_t*zbool*r   )
r
   newr   r   clingo_symbolic_atoms_beginr   r	   clingo_symbolic_atoms_is_validr   clingo_symbolic_atoms_next)r   p_sigp_itp_valids       r   _iterSymbolicAtoms._itery   s     xx:;((7#d66tyy%NOgtBBDIItTUwWWtyy$q'22$99$))T!WdST gtBBDIItTUwWWs   C<D Dc              #   ^   #    U R                  [        R                  5       S h  vN   g  N7fr   )rQ   r
   NULLr)   s    r   __iter__SymbolicAtoms.__iter__   s     ::dii(((s   #-+-c                     [        U[        5      (       d  g[        S[        R                  U R
                  UR
                  5      n[        S[        R                  U R
                  U5      $ )NFclingo_symbolic_atom_iterator_tr'   )
isinstancer   r	   r   clingo_symbolic_atoms_findr   rL   r   r#   r   s      r   __contains__SymbolicAtoms.__contains__   sS    &&))-++IIKK	
 vtBBDIIrRRr   r#   c                     [        S[        R                  U R                  UR                  5      n[        S[        R                  U R                  U5      (       d  g [        U R                  U5      $ )NrX   r'   )r	   r   rZ   r   rL   r   r[   s      r   __getitem__SymbolicAtoms.__getitem__   sW    -++IIKK	
 vtBBDIIrRRDIIr**r   c                 L    [        S[        R                  U R                  5      $ )Nsize_t)r	   r   clingo_symbolic_atoms_sizer   r)   s    r   __len__SymbolicAtoms.__len__   s    x!@!@$))LLr   r   r   r    c              #      #    [         R                  " S5      n[        [        R                  " UR                  5       X#U5      5        U R                  U5       Sh  vN   g N7f)z
Return an iterator over the symbolic atoms with the given signature.

Arguments
---------
name
    The name of the signature.
arity
    The arity of the signature.
positive
    The sign of the signature.
zclingo_signature_t*N)r
   rJ   r   r   clingo_signature_createencoderQ   )r   r   r   r    rN   s        r   by_signatureSymbolicAtoms.by_signature   sJ      ./((O	
 ::e$$$s   AA$A"A$c                    [        S[        R                  U R                  5      n[        R
                  " SU5      n[        [        R                  " U R                  X!5      5        U Vs/ s HM  n[        [        R                  " U5      5      [        R                  " U5      [        R                  " U5      4PMO     sn$ s  snf )zn
The list of predicate signatures occurring in the program.

The Boolean indicates the sign of the signature.
rb   zclingo_signature_t[])r	   r   %clingo_symbolic_atoms_signatures_sizer   r
   rJ   r    clingo_symbolic_atoms_signaturesr   clingo_signature_nameclingo_signature_arityclingo_signature_is_positive)r   sizep_sigsc_sigs       r   
signaturesSymbolicAtoms.signatures   s     x!K!KTYYW0$7d;;DIIvTU  
  	 2259:++E211%8
  
 	
 
s   +ACrG   Nr9   )r:   r;   r<   r=   r>   r   r   r   rQ   rU   r'   r\   r   r   r_   r@   rd   r?   ri   rA   r   r   rt   rB   rC   r   r   r   r   q   s    Uh|4 U)(<0 )Sd S+& +Xl-C +M M 7;%% #%/3%	,	%* 
DsC~!67 
 
r   N)r>   typingr   r   r   r   r   	_internalr	   r
   r   r   r   r#   r   __all__r   r   rC   r   r   <module>ry      sE   < ? > B B ?
+G
 G
TX
J|, X
r   