Clingo
Loading...
Searching...
No Matches
CppClingo::Ground::AtomBase Class Reference

An atom base used to store derivable atoms and associated state. More...

#include <base.hh>

Inheritance diagram for CppClingo::Ground::AtomBase:
CppClingo::Ground::BaseImpl< Symbol, AtomBase >

Public Types

using MapAtom = Util::ordered_map< Symbol, AtomInfo >
 Map containing the atoms.
 
- Public Types inherited from CppClingo::Ground::BaseImpl< Symbol, AtomBase >
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.
 
- Public Member Functions inherited from CppClingo::Ground::BaseImpl< Symbol, AtomBase >
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.
 

Detailed Description

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.

Member Function Documentation

◆ domain()

auto CppClingo::Ground::AtomBase::domain ( ) const
inline

Check if the base is domain.

A base is domain if it contains facts only.

◆ index()

auto CppClingo::Ground::AtomBase::index ( Symbol const &  sym) const -> size_t
inline

Get the atom index of the given symbol.

Note that only derived atoms have indices.

◆ is_fact()

auto CppClingo::Ground::AtomBase::is_fact ( Symbol  sym) const -> bool
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.

◆ mark_negated()

auto CppClingo::Ground::AtomBase::mark_negated ( ) -> size_t
inline

Mark derived atoms as shown.

Returns the index of the first atom not previously shown.

◆ mark_projected()

auto CppClingo::Ground::AtomBase::mark_projected ( ) -> size_t
inline

Mark derived atoms as projected.

Returns the index of the first atom not previously projected.

◆ mark_shown()

auto CppClingo::Ground::AtomBase::mark_shown ( ) -> size_t
inline

Mark derived atoms as shown.

Returns the index of the first atom not previously shown.

◆ simplify()

template<class Pred >
void CppClingo::Ground::AtomBase::simplify ( Pred const &  pred,
size_t &  rem,
size_t &  fact 
)
inline

Simplify the atom base.

Removes false atoms and marks facts based on the predicat.

Parameters
preda predicate to obtain a truth value
remthe number of removed atoms
factthe number of atoms that became facts

The documentation for this class was generated from the following file: