29 const vector<Term*>& new_args,
38 if (new_p ==
nullptr) {
39 cerr <<
"Why would you construct an empty predicate?" << endl;
42 if (new_p->
get_arity() != new_args.size()) {
43 cerr <<
"Number of arguments doesn't match predicate arity" << endl;
44 cerr <<
"Are you mixing up your predicate names?" << endl;
50 unordered_map<Variable*,Term*>& new_vars)
const {
51 vector<Term*> new_args;
52 for (
size_t i = 0; i < arity; i++)
53 new_args.push_back(args[i]->make_copy_with_new_vars_helper(vi, ti, new_vars));
54 Literal result(pred, new_args, arity, polarity);
61 cerr <<
"You shouldn't be making copies of empty Literals" << endl;
63 unordered_map<Variable*,Term*> new_vars;
69 if (pred ==
nullptr || l->pred ==
nullptr) {
70 cerr <<
"You shouldn't be checking compatibility of empty Literals" << endl;
73 return (pred == l->pred &&
74 polarity == l->polarity &&
79 return (pred == l.pred &&
82 !polarity == l.polarity);
87 (pred->
get_name() ==
string(
"$true")) &&
91 (pred->
get_name() ==
string(
"$false")) &&
97 (pred->
get_name() ==
string(
"$false")) &&
101 (pred->
get_name() ==
string(
"$true")) &&
106 for (
size_t i = 0; i < args.size(); i++) {
116 if (pred ==
nullptr || l.pred ==
nullptr) {
117 cerr <<
"You shouldn't be checking equality of empty Literals" << endl;
120 return (pred == l.pred &&
123 polarity == l.polarity);
128 if (pred ==
nullptr || l->pred ==
nullptr) {
129 cerr <<
"You shouldn't be checking subbed equality of empty Literals" << endl;
135 for (
size_t i = 0; i < arity; i++) {
145 result += unicode_symbols::LogSym::neg;
151 string result(
"Empty literal");
156 for (
Term* p : args) {
157 result += p->to_string(subbed);
176 for (
Term* p : args) {
177 result += p->to_prolog_string();
195 for (
Term* p : args) {
196 result += p->to_prolog_string();
204 result += args[0]->to_prolog_string();
209 result += args[1]->to_prolog_string();
223 for (
Term* p : args) {
224 s += p->make_LaTeX(subbed);
236 cerr <<
"You shouldn't be replacing variables in an empty Literal" << endl;
238 for (
size_t i = 0; i < arity; i++) {
247 cerr <<
"You shouldn't be subbing terms in an empty Literal" << endl;
249 for (
size_t i = 0; i < arity; i++) {
254ostream& operator<<(ostream& out,
const Literal& l) {
256 out <<
"Empty literal";
259 out << unicode_symbols::LogSym::neg;
261 size_t s = l.args.size() - 1;
264 for (
Term* p : l.args) {
265 out << p->to_string();
Basic representation of literals, bundling together (pointers to) a Predicate, a collection of argume...
bool is_false() const
Is this equivalent to $false?
void replace_variable_with_term(Term *, Variable *, TermIndex *)
Replace one variable with a term throughout.
string to_string(bool=false) const
Full conversion of Literal to string.
bool is_empty() const
Basic manipulation - entirely self-explanatory.
string make_LaTeX(bool=false) const
Make a useable LaTeX version.
bool contains_variable(Variable *) const
Does this Literal contain the specified variable?
void replace_variable(Variable *, Variable *, TermIndex *)
Replace one variable with another throughout.
string to_tptp_string() const
Convert to a string in a format compatible with the TPTP.
bool is_complement_of(const Literal &) const
Test whether one literal is exactly the same as another, with the exception of the polarity.
bool is_compatible_with(const Literal *) const
Literals can only be unified if the polarity and actual predicate are the same.
Literal make_copy_with_new_vars(VariableIndex &, TermIndex &) const
Make a copy of the Literal but with a new set of variables.
bool operator==(const Literal &) const
Equality without taking account of substutions.
bool is_true() const
Is this equivalent to $true?
string get_small_lit() const
Get the predicate and polarity as a string.
bool subbed_equal(Literal *) const
Equality, taking account of substitutions.
string to_prolog_string() const
Convert to a string in a format readable by Prolog.
Literal make_copy_with_new_vars_helper(VariableIndex &, TermIndex &, unordered_map< Variable *, Term * > &) const
Helper function for make_copy_with_new_vars.
Basic representation of predicates: here just names, ids and arities.
Arity get_arity() const
Basic get method.
string make_LaTeX() const
Make a useable LaTeX version.
string to_string() const
Converting to a string just gives you the name.
string get_name() const
Basic get method.
General representation of terms.
Look after terms, (ideally) using hash consing to avoid storing copies of terms.
Term * replace_variable_in_term_with_term(Term *, Variable *, Term *)
Minor variation on replace_variable_in_term.
Term * replace_variable_in_term(Variable *, Variable *, Term *)
Replace a variable in a term with an alternative, maintaining the structure of the TermIndex.
Basic representation of variables.
Storage of named variables, and management of new, anonymous variables.
Simple function object for putting commas in lists.