Connect++ 0.1
A fast, readable connection prover for first-order logic.
|
Storage of named variables, and management of new, anonymous variables. More...
#include <VariableIndex.hpp>
Public Member Functions | |
VariableIndex (const VariableIndex &)=delete | |
Copying this would be a very silly idea, so explicitly disallow it. | |
VariableIndex (const VariableIndex &&)=delete | |
VariableIndex & | operator= (const VariableIndex &)=delete |
VariableIndex & | operator= (const VariableIndex &&)=delete |
ID | get_next_index () const |
Straightforward access function. | |
ID | get_first_anon_variable () const |
Straightforward access function. | |
ID | get_highest_anon_variable () const |
Straightforward access function. | |
bool | get_all_names_added () const |
Straightforward access function. | |
size_t | get_num_backtracks () const |
Straightforward access function. | |
Variable * | add_named_var (const string &) |
Add a variable with the specified name to the index. | |
Variable * | add_anon_var () |
Add an anonymous variable. | |
Variable * | add_unique_var () |
Add a unique variable when converting to CNF. | |
Variable * | find_variable (const string &) |
Look up a variable by name. | |
void | set_all_names_added () |
Call this to indicate that only anonymous variables can now be created. | |
void | clear_substitutions () |
Undo all substitutions made, to anything, ever. | |
void | add_backtrack_point () |
Add a backtrack point. | |
ID | add_named_backtrack_point () |
Same as add_backtrack_point, but return an identifier allowing multiple levels of backtracking using backtrack_to_named_point. | |
void | backtrack () |
Backtrack to the last marker. | |
void | backtrack_to_named_point (ID) |
Backtrack, possibly multiple times, to the specified point. | |
void | reset () |
Get rid of all the markers used for backtracking. | |
Friends | |
ostream & | operator<< (ostream &, const VariableIndex &) |
Storage of named variables, and management of new, anonymous variables.
Variables are only stored once, and I want backtracking to be easy while recycling old anonymous variables. You should only add named variables once, at the beginning of the process.
You should only make variables using this index. If you do then it takes care of allocation/deallocation for you.
|
delete |
Copying this would be a very silly idea, so explicitly disallow it.
As usual, let the compiler be your friend.
Variable * VariableIndex::add_anon_var | ( | ) |
Add an anonymous variable.
Anonymous variables are recycled after backtracking. Also denies addition of new named variables if you didn't do that yourself. Anonymous variables do get names of the form "_next_index" but are not currently included in the map as they can be found by other means if you absolutely need to, which you shouldn't.
void VariableIndex::add_backtrack_point | ( | ) |
Add a backtrack point.
This is straightforward. All we have to do is remember a starting point so that all anonymous variables after that can easily be reused.
It is the responsibility of the user to insert and maintain an initial backtrack point at the first anonymous variable.
Variable * VariableIndex::add_named_var | ( | const string & | name | ) |
Add a variable with the specified name to the index.
Only allow a named variable to be added once, and before any anonymous variables. If you add something twice you'll just get a pointer to the first copy.
name | Name of Variable to add |
Variable * VariableIndex::add_unique_var | ( | ) |
Add a unique variable when converting to CNF.
Does not immediately deny addition of further named variables.
void VariableIndex::backtrack | ( | ) |
Backtrack to the last marker.
This is straightforward. Substitutions do not have to be undone here as that will happen if a variable is reused.
Variable * VariableIndex::find_variable | ( | const string & | var_name | ) |
Look up a variable by name.
var_name | Name of Variable to find. |
void VariableIndex::reset | ( | ) |
Get rid of all the markers used for backtracking.
Clears all backtracking information.
void VariableIndex::set_all_names_added | ( | ) |
Call this to indicate that only anonymous variables can now be created.
Note: this also adds a backtrack point at the first (currently not created) anonymous variable.