38#include "InferenceItem.hpp"
40#include "ClauseComparisons.hpp"
51using std::filesystem::path;
59using MatrixPairType = pair<ClauseNum, LitNum>;
65using LiteralClausePairType = pair<Literal,Clause>;
140 vector<vector<MatrixPairType>>
index;
149 static std::mt19937
d;
168 void rebuild_index(vector<Clause>&, vector<string>&, vector<string>&);
176 template<
class Comparison>
181 vector<ClauseRoleName> cr;
183 for (
size_t i = 0; i < s; i++) {
189 std::sort(cr.begin(), cr.end(), comparison);
198 size_t s2 =
index.size();
200 index = vector<vector<MatrixPairType> >(s2, vector<MatrixPairType>());
201 for (
size_t i = 0; i < s; i++) {
202 add_clause(std::get<0>(cr[i]), std::get<1>(cr[i]).first, std::get<1>(cr[i]).second);
249 return index[_i].size();
255 return (
index[_i])[_j];
375 vector<Clause>::const_iterator cbegin()
const {
return clauses.cbegin(); }
376 vector<Clause>::const_iterator cend()
const {
return clauses.cend(); }
377 vector<Clause>::iterator begin() {
return clauses.begin(); }
378 vector<Clause>::iterator end() {
return clauses.end(); }
434 friend ostream& operator<<(ostream&,
const Matrix&);
Representation of clauses.
Basic representation of literals, bundling together (pointers to) a Predicate, a collection of argume...
Representation of the Matrix within a proof.
string to_string() const
Make a string representation.
void sort_clauses_by_increasing_size()
Self-explanatory.
vector< Clause > clauses
The Matrix itself is just a set of Clauses.
void deterministic_reorder(size_t)
Deterministic reorder of the clauses.
void move_equals_to_start()
Self-explanatory.
const Literal & inspect_index_literal(size_t i, size_t j)
Straightforward get method.
ClauseNum get_num_clauses() const
Straightforward get method.
vector< string > clause_names
Keep track of the names of the clauses.
string make_LaTeX(bool=false) const
Make a usable LaTeX representation.
vector< string > clause_roles
Keep track of which clauses are conjectures etc.
void make_clauses_copy()
Store a copy of the clauses.
Matrix()
Use this constructor if you really want an empty Matrix.
void get_literal_clause_pair(LitNum, size_t, Literal &, Clause &) const
Get a literal and clause from the index.
string get_name(size_t _i) const
Retrieve the name of one of the clauses in the matrix.
void add_clause(Clause &, string="", string="")
Add a Clause to the Matrix and update the index accordingly.
uint32_t num_equals
You need to know how many equality axioms there are in case you want to move them around.
vector< vector< MatrixPairType > > index
We want to be able to quickly identify where in each clause a particular literal lives.
bool is_negative(size_t i) const
Is a particular Clause negative?
bool copy_saved
Remember whether you've saved a copy.
static std::mt19937 d
Randomness for random reordering.
vector< string > names_copy
It makes sense to keep a copy of the names if your schedule reorders multiple times.
bool is_conjecture(size_t i) const
Is a particular Clause a conjecture?
void make_copy_with_new_unique_vars(size_t, Clause &, VariableIndex &, TermIndex &) const
Make a new copy of a clause in the matrix.
vector< string > roles_copy
It makes sense to keep a copy of the roles if your schedule reorders multiple times.
void write_to_prolog_file(const path &) const
Write to a file that can be read by Prolog.
void random_reorder_literals()
Randomly reorder the literals in each clause in the matrix.
void set_num_equals(uint32_t n)
Straightforward set method.
const Clause & operator[](size_t i) const
Straightforward get method.
Matrix(const Matrix &)=delete
You're never going to need to copy a Matrix.
bool is_positive(size_t i) const
Is a particular Clause positive?
MatrixPairType get_index_entry(size_t _i, size_t _j) const
The ExtensionEnumerator needs to know this.
size_t get_index_entry_size(size_t _i) const
The ExtensionEnumerator needs to know this.
void rebuild_index(vector< Clause > &, vector< string > &, vector< string > &)
Rebuild the index after, for example, reordering.
void show_tptp() const
Output in TPTP compatible format.
const Literal & inspect_literal(size_t i, size_t j)
Straightforward get method.
vector< Clause > clauses_copy
It makes sense to keep a copy of the clauses if your schedule reorders multiple times.
void sort_clauses(Comparison comparison)
Template method for general sorting of clauses, which sorts roles and names at the same time.
void set_num_preds(size_t)
Make an empty index.
vector< vector< LiteralClausePairType > > literal_clause_index
This corresponds closely to index, but has the actual Literal, and the Clause after the Literal's rem...
pair< bool, size_t > find_start() const
Use a simple heuristic to find a good start clause.
void random_reorder()
Randomly reorder the matrix.
vector< bool > negative_clauses
Keep track of which clauses are negative.
vector< bool > ground_clauses
We need to know this to control backtracking.
vector< bool > positive_clauses
Keep track of which clauses are positive.
bool is_ground(size_t i) const
Is a particular Clause ground?
Look after terms, using hash consing to avoid storing copies of terms.
Storage of named variables, and management of new, anonymous and unique variables.
Provide a function object to compare clauses by size.