Clingo
Loading...
Searching...
No Matches
CppClingo::Ground::Term Class Referenceabstract

Term interface. More...

#include <term.hh>

Inheritance diagram for CppClingo::Ground::Term:
CppClingo::Ground::TermBinary CppClingo::Ground::TermFunction CppClingo::Ground::TermLinear CppClingo::Ground::TermProjection CppClingo::Ground::TermSymbol CppClingo::Ground::TermTuple CppClingo::Ground::TermUnary CppClingo::Ground::TermVariable

Public Types

using Key = Symbol
 Key for the concept only matcher interface.
 

Public Member Functions

virtual ~Term ()=default
 Destructor.
 
auto score (double size, std::vector< bool > const &bound) const -> double
 Compute an estimate how often the term can match size symbols given the bound variables.
 
auto match (EvalContext const &ctx, Symbol sym) const -> bool
 Match a term with the given symbol.
 
auto eval (EvalContext const &ctx) const -> std::optional< Symbol >
 Evaluates a term w.r.t.
 
auto rename (SymbolStore &store, RenameMode mode, String const *name, size_t *vars) const -> UTerm
 Create a copy of the term renaming/replacing parts of it.
 
auto rename (Util::unordered_map< size_t, size_t > &vars) const -> UTerm
 Create a copy of the term renaming variables in order of occurrence.
 
void vars (VariableSet &vars, bool provide=false) const
 Collect all variables in the term.
 
auto copy () const -> UTerm
 Create a copy of the term.
 
auto hash () const -> size_t
 Compute a hash for the term.
 
auto signature (VariableSet const &bound, VariableSet const &bind) const -> std::pair< UTerm, VariableVec >
 Compute a signature of the term.
 
auto vars () const -> VariableSet
 Collect all variables in the term.
 

Friends

auto operator== (Term const &a, Term const &b) -> bool
 Compare two terms.
 
auto operator<=> (Term const &a, Term const &b) -> std::strong_ordering
 Compare two terms.
 
auto operator<< (std::ostream &out, Term const &term) -> std::ostream &
 Print the term.
 

Detailed Description

Term interface.

Member Function Documentation

◆ eval()

auto CppClingo::Ground::Term::eval ( EvalContext const &  ctx) const -> std::optional<Symbol>
inline

Evaluates a term w.r.t.

the given assignment.

A term might fail to evaluate if a unary or binary operation is not defined for its arguments.

◆ match()

auto CppClingo::Ground::Term::match ( EvalContext const &  ctx,
Symbol  sym 
) const -> bool
inline

Match a term with the given symbol.

Returns true if the term can match the symbol. Variables in the term are assigned to symbols and stored in the given assignment.

◆ rename()

auto CppClingo::Ground::Term::rename ( SymbolStore store,
RenameMode  mode,
String const *  name,
size_t *  vars 
) const -> UTerm
inline

Create a copy of the term renaming/replacing parts of it.

If a name is given, the name of the outermost function symbol is changed. Otherwise, variables and projection are replaced according to the given mode.

◆ signature()

auto CppClingo::Ground::Term::signature ( VariableSet const &  bound,
VariableSet const &  bind 
) const -> std::pair<UTerm, VariableVec>
inline

Compute a signature of the term.

This renames variables in the term in ascending order and then return a pair of the term and the bound variables.


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