Clingo
|
Inspection of atoms occurring in ground logic programs. More...
Classes | |
struct | clingo_signature |
Represents a predicate signature. More... | |
Typedefs | |
typedef struct clingo_signature | clingo_signature_t |
Represents a predicate signature. | |
typedef struct clingo_base | clingo_base_t |
Object to inspect symbolic atoms in a program—the relevant Herbrand base gringo uses to instantiate programs and the terms that occur in the heads of #show statements. | |
typedef struct clingo_atom_base | clingo_atom_base_t |
Object to inspect the symbolic atoms in a program. | |
typedef struct clingo_term_base | clingo_term_base_t |
Object to inspect the shown terms in a program. | |
typedef int | clingo_theory_term_type_t |
Corresponding type to clingo_theory_term_type_e. | |
typedef struct clingo_theory_base | clingo_theory_base_t |
Object to inspect theory atoms. | |
Enumerations | |
enum | clingo_theory_term_type_e { clingo_theory_term_type_tuple = 0 , clingo_theory_term_type_list = 1 , clingo_theory_term_type_set = 2 , clingo_theory_term_type_function = 3 , clingo_theory_term_type_number = 4 , clingo_theory_term_type_symbol = 5 } |
Enumeration of theory term types. More... | |
Functions | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_base_is_fact (clingo_base_t const *atoms, clingo_literal_t literal, bool *is_fact) |
Check whether the given literal is a fact. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_base_is_external (clingo_base_t const *atoms, clingo_literal_t literal, bool *is_external) |
Check whether an literal is external. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_base_is_shown (clingo_base_t const *atoms, clingo_literal_t literal, bool *is_shown) |
Check whether an literal is shown. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_base_is_projected (clingo_base_t const *atoms, clingo_literal_t literal, bool *is_projected) |
Check whether a literal is subject to projection. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_base_is_current (clingo_base_t const *atoms, clingo_literal_t literal, bool *is_current) |
Check whether a literal has been introduced in the current step. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_base_atoms_size (clingo_base_t const *base, size_t *size) |
Get the number of atom bases in the program. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_base_atoms_at (clingo_base_t const *base, size_t index, clingo_signature_t *signature, clingo_atom_base_t const **atoms) |
Get the signature and atom base at the given index. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_base_atoms_find (clingo_base_t const *base, clingo_signature_t const *signature, clingo_atom_base_t const **atoms, bool *found) |
Find the atom base wit the given signature. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_atom_base_size (clingo_atom_base_t const *atoms, size_t *size) |
Get the size of the given atom base. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_atom_base_find (clingo_atom_base_t const *atoms, clingo_symbol_t symbol, size_t *index) |
Find the index of the atom with the given symbol in the atom base. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_atom_base_symbol (clingo_atom_base_t const *atoms, size_t index, clingo_symbol_t *symbol) |
Get the symbolic representation of an atom. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_atom_base_literal (clingo_atom_base_t const *atoms, size_t index, clingo_literal_t *literal) |
Returns the (numeric) program literal corresponding to the given symbolic atom. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_base_terms (clingo_base_t const *base, clingo_term_base_t const **terms) |
Get the term base capturing show term directives. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_base_theory (clingo_base_t const *base, clingo_theory_base_t const **theory) |
Get the theory base capturing theory terms, elements, and atoms. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_term_base_size (clingo_term_base_t const *terms, size_t *size) |
During grounding, theory atoms get consecutive numbers starting with zero. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_term_base_symbol (clingo_term_base_t const *terms, size_t index, clingo_symbol_t *term) |
Get the symbol of the show directive with the given index. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_term_base_condition (clingo_term_base_t const *terms, size_t index, size_t const **sizes, clingo_literal_t const *const **literals, size_t *size) |
Get the conditions of a show directive. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_term_base_find (clingo_term_base_t const *terms, clingo_symbol_t symbol, size_t *index) |
Get the index of the given symbol. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_control_base (clingo_control_t const *control, clingo_base_t const **base) |
Get the base associated with the control object. | |
Theory Term Inspection | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_theory_base_term_type (clingo_theory_base_t const *theory, clingo_id_t term, clingo_theory_term_type_t *type) |
Get the type of the given theory term. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_theory_base_term_number (clingo_theory_base_t const *theory, clingo_id_t term, int *number) |
Get the number of the given numeric theory term. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_theory_base_term_name (clingo_theory_base_t const *theory, clingo_id_t term, clingo_string_t *name) |
Get the name of the given constant or function theory term. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_theory_base_term_arguments (clingo_theory_base_t const *theory, clingo_id_t term, clingo_id_t const **arguments, size_t *size) |
Get the arguments of the given function theory term. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_theory_base_term_to_string (clingo_theory_base_t const *theory, clingo_id_t term, clingo_string_builder_t *builder) |
Get the string representation of the given theory term. | |
Theory Element Inspection | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_theory_base_element_tuple (clingo_theory_base_t const *theory, clingo_id_t element, clingo_id_t const **tuple, size_t *size) |
Get the tuple (array of theory terms) of the given theory element. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_theory_base_element_condition (clingo_theory_base_t const *theory, clingo_id_t element, clingo_literal_t const **condition, size_t *size) |
Get the condition (array of aspif literals) of the given theory element. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_theory_base_element_condition_id (clingo_theory_base_t const *theory, clingo_id_t element, clingo_literal_t *condition) |
Get the id of the condition of the given theory element. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_theory_base_element_to_string (clingo_theory_base_t const *theory, clingo_id_t element, clingo_string_builder_t *builder) |
Get the string representation of the given theory element. | |
Theory Atom Inspection | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_theory_base_size (clingo_theory_base_t const *theory, size_t *size) |
Get the total number of theory theory. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_theory_base_atom_term (clingo_theory_base_t const *theory, clingo_id_t atom, clingo_id_t *term) |
Get the theory term associated with the theory atom. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_theory_base_atom_elements (clingo_theory_base_t const *theory, clingo_id_t atom, clingo_id_t const **elements, size_t *size) |
Get the theory elements associated with the theory atom. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_theory_base_atom_has_guard (clingo_theory_base_t const *theory, clingo_id_t atom, bool *has_guard) |
Whether the theory atom has a guard. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_theory_base_atom_guard (clingo_theory_base_t const *theory, clingo_id_t atom, clingo_string_t *connective, clingo_id_t *term) |
Get the guard consisting of a theory operator and a theory term of the given theory atom. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_theory_base_atom_literal (clingo_theory_base_t const *theory, clingo_id_t atom, clingo_literal_t *literal) |
Get the aspif literal associated with the given theory atom. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_theory_base_atom_to_string (clingo_theory_base_t const *theory, clingo_id_t atom, clingo_string_builder_t *builder) |
Get the string representation of the given theory atom. | |
Inspection of atoms occurring in ground logic programs.
For an examples, see base-atoms.c and base-theory.c.
typedef struct clingo_atom_base clingo_atom_base_t |
Object to inspect the symbolic atoms in a program.
Atom bases capture atoms over the same signature.
typedef struct clingo_base clingo_base_t |
Object to inspect symbolic atoms in a program—the relevant Herbrand base gringo uses to instantiate programs and the terms that occur in the heads of #show
statements.
typedef struct clingo_signature clingo_signature_t |
Represents a predicate signature.
Signatures have a name and an arity, and can be positive or negative (to represent classical negation).
Enumeration of theory term types.
CLINGO_VISIBILITY_DEFAULT bool clingo_atom_base_find | ( | clingo_atom_base_t const * | atoms, |
clingo_symbol_t | symbol, | ||
size_t * | index | ||
) |
Find the index of the atom with the given symbol in the atom base.
If the symbol is not found, return the size of the atom base.
atoms | the atom base |
symbol | the symbol to lookup |
index | the target index |
CLINGO_VISIBILITY_DEFAULT bool clingo_atom_base_literal | ( | clingo_atom_base_t const * | atoms, |
size_t | index, | ||
clingo_literal_t * | literal | ||
) |
Returns the (numeric) program 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 Abstract Syntax Trees module).
[in] | atoms | the atom base |
[in] | index | the index of the atom |
[out] | literal | the resulting literal |
CLINGO_VISIBILITY_DEFAULT bool clingo_atom_base_size | ( | clingo_atom_base_t const * | atoms, |
size_t * | size | ||
) |
Get the size of the given atom base.
[in] | atoms | the atom base |
[out] | size | the target size |
CLINGO_VISIBILITY_DEFAULT bool clingo_atom_base_symbol | ( | clingo_atom_base_t const * | atoms, |
size_t | index, | ||
clingo_symbol_t * | symbol | ||
) |
Get the symbolic representation of an atom.
[in] | atoms | the atom base |
[in] | index | the index of the atom |
[out] | symbol | the resulting symbol |
CLINGO_VISIBILITY_DEFAULT bool clingo_base_atoms_at | ( | clingo_base_t const * | base, |
size_t | index, | ||
clingo_signature_t * | signature, | ||
clingo_atom_base_t const ** | atoms | ||
) |
Get the signature and atom base at the given index.
The index must be smaller than the size reported by clingo_base_atoms_size(). Either of the two target pointers can be null if the value is not important.
[in] | base | the base |
[in] | index | the index of the atom base |
[out] | signature | the target signature |
[out] | atoms | the target atom base |
CLINGO_VISIBILITY_DEFAULT bool clingo_base_atoms_find | ( | clingo_base_t const * | base, |
clingo_signature_t const * | signature, | ||
clingo_atom_base_t const ** | atoms, | ||
bool * | found | ||
) |
Find the atom base wit the given signature.
[in] | base | the base |
[in] | signature | the signature to lookup |
[out] | atoms | the target atom base |
[out] | found | whether a base has been found |
CLINGO_VISIBILITY_DEFAULT bool clingo_base_atoms_size | ( | clingo_base_t const * | base, |
size_t * | size | ||
) |
Get the number of atom bases in the program.
Each atom base is associated with a signature.
[in] | base | the target |
[out] | size | the number of atoms |
CLINGO_VISIBILITY_DEFAULT bool clingo_base_is_current | ( | clingo_base_t const * | atoms, |
clingo_literal_t | literal, | ||
bool * | is_current | ||
) |
Check whether a literal has been introduced in the current step.
Note that all literals introduced before the last solve call are considered from a previous step.
[in] | atoms | the target |
[in] | literal | the index of the literal |
[out] | is_current | whether the literal was introduced in the current step |
CLINGO_VISIBILITY_DEFAULT bool clingo_base_is_external | ( | clingo_base_t const * | atoms, |
clingo_literal_t | literal, | ||
bool * | is_external | ||
) |
Check whether an literal is external.
A literal 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] | literal | the index of the literal |
[out] | is_external | whether the literal is an external |
CLINGO_VISIBILITY_DEFAULT bool clingo_base_is_fact | ( | clingo_base_t const * | atoms, |
clingo_literal_t | literal, | ||
bool * | is_fact | ||
) |
Check whether the given literal is a fact.
[in] | atoms | the atom base |
[in] | literal | the index of the literal |
[out] | is_fact | whether the literal is a fact |
CLINGO_VISIBILITY_DEFAULT bool clingo_base_is_projected | ( | clingo_base_t const * | atoms, |
clingo_literal_t | literal, | ||
bool * | is_projected | ||
) |
Check whether a literal is subject to projection.
An literal is subject to projection if it occurred in a project directive.
[in] | atoms | the target |
[in] | literal | the index of the literal |
[out] | is_projected | whether the literal is subject to projection |
CLINGO_VISIBILITY_DEFAULT bool clingo_base_is_shown | ( | clingo_base_t const * | atoms, |
clingo_literal_t | literal, | ||
bool * | is_shown | ||
) |
Check whether an literal is shown.
A literal is shown if it has been shown by a show directive.
[in] | atoms | the target |
[in] | literal | the index of the tom |
[out] | is_shown | whether the tom is shown |
CLINGO_VISIBILITY_DEFAULT bool clingo_base_terms | ( | clingo_base_t const * | base, |
clingo_term_base_t const ** | terms | ||
) |
Get the term base capturing show term directives.
base | the base |
terms | the term base |
CLINGO_VISIBILITY_DEFAULT bool clingo_base_theory | ( | clingo_base_t const * | base, |
clingo_theory_base_t const ** | theory | ||
) |
Get the theory base capturing theory terms, elements, and atoms.
During grounding, theory atoms get consecutive numbers starting with zero. The total number of theory atoms can be obtained using clingo_theory_base_size().
For an example, see base-theory.c.
base | the base |
theory | the theory base |
CLINGO_VISIBILITY_DEFAULT bool clingo_control_base | ( | clingo_control_t const * | control, |
clingo_base_t const ** | base | ||
) |
Get the base associated with the control object.
The base can be used to query the atoms and terms occurring in a program.
The function initializes the base struct.
[in] | control | the target |
[in] | base | the base to obtain |
CLINGO_VISIBILITY_DEFAULT bool clingo_term_base_condition | ( | clingo_term_base_t const * | terms, |
size_t | index, | ||
size_t const ** | sizes, | ||
clingo_literal_t const *const ** | literals, | ||
size_t * | size | ||
) |
Get the conditions of a show directive.
Returns the conditions under which a term is shown in form of a disjunction of conjunctions.
[in] | terms | the term base |
[in] | index | the index of the show diriective |
[out] | sizes | the sizes of the conjunctions |
[out] | literals | the target literals |
[out] | size | the size of the disjunction |
CLINGO_VISIBILITY_DEFAULT bool clingo_term_base_find | ( | clingo_term_base_t const * | terms, |
clingo_symbol_t | symbol, | ||
size_t * | index | ||
) |
Get the index of the given symbol.
If the symbol is not found, the index is set to the size of the base.
[in] | terms | the term base |
[in] | symbol | the symbol to lookup |
[out] | index | the target index |
CLINGO_VISIBILITY_DEFAULT bool clingo_term_base_size | ( | clingo_term_base_t const * | terms, |
size_t * | size | ||
) |
During grounding, theory atoms get consecutive numbers starting with zero.
The total number of theory atoms can be obtained using clingo_theory_base_size().
For an example, see base-theory.c.
Get the number of shown terms in a program.
[in] | terms | the term base |
[out] | size | the number of terms in the base |
CLINGO_VISIBILITY_DEFAULT bool clingo_term_base_symbol | ( | clingo_term_base_t const * | terms, |
size_t | index, | ||
clingo_symbol_t * | term | ||
) |
Get the symbol of the show directive with the given index.
[in] | terms | the term base |
[in] | index | the index of the show directive |
[out] | term | the resulting term |
CLINGO_VISIBILITY_DEFAULT bool clingo_theory_base_atom_elements | ( | clingo_theory_base_t const * | theory, |
clingo_id_t | atom, | ||
clingo_id_t const ** | elements, | ||
size_t * | size | ||
) |
Get the theory elements associated with the theory atom.
[in] | theory | container where the atom is stored |
[in] | atom | id of the atom |
[out] | elements | the resulting array of elements |
[out] | size | the number of elements |
CLINGO_VISIBILITY_DEFAULT bool clingo_theory_base_atom_guard | ( | clingo_theory_base_t const * | theory, |
clingo_id_t | atom, | ||
clingo_string_t * | connective, | ||
clingo_id_t * | term | ||
) |
Get the guard consisting of a theory operator and a theory term of the given theory atom.
[in] | theory | container where the atom is stored |
[in] | atom | id of the atom |
[out] | connective | the resulting theory operator |
[out] | term | the resulting term |
CLINGO_VISIBILITY_DEFAULT bool clingo_theory_base_atom_has_guard | ( | clingo_theory_base_t const * | theory, |
clingo_id_t | atom, | ||
bool * | has_guard | ||
) |
Whether the theory atom has a guard.
[in] | theory | container where the atom is stored |
[in] | atom | id of the atom |
[out] | has_guard | whether the theory atom has a guard |
CLINGO_VISIBILITY_DEFAULT bool clingo_theory_base_atom_literal | ( | clingo_theory_base_t const * | theory, |
clingo_id_t | atom, | ||
clingo_literal_t * | literal | ||
) |
Get the aspif literal associated with the given theory atom.
[in] | theory | container where the atom is stored |
[in] | atom | id of the atom |
[out] | literal | the resulting literal |
CLINGO_VISIBILITY_DEFAULT bool clingo_theory_base_atom_term | ( | clingo_theory_base_t const * | theory, |
clingo_id_t | atom, | ||
clingo_id_t * | term | ||
) |
Get the theory term associated with the theory atom.
[in] | theory | container where the atom is stored |
[in] | atom | id of the atom |
[out] | term | the resulting term id |
CLINGO_VISIBILITY_DEFAULT bool clingo_theory_base_atom_to_string | ( | clingo_theory_base_t const * | theory, |
clingo_id_t | atom, | ||
clingo_string_builder_t * | builder | ||
) |
Get the string representation of the given theory atom.
[in] | theory | container where the atom is stored |
[in] | atom | id of the element |
[in] | builder | the builder |
CLINGO_VISIBILITY_DEFAULT bool clingo_theory_base_element_condition | ( | clingo_theory_base_t const * | theory, |
clingo_id_t | element, | ||
clingo_literal_t const ** | condition, | ||
size_t * | size | ||
) |
Get the condition (array of aspif literals) of the given theory element.
[in] | theory | container where the element is stored |
[in] | element | id of the element |
[out] | condition | the resulting array of aspif literals |
[out] | size | the number of term literals |
CLINGO_VISIBILITY_DEFAULT bool clingo_theory_base_element_condition_id | ( | clingo_theory_base_t const * | theory, |
clingo_id_t | element, | ||
clingo_literal_t * | condition | ||
) |
Get the id of the condition of the given theory element.
[in] | theory | container where the element is stored |
[in] | element | id of the element |
[out] | condition | the resulting condition id |
CLINGO_VISIBILITY_DEFAULT bool clingo_theory_base_element_to_string | ( | clingo_theory_base_t const * | theory, |
clingo_id_t | element, | ||
clingo_string_builder_t * | builder | ||
) |
Get the string representation of the given theory element.
[in] | theory | container where the element is stored |
[in] | element | id of the element |
[in] | builder | the builder |
CLINGO_VISIBILITY_DEFAULT bool clingo_theory_base_element_tuple | ( | clingo_theory_base_t const * | theory, |
clingo_id_t | element, | ||
clingo_id_t const ** | tuple, | ||
size_t * | size | ||
) |
Get the tuple (array of theory terms) of the given theory element.
[in] | theory | container where the element is stored |
[in] | element | id of the element |
[out] | tuple | the resulting array of term ids |
[out] | size | the number of term ids |
CLINGO_VISIBILITY_DEFAULT bool clingo_theory_base_size | ( | clingo_theory_base_t const * | theory, |
size_t * | size | ||
) |
Get the total number of theory theory.
[in] | theory | the target |
[out] | size | the resulting number |
CLINGO_VISIBILITY_DEFAULT bool clingo_theory_base_term_arguments | ( | clingo_theory_base_t const * | theory, |
clingo_id_t | term, | ||
clingo_id_t const ** | arguments, | ||
size_t * | size | ||
) |
Get the arguments of the given function theory term.
[in] | theory | container where the term is stored |
[in] | term | id of the term |
[out] | arguments | the resulting arguments in form of an array of term ids |
[out] | size | the number of arguments |
CLINGO_VISIBILITY_DEFAULT bool clingo_theory_base_term_name | ( | clingo_theory_base_t const * | theory, |
clingo_id_t | term, | ||
clingo_string_t * | name | ||
) |
Get the name of the given constant or function theory term.
[in] | theory | container where the term is stored |
[in] | term | id of the term |
[out] | name | the resulting name |
CLINGO_VISIBILITY_DEFAULT bool clingo_theory_base_term_number | ( | clingo_theory_base_t const * | theory, |
clingo_id_t | term, | ||
int * | number | ||
) |
Get the number of the given numeric theory term.
[in] | theory | container where the term is stored |
[in] | term | id of the term |
[out] | number | the resulting number |
CLINGO_VISIBILITY_DEFAULT bool clingo_theory_base_term_to_string | ( | clingo_theory_base_t const * | theory, |
clingo_id_t | term, | ||
clingo_string_builder_t * | builder | ||
) |
Get the string representation of the given theory term.
[in] | theory | container where the term is stored |
[in] | term | id of the term |
[in] | builder | the string builder |
CLINGO_VISIBILITY_DEFAULT bool clingo_theory_base_term_type | ( | clingo_theory_base_t const * | theory, |
clingo_id_t | term, | ||
clingo_theory_term_type_t * | type | ||
) |
Get the type of the given theory term.
[in] | theory | container where the term is stored |
[in] | term | id of the term |
[out] | type | the resulting type |