33#include<unordered_map>
35#include "TermIndex.hpp"
36#include "Predicate.hpp"
41using std::unordered_map;
57 Literal() : pred(
nullptr), args(), arity(0), polarity(
true) {}
83 inline const vector<Term*>&
get_args()
const {
return args; }
103 inline void invert() { polarity = !polarity; }
111 inline bool is_empty()
const {
return (pred ==
nullptr); }
115 void clear() { pred =
nullptr; args.clear(), arity = 0; polarity =
true; }
123 size_t index = pred->
get_ID() << 1;
168 string to_string(
bool =
false)
const;
224 unordered_map<Variable*,Term*>&)
const;
249 friend ostream& operator<<(ostream&,
const Literal&);
Basic representation of literals, bundling together (pointers to) a Predicate, a collection of argume...
Definition Literal.hpp:50
bool is_false() const
Is this equivalent to $false?
Definition Literal.cpp:95
void make_positive()
Basic manipulation - entirely self-explanatory.
Definition Literal.hpp:95
void replace_variable_with_term(Term *, Variable *, TermIndex *)
Replace one variable with a term throughout.
Definition Literal.cpp:213
const vector< Term * > & get_args() const
Basic get method.
Definition Literal.hpp:83
bool is_empty() const
Basic manipulation - entirely self-explanatory.
Definition Literal.hpp:111
string make_LaTeX(bool=false) const
Make a useable LaTeX version.
Definition Literal.cpp:185
bool contains_variable(Variable *) const
Does this Literal contain the specified variable?
Definition Literal.cpp:105
void replace_variable(Variable *, Variable *, TermIndex *)
Replace one variable with another throughout.
Definition Literal.cpp:202
bool is_positive() const
Basic manipulation - entirely self-explanatory.
Definition Literal.hpp:87
bool is_complement_of(const Literal &) const
Test whether one literal is exactly the same as another, with the exception of the polarity.
Definition Literal.cpp:78
Arity get_arity() const
Basic get method.
Definition Literal.hpp:75
bool is_compatible_with(const Literal *) const
Literals can only be unified if the polarity and actual predicate are the same.
Definition Literal.cpp:67
Literal make_copy_with_new_vars(VariableIndex &, TermIndex &) const
Make a copy of the Literal but with a new set of variables.
Definition Literal.cpp:58
void make_empty()
Basic manipulation - entirely self-explanatory.
Definition Literal.hpp:107
bool operator==(const Literal &) const
Equality without taking account of substutions.
Definition Literal.cpp:114
bool get_polarity() const
Basic get method.
Definition Literal.hpp:79
bool is_true() const
Is this equivalent to $true?
Definition Literal.cpp:85
string get_small_lit() const
Get the predicate and polarity as a string.
Definition Literal.cpp:142
size_t get_pred_as_index() const
Turn a Literal into an array index.
Definition Literal.hpp:122
bool subbed_equal(Literal *) const
Equality, taking account of substitutions.
Definition Literal.cpp:126
void invert()
Basic manipulation - entirely self-explanatory.
Definition Literal.hpp:103
bool is_negative() const
Basic manipulation - entirely self-explanatory.
Definition Literal.hpp:91
void clear()
Basic manipulation - entirely self-explanatory.
Definition Literal.hpp:115
string to_prolog_string() const
Convert to a string in a format readable by Prolog.
Definition Literal.cpp:165
void make_negative()
Basic manipulation - entirely self-explanatory.
Definition Literal.hpp:99
Predicate * get_pred() const
Basic get method.
Definition Literal.hpp:71
Literal make_copy_with_new_vars_helper(VariableIndex &, TermIndex &, unordered_map< Variable *, Term * > &) const
Helper function for make_copy_with_new_vars.
Definition Literal.cpp:48
Basic representation of predicates: here just names, ids and arities.
Definition Predicate.hpp:51
ID get_ID() const
Basic get method.
Definition Predicate.hpp:82
General representation of terms.
Definition Term.hpp:62
Look after terms, (ideally) using hash consing to avoid storing copies of terms.
Definition TermIndex.hpp:75
Basic representation of variables.
Definition Variable.hpp:58
Storage of named variables, and management of new, anonymous variables.
Definition VariableIndex.hpp:61