Clingo C API
C API for clingo providing high level functions to control grounding and solving.
Typedefs | Functions
Symbolic Atom Inspection

Detailed Description

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...
 

Functions

bool clingo_symbolic_atoms_size (clingo_symbolic_atoms_t *atoms, size_t *size)
 Get the number of different atoms occurring in a logic program. More...
 
bool clingo_symbolic_atoms_begin (clingo_symbolic_atoms_t *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...
 
bool clingo_symbolic_atoms_end (clingo_symbolic_atoms_t *atoms, clingo_symbolic_atom_iterator_t *iterator)
 Iterator pointing to the end of the sequence of symbolic atoms. More...
 
bool clingo_symbolic_atoms_find (clingo_symbolic_atoms_t *atoms, clingo_symbol_t symbol, clingo_symbolic_atom_iterator_t *iterator)
 Find a symbolic atom given its symbolic representation. More...
 
bool clingo_symbolic_atoms_iterator_is_equal_to (clingo_symbolic_atoms_t *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...
 
bool clingo_symbolic_atoms_symbol (clingo_symbolic_atoms_t *atoms, clingo_symbolic_atom_iterator_t iterator, clingo_symbol_t *symbol)
 Get the symbolic representation of an atom. More...
 
bool clingo_symbolic_atoms_is_fact (clingo_symbolic_atoms_t *atoms, clingo_symbolic_atom_iterator_t iterator, bool *fact)
 Check whether an atom is a fact. More...
 
bool clingo_symbolic_atoms_is_external (clingo_symbolic_atoms_t *atoms, clingo_symbolic_atom_iterator_t iterator, bool *external)
 Check whether an atom is external. More...
 
bool clingo_symbolic_atoms_literal (clingo_symbolic_atoms_t *atoms, clingo_symbolic_atom_iterator_t iterator, clingo_literal_t *literal)
 Returns the (numeric) aspif literal corresponding to the given symbolic atom. More...
 
bool clingo_symbolic_atoms_signatures_size (clingo_symbolic_atoms_t *atoms, size_t *size)
 Get the number of different predicate signatures used in the program. More...
 
bool clingo_symbolic_atoms_signatures (clingo_symbolic_atoms_t *atoms, clingo_signature_t *signatures, size_t size)
 Get the predicate signatures occurring in a logic program. More...
 
bool clingo_symbolic_atoms_next (clingo_symbolic_atoms_t *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...
 
bool clingo_symbolic_atoms_is_valid (clingo_symbolic_atoms_t *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 Documentation

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.

Note
Iterators are valid as long as the underlying sequence is not modified. Operations that can change this sequence are clingo_control_ground(), clingo_control_cleanup(), and functions that modify the underlying non-ground program.
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.

See also
clingo_control_symbolic_atoms()

Function Documentation

bool clingo_symbolic_atoms_begin ( clingo_symbolic_atoms_t 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.

Parameters
[in]atomsthe target
[in]signatureoptional signature
[out]iteratorthe resulting iterator
Returns
whether the call was successful
Examples:
propagator.c, and symbolic-atoms.c.
bool clingo_symbolic_atoms_end ( clingo_symbolic_atoms_t atoms,
clingo_symbolic_atom_iterator_t iterator 
)

Iterator pointing to the end of the sequence of symbolic atoms.

Parameters
[in]atomsthe target
[out]iteratorthe resulting iterator
Returns
whether the call was successful
Examples:
backend.c, propagator.c, and symbolic-atoms.c.
bool clingo_symbolic_atoms_find ( clingo_symbolic_atoms_t atoms,
clingo_symbol_t  symbol,
clingo_symbolic_atom_iterator_t iterator 
)

Find a symbolic atom given its symbolic representation.

Parameters
[in]atomsthe target
[in]symbolthe symbol to lookup
[out]iteratoriterator pointing to the symbolic atom or to the end of the sequence if no corresponding atom is found
Returns
whether the call was successful
Examples:
backend.c.
bool clingo_symbolic_atoms_is_external ( clingo_symbolic_atoms_t 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.

Parameters
[in]atomsthe target
[in]iteratoriterator to the atom
[out]externalwhether the atom is a external
Returns
whether the call was successful
Examples:
symbolic-atoms.c.
bool clingo_symbolic_atoms_is_fact ( clingo_symbolic_atoms_t atoms,
clingo_symbolic_atom_iterator_t  iterator,
bool *  fact 
)

Check whether an atom is a fact.

Note
This does not determine if an atom is a cautious consequence. The grounding or solving component's simplifications can only detect this in some cases.
Parameters
[in]atomsthe target
[in]iteratoriterator to the atom
[out]factwhether the atom is a fact
Returns
whether the call was successful
Examples:
symbolic-atoms.c.
bool clingo_symbolic_atoms_is_valid ( clingo_symbolic_atoms_t 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.

Parameters
[in]atomsthe target
[in]iteratorthe iterator
[out]validwhether the iterator points to some element within the sequence
Returns
whether the call was successful
bool clingo_symbolic_atoms_iterator_is_equal_to ( clingo_symbolic_atoms_t 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).

Parameters
[in]atomsthe target
[in]athe first iterator
[in]bthe second iterator
[out]equalwhether the two iterators are equal
Returns
whether the call was successful
Examples:
backend.c, propagator.c, and symbolic-atoms.c.
bool clingo_symbolic_atoms_literal ( clingo_symbolic_atoms_t 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).

Parameters
[in]atomsthe target
[in]iteratoriterator to the atom
[out]literalthe associated literal
Returns
whether the call was successful
Examples:
backend.c, and propagator.c.
bool clingo_symbolic_atoms_next ( clingo_symbolic_atoms_t 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.

Parameters
[in]atomsthe target
[in]iteratorthe current iterator
[out]nextthe succeeding iterator
Returns
whether the call was successful
Examples:
propagator.c, and symbolic-atoms.c.
bool clingo_symbolic_atoms_signatures ( clingo_symbolic_atoms_t atoms,
clingo_signature_t signatures,
size_t  size 
)

Get the predicate signatures occurring in a logic program.

Parameters
[in]atomsthe target
[out]signaturesthe resulting signatures
[in]sizethe number of signatures
Returns
whether the call was successful; might set one of the following error codes:
See also
clingo_symbolic_atoms_signatures_size()
bool clingo_symbolic_atoms_signatures_size ( clingo_symbolic_atoms_t atoms,
size_t *  size 
)

Get the number of different predicate signatures used in the program.

Parameters
[in]atomsthe target
[out]sizethe number of signatures
Returns
whether the call was successful
bool clingo_symbolic_atoms_size ( clingo_symbolic_atoms_t atoms,
size_t *  size 
)

Get the number of different atoms occurring in a logic program.

Parameters
[in]atomsthe target
[out]sizethe number of atoms
Returns
whether the call was successful
bool clingo_symbolic_atoms_symbol ( clingo_symbolic_atoms_t atoms,
clingo_symbolic_atom_iterator_t  iterator,
clingo_symbol_t symbol 
)

Get the symbolic representation of an atom.

Parameters
[in]atomsthe target
[in]iteratoriterator to the atom
[out]symbolthe resulting symbol
Returns
whether the call was successful
Examples:
propagator.c, and symbolic-atoms.c.