Skip to content

Commit 741459e

Browse files
committed
Moved preprocessing of ITE terms into the preprocessing pipeline
1 parent d96b2ba commit 741459e

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/api/MainSolver.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ void MainSolver::insertFormula(PTRef fla) {
107107
if (logic.getSortRef(fla) != logic.getSort_bool()) {
108108
throw ApiException("Top-level assertion sort must be Bool, got " + logic.printSort(logic.getSortRef(fla)));
109109
}
110-
// TODO: Move this to preprocessing of the formulas
111-
fla = IteHandler(logic, getPartitionManager().getNofPartitions()).rewrite(fla);
112110

113111
if (trackPartitions()) {
114112
// MB: Important for HiFrog! partition index is the index of the formula in an virtual array of inserted
@@ -147,7 +145,10 @@ sstat MainSolver::simplifyFormulas() {
147145
if (context.perPartition) {
148146
vec<PTRef> frameFormulas;
149147
for (PTRef fla : frames[i].formulas) {
150-
PTRef processed = theory->preprocessAfterSubstitutions(fla, context);
148+
auto const partitionIndex = pmanager.getPartitionIndex(fla);
149+
simplifiedFormulasCount++;
150+
PTRef processed = IteHandler(logic, partitionIndex).rewrite(fla);
151+
processed = theory->preprocessAfterSubstitutions(processed, context);
151152
pmanager.transferPartitionMembership(fla, processed);
152153
frameFormulas.push(processed);
153154
preprocessor.addPreprocessedFormula(processed);
@@ -172,7 +173,13 @@ sstat MainSolver::simplifyFormulas() {
172173
if (status == s_False) { break; }
173174
}
174175
} else {
175-
PTRef frameFormula = logic.mkAnd(frames[i].formulas);
176+
vec<PTRef> frameFormulas;
177+
for (PTRef fla : frames[i].formulas) {
178+
fla = IteHandler(logic, simplifiedFormulasCount++).rewrite(fla);
179+
frameFormulas.push(fla);
180+
}
181+
182+
PTRef frameFormula = logic.mkAnd(std::move(frameFormulas));
176183
if (context.frameCount > 0) { frameFormula = applyLearntSubstitutions(frameFormula); }
177184
frameFormula = theory->preprocessBeforeSubstitutions(frameFormula, context);
178185
frameFormula = substitutionPass(frameFormula, context);
@@ -481,6 +488,7 @@ PTRef MainSolver::applyLearntSubstitutions(PTRef fla) {
481488
}
482489

483490
PTRef MainSolver::substitutionPass(PTRef fla, PreprocessingContext const & context) {
491+
assert(not trackPartitions());
484492
if (not config.do_substitutions()) { return fla; }
485493
auto res = computeSubstitutions(fla);
486494
vec<PTRef> args;

src/api/MainSolver.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ class MainSolver {
262262
Theory & getTheory() { return *theory; }
263263
Theory const & getTheory() const { return *theory; }
264264
TermMapper & getTermMapper() const { return *term_mapper; }
265-
PartitionManager & getPartitionManager() { return pmanager; }
266265

267266
// TODO: inefficient
268267
vec<PTRef> getCurrentAssertionsViewImpl() const { return getCurrentAssertions(); }
@@ -323,11 +322,16 @@ class MainSolver {
323322

324323
vec<PTRef> frameTerms;
325324
std::size_t firstNotSimplifiedFrame = 0;
326-
unsigned int insertedFormulasCount = 0;
325+
std::size_t simplifiedFormulasCount = 0;
326+
std::size_t insertedFormulasCount = 0;
327327
};
328328

329329
bool MainSolver::trackPartitions() const {
330330
assert(smt_solver);
331+
332+
// Even if computed independently of resolution proofs, we must track partitions
333+
if (config.produce_unsat_cores() or config.produce_inter()) { return true; }
334+
331335
return smt_solver->logsResolutionProof();
332336
}
333337
} // namespace opensmt

0 commit comments

Comments
 (0)