Connect++ 0.1
A fast, readable connection prover for first-order logic.
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
Literal Class Reference

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.
 
Predicateget_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 &)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Literal()

Literal::Literal ( Predicate new_p,
const vector< Term * > &  new_args,
Arity  new_ar,
bool  new_pol 
)

Construct a Literal from existing material.

Parameters
new_pPointer to a Predicate
new_argsReference to a vector of pointers to Terms
new_arNew value for arity
new_polSet true for positive literal, false for negative (negated).

Member Function Documentation

◆ contains_variable()

bool Literal::contains_variable ( Variable v) const

Does this Literal contain the specified variable?

Parameters
vPointer to Variable to search for.

◆ get_pred_as_index()

size_t Literal::get_pred_as_index ( ) const
inline

Turn a Literal into an array index.

This is straightforward: positive literals have even indices and negative literals odd.

◆ is_compatible_with()

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.

Parameters
lPointer to Literal to compare with.

◆ is_complement_of()

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.

◆ make_copy_with_new_vars()

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.

Parameters
viReference to the VariableIndex
tiReference to the TermIndex

◆ make_copy_with_new_vars_helper()

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.

Parameters
viReference to the VariableIndex
tiReference to the TermIndex
new_varsReference 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.

◆ make_LaTeX()

string Literal::make_LaTeX ( bool  subbed = false) const

Make a useable LaTeX version.

Assumes you are typesetting in Math Mode.

Parameters
subbedImplement substitutions if true.

◆ operator==()

bool Literal::operator== ( const Literal l) const

Equality without taking account of substutions.

Parameters
lLiteral to compare with.

◆ replace_variable()

void Literal::replace_variable ( Variable new_var,
Variable old_var,
TermIndex ti 
)

Replace one variable with another throughout.

Iterate over the args using the replace_variable_in_term method in TermIndex to do the real work.

Parameters
new_varPointer to new Variable
old_varPointer to old Variable
tiPointer to the TermIndex

◆ replace_variable_with_term()

void Literal::replace_variable_with_term ( Term new_term,
Variable old_var,
TermIndex ti 
)

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.

Parameters
new_termPointer to new Term
old_varPointer to old Variable
tiPointer to the TermIndex

◆ subbed_equal()

bool Literal::subbed_equal ( Literal l) const

Equality, taking account of substitutions.

Parameters
lPointer to Literal to compare with

◆ to_prolog_string()

string Literal::to_prolog_string ( ) const

Convert to a string in a format readable by Prolog.

Does not apply substitutions.

◆ to_string()

string Literal::to_string ( bool  subbed = false) const

Full conversion of Literal to string.

Parameters
subbedImplement substitutions if true.

The documentation for this class was generated from the following files: