Connect++ 0.6.1
A fast, readable connection prover for first-order logic.
Loading...
Searching...
No Matches
ClauseCopyCache.hpp
1/*
2
3Copyright © 2023-25 Sean Holden. All rights reserved.
4
5*/
6/*
7
8This file is part of Connect++.
9
10Connect++ is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License as published by the
12Free Software Foundation, either version 3 of the License, or (at your
13option) any later version.
14
15Connect++ is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18more details.
19
20You should have received a copy of the GNU General Public License along
21with Connect++. If not, see <https://www.gnu.org/licenses/>.
22
23*/
24
25#ifndef CLAUSECOPYCACHE_HPP
26#define CLAUSECOPYCACHE_HPP
27
28#include<iostream>
29#include<string>
30#include<vector>
31
32#include "Matrix.hpp"
33
34using std::vector;
35using std::string;
36using std::ostream;
37using std::endl;
38using std::cout;
39
41private:
47 vector<vector<Clause>> cache;
52 size_t size;
64 vector<size_t> next_copy_index;
69 vector<size_t> stack;
70public:
76 : size(0)
77 , cache()
80 , stack()
81 {}
85 inline void set_size(size_t _s) { size = _s; }
96 void reset(const Matrix&, VariableIndex&, TermIndex&);
114 void backtrack();
119 void show_counts() const;
120
121 friend ostream& operator<<(ostream&, const ClauseCopyCache&);
122};
123
124#endif
vector< vector< Clause > > cache
Cache containing some number of copies (with unique variables, not used anywhere else) of clauses fro...
vector< size_t > next_copy_index
Index of the next available copy of each clause.
vector< size_t > stack
Each time you supply a copy, remember the action so that you can backtrack.
void make_copy_with_new_variables(size_t, Clause &, const Matrix &, VariableIndex &, TermIndex &)
If there is a copy cached, replace the parameter with it. Otherwise, use the parameter to actually ma...
void set_size(size_t _s)
Set the number of clauses we need cached copies for.
void backtrack()
Backtracking is just looking at the last copy supplied and undoing that action.
ClauseCopyCache()
You probably don't know the size at the point when this needs to be constructed.
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...
void reset(const Matrix &, VariableIndex &, TermIndex &)
This is for any actual initialisation, when you either (1) intially know what you're dealing with,...
size_t size
Keep track of how many clauses there are in the matrix.
void show_counts() const
Mostly for development. See how many copies you actually ended up with.
Representation of clauses.
Definition Clause.hpp:52
Representation of the Matrix within a proof.
Definition Matrix.hpp:74
Look after terms, using hash consing to avoid storing copies of terms.
Definition TermIndex.hpp:54
Storage of named variables, and management of new, anonymous and unique variables.