Skip to content

Commit

Permalink
--transform -z (proof compression) feature
Browse files Browse the repository at this point in the history
+ fix issue where a requested target theorem that resulted in a proper
  schema would invalidate the request when it is also a required
  intermediate result (solves issues with '--transform -t .')
  • Loading branch information
xamidi committed Jun 15, 2024
1 parent c76302a commit 5e40660
Show file tree
Hide file tree
Showing 8 changed files with 463 additions and 33 deletions.
3 changes: 2 additions & 1 deletion README.html
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ <h4 id="usage">Usage</h4>
-f: proofs are given by input file path (where a comma-separated string is stored), ignoring all CR, LF, whitespace, and lines starting with '%'
-o: redirect the result's output to the specified file
-d: print debug information
--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;] [-f] [-o &lt;output file&gt;] [-d]
--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;] [-z] [-f] [-o &lt;output file&gt;] [-d]
Transform proof summary (as by '--parse [...] -s') into recombined variant ; ignores configured system (proof summaries provide their own axioms) ; "," represents LF
-s: list a subproof with its conclusion if it occurs in the given comma-separated list of conclusions
-j: join common subproofs together when they are used at least a given amount of times ; default: 2
Expand All @@ -466,6 +466,7 @@ <h4 id="usage">Usage</h4>
-e: keep expanded proof strings ; show fully detailed condensed detachment proofs rather than allowing them to contain references
-i: decrease memory requirements but increase time consumption by not storing intermediate unfoldings that exceed a certain length ; default: -1
-l: abort computation when combined requested proof sequences exceed the given limit in bytes ; default: 134217728 (i.e. 128 MiB)
-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
-f: proof summary is given by input file path ; ignores lines that are empty or starting with '%'
-o: redirect the result's output to the specified file
-d: print debug information
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Some more – and very special – proof systems are illustrated [further down b
-f: proofs are given by input file path (where a comma-separated string is stored), ignoring all CR, LF, whitespace, and lines starting with '%'
-o: redirect the result's output to the specified file
-d: print debug information
--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>] [-f] [-o <output file>] [-d]
--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>] [-z] [-f] [-o <output file>] [-d]
Transform proof summary (as by '--parse [...] -s') into recombined variant ; ignores configured system (proof summaries provide their own axioms) ; "," represents LF
-s: list a subproof with its conclusion if it occurs in the given comma-separated list of conclusions
-j: join common subproofs together when they are used at least a given amount of times ; default: 2
Expand All @@ -91,6 +91,7 @@ Some more – and very special – proof systems are illustrated [further down b
-e: keep expanded proof strings ; show fully detailed condensed detachment proofs rather than allowing them to contain references
-i: decrease memory requirements but increase time consumption by not storing intermediate unfoldings that exceed a certain length ; default: -1
-l: abort computation when combined requested proof sequences exceed the given limit in bytes ; default: 134217728 (i.e. 128 MiB)
-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
-f: proof summary is given by input file path ; ignores lines that are empty or starting with '%'
-o: redirect the result's output to the specified file
-d: print debug information
Expand Down
1 change: 1 addition & 0 deletions __dependency_graph.dot
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ digraph {
DRuleParser -> DlFormula [color=blue]
DRuleParser -> "boost/algorithm/string" [color=blue]
DRuleParser -> "(iostream)" [color=blue]
DRuleParser -> "(numeric)" [color=blue]
DRuleParser -> "(cstddef)" [color=red]
DRuleParser -> "(map)" [color=red]
DRuleParser -> "(memory)" [color=red]
Expand Down
4 changes: 2 additions & 2 deletions logic/DlProofEnumerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ void DlProofEnumerator::convertProofSummaryToAbstractDProof(const string& input,
//#if (optOut_requiredIntermediateResults) cout << "requiredIntermediateResults = " << FctHelper::vectorStringF(*optOut_requiredIntermediateResults, [](const DRuleParser::AxiomInfo& ax) { return DlCore::formulaRepresentation_traverse(ax.refinedAxiom) + "[" + ax.name + "]"; }) << endl;
}

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, const string* outputFile, bool debug) {
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 compress, const string* outputFile, bool debug) {
vector<DRuleParser::AxiomInfo> customAxioms;
vector<string> abstractDProof_input;
vector<DRuleParser::AxiomInfo> requiredIntermediateResults;
Expand All @@ -1005,7 +1005,7 @@ void DlProofEnumerator::recombineProofSummary(const string& input, bool useInput
if (conclusionsWithHelperProofs)
toAxiomInfoVector(*conclusionsWithHelperProofs, conclusionsWithHelperProofs_axInfo);
vector<shared_ptr<DlFormula>> conclusions;
const vector<string> abstractDProof = DRuleParser::recombineAbstractDProof(abstractDProof_input, conclusions, &customAxioms, filterForTheorems ? *filterForTheorems != "." ? &filterForTheorems_axInfo : &requiredIntermediateResults : nullptr, conclusionsWithHelperProofs ? &conclusionsWithHelperProofs_axInfo : nullptr, minUseAmountToCreateHelperProof, &requiredIntermediateResults, debug, maxLengthToKeepProof, abstractProofStrings, storeIntermediateUnfoldingLimit, maxLengthToComputeDProof);
const vector<string> abstractDProof = DRuleParser::recombineAbstractDProof(abstractDProof_input, conclusions, &customAxioms, filterForTheorems ? *filterForTheorems != "." ? &filterForTheorems_axInfo : &requiredIntermediateResults : nullptr, conclusionsWithHelperProofs ? &conclusionsWithHelperProofs_axInfo : nullptr, minUseAmountToCreateHelperProof, &requiredIntermediateResults, debug, maxLengthToKeepProof, abstractProofStrings, storeIntermediateUnfoldingLimit, maxLengthToComputeDProof, compress);

auto print = [&](ostream& mout) -> string::size_type {
auto infixUnicode = [](const shared_ptr<DlFormula>& f) { string s = DlCore::formulaRepresentation_traverse(f); boost::replace_all(s, DlCore::terminalStr_and(), "∧"); boost::replace_all(s, DlCore::terminalStr_or(), "∨"); boost::replace_all(s, DlCore::terminalStr_nand(), "↑"); boost::replace_all(s, DlCore::terminalStr_nor(), "↓"); boost::replace_all(s, DlCore::terminalStr_imply(), "→"); boost::replace_all(s, DlCore::terminalStr_implied(), "←"); boost::replace_all(s, DlCore::terminalStr_nimply(), "↛"); boost::replace_all(s, DlCore::terminalStr_nimplied(), "↚"); boost::replace_all(s, DlCore::terminalStr_equiv(), "↔"); boost::replace_all(s, DlCore::terminalStr_xor(), "↮"); boost::replace_all(s, DlCore::terminalStr_com(), "↷"); boost::replace_all(s, DlCore::terminalStr_app(), "↝"); boost::replace_all(s, DlCore::terminalStr_not(), "¬"); boost::replace_all(s, DlCore::terminalStr_nece(), "□"); boost::replace_all(s, DlCore::terminalStr_poss(), "◇"); boost::replace_all(s, DlCore::terminalStr_obli(), "○"); boost::replace_all(s, DlCore::terminalStr_perm(), "⌔"); boost::replace_all(s, DlCore::terminalStr_top(), "⊤"); boost::replace_all(s, DlCore::terminalStr_bot(), "⊥"); return s; };
Expand Down
2 changes: 1 addition & 1 deletion logic/DlProofEnumerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct DlProofEnumerator {
static void sampleCombinations();
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);
static void convertProofSummaryToAbstractDProof(const std::string& input, std::vector<metamath::DRuleParser::AxiomInfo>& out_customAxioms, std::vector<std::string>& out_abstractDProof, std::vector<metamath::DRuleParser::AxiomInfo>* optOut_requiredIntermediateResults = nullptr, bool useInputFile = false, bool normalPolishNotation = false, bool debug = true);
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, const std::string* outputFile = nullptr, bool debug = false);
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 compress = false, const std::string* outputFile = nullptr, bool debug = false);
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, const std::string* outputFile = nullptr, bool debug = false);

// Data prediction
Expand Down
Loading

0 comments on commit 5e40660

Please sign in to comment.