36: v(nullptr), f(new_f), args(new_args)
38 if (new_f->
get_arity() != new_args.size()) {
39 cerr <<
"Number of arguments doesn't match function arity" << endl;
40 cerr <<
"Perhaps your function names are mixed up?" << endl;
51 if (args.size() == 0) {
52 cerr <<
"You shouldn't be accessing a term's arguments here." << endl;
63 for (
size_t i = 0; i < args.size(); i++) {
76 for (
Term* t : args) {
77 if (!t->is_ground()) {
100 else if (tv !=
nullptr) {
112 for (
size_t i = 0; i < f->
get_arity(); i++) {
136 cerr <<
"You shouldn't be using this with a function term." << endl;
147 for (
size_t i = 0; i < args.size(); i++)
175 for (
size_t i = 0; i < args.size(); i++)
185 else if (f !=
nullptr) {
188 result += vector_to_string(args, subbed, show_addresses);
192 result +=
"You're trying to print a badly-formed term.";
193 if (show_addresses) {
207 else if (f !=
nullptr) {
210 if (args.size() > 0) {
212 for (
size_t j = 0; j < args.size(); j++) {
213 result += args[j]->to_prolog_string(subbed);
227 if (args.size() > 0) {
230 for (
size_t j = 0; j < args.size(); j++) {
231 s += args[j]->make_LaTeX(subbed);
244 if (args.size() > 0) {
247 for (
size_t j = 0; j < args.size(); j++) {
248 s += args[j]->make_Graphviz(subbed);
273 bool& _subbed_is_var,
276 size_t& _subbed_arity)
const {
278 if (f ==
nullptr && v ==
nullptr) {
281 while (p->f ==
nullptr) {
289 if (p->f ==
nullptr) {
293 _subbed_is_var =
true;
299 _subbed_is_var =
false;
308 cerr <<
"STOP IT!!! You shouldn't be using this with substituted variables!" << endl;
313 for (
Term* p : args) {
314 set<Term*> some_vars = p->all_variables();
315 result.insert(some_vars.begin(), some_vars.end());
321ostream& operator<<(ostream& out,
const Term& t) {
322 out << t.
to_string(params::output_terms_with_substitution,
true);
338 string s = cs(name).lblue();
339 if (subbed && substitution !=
nullptr) {
340 s += unicode_symbols::LogSym::subbed;
347 if (subbed && substitution !=
nullptr) {
354 if (subbed && substitution !=
nullptr)
357 string s (
"\\text{");
358 s += latex_escape_characters(name);
365 if (subbed && substitution !=
nullptr)
373 if (substitution ==
nullptr)
380 if (substitution ==
nullptr)
387 if (substitution ==
nullptr) {
396 if (substitution ==
nullptr)
403 if (substitution ==
nullptr) {
404 cerr <<
"There is no function name to be found..." << endl;
412 if (substitution ==
nullptr) {
413 cerr <<
"There is no arity to be found..." << endl;
421 if (substitution !=
nullptr) {
424 cerr <<
"Stop it! You're trying to skip something inappropriate!" << endl;
Basic representation of functions.
string make_Graphviz() const
Make a useable Graphviz version.
string make_LaTeX() const
Make a useable LaTeX version.
string to_string() const
Make a useable string representation.
Arity get_arity() const
Most basic access function.
string get_name() const
Most basic access function.
General representation of terms.
Function * get_subbed_f() const
Taking substitution into account, what function do we actually have?
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.
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.
string make_Graphviz(bool=false) const
Make a useable Graphviz representation.
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.
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,...
Term * skip_leading_variables_for_unification(bool &, Variable *&, Function *&, size_t &) const
It may be that there is a chain of substitutions attached to a variable.
bool is_ground() const
Is the term ground?
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?
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.
string to_prolog_string(bool=false) const
Convert to a string that can be read by Prolog.
bool is_subbed() const
Test whether any variable has been substituted.
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?
Basic representation of variables.
Variable * subbed_variable() const
If the variable is unsubbed then return "this"; otherwise a pointer to the variable at the end of a c...
Term * skip_leading_variables() const
It may be that there is a chain of substitutions attached to this variable: skip the leading ones.
bool contains_variable(Variable *) const
Does the substitution turn the variable into something that includes the variable passed?
bool subbed_is_variable() const
Is the variable still in fact a variable, taking substitution into account?
string to_prolog_string(bool=false) const
Convert to a Prolog string.
bool is_subbed() const
Is this variable currently substituted?
Arity get_subbed_arity() const
If there is a chain of substitutions ending in a function, find that function's arity.
Function * get_subbed_f() const
If there is a chain of substitutions ending in a function, find that function.
string to_string(bool=false) const
Convert to a (coloured) string.
string make_Graphviz(bool=false) const
Convert the Variable to a useable Graphviz representation.
bool subbed_is_function() const
Is the variable now a function, taking substitution into account?
string make_LaTeX(bool=false) const
Convert the Variable to a useable LaTeX representation.
Term * get_subbed_term() const
Get the current substitution, or nullptr.
Simple addition of colour to strings and ostreams.
Simple function object for putting commas in lists.