27std::mt19937
Matrix::d(params::random_seed);
32, index((num_predicates * 2), vector<MatrixPairType>())
33, literal_clause_index((num_predicates * 2), vector<LiteralClausePairType>())
47 index = vector<vector<MatrixPairType> >((num_predicates * 2), vector<MatrixPairType>());
48 literal_clause_index = vector<vector<LiteralClausePairType> >((num_predicates * 2), vector<LiteralClausePairType>());
57 bool found_positive =
false;
58 bool found_negative =
false;
59 size_t first_positive = 0;
60 size_t first_negative = 0;
61 bool found_candidate =
false;
66 if (!found_positive) {
68 found_positive =
true;
72 if (!found_negative) {
74 found_negative =
true;
80 found_candidate =
true;
86 if (!(found_positive && found_negative))
87 return pair<bool,size_t>(
false, 0);
89 return pair<bool, size_t>(
true, candidate);
90 else if (params::positive_representation)
91 return pair<bool, size_t>(
true, first_positive);
93 return pair<bool, size_t>(
true, first_negative);
100 ClauseNum clause_number =
clauses.size();
101 LitNum literal_number = 0;
102 for (
size_t j = 0; j < clause.
size(); j++) {
103 size_t i = clause[j].get_pred_as_index();
104 index[i].push_back(MatrixPairType(clause_number, literal_number));
105 Clause new_clause = clause;
120 vector<string>& ns) {
128 size_t s2 =
index.size();
132 index = vector<vector<MatrixPairType> >(s2, vector<MatrixPairType>());
133 literal_clause_index = vector<vector<LiteralClausePairType> >(s3, vector<LiteralClausePairType>());
134 for (
size_t i = 0; i < s; i++) {
150 vector<uint32_t> new_order;
152 for (
size_t i = 0; i < s; i++)
153 new_order.push_back(i);
154 new_order = deterministic_reorder_n_times<uint32_t>(new_order, n);
161 for (
size_t i = 0; i < s; i++) {
162 size_t j = new_order[i];
174 vector<Clause> saved_clauses(
clauses);
180 vector<uint32_t> new_order;
182 for (
size_t i = 0; i < s; i++)
183 new_order.push_back(i);
184 std::shuffle(new_order.begin(), new_order.end(),
d);
191 for (
size_t i = 0; i < s; i++) {
192 size_t j = new_order[i];
193 cs.push_back(saved_clauses[j]);
194 ss.push_back(saved_clause_roles[j]);
195 ns.push_back(saved_clause_names[j]);
204 vector<Clause> saved_clauses(
clauses);
211 for (
size_t i = 0; i < s; i++) {
212 Clause c(saved_clauses[i]);
214 saved_clauses[i] = c;
219 rebuild_index(saved_clauses, saved_clause_roles, saved_clause_names);
224 cerr <<
"Why are you trying to move equality axioms - there aren't any?" << endl;
234 size_t s2 =
index.size();
238 index = vector<vector<MatrixPairType> >(s2, vector<MatrixPairType>());
239 literal_clause_index = vector<vector<LiteralClausePairType> >(s3, vector<LiteralClausePairType>());
241 for (
size_t i = n_clauses -
num_equals; i < n_clauses; i++) {
244 for (
size_t i = 0; i < n_clauses -
num_equals; i++) {
258 result += cs(
"*").orange();
262 result += cs(
"+").orange();
264 result += cs(
"-").orange();
268 result += c.to_string();
278 string s (
"\\[\n\\begin{split}\n");
279 s +=
"\\textcolor{magenta}{M} = ";
282 s += std::to_string(i++);
284 s += c.make_LaTeX(subbed);
287 s +=
"\n\\end{split}\n\\]\n";
293 std::ofstream file(path_to_file);
297 file <<
":- style_check(-singleton)." << std::endl;
300 file << std::to_string(matrix_i++);
302 file << c.to_prolog_string();
312 cout <<
"cnf(matrix-";
313 cout << std::to_string(matrix_i++);
315 cout << c.to_tptp_string();
324 _clause = result.second;
329 _c =
clauses[_index].make_copy_with_new_unique_vars(_vi, _ti);
332ostream& operator<<(ostream& out,
const Matrix& m) {
333 out <<
"Clauses in matrix:" << endl;
334 out <<
"------------------" << endl;
337 out << setw(params::output_width) << i
346 vector<string> index_lits(m.
index.size(),
string(
""));
348 for (
size_t i = 0; i < c.
size(); i++)
349 index_lits[c[i].get_pred_as_index()] = c[i].get_small_lit();
351 out << endl <<
"Index: (Clause, Literal):" << endl;
352 out <<
"-------------------------" << endl;
353 for (vector<MatrixPairType> v : m.
index) {
354 out << setw(params::output_width + 20) << index_lits[i++] <<
": ";
355 for (MatrixPairType p : v) {
356 out <<
"(" << p.first <<
", " << p.second <<
") ";
360 out << endl <<
"Index: (Literal, Clause without Literal):" << endl;
361 out <<
"-----------------------------------------" << endl;
364 out << setw(params::output_width + 20) << index_lits[i++] <<
": " << endl;;
365 for (LiteralClausePairType p : v) {
366 out << p.first.to_string() <<
" --- " << p.second.to_string() << endl;
Representation of clauses.
void random_reorder()
Randomly re-order the literals.
bool is_positive() const
A clause is positive if it has no negated literals.
size_t size() const
Straightforward get method.
bool is_negative() const
A clause is negative if it has only negated literals.
bool is_ground() const
Is this a ground clause?
void drop_literal(LitNum)
Get rid of the specified Literal.
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.
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.
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.
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 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 rebuild_index(vector< Clause > &, vector< string > &, vector< string > &)
Rebuild the index after, for example, reordering.
void show_tptp() const
Output in TPTP compatible format.
vector< Clause > clauses_copy
It makes sense to keep a copy of the clauses if your schedule reorders multiple times.
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.
Look after terms, using hash consing to avoid storing copies of terms.
Storage of named variables, and management of new, anonymous and unique variables.
Simple addition of colour to strings and ostreams.