Skip to content

Commit 5c66a6a

Browse files
committed
code style improvements
1 parent a289ed4 commit 5c66a6a

File tree

7 files changed

+53
-73
lines changed

7 files changed

+53
-73
lines changed

logic/DlCore.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
using namespace std;
1818
using namespace xamidi::helper;
19-
using namespace xamidi::tree;
2019
using namespace xamidi::grammar;
2120
using namespace xamidi::metamath;
2221

@@ -523,7 +522,7 @@ void DlCore::_toBasicDlFormula(const shared_ptr<DlFormula>& destinationNode, con
523522
}
524523
}
525524
} else { // not at an operator, i.e. at a variable
526-
*destinationNode = *formula; // copy original variable (includes meaning) // NOTE: Meanings of variables are copied regardless of 'calculateMeanings'.
525+
*destinationNode = *formula; // copy original variable (includes meaning) ; NOTE: Meanings of variables are copied regardless of 'calculateMeanings'.
527526
if (optOut_originals)
528527
optOut_originals->insert(make_pair(destinationNode, formula));
529528
}

logic/DlFormula.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "DlCore.h"
55

66
using namespace std;
7-
using namespace xamidi::helper;
87

98
namespace xamidi {
109
namespace logic {

logic/DlProofEnumerator.cpp

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,12 @@ bool DlProofEnumerator::resetRepresentativesFor(const vector<string>* customAxio
132132
for (size_t i = 0; i < customAxiomFormulas.size(); i++)
133133
representativeProofs.emplace(customAxiomFormulas[i], customAxiomNames[i]);
134134
_removeRedundantConclusionsForProofsOfMaxLength(1, representativeProofs, nullptr, representativeCounter, redundantCounter);
135-
if (redundantCounter)
136-
if (errOut)
137-
*errOut << "Warning: Detected " << redundantCounter << (redundantCounter == 1 ? " axiom which is a specification of another axiom." : " axioms which are specifications of other axioms.") << endl;
135+
if (redundantCounter && errOut)
136+
*errOut << "Warning: Detected " << redundantCounter << (redundantCounter == 1 ? " axiom which is a specification of another axiom." : " axioms which are specifications of other axioms.") << endl;
138137
if (representativeProofs.size() < customAxiomFormulas.size()) { // some axioms are redundant
139138
uint64_t numDuplicates = customAxiomFormulas.size() - representativeProofs.size() - redundantCounter;
140-
if (numDuplicates)
141-
if (errOut)
142-
*errOut << "Warning: There " << (numDuplicates == 1 ? "is " : "are ") << numDuplicates << " axiom" << (numDuplicates == 1 ? " which is a duplicate." : "s which are duplicates.") << endl;
139+
if (numDuplicates && errOut)
140+
*errOut << "Warning: There " << (numDuplicates == 1 ? "is " : "are ") << numDuplicates << " axiom" << (numDuplicates == 1 ? " which is a duplicate." : "s which are duplicates.") << endl;
143141
vector<pair<string, string>> redundancies;
144142
for (size_t i = 0; i < customAxiomFormulas.size(); i++) {
145143
tbb::concurrent_hash_map<string, string>::const_accessor rAcc;
@@ -579,7 +577,7 @@ bool DlProofEnumerator::readRepresentativesLookupVectorFromFiles_par(vector<vect
579577
else {
580578
bool startedNext = false;
581579
while (!startedNext && !abortAll) {
582-
for (unsigned t = 0; t < concurrencyCount; t++) {
580+
for (unsigned t = 0; t < concurrencyCount; t++)
583581
if (threadComplete[t]) {
584582
threadComplete[t] = 0;
585583
threads[t].join();
@@ -595,7 +593,6 @@ bool DlProofEnumerator::readRepresentativesLookupVectorFromFiles_par(vector<vect
595593
startedNext = true;
596594
break;
597595
}
598-
}
599596
this_thread::yield(); // avoid deadlock ; put current thread at the back of the queue of threads that are ready to execute => allow other threads to run before this thread is scheduled again
600597
}
601598
}
@@ -761,7 +758,7 @@ void DlProofEnumerator::sampleCombinations() {
761758
cerr << "Some tests failed." << endl;
762759
}
763760

764-
void DlProofEnumerator::printProofs(const vector<string>& dProofs, DlFormulaStyle outputNotation, bool conclusionsOnly, bool summaryMode, unsigned minUseAmountToCreateHelperProof, bool abstractProofStrings, const string* inputFile, const string* outputFile, bool debug, string* optOut_result, unordered_map<size_t, size_t>* optOut_indexOrigins) {
761+
void DlProofEnumerator::printProofs(const vector<string>& dProofs, DlFormulaStyle outputNotation, bool conclusionsOnly, bool summaryMode, unsigned minUseAmountToCreateHelperProof, bool abstractProofStrings, const string* inputFile, const string* outputFile, bool debug, string* optOut_result, unordered_map<size_t, size_t>* optOut_indexOrigins, bool silent) {
765762
chrono::time_point<chrono::steady_clock> startTime;
766763
vector<string> dProofsFromFile;
767764
if (inputFile) {
@@ -819,7 +816,7 @@ void DlProofEnumerator::printProofs(const vector<string>& dProofs, DlFormulaStyl
819816
}
820817
if (debug)
821818
cout << "Resulted in " << rawParseData.size() << " proof" << (rawParseData.size() == 1 ? "" : "s") << " after " << FctHelper::durationStringMs(chrono::duration_cast<chrono::microseconds>(chrono::steady_clock::now() - startTime)) << "." << endl;
822-
if (!duplicates.empty())
819+
if (!silent && !duplicates.empty())
823820
cout << "The input contains duplicates at indices " << FctHelper::mapString(duplicates) << "." << endl;
824821
auto polish = [](const shared_ptr<DlFormula>& f) { return DlCore::toPolishNotation_noRename(f); };
825822
auto polishStd = [](const shared_ptr<DlFormula>& f) { const map<string, string> customVariableTranslation = { { "0", "p" }, { "1", "q" }, { "2", "r" }, { "3", "s" }, { "4", "t" }, { "5", "u" }, { "6", "v" }, { "7", "w" }, { "8", "x" }, { "9", "y" }, { "10", "z" }, { "11", "a" }, { "12", "b" }, { "13", "c" }, { "14", "d" }, { "15", "e" }, { "16", "f" }, { "17", "g" }, { "18", "h" }, { "19", "i" }, { "20", "j" }, { "21", "k" }, { "22", "l" }, { "23", "m" }, { "24", "n" }, { "25", "o" } }; return DlCore::toPolishNotation(f, false, nullptr, &customVariableTranslation, { }); };
@@ -882,7 +879,7 @@ void DlProofEnumerator::printProofs(const vector<string>& dProofs, DlFormulaStyl
882879
cout << FctHelper::durationStringMs(chrono::duration_cast<chrono::microseconds>(chrono::steady_clock::now() - startTime)) << " taken to save " << ss.str().length() << " bytes to \"" << *outputFile << "\"." << endl;
883880
} else if (!optOut_result)
884881
cout << ss.str() << flush;
885-
if (!conclusionsOnly && (_dProofs.size() != rawParseData.size() || !duplicates.empty() || any_of(indexOrigins.begin(), indexOrigins.end(), [](const pair<const size_t, size_t>& p) { return p.first != p.second; })))
882+
if (!silent && !conclusionsOnly && (_dProofs.size() != rawParseData.size() || !duplicates.empty() || any_of(indexOrigins.begin(), indexOrigins.end(), [](const pair<const size_t, size_t>& p) { return p.first != p.second; })))
886883
cout << "Index correspondences (out,in) are " << FctHelper::mapString(map<size_t, size_t>(indexOrigins.begin(), indexOrigins.end())) << "." << endl;
887884
}
888885

@@ -1113,7 +1110,7 @@ void DlProofEnumerator::unfoldProofSummary(const string& input, bool useInputFil
11131110
bytes += len;
11141111
}
11151112
}
1116-
else {
1113+
else
11171114
for (size_t i = 0; i < dProofs.size(); i++) {
11181115
if (i) {
11191116
mout << ",\n";
@@ -1123,7 +1120,6 @@ void DlProofEnumerator::unfoldProofSummary(const string& input, bool useInputFil
11231120
mout << dProof;
11241121
bytes += dProof.length();
11251122
}
1126-
}
11271123
mout << "\n";
11281124
bytes++;
11291125
return bytes;
@@ -2052,7 +2048,7 @@ void DlProofEnumerator::generateDProofRepresentativeFiles(uint32_t limit, bool r
20522048
cout << "\n[REMOVAL COUNT ESTIMATION] counts = " << FctHelper::mapString(counts) << endl;
20532049
map<uint32_t, uint64_t> myCounts;
20542050
vector<pair<const uint32_t, uint64_t>> pairs;
2055-
for (const pair<const uint32_t, uint64_t>& p : counts) {
2051+
for (const pair<const uint32_t, uint64_t>& p : counts)
20562052
if (counts.count(p.first + c)) {
20572053
myCounts.insert(p);
20582054
#if 1 //### simulate we're in a hole of the data
@@ -2090,7 +2086,6 @@ void DlProofEnumerator::generateDProofRepresentativeFiles(uint32_t limit, bool r
20902086
else
20912087
cout << endl;
20922088
}
2093-
}
20942089
};
20952090
estimationSummary(_customAxiomsPtr ? removalCounts_custom : removalCounts());
20962091
exit(0);
@@ -2226,7 +2221,7 @@ void DlProofEnumerator::generateDProofRepresentativeFiles(uint32_t limit, bool r
22262221
cout << " -> diffs:" << FctHelper::mapStringF(diffAB, [](const pair<const string::size_type, pair<size_t, size_t>>& p) { return "(" + to_string(p.first) + ": " + to_string(p.second.first) + "|" + to_string(p.second.second) + ")"; }) << endl;
22272222
cout << " -> missing from " << nameA << ":" << FctHelper::mapString(missingA) << endl;
22282223
cout << " -> missing from " << nameB << ":" << FctHelper::mapString(missingB) << endl;
2229-
if (!diffAB.empty()) {
2224+
if (!diffAB.empty())
22302225
for (map<string::size_type, pair<size_t, size_t>>::const_iterator it = diffAB.begin(); it != diffAB.end(); ++it) {
22312226
string::size_type proofLen = it->first;
22322227
vector<string>& representatives = allRepresentatives[proofLen];
@@ -2240,10 +2235,9 @@ void DlProofEnumerator::generateDProofRepresentativeFiles(uint32_t limit, bool r
22402235
}
22412236
set<string> conclusionsSet(conclusions.begin(), conclusions.end());
22422237
vector<string> conclusionsOfProofLen;
2243-
for (tbb::concurrent_hash_map<string, string>::const_iterator itR = representativeProofs.begin(); itR != representativeProofs.end(); ++itR) {
2238+
for (tbb::concurrent_hash_map<string, string>::const_iterator itR = representativeProofs.begin(); itR != representativeProofs.end(); ++itR)
22442239
if (itR->second.length() == proofLen)
22452240
conclusionsOfProofLen.push_back(itR->first);
2246-
}
22472241
cout << "[NOTE] For proof length " << proofLen << ": |representatives| = " << representatives.size() << ", |conclusions| = " << conclusions.size() << ", |conclusionsSet| = " << conclusionsSet.size() << ", |conclusionsOfProofLen| = " << conclusionsOfProofLen.size() << endl;
22482242
set<string> conclusionsOfProofLenSet(conclusionsOfProofLen.begin(), conclusionsOfProofLen.end());
22492243
for (size_t i = 0; i < conclusions.size(); i++) {
@@ -2267,7 +2261,6 @@ void DlProofEnumerator::generateDProofRepresentativeFiles(uint32_t limit, bool r
22672261
cout << "Missing from 'allRepresentatives' and 'allConclusions' at [" << proofLen << "]: " << rAcc->second << ":" << conclusion << endl;
22682262
}
22692263
}
2270-
}
22712264
};
22722265
if (diff12) {
22732266
cout << "amountPerLength: 'representativeProofs' != 'allRepresentatives'" << endl;
@@ -2921,15 +2914,14 @@ map<string, string> DlProofEnumerator::searchProofFiles(const vector<string>& se
29212914
// 4. List missing entries.
29222915
bool first = true;
29232916
stringstream ss;
2924-
for (size_t i = 0; i < _searchTerms.size(); i++) {
2917+
for (size_t i = 0; i < _searchTerms.size(); i++)
29252918
if (!found[i]) {
29262919
if (first)
29272920
first = false;
29282921
else
29292922
ss << ", ";
29302923
ss << "[" << i << "] : \"" << terms[i] << "\"" << (modified[i] ? " (originally \"" + _searchTerms[i] + "\")" : "");
29312924
}
2932-
}
29332925
if (!first)
29342926
cout << "Missing " << ss.str() << "." << endl;
29352927
break;
@@ -3087,15 +3079,14 @@ map<string, string> DlProofEnumerator::searchProofFiles(const vector<string>& se
30873079
// 5. List missing entries.
30883080
bool first = true;
30893081
stringstream ss;
3090-
for (size_t i = 0; i < _searchTerms.size(); i++) {
3082+
for (size_t i = 0; i < _searchTerms.size(); i++)
30913083
if (lowestLimitsWithResults[i] == UINT32_MAX) {
30923084
if (first)
30933085
first = false;
30943086
else
30953087
ss << ", ";
30963088
ss << "[" << i << "] : \"" << terms[i] << "\"" << (modified[i] ? " (originally \"" + _searchTerms[i] + "\")" : "");
30973089
}
3098-
}
30993090
if (!first)
31003091
cout << "Missing " << ss.str() << "." << endl;
31013092
break;
@@ -3175,15 +3166,14 @@ map<string, string> DlProofEnumerator::searchProofFiles(const vector<string>& se
31753166
// 3. List missing entries.
31763167
bool first = true;
31773168
stringstream ss;
3178-
for (size_t i = 0; i < _searchTerms.size(); i++) {
3169+
for (size_t i = 0; i < _searchTerms.size(); i++)
31793170
if (!results.count(i)) {
31803171
if (first)
31813172
first = false;
31823173
else
31833174
ss << ", ";
31843175
ss << "[" << i << "] : \"" << terms[i] << "\"" << (modified[i] ? " (originally \"" + _searchTerms[i] + "\")" : "");
31853176
}
3186-
}
31873177
if (!first)
31883178
cout << "Missing " << ss.str() << "." << endl;
31893179
break;
@@ -4256,10 +4246,10 @@ void DlProofEnumerator::_collectProvenFormulas(tbb::concurrent_hash_map<string,
42564246
const string& fB = allConclusions[lenB][iB];
42574247
shared_ptr<DlFormula> tA;
42584248
shared_ptr<DlFormula> tB;
4259-
if(!DlCore::fromPolishNotation_noRename(tA, fA))
4249+
if (!DlCore::fromPolishNotation_noRename(tA, fA))
42604250
throw domain_error("Could not parse \"" + fA + "\" as a formula in dotted Polish notation.");
42614251
distinguishVariables(tA);
4262-
if(!DlCore::fromPolishNotation_noRename(tB, fB))
4252+
if (!DlCore::fromPolishNotation_noRename(tB, fB))
42634253
throw domain_error("Could not parse \"" + fB + "\" as a formula in dotted Polish notation.");
42644254
shared_ptr<DlFormula> conclusionVariant;
42654255
string conclusion;
@@ -4906,7 +4896,7 @@ void DlProofEnumerator::_loadCondensedDetachmentProofs_useConclusions(uint32_t k
49064896
const string& fA = conclusionsA[iA];
49074897
lock_guard<mutex> lock(mtx);
49084898
if (!tA_init) { // parse fA, store in tA
4909-
if(!DlCore::fromPolishNotation_noRename(tA, fA))
4899+
if (!DlCore::fromPolishNotation_noRename(tA, fA))
49104900
throw domain_error("Could not parse \"" + fA + "\" as a formula in dotted Polish notation.");
49114901
distinguishVariables(tA, lenA, iA);
49124902
tA_init = true;
@@ -4916,7 +4906,7 @@ void DlProofEnumerator::_loadCondensedDetachmentProofs_useConclusions(uint32_t k
49164906
const string& fB = conclusionsB[iB];
49174907
lock_guard<mutex> lock(mtx);
49184908
if (!tB_init) { // parse fB, store in tB
4919-
if(!DlCore::fromPolishNotation_noRename(tB, fB))
4909+
if (!DlCore::fromPolishNotation_noRename(tB, fB))
49204910
throw domain_error("Could not parse \"" + fB + "\" as a formula in dotted Polish notation.");
49214911
distinguishVariables(tB, lenB, iB);
49224912
tB_init = true;
@@ -4926,7 +4916,7 @@ void DlProofEnumerator::_loadCondensedDetachmentProofs_useConclusions(uint32_t k
49264916
}
49274917
});
49284918
}
4929-
} else { // NOTE: Sequences are processed at 'auto process_useConclusionStrings'.
4919+
} else // NOTE: Sequences are processed at 'auto process_useConclusionStrings'.
49304920
for (const pair<array<uint32_t, 2>, unsigned>& p : combinations) {
49314921
size_t lenA = p.first[0];
49324922
size_t lenB = p.first[1];
@@ -4937,7 +4927,6 @@ void DlProofEnumerator::_loadCondensedDetachmentProofs_useConclusions(uint32_t k
49374927
registerD(lenA, lenB, iA, iB);
49384928
});
49394929
}
4940-
}
49414930

49424931
// 2. Build & register N-rules (if applicable).
49434932
if (necessitationLimit) {

logic/DlProofEnumerator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct DlProofEnumerator {
7272
static std::vector<std::pair<std::array<std::uint32_t, 2>, unsigned>> proofLengthCombinationsD_oddLengths(std::uint32_t knownLimit, bool singleStep = false);
7373
static std::vector<std::pair<std::array<std::uint32_t, 2>, unsigned>> proofLengthCombinationsD_allLengths(std::uint32_t knownLimit, bool singleStep = false);
7474
static void sampleCombinations();
75-
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);
75+
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);
7878
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);

logic/DlStructure.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
#include "../grammar/CfgGrammar.h"
44

55
using namespace std;
6-
using namespace xamidi::helper;
76
using namespace xamidi::grammar;
8-
using namespace xamidi::tree;
97

108
namespace xamidi {
119
namespace logic {

0 commit comments

Comments
 (0)