Skip to content

Commit 097551e

Browse files
committed
increase efficiency of '--transform -x,-z' + "baby steps" option ('-#')
- as suggested in #2 (comment) (discussions) - standard proof compression rounds essentially use '-x 3' until no more changes, instead of slower nested loop approach - can still use N-loop (i.e. looking for N-rules as replacements), but nested D-loop was too inefficient - no more '--transform -y' (single-threaded D-rule replacement search) - baby steps ('--transform -#') progress slower, but may synthesize more theorems + fix bug where calling removeDuplicateConclusionsFromAbstractDProof() or compressAbstractDProof() with !filterForTheorems could cause the target theorem to deviate from the final conclusion of the input
1 parent 65e0791 commit 097551e

File tree

9 files changed

+264
-279
lines changed

9 files changed

+264
-279
lines changed

README.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ <h4 id="usage">Usage</h4>
480480
-f: proofs are given by input file path (where a comma-separated string is stored), ignoring all CR, LF, whitespace, and lines starting with '%'
481481
-o: redirect the result's output to the specified file
482482
-d: print debug information
483-
--transform &lt;string&gt; [-s &lt;string&gt;] [-j &lt;limit or -1&gt;] [-p &lt;limit or -1&gt;] [-n] [-u] [-t &lt;string&gt;] [-e] [-i &lt;limit or -1&gt;] [-l &lt;limit or -1&gt;] [-b] [-w] [-z] [-x &lt;limit&gt;] [-y] [-k] [-v &lt;file&gt;] [-h] [-q] [-f] [-o &lt;output file&gt;] [-d]
483+
--transform &lt;string&gt; [-s &lt;string&gt;] [-j &lt;limit or -1&gt;] [-p &lt;limit or -1&gt;] [-n] [-u] [-t &lt;string&gt;] [-e] [-i &lt;limit or -1&gt;] [-l &lt;limit or -1&gt;] [-b] [-w] [-z] [-x &lt;limit&gt;] [-#] [-k] [-v &lt;file&gt;] [-h] [-q] [-f] [-o &lt;output file&gt;] [-d]
484484
Transform proof summary (as by '--parse [...] -s') into recombined variant ; ignores configured system (proof summaries provide their own axioms) ; "," represents LF
485485
-s: list a subproof with its conclusion if it occurs in the given comma-separated list of conclusions
486486
-j: join common subproofs together when they are used at least a given amount of times ; default: 2
@@ -494,12 +494,12 @@ <h4 id="usage">Usage</h4>
494494
-b: duplicate conclusion removal ; replace each given subproof that has a redundant conclusion with its first shortest alternative and remove duplicates ; beneficial in preparing '-x' or '-z'
495495
-w: read input without conclusions given
496496
-z: proof compression ; find and remove internal redundancies (e.g. non-trivial parts not affecting intermediate theorems) by attempting to use shorter owned subproofs at all positions
497-
-x: proof compression with extended modification range; before each round generate relative abstract proofs (D-rules only) with up to &lt;range&gt; steps, potentially improving rules with new formulas ; default: 0
498-
-y: disable multi-threaded D-rule replacement search in case proof compression is performed (enables deterministic procedure) ; not affecting exhaustive generations via '-x', which remain nondeterministic
499-
-k: store maximum-size proofs generated via 'x' also when they do not prove known intermediate theorems, so they can still be used as replacements for subproofs ; increases memory consumption significantly
500-
-v: coordinate iteration phases for maximum-size proofs generated via 'x' with the specified vault file (to avoid repeating these computations over multiple runs) ; used only when '-k' unspecified
501-
-h: save raw intermediate results in files before each proof compression round (and after productive rounds) ; after each preparation phase (exhaustive generation) in case '-x' is specified
502-
-q: skip first round preparation for '-x' ; useful to continue working on intermediate results produced by an aborted computation using '-h'
497+
-x: proof compression with extended modification range; for '-x 5' or higher: prepare each round with relative abstract proofs (D-rules only) of up to &lt;range&gt; steps, potentially improving rules with new formulas ; default: 0
498+
-#: use smaller, less efficient proof compression steps ; increases the number of potential rounds and newly introduced intermediate conclusions, potentially leading to shorter proofs eventually
499+
-k: store maximum-size proofs prepared via '-x' also when they do not prove known intermediate theorems, so they can still be used as replacements for subproofs ; increases memory consumption significantly
500+
-v: coordinate preparation phases for maximum-size proofs generated via '-x' with the specified vault file (to avoid repeating these computations over multiple runs) ; used only when '-k' unspecified
501+
-h: save raw intermediate results in files at the beginning of each proof compression round (and at the end of productive rounds) ; after each preparation phase in case '-x' is specified
502+
-q: skip first round preparation for '-x' ; useful to eliminate inefficiencies before extensive preparations, or to continue working on intermediate results produced by an aborted computation using '-h'
503503
-f: proof summary is given by input file path ; ignores lines that are empty or starting with '%'
504504
-o: redirect the result's output to the specified file
505505
-d: print debug information

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Some more – and very special – proof systems are illustrated [further down b
118118
-f: proofs are given by input file path (where a comma-separated string is stored), ignoring all CR, LF, whitespace, and lines starting with '%'
119119
-o: redirect the result's output to the specified file
120120
-d: print debug information
121-
--transform <string> [-s <string>] [-j <limit or -1>] [-p <limit or -1>] [-n] [-u] [-t <string>] [-e] [-i <limit or -1>] [-l <limit or -1>] [-b] [-w] [-z] [-x <limit>] [-y] [-k] [-v <file>] [-h] [-q] [-f] [-o <output file>] [-d]
121+
--transform <string> [-s <string>] [-j <limit or -1>] [-p <limit or -1>] [-n] [-u] [-t <string>] [-e] [-i <limit or -1>] [-l <limit or -1>] [-b] [-w] [-z] [-x <limit>] [-#] [-k] [-v <file>] [-h] [-q] [-f] [-o <output file>] [-d]
122122
Transform proof summary (as by '--parse [...] -s') into recombined variant ; ignores configured system (proof summaries provide their own axioms) ; "," represents LF
123123
-s: list a subproof with its conclusion if it occurs in the given comma-separated list of conclusions
124124
-j: join common subproofs together when they are used at least a given amount of times ; default: 2
@@ -132,12 +132,12 @@ Some more – and very special – proof systems are illustrated [further down b
132132
-b: duplicate conclusion removal ; replace each given subproof that has a redundant conclusion with its first shortest alternative and remove duplicates ; beneficial in preparing '-x' or '-z'
133133
-w: read input without conclusions given
134134
-z: proof compression ; find and remove internal redundancies (e.g. non-trivial parts not affecting intermediate theorems) by attempting to use shorter owned subproofs at all positions
135-
-x: proof compression with extended modification range; before each round generate relative abstract proofs (D-rules only) with up to <range> steps, potentially improving rules with new formulas ; default: 0
136-
-y: disable multi-threaded D-rule replacement search in case proof compression is performed (enables deterministic procedure) ; not affecting exhaustive generations via '-x', which remain nondeterministic
137-
-k: store maximum-size proofs generated via 'x' also when they do not prove known intermediate theorems, so they can still be used as replacements for subproofs ; increases memory consumption significantly
138-
-v: coordinate iteration phases for maximum-size proofs generated via 'x' with the specified vault file (to avoid repeating these computations over multiple runs) ; used only when '-k' unspecified
139-
-h: save raw intermediate results in files before each proof compression round (and after productive rounds) ; after each preparation phase (exhaustive generation) in case '-x' is specified
140-
-q: skip first round preparation for '-x' ; useful to continue working on intermediate results produced by an aborted computation using '-h'
135+
-x: proof compression with extended modification range; for '-x 5' or higher: prepare each round with relative abstract proofs (D-rules only) of up to <range> steps, potentially improving rules with new formulas ; default: 0
136+
-#: use smaller, less efficient proof compression steps ; increases the number of potential rounds and newly introduced intermediate conclusions, potentially leading to shorter proofs eventually
137+
-k: store maximum-size proofs prepared via '-x' also when they do not prove known intermediate theorems, so they can still be used as replacements for subproofs ; increases memory consumption significantly
138+
-v: coordinate preparation phases for maximum-size proofs generated via '-x' with the specified vault file (to avoid repeating these computations over multiple runs) ; used only when '-k' unspecified
139+
-h: save raw intermediate results in files at the beginning of each proof compression round (and at the end of productive rounds) ; after each preparation phase in case '-x' is specified
140+
-q: skip first round preparation for '-x' ; useful to eliminate inefficiencies before extensive preparations, or to continue working on intermediate results produced by an aborted computation using '-h'
141141
-f: proof summary is given by input file path ; ignores lines that are empty or starting with '%'
142142
-o: redirect the result's output to the specified file
143143
-d: print debug information

helper/FctHelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ string FctHelper::durationYearsToMs(const chrono::microseconds& dur, bool innerA
358358
empty = false;
359359
} else
360360
appendRequestedBlankIndent(2 + sId.length());
361-
if (milliseconds || empty) {
361+
if (durationUs || empty) {
362362
string ms = FctHelper::round(milliseconds, round);
363363
ss << spaceIfNonEmpty() << requestedIndent(round ? 4 + round : 3, ms) << ms << msId;
364364
} else

logic/DlProofEnumerator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ void DlProofEnumerator::convertProofSummaryToAbstractDProof(const string& input,
10361036
//#if (optOut_requiredIntermediateResults) cout << "requiredIntermediateResults = " << FctHelper::vectorStringF(*optOut_requiredIntermediateResults, [](const DRuleParser::AxiomInfo& ax) { return DlCore::formulaRepresentation_traverse(ax.refinedAxiom) + "[" + ax.name + "]"; }) << endl;
10371037
}
10381038

1039-
void DlProofEnumerator::recombineProofSummary(const string& input, bool useInputFile, const string* conclusionsWithHelperProofs, unsigned minUseAmountToCreateHelperProof, size_t maxLengthToKeepProof, bool normalPolishNotation, bool printInfixUnicode, const string* filterForTheorems, bool abstractProofStrings, size_t storeIntermediateUnfoldingLimit, size_t maxLengthToComputeDProof, bool removeDuplicateConclusions, bool compress, bool noInputConclusions, const string* outputFile, bool debug, bool compress_concurrentDRuleSearch, size_t compress_modificationRange, bool compress_keepMaxRules, const string* compress_vaultFile, bool compress_sureSaves, bool compress_skipFirstPrep) {
1039+
void DlProofEnumerator::recombineProofSummary(const string& input, bool useInputFile, const string* conclusionsWithHelperProofs, unsigned minUseAmountToCreateHelperProof, size_t maxLengthToKeepProof, bool normalPolishNotation, bool printInfixUnicode, const string* filterForTheorems, bool abstractProofStrings, size_t storeIntermediateUnfoldingLimit, size_t maxLengthToComputeDProof, bool removeDuplicateConclusions, bool compress, bool noInputConclusions, const string* outputFile, bool debug, size_t compress_modificationRange, bool compress_keepMaxRules, const string* compress_vaultFile, bool compress_sureSaves, bool compress_skipFirstPrep, bool compress_babySteps) {
10401040
vector<DRuleParser::AxiomInfo> customAxioms;
10411041
vector<string> abstractDProof_input;
10421042
vector<DRuleParser::AxiomInfo> requiredIntermediateResults;
@@ -1074,7 +1074,7 @@ void DlProofEnumerator::recombineProofSummary(const string& input, bool useInput
10741074
if (conclusionsWithHelperProofs)
10751075
toAxiomInfoVector(*conclusionsWithHelperProofs, conclusionsWithHelperProofs_axInfo);
10761076
vector<shared_ptr<DlFormula>> conclusions;
1077-
const vector<string> abstractDProof = DRuleParser::recombineAbstractDProof(abstractDProof_input, conclusions, &customAxioms, targetEverything, filterForTheorems && !targetEverything ? *filterForTheorems != "." || noInputConclusions ? &filterForTheorems_axInfo : &requiredIntermediateResults : nullptr, conclusionsWithHelperProofs ? &conclusionsWithHelperProofs_axInfo : nullptr, minUseAmountToCreateHelperProof, noInputConclusions ? nullptr : &requiredIntermediateResults, debug, maxLengthToKeepProof, abstractProofStrings, storeIntermediateUnfoldingLimit, maxLengthToComputeDProof, removeDuplicateConclusions, compress, compress_concurrentDRuleSearch, compress_modificationRange, compress_keepMaxRules, compress_vaultFile, compress_sureSaves, compress_skipFirstPrep);
1077+
const vector<string> abstractDProof = DRuleParser::recombineAbstractDProof(abstractDProof_input, conclusions, &customAxioms, targetEverything, filterForTheorems && !targetEverything ? *filterForTheorems != "." || noInputConclusions ? &filterForTheorems_axInfo : &requiredIntermediateResults : nullptr, conclusionsWithHelperProofs ? &conclusionsWithHelperProofs_axInfo : nullptr, minUseAmountToCreateHelperProof, noInputConclusions ? nullptr : &requiredIntermediateResults, debug, maxLengthToKeepProof, abstractProofStrings, storeIntermediateUnfoldingLimit, maxLengthToComputeDProof, removeDuplicateConclusions, compress, compress_modificationRange, compress_keepMaxRules, compress_vaultFile, compress_sureSaves, compress_skipFirstPrep, compress_babySteps);
10781078

10791079
chrono::time_point<chrono::steady_clock> startTime;
10801080
if (debug)

logic/DlProofEnumerator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ struct DlProofEnumerator {
7575
static void printProofs(const std::vector<std::string>& dProofs, DlFormulaStyle outputNotation = DlFormulaStyle::PolishNumeric, bool conclusionsOnly = false, bool summaryMode = false, unsigned minUseAmountToCreateHelperProof = 2, bool abstractProofStrings = false, const std::string* inputFile = nullptr, const std::string* outputFile = nullptr, bool debug = false, std::string* optOut_result = nullptr, std::unordered_map<std::size_t, std::size_t>* optOut_indexOrigins = nullptr, bool silent = false);
7676
static std::string::size_type printProofSummary(std::ostream& mout, const std::vector<metamath::DRuleParser::AxiomInfo>& axioms, const std::vector<std::string>& abstractDProof, const std::vector<std::shared_ptr<DlFormula>>& conclusions, bool normalPolishNotation = false, bool printInfixUnicode = false);
7777
static void convertProofSummaryToAbstractDProof(const std::string& input, std::vector<metamath::DRuleParser::AxiomInfo>* optOut_customAxioms = nullptr, std::vector<std::string>* optOut_abstractDProof = nullptr, std::vector<metamath::DRuleParser::AxiomInfo>* optOut_requiredIntermediateResults = nullptr, bool useInputFile = false, bool normalPolishNotation = false, bool noInputConclusions = false, bool debug = true);
78-
static void recombineProofSummary(const std::string& input, bool useInputFile, const std::string* conclusionsWithHelperProofs = nullptr, unsigned minUseAmountToCreateHelperProof = 2, std::size_t maxLengthToKeepProof = SIZE_MAX, bool normalPolishNotation = false, bool printInfixUnicode = false, const std::string* filterForTheorems = nullptr, bool abstractProofStrings = true, std::size_t storeIntermediateUnfoldingLimit = SIZE_MAX, std::size_t maxLengthToComputeDProof = 134217728, bool removeDuplicateConclusions = false, bool compress = false, bool noInputConclusions = false, const std::string* outputFile = nullptr, bool debug = false, bool compress_concurrentDRuleSearch = true, std::size_t compress_modificationRange = 0, bool compress_keepMaxRules = false, const std::string* compress_vaultFile = nullptr, bool compress_sureSaves = false, bool compress_skipFirstPrep = false);
78+
static void recombineProofSummary(const std::string& input, bool useInputFile, const std::string* conclusionsWithHelperProofs = nullptr, unsigned minUseAmountToCreateHelperProof = 2, std::size_t maxLengthToKeepProof = SIZE_MAX, bool normalPolishNotation = false, bool printInfixUnicode = false, const std::string* filterForTheorems = nullptr, bool abstractProofStrings = true, std::size_t storeIntermediateUnfoldingLimit = SIZE_MAX, std::size_t maxLengthToComputeDProof = 134217728, bool removeDuplicateConclusions = false, bool compress = false, bool noInputConclusions = false, const std::string* outputFile = nullptr, bool debug = false, std::size_t compress_modificationRange = 0, bool compress_keepMaxRules = false, const std::string* compress_vaultFile = nullptr, bool compress_sureSaves = false, bool compress_skipFirstPrep = false, bool compress_babySteps = false);
7979
static void unfoldProofSummary(const std::string& input, bool useInputFile, bool normalPolishNotation, const std::string* filterForTheorems = nullptr, std::size_t storeIntermediateUnfoldingLimit = SIZE_MAX, std::size_t maxLengthToComputeDProof = 134217728, bool wrap = false, bool noInputConclusions = false, const std::string* outputFile = nullptr, bool debug = false);
8080
static void uniteProofSummary(const std::string& input, bool normalPolishNotation, bool removeDuplicateConclusions = false, const std::string* outputFile = nullptr, bool debug = false);
8181

0 commit comments

Comments
 (0)