![]() |
Connect++ 0.3.0
A fast, readable connection prover for first-order logic.
|
Prover using a pair of stacks to conduct the proof search. More...
#include <StackProver.hpp>
Public Member Functions | |
StackProver () | |
You only need a basic constructor. | |
StackProver (const StackProver &)=delete | |
Don't try to copy this. | |
StackProver (const StackProver &&)=delete | |
StackProver & | operator= (const StackProver &)=delete |
StackProver & | operator= (const StackProver &&)=delete |
std::tuple< VariableIndex *, FunctionIndex *, PredicateIndex *, TermIndex * > | get_indexes () |
Straightforward get method. | |
string | get_status () const |
Straightforward get method. | |
void | set_timeout (chrono::steady_clock::time_point time) |
Set a timeout. | |
void | set_problem_path (fs::path &p) |
Set the path for the problem being solved. U. | |
void | set_num_preds (size_t) |
Set the number of predicates. | |
void | read_from_tptp_file (const string &, bool &, size_t &) |
Obviously, reads a problem from a TPTP file. | |
void | add_equality_axioms (Predicate *) |
After reading a problem in which = and/or != appears, add the axioms for equality. | |
void | deterministic_reorder (uint32_t n) |
Deterministically reorder the matrix n times. | |
void | random_reorder () |
Randomly reorder the matrix. | |
void | show_matrix () |
Show a nicely formatted matrix. | |
Matrix & | get_matrix () |
Get a reference to the matrix. | |
bool | problem_is_cnf_only () const |
Find out whether the problem is CNF only. | |
bool | problem_has_true_conjecture () const |
Find out whether the problem's conjecture is $true. | |
bool | problem_has_false_conjecture () const |
Find out whether the problem's conjecture is $false. | |
bool | problem_has_missing_conjecture () const |
Find out whether the problem's conjecture is missing, in the sense that it didn't appear in the input file. | |
bool | problem_has_negated_conjecture_removed () const |
Find out whether the problem's negated conjecture was simplified out. | |
bool | problem_has_fof_axioms () const |
Find out from the parser whether the problem had axioms before simplification. | |
bool | simplified_problem_has_fof_axioms () const |
Find out from the parser whether the problem had axioms after simplification. | |
void | show_tptp_proof () |
Show a Prolog-formatted proof. | |
ProverOutcome | prove () |
Here is where the magic happens. | |
vector< pair< string, vector< size_t > > > | get_internal_proof () const |
Get an internal representation of the proof stack. | |
void | show_matrix () const |
void | show_path () const |
void | show_stack () |
void | show_right_stack () |
void | show_term_index () |
void | show_statistics () const |
Private Member Functions | |
ProverResult | go () |
This runs the proof search from a given Start Move. | |
void | populate_stack_item () |
Fill the vector of possible actions with everything available. | |
void | extend_with_action () |
Take a single inference (action) and update the stacks accordingly. | |
bool | depth_limited () |
Test for the depth limit. | |
bool | axiom () const |
Test to see if you're at an axiom. | |
void | process_axiom_forward () |
Start a right branch to continue from an axiom. | |
void | backtrack_once () |
Basic, single step backtrack on the stack. | |
void | reduction_backtrack () |
One of several different kinds of backtracking. | |
void | lemmata_backtrack () |
One of several different kinds of backtracking. | |
void | left_extension_backtrack () |
One of several different kinds of backtracking. | |
void | right_extension_backtrack () |
One of several different kinds of backtracking. | |
void | set_up_start_clauses () |
The start clauses to use depend on the settings, and the settings can change. | |
void | reset_for_start () |
Reset everything so that you can start from a specified start clause. | |
Private Attributes | |
size_t | num_preds |
How many prdicates does the problem of interest have? | |
VariableIndex | var_index |
This class needs one of each kind of index to keep track of Variables, Terms etc. | |
FunctionIndex | fun_index |
This class needs one of each kind of index to keep track of Variables, Terms etc. | |
TermIndex | term_index |
This class needs one of each kind of index to keep track of Variables, Terms etc. | |
PredicateIndex | pred_index |
This class needs one of each kind of index to keep track of Variables, Terms etc. | |
SubstitutionStack | sub_stack |
There is a separate stack to make application and removal of substitutions straightforward. | |
vector< StartClauseStatus > | results |
This is populated by the StackProver::set_up_start_clauses method. | |
Matrix | matrix |
A copy of the matrix you're working with. | |
SimplePath | path |
At any point in the search process this is a copy of the path for the current node in the proof being constructed. | |
Clause | new_C |
At any point in the search process this is a copy of the clause for the current node in the proof being constructed. | |
Lemmata | lemmata |
At any point in the search process this is a copy of the list of lemmata for the current node in the proof being constructed. | |
Unifier | u |
We need a single Unifier to use throught the process. | |
InferenceItem | action |
Stores the next action from the current StackItem. | |
StackItem * | si |
Pointer to the current StackItem. | |
uint32_t | current_depth_limit |
Self-explanatary. | |
uint32_t | current_depth |
Self-explanatary. | |
bool | depth_limit_reached |
Self-explanatary. | |
string | status |
Problem status, if found in input file. | |
vector< StackItem > | stack |
Main stack: this is constructed by the search process and, if completed, represents a proof. | |
vector< StackItem > | right_branch_stack |
We build the proof by trying the left branches of extensions first: this stack keeps track of the right branches that we need to come back to. | |
bool | backtrack |
Are we moving up or down the stack? | |
ProofPrinter | proof_printer |
You need one of these to print LaTeX output or any kind of proof certificate. | |
fs::path | problem_path |
Path for the problem of interest. | |
Interval | output_interval |
How often do you output updates about progress? | |
uint32_t | reductions_tried |
We'll be keeping some simple statistics about the search process. | |
uint32_t | extensions_tried |
We'll be keeping some simple statistics about the search process. | |
uint32_t | lemmata_tried |
We'll be keeping some simple statistics about the search process. | |
uint32_t | right_branches_started |
We'll be keeping some simple statistics about the search process. | |
uint32_t | proof_count |
If we're searching for multiple proofs, keep count of which one this is. | |
bool | use_timeout |
Are we using a timeout? | |
chrono::steady_clock::time_point | end_time |
When do we stop because of a timeout? | |
verbose_print::VPrint | show |
Set up printing according to verbosity. | |
bool | cnf_only |
Keep track of whether there were any FOF formulas in the problem file. | |
bool | conjecture_true |
Keep track of whether the parser found the conjecture to be true. | |
bool | conjecture_false |
Keep track of whether the parser found the conjecture to be false. | |
bool | conjecture_missing |
Keep track of whether the parser found a conjecture in the problem file. | |
bool | negated_conjecture_removed |
Keep track of whether the parser simplified the conjecture away. | |
bool | fof_has_axioms |
Keep track of whether the parser found that it's an FOF problem with axioms before simplification. | |
bool | simplified_fof_has_axioms |
Keep track of whether the parser found that it's an FOF problem with axioms after simplification. | |
Friends | |
ostream & | operator<< (ostream &, const StackProver &) |
Prover using a pair of stacks to conduct the proof search.
This version is a straightforward translation of the proof method to search for a tree with all its leaves being axioms. However, by not using recursion we retain the ability to fully control backtracking and therefore, amongst other things, find all possible proofs.
This is really the main class for Connect++, and everything else essentially exists to support it. There's a lot going on here so hang on to your hat!
This is also one of only a small number of places where you'll need to modify stuff to incorporate machine learning. The main advice is simple: take notice of the comments that point out where to do this, and be very careful to leave the general stack manipulation code alone unless you really know what you're doing, because that stuff is quite easy to break.
Definition at line 74 of file StackProver.hpp.
StackProver::StackProver | ( | ) |
You only need a basic constructor.
Definition at line 28 of file StackProver.cpp.
void StackProver::add_equality_axioms | ( | Predicate * | equals_predicate | ) |
After reading a problem in which = and/or != appears, add the axioms for equality.
equals_predicate | Pointer to a Predicate representing equals. This will have been obtained as an output from parsing the input file. |
Definition at line 125 of file StackProver.cpp.
|
private |
Test to see if you're at an axiom.
Definition at line 352 of file StackProver.cpp.
|
private |
Basic, single step backtrack on the stack.
Careful though: you need to treat the depth of the tree correctly if you want to keep track of it.
Definition at line 550 of file StackProver.cpp.
|
private |
Test for the depth limit.
Definition at line 343 of file StackProver.cpp.
|
inline |
Deterministically reorder the matrix n times.
n | Number of times to reorder. |
Definition at line 426 of file StackProver.hpp.
|
private |
Take a single inference (action) and update the stacks accordingly.
Definition at line 356 of file StackProver.cpp.
|
inline |
Straightforward get method.
Definition at line 365 of file StackProver.hpp.
vector< pair< string, vector< size_t > > > StackProver::get_internal_proof | ( | ) | const |
Get an internal representation of the proof stack.
Definition at line 1221 of file StackProver.cpp.
|
inline |
Get a reference to the matrix.
Definition at line 445 of file StackProver.hpp.
|
inline |
|
private |
This runs the proof search from a given Start Move.
Definition at line 659 of file StackProver.cpp.
|
private |
One of several different kinds of backtracking.
Definition at line 566 of file StackProver.cpp.
|
private |
One of several different kinds of backtracking.
Definition at line 562 of file StackProver.cpp.
|
private |
Fill the vector of possible actions with everything available.
Definition at line 302 of file StackProver.cpp.
|
inline |
Find out whether the problem's conjecture
is $false.
Definition at line 466 of file StackProver.hpp.
|
inline |
Find out from the parser whether the problem had axioms before simplification.
Definition at line 488 of file StackProver.hpp.
|
inline |
Find out whether the problem's conjecture
is missing, in the sense that it didn't appear in the input file.
Definition at line 474 of file StackProver.hpp.
|
inline |
Find out whether the problem's
negated conjecture was simplified out.
Definition at line 481 of file StackProver.hpp.
|
inline |
Find out whether the problem's conjecture
is $true.
Definition at line 459 of file StackProver.hpp.
|
inline |
Find out whether the problem is CNF only.
Definition at line 452 of file StackProver.hpp.
|
private |
Start a right branch to continue from an axiom.
You do this by taking the next available thing from the stack of right branches.
Definition at line 506 of file StackProver.cpp.
ProverOutcome StackProver::prove | ( | ) |
Here is where the magic happens.
You should only need to load the problem and call this method.
Definition at line 1039 of file StackProver.cpp.
|
inline |
void StackProver::read_from_tptp_file | ( | const string & | file_name, |
bool & | found_conjecture, | ||
size_t & | fof_size | ||
) |
Obviously, reads a problem from a TPTP file.
Does pretty much all of the setup required.
file_name | Name of the file to use. |
found_conjecture | Used to indicate whether a conjecture is found in the problem. |
fof_size | Number of first-order formulas found. |
Definition at line 76 of file StackProver.cpp.
|
private |
One of several different kinds of backtracking.
Definition at line 557 of file StackProver.cpp.
|
inlineprivate |
Reset everything so that you can start from a specified start clause.
Definition at line 309 of file StackProver.hpp.
|
private |
One of several different kinds of backtracking.
Here be DRAGONS.
Care needed here. If the state is a right branch, then it may or may not have to go back on right_branch_stack as you may or may not need to try it again, depending on the settings.
If you get this wrong you get a REALLY evil bug, because with the standard restricted backtracking you put it back on the stack when it's not needed. You then end up with extra things in the proof certificate which invalidate it, even though you can take them out and possibly get something valid.
Guess how I know this!
TODO: when I implement params::hard_prune it needs to be considered here.
Definition at line 597 of file StackProver.cpp.
void StackProver::set_num_preds | ( | size_t | n | ) |
Set the number of predicates.
But don't! You should never need to do this.
Definition at line 70 of file StackProver.cpp.
|
inline |
Set the path for the problem being solved. U.
Used only to produce nice output.
Definition at line 393 of file StackProver.hpp.
|
inline |
Set a timeout.
A StackProver is always constructed to have no timeout. This sets a timeout to use in seconds. The parameters are separate from the params::???? values as the latter apply globally whereas these allow for schedules to be constructed.
time | the time to stop: you will need to know about the standard library! |
Definition at line 384 of file StackProver.hpp.
|
private |
The start clauses to use depend on the settings, and the settings can change.
Definition at line 912 of file StackProver.cpp.
|
inline |
Show a nicely formatted matrix.
Definition at line 438 of file StackProver.hpp.
|
inline |
Definition at line 522 of file StackProver.hpp.
|
inline |
Definition at line 523 of file StackProver.hpp.
void StackProver::show_right_stack | ( | ) |
Definition at line 1235 of file StackProver.cpp.
void StackProver::show_stack | ( | ) |
Definition at line 1225 of file StackProver.cpp.
void StackProver::show_statistics | ( | ) | const |
Definition at line 1245 of file StackProver.cpp.
|
inline |
Definition at line 526 of file StackProver.hpp.
|
inline |
Show a Prolog-formatted proof.
Definition at line 501 of file StackProver.hpp.
|
inline |
Find out from the parser whether the problem had axioms after simplification.
Definition at line 495 of file StackProver.hpp.
|
friend |
Definition at line 1257 of file StackProver.cpp.
|
private |
Stores the next action from the current StackItem.
Definition at line 146 of file StackProver.hpp.
|
private |
Are we moving up or down the stack?
Definition at line 187 of file StackProver.hpp.
|
private |
Keep track of whether there were any FOF formulas in the problem file.
Definition at line 323 of file StackProver.hpp.
|
private |
Keep track of whether the parser found the conjecture to be false.
Definition at line 331 of file StackProver.hpp.
|
private |
Keep track of whether the parser found a conjecture in the problem file.
Definition at line 335 of file StackProver.hpp.
|
private |
Keep track of whether the parser found the conjecture to be true.
Definition at line 327 of file StackProver.hpp.
|
private |
Self-explanatary.
Definition at line 164 of file StackProver.hpp.
|
private |
Self-explanatary.
Definition at line 160 of file StackProver.hpp.
|
private |
Self-explanatary.
Definition at line 168 of file StackProver.hpp.
|
private |
When do we stop because of a timeout?
Definition at line 236 of file StackProver.hpp.
|
private |
We'll be keeping some simple statistics about the search process.
Definition at line 213 of file StackProver.hpp.
|
private |
Keep track of whether the parser found that it's an FOF problem with axioms before simplification.
Definition at line 344 of file StackProver.hpp.
|
private |
This class needs one of each kind of index to keep track of Variables, Terms etc.
Definition at line 90 of file StackProver.hpp.
|
private |
At any point in the search process this is a copy of the list of lemmata for the current node in the proof being constructed.
Definition at line 138 of file StackProver.hpp.
|
private |
We'll be keeping some simple statistics about the search process.
Definition at line 218 of file StackProver.hpp.
|
private |
A copy of the matrix you're working with.
Definition at line 120 of file StackProver.hpp.
|
private |
Keep track of whether the parser simplified the conjecture away.
Definition at line 339 of file StackProver.hpp.
|
private |
At any point in the search process this is a copy of the clause for the current node in the proof being constructed.
Definition at line 132 of file StackProver.hpp.
|
private |
How many prdicates does the problem of interest have?
Definition at line 80 of file StackProver.hpp.
|
private |
How often do you output updates about progress?
Definition at line 200 of file StackProver.hpp.
|
private |
At any point in the search process this is a copy of the path for the current node in the proof being constructed.
Definition at line 126 of file StackProver.hpp.
|
private |
This class needs one of each kind of index to keep track of Variables, Terms etc.
Definition at line 100 of file StackProver.hpp.
|
private |
Path for the problem of interest.
Definition at line 196 of file StackProver.hpp.
|
private |
If we're searching for multiple proofs, keep count
of which one this is.
Definition at line 228 of file StackProver.hpp.
|
private |
You need one of these to print LaTeX output or any kind of proof certificate.
Definition at line 192 of file StackProver.hpp.
|
private |
We'll be keeping some simple statistics about the search process.
Note that at present these statistics include everything tried over all steps in a schedule.
Definition at line 208 of file StackProver.hpp.
|
private |
This is populated by the StackProver::set_up_start_clauses method.
That method looks at the settings for start clauses and tries to achieve them all in a sensible way. Initially this indicates which clauses to use to start, but then stores the results obtained after trying each possibility.
Definition at line 116 of file StackProver.hpp.
|
private |
We build the proof by trying the left branches of extensions first: this stack keeps track of the right branches that we need to come back to.
Definition at line 183 of file StackProver.hpp.
|
private |
We'll be keeping some simple statistics about the search process.
Definition at line 223 of file StackProver.hpp.
|
private |
Set up printing according to verbosity.
Definition at line 240 of file StackProver.hpp.
|
private |
Pointer to the current StackItem.
Be very careful with this. At present its use is fine because I don't think that the stack gets modified while the pointer is in use. BUT it may be a good future modification to make this an index rather than a pointer in case we run into trouble with the vector class moving things in memory.
Definition at line 156 of file StackProver.hpp.
|
private |
Keep track of whether the parser found that it's an FOF problem with axioms after simplification.
Definition at line 349 of file StackProver.hpp.
|
private |
Main stack: this is constructed by the search process and, if completed, represents a proof.
Definition at line 177 of file StackProver.hpp.
|
private |
Problem status, if found in input file.
Definition at line 172 of file StackProver.hpp.
|
private |
There is a separate stack to make application and removal of substitutions straightforward.
Definition at line 105 of file StackProver.hpp.
|
private |
This class needs one of each kind of index to keep track of Variables, Terms etc.
Definition at line 95 of file StackProver.hpp.
|
private |
We need a single Unifier to use throught the process.
Definition at line 142 of file StackProver.hpp.
|
private |
Are we using a timeout?
Definition at line 232 of file StackProver.hpp.
|
private |
This class needs one of each kind of index to keep track of Variables, Terms etc.
Definition at line 85 of file StackProver.hpp.