Clingo C API
C API for clingo providing high level functions to control grounding and solving.
|
Inspection of atoms occurring in ground logic programs.
For an example, see symbolic-atoms.c.
Typedefs | |
typedef struct clingo_symbolic_atoms | clingo_symbolic_atoms_t |
Object to inspect symbolic atoms in a program—the relevant Herbrand base gringo uses to instantiate programs. More... | |
typedef uint64_t | clingo_symbolic_atom_iterator_t |
Object to iterate over symbolic atoms. More... | |
typedef bool(* | clingo_symbol_callback_t) (clingo_symbol_t const *symbols, size_t symbols_size, void *data) |
Callback function to inject symbols. More... | |
Functions | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbolic_atoms_size (clingo_symbolic_atoms_t const *atoms, size_t *size) |
Get the number of different atoms occurring in a logic program. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbolic_atoms_begin (clingo_symbolic_atoms_t const *atoms, clingo_signature_t const *signature, clingo_symbolic_atom_iterator_t *iterator) |
Get a forward iterator to the beginning of the sequence of all symbolic atoms optionally restricted to a given signature. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbolic_atoms_end (clingo_symbolic_atoms_t const *atoms, clingo_symbolic_atom_iterator_t *iterator) |
Iterator pointing to the end of the sequence of symbolic atoms. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbolic_atoms_find (clingo_symbolic_atoms_t const *atoms, clingo_symbol_t symbol, clingo_symbolic_atom_iterator_t *iterator) |
Find a symbolic atom given its symbolic representation. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbolic_atoms_iterator_is_equal_to (clingo_symbolic_atoms_t const *atoms, clingo_symbolic_atom_iterator_t a, clingo_symbolic_atom_iterator_t b, bool *equal) |
Check if two iterators point to the same element (or end of the sequence). More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbolic_atoms_symbol (clingo_symbolic_atoms_t const *atoms, clingo_symbolic_atom_iterator_t iterator, clingo_symbol_t *symbol) |
Get the symbolic representation of an atom. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbolic_atoms_is_fact (clingo_symbolic_atoms_t const *atoms, clingo_symbolic_atom_iterator_t iterator, bool *fact) |
Check whether an atom is a fact. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbolic_atoms_is_external (clingo_symbolic_atoms_t const *atoms, clingo_symbolic_atom_iterator_t iterator, bool *external) |
Check whether an atom is external. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbolic_atoms_literal (clingo_symbolic_atoms_t const *atoms, clingo_symbolic_atom_iterator_t iterator, clingo_literal_t *literal) |
Returns the (numeric) aspif literal corresponding to the given symbolic atom. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbolic_atoms_signatures_size (clingo_symbolic_atoms_t const *atoms, size_t *size) |
Get the number of different predicate signatures used in the program. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbolic_atoms_signatures (clingo_symbolic_atoms_t const *atoms, clingo_signature_t *signatures, size_t size) |
Get the predicate signatures occurring in a logic program. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbolic_atoms_next (clingo_symbolic_atoms_t const *atoms, clingo_symbolic_atom_iterator_t iterator, clingo_symbolic_atom_iterator_t *next) |
Get an iterator to the next element in the sequence of symbolic atoms. More... | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_symbolic_atoms_is_valid (clingo_symbolic_atoms_t const *atoms, clingo_symbolic_atom_iterator_t iterator, bool *valid) |
Check whether the given iterator points to some element with the sequence of symbolic atoms or to the end of the sequence. More... | |
typedef bool(* clingo_symbol_callback_t) (clingo_symbol_t const *symbols, size_t symbols_size, void *data) |
Callback function to inject symbols.
symbols | array of symbols |
symbols_size | size of the symbol array |
data | user data of the callback |
typedef uint64_t clingo_symbolic_atom_iterator_t |
Object to iterate over symbolic atoms.
Such an iterator either points to a symbolic atom within a sequence of symbolic atoms or to the end of the sequence.
typedef struct clingo_symbolic_atoms clingo_symbolic_atoms_t |
Object to inspect symbolic atoms in a program—the relevant Herbrand base gringo uses to instantiate programs.
CLINGO_VISIBILITY_DEFAULT bool clingo_symbolic_atoms_begin | ( | clingo_symbolic_atoms_t const * | atoms, |
clingo_signature_t const * | signature, | ||
clingo_symbolic_atom_iterator_t * | iterator | ||
) |
Get a forward iterator to the beginning of the sequence of all symbolic atoms optionally restricted to a given signature.
[in] | atoms | the target |
[in] | signature | optional signature |
[out] | iterator | the resulting iterator |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbolic_atoms_end | ( | clingo_symbolic_atoms_t const * | atoms, |
clingo_symbolic_atom_iterator_t * | iterator | ||
) |
Iterator pointing to the end of the sequence of symbolic atoms.
[in] | atoms | the target |
[out] | iterator | the resulting iterator |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbolic_atoms_find | ( | clingo_symbolic_atoms_t const * | atoms, |
clingo_symbol_t | symbol, | ||
clingo_symbolic_atom_iterator_t * | iterator | ||
) |
Find a symbolic atom given its symbolic representation.
[in] | atoms | the target |
[in] | symbol | the symbol to lookup |
[out] | iterator | iterator pointing to the symbolic atom or to the end of the sequence if no corresponding atom is found |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbolic_atoms_is_external | ( | clingo_symbolic_atoms_t const * | atoms, |
clingo_symbolic_atom_iterator_t | iterator, | ||
bool * | external | ||
) |
Check whether an atom is external.
An atom is external if it has been defined using an external directive and has not been released or defined by a rule.
[in] | atoms | the target |
[in] | iterator | iterator to the atom |
[out] | external | whether the atom is a external |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbolic_atoms_is_fact | ( | clingo_symbolic_atoms_t const * | atoms, |
clingo_symbolic_atom_iterator_t | iterator, | ||
bool * | fact | ||
) |
Check whether an atom is a fact.
[in] | atoms | the target |
[in] | iterator | iterator to the atom |
[out] | fact | whether the atom is a fact |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbolic_atoms_is_valid | ( | clingo_symbolic_atoms_t const * | atoms, |
clingo_symbolic_atom_iterator_t | iterator, | ||
bool * | valid | ||
) |
Check whether the given iterator points to some element with the sequence of symbolic atoms or to the end of the sequence.
[in] | atoms | the target |
[in] | iterator | the iterator |
[out] | valid | whether the iterator points to some element within the sequence |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbolic_atoms_iterator_is_equal_to | ( | clingo_symbolic_atoms_t const * | atoms, |
clingo_symbolic_atom_iterator_t | a, | ||
clingo_symbolic_atom_iterator_t | b, | ||
bool * | equal | ||
) |
Check if two iterators point to the same element (or end of the sequence).
[in] | atoms | the target |
[in] | a | the first iterator |
[in] | b | the second iterator |
[out] | equal | whether the two iterators are equal |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbolic_atoms_literal | ( | clingo_symbolic_atoms_t const * | atoms, |
clingo_symbolic_atom_iterator_t | iterator, | ||
clingo_literal_t * | literal | ||
) |
Returns the (numeric) aspif literal corresponding to the given symbolic atom.
Such a literal can be mapped to a solver literal (see the Theory Propagation module) or be used in rules in aspif format (see the Program Building module).
[in] | atoms | the target |
[in] | iterator | iterator to the atom |
[out] | literal | the associated literal |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbolic_atoms_next | ( | clingo_symbolic_atoms_t const * | atoms, |
clingo_symbolic_atom_iterator_t | iterator, | ||
clingo_symbolic_atom_iterator_t * | next | ||
) |
Get an iterator to the next element in the sequence of symbolic atoms.
[in] | atoms | the target |
[in] | iterator | the current iterator |
[out] | next | the succeeding iterator |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbolic_atoms_signatures | ( | clingo_symbolic_atoms_t const * | atoms, |
clingo_signature_t * | signatures, | ||
size_t | size | ||
) |
Get the predicate signatures occurring in a logic program.
[in] | atoms | the target |
[out] | signatures | the resulting signatures |
[in] | size | the number of signatures |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbolic_atoms_signatures_size | ( | clingo_symbolic_atoms_t const * | atoms, |
size_t * | size | ||
) |
Get the number of different predicate signatures used in the program.
[in] | atoms | the target |
[out] | size | the number of signatures |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbolic_atoms_size | ( | clingo_symbolic_atoms_t const * | atoms, |
size_t * | size | ||
) |
Get the number of different atoms occurring in a logic program.
[in] | atoms | the target |
[out] | size | the number of atoms |
CLINGO_VISIBILITY_DEFAULT bool clingo_symbolic_atoms_symbol | ( | clingo_symbolic_atoms_t const * | atoms, |
clingo_symbolic_atom_iterator_t | iterator, | ||
clingo_symbol_t * | symbol | ||
) |
Get the symbolic representation of an atom.
[in] | atoms | the target |
[in] | iterator | iterator to the atom |
[out] | symbol | the resulting symbol |