
    cwi               	          % S r SSKJr  SSKJrJrJrJr  SSKJ	r	J
r
JrJrJrJr  SSKJrJr  / SQr " S S	\5      r\ " S
 S5      5       r/ S4S\S\\   S\S\4S jjrS\S\4S jrS\S\4S jrS\\   S\4S jr\R8                  " S5      r\R8                  " S5      r\R>                  " \5        \R@                  " \5        \" \S   5      r!\\"S'   \" \S   5      r#\\"S'     SS\S\\\\/S4      S\S\4S jjr$g)a  
Functions and classes for symbol manipulation.

Examples
--------

    >>> from clingo.symbol import Function, Number, parse_term
    >>>
    >>> num = Number(42)
    >>> num.number
    42
    >>> fun = Function("f", [num])
    >>> fun.name
    'f'
    >>> [ str(arg) for arg in fun.arguments ]
    ['42']
    >>> parse_term(str(fun)) == fun
    True
    >>> clingo.parse_term('p(1+2)')
    p(3)
    )total_ordering)CallableListOptionalSequence   )_c_call_c_call2_ffi_lib_str_to_str)MessageCodeOrderedEnum)	FunctionInfimumNumberStringSupremumSymbol
SymbolTypeTuple_
parse_termc                       \ rS rSrSr\R                  r \R                  r	 \R                  r \R                  r \R                  rSrg)r   *   z
Enumeration of symbols types.
 N)__name__
__module____qualname____firstlineno____doc__r   clingo_symbol_type_functionr   clingo_symbol_type_infimumr   clingo_symbol_type_numberr   clingo_symbol_type_stringr   clingo_symbol_type_supremumr   __static_attributes__r       G/home/james-whalen/.local/lib/python3.13/site-packages/clingo/symbol.pyr   r   *   sa     //H --G ++F ++F //Hr(   r   c            	       <   \ rS 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	\S\4S jrSS\S\
S\S\4S jj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\4S j5       r\S\4S j5       r\S\4S j5       rSrg)r   E   ab  
Represents a gringo symbol.

This includes numbers, strings, functions (including constants with
`len(arguments) == 0` and tuples with `len(name) == 0`), `#inf` and `#sup`.

Symbol objects implement Python's rich comparison operators and are ordered
like in gringo. They can also be used as keys in dictionaries. Their string
representation corresponds to their gringo representation.

