![]() |
Connect++ 0.6.0
A fast, readable connection prover for first-order logic.
|
Look after terms, using hash consing to avoid storing copies of terms. More...
#include <TermIndex.hpp>
Public Member Functions | |
TermIndex (const TermIndex &)=delete | |
Don't allow copying as this is a terrible idea. | |
TermIndex (const TermIndex &&)=delete | |
TermIndex & | operator= (const TermIndex &)=delete |
TermIndex & | operator= (const TermIndex &&)=delete |
size_t | get_size () const |
Basic get method. | |
Term * | add_variable_term (Variable *) |
Self-explanatory: add a Term containing a variable to the index. | |
Term * | add_function_term (Function *, const vector< Term * > &) |
Self-explanatory: add a Term containing a function to the index. | |
Term * | replace_variable_in_term (Variable *, Variable *, Term *) |
Replace a variable in a term with an alternative, maintaining the structure of the TermIndex. | |
Term * | replace_variable_in_term_with_term (Term *, Variable *, Term *) |
Minor variation on replace_variable_in_term. | |
Private Member Functions | |
Term * | find (const Term &) |
Find a term in the index. | |
Private Attributes | |
unordered_map< Term, Term *, term_hash > | index |
Hash table for storing pointers to where Terms are actually stored. | |
vector< Term * > | term_pointers |
Used to make destruction easy. | |
Friends | |
ostream & | operator<< (ostream &, const TermIndex &) |
Look after terms, using hash consing to avoid storing copies of terms.
Everything is implemented such that this ignores whether or not Variables are substituted. (Because to do otherwise isn't necessary.)
Using the unordered_map means allowing various kinds of copying of Terms, which I'd rather not do.
You should only use this to make Terms. As long as you do that then this class takes all the responsibility for memory allocation and deallocation for Terms.
Definition at line 54 of file TermIndex.hpp.
|
inline |
Definition at line 75 of file TermIndex.hpp.
TermIndex::~TermIndex | ( | ) |
Definition at line 36 of file TermIndex.cpp.
|
delete |
Don't allow copying as this is a terrible idea.
As usual, let the compiler be your friend.
Self-explanatory: add a Term containing a function to the index.
It's only actually added if it's not already present. If present, a pointer to the existing copy is returned.
fp | Pointer to a Function for which an appropriate Term is to be added |
args | Vector of pointers to Terms constituting the arguments for the new function Term to be added. |
Definition at line 56 of file TermIndex.cpp.
Self-explanatory: add a Term containing a variable to the index.
It's only actually added if it's not already present. If present, a pointer to the existing copy is returned.
Definition at line 41 of file TermIndex.cpp.
Find a term in the index.
t | The term you want to look up. |
Definition at line 28 of file TermIndex.cpp.
|
inline |
Replace a variable in a term with an alternative, maintaining the structure of the TermIndex.
The first two arguments are variables and the third a general term. Replace one variable with another while keeping the structure of the index correct. Replacement replaces any substitutions for the variable being replaced with those applied to the new one. You should probably not do that as ideally the index should only contain unsubstituted variables.
new_v | Pointer to a Variable to use as replacement. |
old_v | Pointer to a Variable to be replaced. |
t | Pointer to Term to make the replacement for. This should already be in the index. |
Definition at line 74 of file TermIndex.cpp.
Minor variation on replace_variable_in_term.
ONLY use this if the new Term is in the index!
new_t | Pointer to a Term to use as replacement. |
old_v | Pointer to a Variable to be replaced. |
t | Pointer to Term to make the replacement for. This should already be in the index. |
Definition at line 95 of file TermIndex.cpp.
|
friend |
Definition at line 114 of file TermIndex.cpp.
Hash table for storing pointers to where Terms are actually stored.
The key is the Term itself. term_hash is defined in TermHash.hpp.
Definition at line 63 of file TermIndex.hpp.
|
private |
Used to make destruction easy.
Definition at line 67 of file TermIndex.hpp.