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++) {
85 else if (tv !=
nullptr) {
97 for (
size_t i = 0; i < f->
get_arity(); i++) {
121 cerr <<
"You shouldn't be using this with a function term." << endl;
132 for (
size_t i = 0; i < args.size(); i++)
160 for (
size_t i = 0; i < args.size(); i++)
170 else if (f !=
nullptr) {
174 for (
size_t j = 0; j < args.size(); j++) {
175 result += args[j]->to_string(subbed, show_addresses);
181 result +=
"You're trying to print a badly-formed term.";
182 if (show_addresses) {
196 else if (f !=
nullptr) {
199 if (args.size() > 0) {
201 for (
size_t j = 0; j < args.size(); j++) {
202 result += args[j]->to_prolog_string();
216 if (args.size() > 0) {
219 for (
size_t j = 0; j < args.size(); j++) {
220 s += args[j]->make_LaTeX(subbed);
248 cerr <<
"STOP IT!!! You shouldn't be using this with substituted variables!" << endl;
253 for (
Term* p : args) {
254 set<Term*> some_vars = p->all_variables();
255 result.insert(some_vars.begin(), some_vars.end());
261ostream& operator<<(ostream& out,
const Term& t) {
262 out << t.
to_string(params::output_terms_with_substitution,
true);
278 if (!subbed || substitution ==
nullptr)
279 return cs(name).lblue();
285 if (subbed && substitution !=
nullptr)
288 string s (
"\\text{");
289 s += latex_escape_characters(name);
296 if (substitution ==
nullptr)
303 if (substitution ==
nullptr)
310 if (substitution ==
nullptr) {
319 if (substitution ==
nullptr)
326 if (substitution ==
nullptr) {
327 cerr <<
"There is no function name to be found..." << endl;
335 if (substitution ==
nullptr) {
336 cerr <<
"There is no arity to be found..." << endl;
344 if (substitution !=
nullptr) {
347 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,...
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
Self-explanatory.
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
Self-explanatory.
Simple addition of colour to strings and ostreams.
Simple function object for putting commas in lists.