Connect++ 0.6.0
A fast, readable connection prover for first-order logic.
Loading...
Searching...
No Matches
ClauseCopyCache Class Reference
Collaboration diagram for ClauseCopyCache:

Public Member Functions

 ClauseCopyCache ()
 You probably don't know the size at the point when this needs to be constructed.
 
 ClauseCopyCache (size_t _size)
 This is the only constructor that makes sense if you know the size.
 
void set_size (size_t)
 You probably don't know the size at the point when this needs to be constructed.
 
void make_copy_with_new_variables (size_t, Clause &, VariableIndex &, TermIndex &)
 If there is a copy cached, replace the parameter with it. Otherwise, use the parameter to actually make a copy, then add it to the cache and return it in the same way.
 
void backtrack ()
 Backtracking is just looking at the last copy supplied and undoing that action.
 
void clear ()
 We will sometimes need to clear the cache and start again because of reordering operations on the matrix.
 

Private Attributes

vector< vector< Clause > > cache
 Cache containing some number of copies (with unique variables, not used anywhere else) of clauses from the matrix.
 
size_t size
 Keep track of how many clauses there are in the matrix.
 
vector< size_t > number_of_copies_available
 How many copies of each clause, in total, are currently available? At any given time some may be available immediately. Anything beyond this requires an actual new copy to be made.
 
vector< size_t > current_copy_number
 When 0, there are no copies available. When 1, the last copy we used is the one at index 0, and so on.
 
vector< size_t > stack
 Each time you supply a copy, remember the action so that you can backtrack.
 

Detailed Description

Definition at line 40 of file ClauseCopyCache.hpp.

Constructor & Destructor Documentation

◆ ClauseCopyCache() [1/2]

ClauseCopyCache::ClauseCopyCache ( )
inline

You probably don't know the size at the point when this needs to be constructed.

Definition at line 77 of file ClauseCopyCache.hpp.

78 : size(0)
79 , cache()
82 , stack()
83 {}
vector< vector< Clause > > cache
Cache containing some number of copies (with unique variables, not used anywhere else) of clauses fro...
vector< size_t > stack
Each time you supply a copy, remember the action so that you can backtrack.
vector< size_t > current_copy_number
When 0, there are no copies available. When 1, the last copy we used is the one at index 0,...
vector< size_t > number_of_copies_available
How many copies of each clause, in total, are currently available? At any given time some may be avai...
size_t size
Keep track of how many clauses there are in the matrix.

◆ ClauseCopyCache() [2/2]

ClauseCopyCache::ClauseCopyCache ( size_t _size)
inline

This is the only constructor that makes sense if you know the size.

Definition at line 88 of file ClauseCopyCache.hpp.

89 : size(_size)
90 , cache(_size, vector<Clause>())
92 , current_copy_number(_size, 0)
93 , stack()
94 {}

Member Function Documentation

◆ backtrack()

void ClauseCopyCache::backtrack ( )

Backtracking is just looking at the last copy supplied and undoing that action.

Definition at line 48 of file ClauseCopyCache.cpp.

48 {
49 size_t i = stack.back();
50 stack.pop_back();
52}

◆ clear()

void ClauseCopyCache::clear ( )

We will sometimes need to clear the cache and start again because of reordering operations on the matrix.

Definition at line 54 of file ClauseCopyCache.cpp.

54 {
55 cache = vector<vector<Clause>>(size, vector<Clause>());
56 number_of_copies_available = vector<size_t>(size, 0);
57 current_copy_number = vector<size_t>(size, 0);
58 stack.clear();
59}

◆ make_copy_with_new_variables()

void ClauseCopyCache::make_copy_with_new_variables ( size_t _index,
Clause & _clause,
VariableIndex & _vi,
TermIndex & _ti )

If there is a copy cached, replace the parameter with it. Otherwise, use the parameter to actually make a copy, then add it to the cache and return it in the same way.

Parameters
_indexIndex of the clause in the matrix.
_clauseClause you want a copy of.
_viReference to the variable index.
_tiReference to the term index.

Definition at line 33 of file ClauseCopyCache.cpp.

34 {
35 size_t n = current_copy_number[_index];
36 if (n < number_of_copies_available[_index]) {
37 _clause = (cache[_index])[n];
38 }
39 else {
40 // _clause = Make an actual copy
41 cache[_index].push_back(_clause);
43 }
44 current_copy_number[_index]++;
45 stack.push_back(_index);
46}

◆ set_size()

void ClauseCopyCache::set_size ( size_t _size)

You probably don't know the size at the point when this needs to be constructed.

Definition at line 28 of file ClauseCopyCache.cpp.

28 {
29 size = _size;
30 clear();
31}
void clear()
We will sometimes need to clear the cache and start again because of reordering operations on the mat...

Member Data Documentation

◆ cache

vector<vector<Clause> > ClauseCopyCache::cache
private

Cache containing some number of copies (with unique variables, not used anywhere else) of clauses from the matrix.

Definition at line 47 of file ClauseCopyCache.hpp.

◆ current_copy_number

vector<size_t> ClauseCopyCache::current_copy_number
private

When 0, there are no copies available. When 1, the last copy we used is the one at index 0, and so on.

Definition at line 66 of file ClauseCopyCache.hpp.

◆ number_of_copies_available

vector<size_t> ClauseCopyCache::number_of_copies_available
private

How many copies of each clause, in total, are currently available? At any given time some may be available immediately. Anything beyond this requires an actual new copy to be made.

Definition at line 60 of file ClauseCopyCache.hpp.

◆ size

size_t ClauseCopyCache::size
private

Keep track of how many clauses there are in the matrix.

Definition at line 52 of file ClauseCopyCache.hpp.

◆ stack

vector<size_t> ClauseCopyCache::stack
private

Each time you supply a copy, remember the action so that you can backtrack.

Definition at line 71 of file ClauseCopyCache.hpp.


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