![]() |
Connect++ 0.6.0
A fast, readable connection prover for first-order logic.
|
Representation of the Matrix within a proof. More...
#include <Matrix.hpp>
Public Member Functions | |
Matrix () | |
Use this constructor if you really want an empty Matrix. | |
Matrix (size_t) | |
Use this constructor when you know how many predicates there are. | |
Matrix (const Matrix &)=delete | |
You're never going to need to copy a Matrix. | |
Matrix (const Matrix &&)=delete | |
Matrix & | operator= (const Matrix &)=delete |
Matrix & | operator= (const Matrix &&)=delete |
ClauseNum | get_num_clauses () const |
Straightforward get method. | |
size_t | get_index_entry_size (size_t _i) const |
The ExtensionEnumerator needs to know this. | |
MatrixPairType | get_index_entry (size_t _i, size_t _j) const |
The ExtensionEnumerator needs to know this. | |
const Clause & | operator[] (size_t i) const |
Straightforward get method. | |
const Literal & | inspect_literal (size_t i, size_t j) |
Straightforward get method. | |
const Literal & | inspect_index_literal (size_t i, size_t j) |
Straightforward get method. | |
bool | is_positive (size_t i) const |
Is a particular Clause positive? | |
bool | is_negative (size_t i) const |
Is a particular Clause negative? | |
bool | is_ground (size_t i) const |
Is a particular Clause ground? | |
bool | is_conjecture (size_t i) const |
Is a particular Clause a conjecture? | |
void | set_num_equals (uint32_t n) |
Straightforward set method. | |
pair< bool, size_t > | find_start () const |
Use a simple heuristic to find a good start clause. | |
void | set_num_preds (size_t) |
Make an empty index. | |
void | add_clause (Clause &, string="") |
Add a Clause to the Matrix and update the index accordingly. | |
void | deterministic_reorder (size_t) |
Deterministic reorder of the clauses. | |
void | random_reorder () |
Randomly reorder the matrix. | |
void | random_reorder_literals () |
Randomly reorder the literals in each clause in the matrix. | |
void | move_equals_to_start () |
Self-explanatory. | |
vector< Clause >::const_iterator | cbegin () const |
vector< Clause >::const_iterator | cend () const |
vector< Clause >::iterator | begin () |
vector< Clause >::iterator | end () |
string | to_string () const |
Make a string representation. | |
string | make_LaTeX (bool=false) const |
Make a usable LaTeX representation. | |
void | write_to_prolog_file (const path &) const |
Write to a file that can be read by Prolog. | |
void | show_tptp () const |
Output in TPTP compatible format. | |
void | sort_clauses_by_increasing_size () |
Self-explanatory. | |
void | get_literal_clause_pair (LitNum, size_t, Literal &, Clause &) const |
Get a literal and clause from the index. | |
Private Member Functions | |
void | make_clauses_copy () |
Store a copy of the clauses. | |
void | rebuild_index (vector< Clause > &, vector< string > &) |
Rebuild the index after, for example, reordering. | |
template<class Comparison > | |
void | sort_clauses (Comparison comparison) |
Template method for general sorting of clauses, which sorts roles at the same time. | |
Private Attributes | |
vector< Clause > | clauses |
The Matrix itself is just a set of Clauses. | |
vector< bool > | positive_clauses |
Keep track of which clauses are positive. | |
vector< bool > | negative_clauses |
Keep track of which clauses are negative. | |
vector< bool > | ground_clauses |
We need to know this to control backtracking. | |
vector< string > | clause_roles |
Keep track of which clauses are conjectures etc. | |
uint32_t | num_equals |
You need to know how many equality axioms there are in case you want to move them around. | |
vector< Clause > | clauses_copy |
It makes sense to keep a copy of the clauses if your schedule reorders multiple times. | |
vector< string > | roles_copy |
It makes sense to keep a copy of the roles if your schedule reorders multiple times. | |
bool | copy_saved |
Remember whether you've saved a copy. | |
vector< vector< MatrixPairType > > | index |
We want to be able to quickly identify where in each clause a particular literal lives. | |
vector< vector< LiteralClausePairType > > | literal_clause_index |
This corresponds closely to index, but has the actual Literal, and the Clause after the Literal's removal. | |
Static Private Attributes | |
static std::mt19937 | d |
Randomness for random reordering. | |
Friends | |
ostream & | operator<< (ostream &, const Matrix &) |
Representation of the Matrix within a proof.
The Matrix itself never actually changes. However we do want to be able to look things up quickly when finding possible extension steps, so we build a pair of indexes to help with that.
Definition at line 74 of file Matrix.hpp.
|
inline |
Use this constructor if you really want an empty Matrix.
Definition at line 194 of file Matrix.hpp.
Matrix::Matrix | ( | size_t | num_predicates | ) |
Use this constructor when you know how many predicates there are.
num_predicates | Number of predicates. |
Definition at line 30 of file Matrix.cpp.
|
delete |
You're never going to need to copy a Matrix.
Let the compiler be your friend.
void Matrix::add_clause | ( | Clause & | clause, |
string | role = "" ) |
Add a Clause to the Matrix and update the index accordingly.
Optionally add a clause role.
clause | Reference to the Clause. |
role | A string denoting the role of the clause. |
Definition at line 97 of file Matrix.cpp.
|
inline |
Definition at line 351 of file Matrix.hpp.
|
inline |
Definition at line 349 of file Matrix.hpp.
|
inline |
Definition at line 350 of file Matrix.hpp.
void Matrix::deterministic_reorder | ( | size_t | n | ) |
Deterministic reorder of the clauses.
Call the reorder algorithm the specified number of times. This assumes you have stored a copy of the original clauses.
n | Number of times to call the reorder algorithm |
Only store a copy of the clauses the first time you do this.
Definition at line 133 of file Matrix.cpp.
|
inline |
Definition at line 352 of file Matrix.hpp.
pair< bool, size_t > Matrix::find_start | ( | ) | const |
Use a simple heuristic to find a good start clause.
Find a start clause that is positive/negative according to the –negative flag, and if possible also a conjecture clause. Also, indicate if there is no positive/negative clause, which means the problem is trivial.
Definition at line 54 of file Matrix.cpp.
|
inline |
The ExtensionEnumerator needs to know this.
Definition at line 235 of file Matrix.hpp.
|
inline |
The ExtensionEnumerator needs to know this.
Definition at line 229 of file Matrix.hpp.
void Matrix::get_literal_clause_pair | ( | LitNum | _l, |
size_t | _i, | ||
Literal & | _lit, | ||
Clause & | _clause ) const |
Get a literal and clause from the index.
_l | Index for the literal of interest. |
_i | Index for where the pair is in _lit's vector. |
_lit | Result literal. |
_clause | Result clause. |
Definition at line 301 of file Matrix.cpp.
|
inline |
|
inline |
Straightforward get method.
Beware - the parameters are not checked, so behave!
i | Index in literal_clause_index; |
j | Index of required entry. |
Definition at line 265 of file Matrix.hpp.
|
inline |
Straightforward get method.
Beware - the parameters are not checked, so behave!
i | Index of clause to get. |
j | Index of literal in clause. |
Definition at line 254 of file Matrix.hpp.
bool Matrix::is_conjecture | ( | size_t | i | ) | const |
Is a particular Clause a conjecture?
i | Index of Clause to check. |
Definition at line 49 of file Matrix.cpp.
|
inline |
Is a particular Clause ground?
i | Index of Clause to check. |
Definition at line 285 of file Matrix.hpp.
|
inline |
Is a particular Clause negative?
i | Index of Clause to check. |
Definition at line 279 of file Matrix.hpp.
|
inline |
Is a particular Clause positive?
i | Index of Clause to check. |
Definition at line 273 of file Matrix.hpp.
|
inlineprivate |
Store a copy of the clauses.
Definition at line 141 of file Matrix.hpp.
string Matrix::make_LaTeX | ( | bool | subbed = false | ) | const |
Make a usable LaTeX representation.
subbed | Implement substitutions if true. |
Definition at line 259 of file Matrix.cpp.
void Matrix::move_equals_to_start | ( | ) |
Self-explanatory.
BUT only do this to the matrix built at the start of the process, as it assumes the equality axioms are at the end of the matrix.
Definition at line 208 of file Matrix.cpp.
|
inline |
Straightforward get method.
Beware - the parameter is not checked, so behave!
i | Index of item to get. |
Definition at line 245 of file Matrix.hpp.
void Matrix::random_reorder | ( | ) |
Randomly reorder the matrix.
Definition at line 164 of file Matrix.cpp.
void Matrix::random_reorder_literals | ( | ) |
Randomly reorder the literals in each clause in the matrix.
Definition at line 190 of file Matrix.cpp.
|
private |
Rebuild the index after, for example, reordering.
cs | Vector of clauses. |
ss | Vector of strings. |
Definition at line 115 of file Matrix.cpp.
|
inline |
Straightforward set method.
n | Number of equality axioms. |
Definition at line 297 of file Matrix.hpp.
void Matrix::set_num_preds | ( | size_t | num_predicates | ) |
Make an empty index.
Definition at line 44 of file Matrix.cpp.
void Matrix::show_tptp | ( | ) | const |
Output in TPTP compatible format.
Definition at line 289 of file Matrix.cpp.
|
inlineprivate |
Template method for general sorting of clauses, which sorts roles at the same time.
ClauseComparisons.hpp contains function objects that can be used with this to implement different orderings.
Definition at line 162 of file Matrix.hpp.
|
inline |
Self-explanatory.
Inspired by "Machine Learning Guidance for Connection Tableaux," Farber et al. 2020 although with a different measure of size and happening at a different place.
Makes use of the sort_clauses template.
Definition at line 385 of file Matrix.hpp.
string Matrix::to_string | ( | ) | const |
Make a string representation.
Definition at line 236 of file Matrix.cpp.
void Matrix::write_to_prolog_file | ( | const path & | path_to_file | ) | const |
Write to a file that can be read by Prolog.
This is for proof checking.
path_to_file | Reference to path object. |
Definition at line 272 of file Matrix.cpp.
|
friend |
Definition at line 307 of file Matrix.cpp.
|
private |
Keep track of which clauses are conjectures etc.
This allows start clause heuristics to be applied.
Definition at line 101 of file Matrix.hpp.
|
private |
The Matrix itself is just a set of Clauses.
Definition at line 79 of file Matrix.hpp.
|
private |
It makes sense to keep a copy of the clauses if your schedule reorders multiple times.
Definition at line 111 of file Matrix.hpp.
|
private |
Remember whether you've saved a copy.
Definition at line 120 of file Matrix.hpp.
|
staticprivate |
Randomness for random reordering.
Definition at line 137 of file Matrix.hpp.
|
private |
We need to know this to control backtracking.
Definition at line 95 of file Matrix.hpp.
|
private |
We want to be able to quickly identify where in each clause a particular literal lives.
Store clause and position as pairs in a row corresponding to the literal.
Definition at line 128 of file Matrix.hpp.
|
private |
This corresponds closely to index, but has the actual Literal, and the Clause after the Literal's removal.
Definition at line 133 of file Matrix.hpp.
|
private |
Keep track of which clauses are negative.
This allows start clause heuristics to be applied.
Definition at line 91 of file Matrix.hpp.
|
private |
You need to know how many equality axioms there are in case you want to move them around.
Definition at line 106 of file Matrix.hpp.
|
private |
Keep track of which clauses are positive.
This allows start clause heuristics to be applied.
Definition at line 85 of file Matrix.hpp.
|
private |
It makes sense to keep a copy of the roles if your schedule reorders multiple times.
Definition at line 116 of file Matrix.hpp.