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();
227 if (args.size() > 0) {
230 for (
size_t j = 0; j < args.size(); j++) {
231 s += args[j]->make_LaTeX(subbed);
256 bool& _subbed_is_var,
259 size_t& _subbed_arity)
const {
261 if (f ==
nullptr && v ==
nullptr) {
264 while (p->f ==
nullptr) {
272 if (p->f ==
nullptr) {
276 _subbed_is_var =
true;
282 _subbed_is_var =
false;
291 cerr <<
"STOP IT!!! You shouldn't be using this with substituted variables!" << endl;
296 for (
Term* p : args) {
297 set<Term*> some_vars = p->all_variables();
298 result.insert(some_vars.begin(), some_vars.end());
304ostream& operator<<(ostream& out,
const Term& t) {
305 out << t.
to_string(params::output_terms_with_substitution,
true);
321 string s = cs(name).lblue();
322 if (subbed && substitution !=
nullptr) {
323 s += unicode_symbols::LogSym::subbed;
330 if (subbed && substitution !=
nullptr)
333 string s (
"\\text{");
334 s += latex_escape_characters(name);
341 if (substitution ==
nullptr)
348 if (substitution ==
nullptr)
355 if (substitution ==
nullptr) {
364 if (substitution ==
nullptr)
371 if (substitution ==
nullptr) {
372 cerr <<
"There is no function name to be found..." << endl;
380 if (substitution ==
nullptr) {
381 cerr <<
"There is no arity to be found..." << endl;
389 if (substitution !=
nullptr) {
392 cerr <<
"Stop it! You're trying to skip something inappropriate!" << endl;
Basic representation of functions.
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.
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() 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?
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.
bool subbed_is_function() const
Is the variable now a function, taking substitution into account?
string get_name() const
Self-explanatory access function.
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.