![]() |
Connect++ 0.6.0
A fast, readable connection prover for first-order logic.
|
Basic representation of literals, bundling together (pointers to) a Predicate, a collection of arguments each a (pointer to a) Term, an arity and a polarity. More...
#include <Literal.hpp>
Public Member Functions | |
Literal (Predicate *, const vector< Term * > &, Arity, bool) | |
Construct a Literal from existing material. | |
Predicate * | get_pred () const |
Basic get method. | |
Arity | get_arity () const |
Basic get method. | |
bool | get_polarity () const |
Basic get method. | |
const vector< Term * > & | get_args () const |
Basic get method. | |
Term * | operator[] (size_t i) const |
Basic get method. | |
bool | is_positive () const |
Basic manipulation - entirely self-explanatory. | |
bool | is_negative () const |
Basic manipulation - entirely self-explanatory. | |
void | make_positive () |
Basic manipulation - entirely self-explanatory. | |
void | make_negative () |
Basic manipulation - entirely self-explanatory. | |
void | invert () |
Basic manipulation - entirely self-explanatory. | |
void | make_empty () |
Basic manipulation - entirely self-explanatory. | |
bool | is_empty () const |
Basic manipulation - entirely self-explanatory. | |
void | clear () |
Basic manipulation - entirely self-explanatory. | |
size_t | get_pred_as_index () const |
Turn a Literal into an array index. | |
bool | is_ground () const |
Is the literal ground? | |
bool | is_true () const |
Is this equivalent to $true? | |
bool | is_false () const |
Is this equivalent to $false? | |
bool | contains_variable (Variable *) const |
Does this Literal contain the specified variable? | |
bool | is_compatible_with (const Literal *) const |
Literals can only be unified if the polarity and actual predicate are the same. | |
bool | is_complement_of (const Literal &) const |
Test whether one literal is exactly the same as another, with the exception of the polarity. | |
string | get_small_lit () const |
Get the predicate and polarity as a string. | |
string | to_string (bool=false) const |
Full conversion of Literal to string. | |
string | to_prolog_string () const |
Convert to a string in a format readable by Prolog. | |
string | to_tptp_string () const |
Convert to a string in a format compatible with the TPTP. | |
string | make_LaTeX (bool=false) const |
Make a useable LaTeX version. | |
bool | operator== (const Literal &) const |
Equality without taking account of substutions. | |
bool | subbed_equal (Literal *) const |
Equality, taking account of substitutions. | |
Literal | make_copy_with_new_vars (VariableIndex &, TermIndex &) const |
Make a copy of the Literal but with a new set of variables. | |
Literal | make_copy_with_new_vars_helper (VariableIndex &, TermIndex &, unordered_map< Variable *, Term * > &) const |
Helper function for make_copy_with_new_vars. | |
void | make_copy_with_new_vars_replace_helper (VariableIndex &, TermIndex &, unordered_map< Variable *, Term * > &) |
Helper function for making copies with new variables. | |
void | replace_variable (Variable *, Variable *, TermIndex *) |
Replace one variable with another throughout. | |
void | replace_variable_with_term (Term *, Variable *, TermIndex *) |
Replace one variable with a term throughout. | |
Private Attributes | |
Predicate * | pred |
vector< Term * > | args |
Arity | arity |
bool | polarity |
Friends | |
ostream & | operator<< (ostream &, const Literal &) |
Basic representation of literals, bundling together (pointers to) a Predicate, a collection of arguments each a (pointer to a) Term, an arity and a polarity.
Definition at line 50 of file Literal.hpp.
|
inline |
Definition at line 57 of file Literal.hpp.
Literal::Literal | ( | Predicate * | new_p, |
const vector< Term * > & | new_args, | ||
Arity | new_ar, | ||
bool | new_pol ) |
Construct a Literal from existing material.
new_p | Pointer to a Predicate |
new_args | Reference to a vector of pointers to Terms |
new_ar | New value for arity |
new_pol | Set true for positive literal, false for negative (negated). |
Definition at line 28 of file Literal.cpp.
|
inline |
Basic manipulation - entirely self-explanatory.
Definition at line 119 of file Literal.hpp.
bool Literal::contains_variable | ( | Variable * | v | ) | const |
Does this Literal contain the specified variable?
v | Pointer to Variable to search for. |
Definition at line 121 of file Literal.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Turn a Literal into an array index.
This is straightforward: positive literals have even indices and negative literals odd.
Definition at line 126 of file Literal.hpp.
string Literal::get_small_lit | ( | ) | const |
Get the predicate and polarity as a string.
Definition at line 158 of file Literal.cpp.
|
inline |
Basic manipulation - entirely self-explanatory.
Definition at line 107 of file Literal.hpp.
bool Literal::is_compatible_with | ( | const Literal * | l | ) | const |
Literals can only be unified if the polarity and actual predicate are the same.
One does not generally expect literals to be differentiated by arity, but it's possible so we check that too.
l | Pointer to Literal to compare with. |
Definition at line 74 of file Literal.cpp.
bool Literal::is_complement_of | ( | const Literal & | l | ) | const |
Test whether one literal is exactly the same as another, with the exception of the polarity.
This also requires that the argument lists are the same.
l | Literal to compare with. |
Definition at line 85 of file Literal.cpp.
|
inline |
Basic manipulation - entirely self-explanatory.
Definition at line 115 of file Literal.hpp.
bool Literal::is_false | ( | ) | const |
Is this equivalent to $false?
Definition at line 111 of file Literal.cpp.
bool Literal::is_ground | ( | ) | const |
Is the literal ground?
Do not attempt to follow substitutions.
Definition at line 92 of file Literal.cpp.
|
inline |
Basic manipulation - entirely self-explanatory.
Definition at line 95 of file Literal.hpp.
|
inline |
Basic manipulation - entirely self-explanatory.
Definition at line 91 of file Literal.hpp.
bool Literal::is_true | ( | ) | const |
Literal Literal::make_copy_with_new_vars | ( | VariableIndex & | vi, |
TermIndex & | ti ) const |
Make a copy of the Literal but with a new set of variables.
All the heavy lifting is done by the Term class. Essentially just initializes an unordered_map and calls the corresponging helper.
vi | Reference to the VariableIndex |
ti | Reference to the TermIndex |
Definition at line 65 of file Literal.cpp.
Literal Literal::make_copy_with_new_vars_helper | ( | VariableIndex & | vi, |
TermIndex & | ti, | ||
unordered_map< Variable *, Term * > & | new_vars ) const |
Helper function for make_copy_with_new_vars.
Iterates over the args using the corresponding method in the Term class to do the real work.
vi | Reference to the VariableIndex |
ti | Reference to the TermIndex |
new_vars | Reference to an unordered_map from pointers to Variables, to pointers to Terms. Initially empty. On completion contains a map from variables, to the terms corresponding to the new variables made to replace them. |
Definition at line 48 of file Literal.cpp.
void Literal::make_copy_with_new_vars_replace_helper | ( | VariableIndex & | vi, |
TermIndex & | ti, | ||
unordered_map< Variable *, Term * > & | new_vars ) |
Helper function for making copies with new variables.
Iterates over the args using the corresponding method in the Term class to do the real work.
vi | Reference to the VariableIndex |
ti | Reference to the TermIndex |
new_vars | Reference to an unordered_map from pointers to Variables, to pointers to Terms. Initially empty. On completion contains a map from variables, to the terms corresponding to the new variables made to replace them. |
Definition at line 58 of file Literal.cpp.
|
inline |
Basic manipulation - entirely self-explanatory.
Definition at line 111 of file Literal.hpp.
string Literal::make_LaTeX | ( | bool | subbed = false | ) | const |
Make a useable LaTeX version.
Assumes you are typesetting in Math Mode.
subbed | Implement substitutions if true. |
Definition at line 236 of file Literal.cpp.
|
inline |
Basic manipulation - entirely self-explanatory.
Definition at line 103 of file Literal.hpp.
|
inline |
Basic manipulation - entirely self-explanatory.
Definition at line 99 of file Literal.hpp.
bool Literal::operator== | ( | const Literal & | l | ) | const |
Equality without taking account of substutions.
l | Literal to compare with. |
Definition at line 130 of file Literal.cpp.
|
inline |
Replace one variable with another throughout.
Iterate over the args using the replace_variable_in_term method in TermIndex to do the real work.
Definition at line 253 of file Literal.cpp.
Replace one variable with a term throughout.
Iterate over the args using the replace_variable_in_term_with_term method in TermIndex to do the real work.
Definition at line 264 of file Literal.cpp.
bool Literal::subbed_equal | ( | Literal * | l | ) | const |
Equality, taking account of substitutions.
l | Pointer to Literal to compare with |
Definition at line 142 of file Literal.cpp.
string Literal::to_prolog_string | ( | ) | const |
Convert to a string in a format readable by Prolog.
Does not apply substitutions.
Definition at line 186 of file Literal.cpp.
string Literal::to_string | ( | bool | subbed = false | ) | const |
Full conversion of Literal to string.
subbed | Implement substitutions if true. |
Definition at line 166 of file Literal.cpp.
string Literal::to_tptp_string | ( | ) | const |
Convert to a string in a format compatible with the TPTP.
Does not apply substitutions.
Definition at line 206 of file Literal.cpp.
|
friend |
Definition at line 275 of file Literal.cpp.
|
private |
Definition at line 53 of file Literal.hpp.
|
private |
Definition at line 54 of file Literal.hpp.
|
private |
Definition at line 55 of file Literal.hpp.
|
private |
Definition at line 52 of file Literal.hpp.