Clingo
|
An atom base used to store derivable atoms and associated state. More...
#include <base.hh>
Public Types | |
using | MapAtom = Util::ordered_map< Symbol, AtomInfo > |
Map containing the atoms. | |
![]() | |
using | Key = Symbol |
The key identifies an atom and is usually associated with further state. | |
Public Member Functions | |
auto | domain () const |
Check if the base is domain. | |
auto | is_fact (Symbol sym) const -> bool |
Check if the given atom is a fact. | |
auto | find (Symbol const &sym) -> std::optional< MapAtom::iterator > |
Check if the base contains the given atom. | |
template<class Gen > | |
auto | add (Symbol atom, StateAtom state, Gen &&gen) -> std::pair< MapAtom::iterator, AtomUpdate > |
Add an atom to the base. | |
auto | size () const -> size_t |
Get the number of derived atoms. | |
auto | num_shown () const -> size_t |
Get the number of shown atoms. | |
auto | index (Symbol const &sym) const -> size_t |
Get the atom index of the given symbol. | |
auto | nth (size_t i) const -> MapAtom::const_iterator |
Get the i-th atom in the base. | |
auto | nth (size_t i) -> MapAtom::iterator |
Get the i-th atom in the base. | |
void | mark (SymbolCollector &gc) |
Mark all symbols held by the base. | |
auto | mark_shown () -> size_t |
Mark derived atoms as shown. | |
auto | mark_negated () -> size_t |
Mark derived atoms as shown. | |
auto | mark_projected () -> size_t |
Mark derived atoms as projected. | |
template<class Pred > | |
void | simplify (Pred const &pred, size_t &rem, size_t &fact) |
Simplify the atom base. | |
![]() | |
auto | begin (MatcherType type) const -> size_t |
Get the index of the first atom in the given generation. | |
auto | end (MatcherType type) const -> size_t |
Get the index plus one of the last atom in the given generation. | |
auto | contains (Key const &sym, MatcherType type) const -> std::optional< size_t > |
Check if the base contains the given atom with in the given generation. | |
void | update (size_t generation) |
Update the generation counts. | |
void | ensure (size_t generation) |
Ensure that atoms are added to the given generation. | |
auto | context () -> T & |
Get the context of the base with the desired type. | |
void | clear_context () |
Clear the current context. | |
auto | has_update () const -> bool |
Check if the base has an update. | |
An atom base used to store derivable atoms and associated state.
The base tracks the generation of atoms for semi-naive evaluation, and the state of atoms.
An atom base can also store unknown atoms. For such atoms it is not yet know whether there will be a rule deriving them. The only purpose is to store them here is to associated them with a unique id.
|
inline |
Check if the base is domain.
A base is domain if it contains facts only.
|
inline |
Get the atom index of the given symbol.
Note that only derived atoms have indices.
|
inline |
Check if the given atom is a fact.
This function does not take into account to which generation an atom belongs. It can also return true for atoms added to upcoming generations.
|
inline |
Mark derived atoms as shown.
Returns the index of the first atom not previously shown.
|
inline |
Mark derived atoms as projected.
Returns the index of the first atom not previously projected.
|
inline |
Mark derived atoms as shown.
Returns the index of the first atom not previously shown.
|
inline |
Simplify the atom base.
Removes false atoms and marks facts based on the predicat.
pred | a predicate to obtain a truth value |
rem | the number of removed atoms |
fact | the number of atoms that became facts |