33#include<unordered_map>
35#include "VariableIndex.hpp"
39using std::unordered_map;
41using std::ostringstream;
45using VarMapType = pair<Variable*,Term*>;
72 Term() : v(nullptr), f(nullptr), args() {}
99 Term& operator=(
const Term&) =
delete;
100 Term& operator=(
const Term&&) =
delete;
122 inline Arity
arity()
const {
return args.size(); }
139 string to_string(
bool =
false,
bool =
false)
const;
281 unordered_map<Variable*,Term*>&)
const;
288 friend ostream& operator<<(ostream&,
const Term&);
Basic representation of functions.
General representation of terms.
Function * get_subbed_f() const
Taking substitution into account, what function do we actually have?
Term * make_copy_with_new_vars(VariableIndex &, TermIndex &) const
Does as the name suggests.
bool is_unsubbed_variable() const
Is this a variable that hasn't been substituted?
string make_LaTeX(bool=false) const
Make a useable LaTeX representation.
Variable * get_v() const
Self-explanatory access function.
bool subbed_equal(Term *) const
Equality test, taking substitution into account.
Term * skip_leading_variables() const
It may be that there is a chain of substitutions attached to a variable.
void find_subbed_vars(set< Variable * > &) const
Taking substitution into account, find all the variables in a term.
bool subbed_is_variable() const
Is this term a variable, taking substitution into accoumt?
set< Term * > all_variables() const
Assuming nothing has been substituted, find all the variables in this term.
Term * make_copy_with_new_vars_helper(VariableIndex &, TermIndex &, unordered_map< Variable *, Term * > &) const
Main implementation of make_copy_with_new_vars.
string to_string(bool=false, bool=false) const
Make a string representation of the Term, taking into account any substitutions that have been made.
Term()
Constructors - these are private as Terms should only ever be constructed by the TermIndex,...
Variable * subbed_variable() const
Taking substitution into account, what variable do we actually have?
Arity get_subbed_arity() const
Taking substitution into account, what arity do we actually have?
Function * get_f() const
Self-explanatory access function.
bool contains_variable(Variable *) const
Taking substitution into account, does the term include the variable passed?
bool operator==(const Term &) const
For the TermIndex you want strict equaliity of the data members.
bool is_function() const
Self-explanatory.
bool is_variable() const
Self-explanatory.
string to_prolog_string() const
Convert to a string that can be read by Prolog.
bool is_subbed() const
Test whether any variable has been substituted.
Arity arity() const
Self-explanatory access function.
Term * operator[](size_t) const
Access to args, but don't mess with them!
bool subbed_is_function() const
Is this term a function, taking substitution into accoumt?
Term(const Term &)=delete
Look after terms, (ideally) using hash consing to avoid storing copies of terms.
Basic representation of variables.
Storage of named variables, and management of new, anonymous variables.