Notes
-----
Note that this class does not have a constructor. Instead there are the
functions `Number`, `String`, `Tuple_`, and `Function` to construct symbol
objects or the preconstructed symbols `Infimum` and `Supremum`.
_repc                     Xl         g Nr,   )selfreps     r)   __init__Symbol.__init__Z   s    	r(   returnc                 h    [        [        R                  [        R                  U R                  5      $ r/   )r   r   clingo_symbol_to_string_sizeclingo_symbol_to_stringr-   r0   s    r)   __str__Symbol.__str__]   s&    --t/K/KTYY
 	
r(   c                    U R                   [        R                  :X  a  gU R                   [        R                  :X  a  gU R                   [        R                  :X  a  SU R
                  < S3$ U R                   [        R                  :X  a  SU R                  < S3$ U R                   [        R                  :X  d   eSU R                  < SU R                  < SU R                  < S3$ )Nr   r   zNumber()zString(z	Function(z, )typer   r   r   r   numberr   stringr   name	argumentspositiver8   s    r)   __repr__Symbol.__repr__b   s    99
***99
+++99
)))T[[O1--99
)))T[[O1--yyJ/////499-r$..);2dmm=NaPPr(   c                 B    [         R                  " U R                  5      $ r/   )r   clingo_symbol_hashr-   r8   s    r)   __hash__Symbol.__hash__n   s    &&tyy11r(   otherc                     [        U[        5      (       d  [        $ [        R                  " U R
                  UR
                  5      $ r/   )
isinstancer   NotImplementedr   clingo_symbol_is_equal_tor-   r0   rI   s     r)   __eq__Symbol.__eq__q   s0    %((!!--diiDDr(   c                     [        U[        5      (       d  [        $ [        R                  " U R
                  UR
                  5      $ r/   )rK   r   rL   r   clingo_symbol_is_less_thanr-   rN   s     r)   __lt__Symbol.__lt__v   s0    %((!!..tyy%**EEr(   r@   arityrB   c                     U R                   [        R                  :H  =(       aD    U R                  U:H  =(       a.    U R                  U:H  =(       a    [        U R                  5      U:H  $ )a  
Check if this is a function symbol with 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 function matches.
)r=   r   r   rB   r@   lenrA   )r0   r@   rU   rB   s       r)   matchSymbol.match{   sU    ( II,,, -)-		T!- DNN#u,		
r(   c                     [        SS[        R                  U R                  5      u  p[	        U5       Vs/ s H  n[        X   5      PM     sn$ s  snf )z
The arguments of a function.
clingo_symbol_t*size_t)r
   r   clingo_symbol_argumentsr-   ranger   )r0   argssizeis       r)   rA   Symbol.arguments   sG    
 $*F*F		

 */t5Atw555s   Ac                 ^    [        [        S[        R                  U R                  5      5      $ )z
The name of a function.
char*)r   r	   r   clingo_symbol_namer-   r8   s    r)   r@   Symbol.name   s"    
 ww(?(?KLLr(   c                 L    [        S[        R                  U R                  5      $ )z"
The inverted sign of a function.
bool)r	   r   clingo_symbol_is_negativer-   r8   s    r)   negativeSymbol.negative       
 vt==tyyIIr(   c                 L    [        S[        R                  U R                  5      $ )z
The value of a number.
int)r	   r   clingo_symbol_numberr-   r8   s    r)   r>   Symbol.number   s    
 ud77CCr(   c                 L    [        S[        R                  U R                  5      $ )z
The sign of a function.
rh   )r	   r   clingo_symbol_is_positiver-   r8   s    r)   rB   Symbol.positive   rl   r(   c                 ^    [        [        S[        R                  U R                  5      5      $ )z
The value of a string.
rd   )r   r	   r   clingo_symbol_stringr-   r8   s    r)   r?   Symbol.string   s"    
 ww(A(A499MNNr(   c                 T    [        [        R                  " U R                  5      5      $ )z
The type of the symbol.
)r   r   clingo_symbol_typer-   r8   s    r)   r=   Symbol.type   s    
 $11$))<==r(   N)T)r   r   r   r    r!   	__slots__r2   strr9   rC   rn   rG   objectrh   rO   rS   rX   propertyr   rA   r@   rj   r>   rB   r?   r   r=   r'   r   r(   r)   r   r   E   sV   " I
 


Q# 
Q2# 2EF Et E
FF Ft F

# 
c 
T 
T 
4 64> 6 6 Mc M M J$ J J D D D J$ J J O O O >j > >r(   r   Tr@   rA   rB   r4   c           	         [         R                  " S[        U5      5      n[        U5       H  u  pEUR                  X4'   M     [        S[        R                  U R                  5       U[        U5      U5      n[        U5      $ )a  
Construct a function symbol.

This includes constants and tuples. Constants have an empty argument list
and tuples have an empty name. Functions can represent classically negated
atoms. Argument `positive` has to be set to false to represent such atoms.

Parameters
----------
name
    The name of the function (empty for tuples).
arguments
    The arguments in form of a list of symbols.
positive
    The sign of the function (tuples must not have signs).
zclingo_symbol_t[]clingo_symbol_t)
r   newrW   	enumerater-   r	   r   clingo_symbol_create_functionencoder   )r@   rA   rB   c_argsra   argsyms          r)   r   r      sm    ( XX)3y>:FI&HH	 '
**IC #;r(   r>   c                 v    [         R                  " S5      n[        R                  " X5        [	        US   5      $ )z`
Construct a numeric symbol given a number.

Parameters
----------
number
    The given number.
r[   r   )r   r   r   clingo_symbol_create_numberr   )r>   p_reps     r)   r   r      s0     HH'(E$$V3%(r(   r?   c                 f    [        [        S[        R                  U R	                  5       5      5      $ )z_
Construct a string symbol given a string.

Parameters
----------
string
    The given string.
r   )r   r	   r   clingo_symbol_create_stringr   )r?   s    r)   r   r      s*     !4#C#CV]]_U r(   c                     [        SU 5      $ )z
A shortcut for `Function("", arguments)`.

Parameters
----------
arguments
    The arguments in form of a list of symbols.

See Also
--------
Function
 )r   )rA   s    r)   r   r   
  s     B	""r(   r[   r   r   Nloggermessage_limitc           
          Ub'  [         R                  " U5      n[        R                  nO [         R                  n[         R                  n[        [        S[        R                  U R                  5       UUU5      5      $ )aD  
Parse the given string using gringo's term parser for ground terms.

The function also evaluates arithmetic functions.

Parameters
----------
string
    The string to be parsed.
logger
    Function to intercept messages normally printed to standard error.
message_limit
    Maximum number of messages passed to the logger.
r   )	r   
new_handler   pyclingo_logger_callbackNULLr   r	   clingo_parse_termr   )r?   r   r   c_handlec_cbs        r)   r   r   $  sh    & ??6*,,99yy""MMO	
	 	r(   )N   )%r!   	functoolsr   typingr   r   r   r   	_internalr	   r
   r   r   r   r   corer   r   __all__r   r   r{   rh   r   rn   r   r   r   r   
_p_infimum_p_supremumclingo_symbol_create_infimumclingo_symbol_create_supremumr   __annotations__r   r   r   r(   r)   <module>r      sf  , % 5 5 C C *
 6 A> A> A>J .0$
"6*;?D3 6 3 6 #hv& #6 #" XX()
hh)*  ! !* -  " "; /A' '+a.)& )
 <@##X{C0$678# # 	#r(   