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

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
 
VariableIndexoperator= (const VariableIndex &)=delete
 
VariableIndexoperator= (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.
 
Variableadd_named_var (const string &)
 Add a variable with the specified name to the index.
 
Variableadd_anon_var ()
 Add an anonymous variable.
 
Variableadd_unique_var ()
 Add a unique variable when converting to CNF.
 
Variablefind_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 &)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ VariableIndex()

VariableIndex::VariableIndex ( const VariableIndex )
delete

Copying this would be a very silly idea, so explicitly disallow it.

As usual, let the compiler be your friend.

Member Function Documentation

◆ add_anon_var()

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.

◆ add_backtrack_point()

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.

◆ add_named_var()

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.

Parameters
nameName of Variable to add

◆ add_unique_var()

Variable * VariableIndex::add_unique_var ( )

Add a unique variable when converting to CNF.

Does not immediately deny addition of further named variables.

◆ backtrack()

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.

◆ find_variable()

Variable * VariableIndex::find_variable ( const string &  var_name)

Look up a variable by name.

Parameters
var_nameName of Variable to find.

◆ reset()

void VariableIndex::reset ( )

Get rid of all the markers used for backtracking.

Clears all backtracking information.

◆ set_all_names_added()

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.


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