Connect++ 0.1
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. | |
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_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 | 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 | 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. | |
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.
bool Literal::contains_variable | ( | Variable * | v | ) | const |
|
inline |
Turn a Literal into an array index.
This is straightforward: positive literals have even indices and negative literals odd.
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. |
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.
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 |
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. |
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. |
bool Literal::operator== | ( | const Literal & | l | ) | const |
Equality without taking account of substutions.
l | Literal to compare with. |
bool Literal::subbed_equal | ( | Literal * | l | ) | const |
Equality, taking account of substitutions.
l | Pointer to Literal to compare with |
string Literal::to_prolog_string | ( | ) | const |
Convert to a string in a format readable by Prolog.
Does not apply substitutions.
string Literal::to_string | ( | bool | subbed = false | ) | const |
Full conversion of Literal to string.
subbed | Implement substitutions if true. |