Working with (evaluated) ground terms and related functions.
- Note
- All functions in this module are thread-safe.
For an example, see symbol.c.
|
bool | clingo_symbol_number (clingo_symbol_t symbol, int *number) |
| Get the number of a symbol. More...
|
|
bool | clingo_symbol_name (clingo_symbol_t symbol, char const **name) |
| Get the name of a symbol. More...
|
|
bool | clingo_symbol_string (clingo_symbol_t symbol, char const **string) |
| Get the string of a symbol. More...
|
|
bool | clingo_symbol_is_positive (clingo_symbol_t symbol, bool *positive) |
| Check if a function is positive (does not have a sign). More...
|
|
bool | clingo_symbol_is_negative (clingo_symbol_t symbol, bool *negative) |
| Check if a function is negative (has a sign). More...
|
|
bool | clingo_symbol_arguments (clingo_symbol_t symbol, clingo_symbol_t const **arguments, size_t *arguments_size) |
| Get the arguments of a symbol. More...
|
|
clingo_symbol_type_t | clingo_symbol_type (clingo_symbol_t symbol) |
| Get the type of a symbol. More...
|
|
bool | clingo_symbol_to_string_size (clingo_symbol_t symbol, size_t *size) |
| Get the size of the string representation of a symbol (including the terminating 0). More...
|
|
bool | clingo_symbol_to_string (clingo_symbol_t symbol, char *string, size_t size) |
| Get the string representation of a symbol. More...
|
|
Represents a predicate signature.
Signatures have a name and an arity, and can be positive or negative (to represent classical negation).
Represents a symbol.
This includes numbers, strings, functions (including constants when arguments are empty and tuples when the name is empty), #inf
and #sup
.
Enumeration of available symbol types.
Enumerator |
---|
clingo_symbol_type_infimum |
the #inf symbol
|
clingo_symbol_type_number |
a numeric symbol, e.g., 1
|
clingo_symbol_type_string |
a string symbol, e.g., "a"
|
clingo_symbol_type_function |
a numeric symbol, e.g., c , (1, "a") , or f(1,"a")
|
clingo_symbol_type_supremum |
the #sup symbol
|
bool clingo_add_string |
( |
char const * |
string, |
|
|
char const ** |
result |
|
) |
| |
Internalize a string.
This functions takes a string as input and returns an equal unique string that is (at the moment) not freed until the program is closed. All strings returned from clingo API functions are internalized and must not be freed.
- Parameters
-
[in] | string | the string to internalize |
[out] | result | the internalized string |
- Returns
- whether the call was successful; might set one of the following error codes:
Parse a term in string form.
The result of this function is a symbol. The input term can contain unevaluated functions, which are evaluated during parsing.
- Parameters
-
[in] | string | the string to parse |
[in] | logger | optional logger to report warnings during parsing |
[in] | logger_data | user data for the logger |
[in] | message_limit | maximum number of times to call the logger |
[out] | symbol | the resulting symbol |
- Returns
- whether the call was successful; might set one of the following error codes:
Get the arity of a signature.
- Parameters
-
[in] | signature | the target signature |
- Returns
- the arity of the signature
bool clingo_signature_create |
( |
char const * |
name, |
|
|
uint32_t |
arity, |
|
|
bool |
positive, |
|
|
clingo_signature_t * |
signature |
|
) |
| |
Create a new signature.
- Parameters
-
[in] | name | name of the signature |
[in] | arity | arity of the signature |
[in] | positive | false if the signature has a classical negation sign |
[out] | signature | the resulting signature |
- Returns
- whether the call was successful; might set one of the following error codes:
- Examples:
- propagator.c.
Calculate a hash code of a signature.
- Parameters
-
[in] | signature | the target signature |
- Returns
- the hash code of the signature
Check if two signatures are equal.
- Parameters
-
[in] | a | first signature |
[in] | b | second signature |
- Returns
- whether a == b
Check if a signature is less than another signature.
Signatures are compared first by sign (unsigned < signed), then by arity, then by name.
- Parameters
-
[in] | a | first signature |
[in] | b | second signature |
- Returns
- whether a < b
Whether the signature is negative (is classically negated).
- Parameters
-
[in] | signature | the target signature |
- Returns
- whether the signature has a sign
Whether the signature is positive (is not classically negated).
- Parameters
-
[in] | signature | the target signature |
- Returns
- whether the signature has no sign
Get the name of a signature.
- Parameters
-
[in] | signature | the target signature |
- Returns
- the name of the signature
Get the arguments of a symbol.
- Parameters
-
[in] | symbol | the target symbol |
[out] | arguments | the resulting arguments |
[out] | arguments_size | the number of arguments |
- Returns
- whether the call was successful; might set one of the following error codes:
- Examples:
- propagator.c, and symbol.c.
bool clingo_symbol_create_function |
( |
char const * |
name, |
|
|
clingo_symbol_t const * |
arguments, |
|
|
size_t |
arguments_size, |
|
|
bool |
positive, |
|
|
clingo_symbol_t * |
symbol |
|
) |
| |
Construct a symbol representing a function or tuple.
- Note
- To create tuples, the empty string has to be used as name.
- Parameters
-
[in] | name | the name of the function |
[in] | arguments | the arguments of the function |
[in] | arguments_size | the number of arguments |
[in] | positive | whether the symbol has a classical negation sign |
[out] | symbol | the resulting symbol |
- Returns
- whether the call was successful; might set one of the following error codes:
- Examples:
- symbol.c.
bool clingo_symbol_create_id |
( |
char const * |
name, |
|
|
bool |
positive, |
|
|
clingo_symbol_t * |
symbol |
|
) |
| |
Construct a symbol representing an id.
- Note
- This is just a shortcut for clingo_symbol_create_function() with empty arguments.
- Parameters
-
[in] | name | the name |
[in] | positive | whether the symbol has a classical negation sign |
[out] | symbol | the resulting symbol |
- Returns
- whether the call was successful; might set one of the following error codes:
- Examples:
- ast.c, backend.c, and symbol.c.
Construct a symbol representing #inf
.
- Parameters
-
[out] | symbol | the resulting symbol |
Construct a symbol representing a number.
- Parameters
-
[in] | number | the number |
[out] | symbol | the resulting symbol |
- Examples:
- propagator.c, and symbol.c.
bool clingo_symbol_create_string |
( |
char const * |
string, |
|
|
clingo_symbol_t * |
symbol |
|
) |
| |
Construct a symbol representing a string.
- Parameters
-
[in] | string | the string |
[out] | symbol | the resulting symbol |
- Returns
- whether the call was successful; might set one of the following error codes:
Construct a symbol representing #sup.
- Parameters
-
[out] | symbol | the resulting symbol |
Calculate a hash code of a symbol.
- Parameters
-
[in] | symbol | the target symbol |
- Returns
- the hash code of the symbol
- Examples:
- symbol.c.
Check if two symbols are equal.
- Parameters
-
[in] | a | first symbol |
[in] | b | second symbol |
- Returns
- whether a == b
- Examples:
- symbol.c.
Check if a symbol is less than another symbol.
Symbols are first compared by type. If the types are equal, the values are compared (where strings are compared using strcmp). Functions are first compared by signature and then lexicographically by arguments.
- Parameters
-
[in] | a | first symbol |
[in] | b | second symbol |
- Returns
- whether a < b
- Examples:
- symbol.c.
Check if a function is negative (has a sign).
- Parameters
-
[in] | symbol | the target symbol |
[out] | negative | the result |
- Returns
- whether the call was successful; might set one of the following error codes:
Check if a function is positive (does not have a sign).
- Parameters
-
[in] | symbol | the target symbol |
[out] | positive | the result |
- Returns
- whether the call was successful; might set one of the following error codes:
Get the name of a symbol.
- Parameters
-
[in] | symbol | the target symbol |
[out] | name | the resulting name |
- Returns
- whether the call was successful; might set one of the following error codes:
Get the number of a symbol.
- Parameters
-
[in] | symbol | the target symbol |
[out] | number | the resulting number |
- Returns
- whether the call was successful; might set one of the following error codes:
- Examples:
- propagator.c.
Get the string of a symbol.
- Parameters
-
[in] | symbol | the target symbol |
[out] | string | the resulting string |
- Returns
- whether the call was successful; might set one of the following error codes:
bool clingo_symbol_to_string |
( |
clingo_symbol_t |
symbol, |
|
|
char * |
string, |
|
|
size_t |
size |
|
) |
| |
Get the string representation of a symbol.
- Parameters
-
[in] | symbol | the target symbol |
[out] | string | the resulting string |
[in] | size | the size of the string |
- Returns
- whether the call was successful; might set one of the following error codes:
- See also
- clingo_symbol_to_string_size()
- Examples:
- ast.c, backend.c, configuration.c, control.c, model.c, propagator.c, solve-async.c, solve-iteratively.c, statistics.c, symbol.c, symbolic-atoms.c, and theory-atoms.c.
bool clingo_symbol_to_string_size |
( |
clingo_symbol_t |
symbol, |
|
|
size_t * |
size |
|
) |
| |
Get the size of the string representation of a symbol (including the terminating 0).
- Parameters
-
[in] | symbol | the target symbol |
[out] | size | the resulting size |
- Returns
- whether the call was successful; might set one of the following error codes:
- Examples:
- ast.c, backend.c, configuration.c, control.c, model.c, propagator.c, solve-async.c, solve-iteratively.c, statistics.c, symbol.c, symbolic-atoms.c, and theory-atoms.c.
Get the type of a symbol.
- Parameters
-
[in] | symbol | the target symbol |
- Returns
- the type of the symbol