Skip to content

Commit 10406a3

Browse files
committed
Do not postpone preprocessing of ITEs when UF is combined with LA
1 parent de8825e commit 10406a3

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/api/MainSolver.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ void MainSolver::insertFormula(PTRef fla) {
114114
throw ApiException("Top-level assertion sort must be Bool, got " + logic.sortToString(logic.getSortRef(fla)));
115115
}
116116

117+
if (preprocessItesWhenAsserting()) {
118+
assert(not trackPartitions());
119+
fla = preprocessFormulaItes(fla, {.perPartition = false}, {.useCache = false});
120+
}
121+
117122
if (trackPartitions()) {
118123
// MB: Important for HiFrog! partition index is the index of the formula in an virtual array of inserted
119124
// formulas,
@@ -202,6 +207,7 @@ vec<PTRef> MainSolver::preprocessFormulasPerPartition(vec<PTRef> const & frameFo
202207
for (std::size_t i = context.preprocessedFrameAssertionsCount; i < frameFormulasCount; ++i) {
203208
PTRef fla = frameFormulas[i];
204209
PTRef processed = fla;
210+
assert(not preprocessItesWhenAsserting());
205211
// Do not use the cache, it is processed for the first time
206212
processed = preprocessFormulaItes(processed, context, {.useCache = false});
207213
processed = preprocessFormulaBeforeFinalTheoryPreprocessing(processed, context);
@@ -257,7 +263,7 @@ PTRef MainSolver::preprocessFormulaItesImpl(PTRef fla, PreprocessingContext cons
257263
PTRef MainSolver::preprocessFormula(PTRef fla, PreprocessingContext const & context,
258264
PreprocessFormulaItesConfig const & iteConfig) {
259265
PTRef processed = fla;
260-
processed = preprocessFormulaItes(processed, context, iteConfig);
266+
if (not preprocessItesWhenAsserting()) { processed = preprocessFormulaItes(processed, context, iteConfig); }
261267
processed = preprocessFormulaBeforeFinalTheoryPreprocessing(processed, context);
262268
preprocessFormulaDoFinalTheoryPreprocessing(context);
263269
processed = preprocessFormulaAfterFinalTheoryPreprocessing(processed, context);

src/api/MainSolver.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ class MainSolver {
306306
}
307307
PTRef preprocessFormulaItesImpl(PTRef, PreprocessingContext const &);
308308

309+
inline bool preprocessItesWhenAsserting() const;
310+
309311
virtual PTRef preprocessFormula(PTRef, PreprocessingContext const &, PreprocessFormulaItesConfig const &);
310312
PTRef preprocessFormula(PTRef fla, PreprocessingContext const & context) {
311313
return preprocessFormula(fla, context, {});
@@ -366,6 +368,21 @@ bool MainSolver::trackPartitions() const {
366368

367369
return false;
368370
}
371+
372+
bool MainSolver::preprocessItesWhenAsserting() const {
373+
// We still must keep tracking the terms which only happens in the pipeline
374+
if (trackPartitions()) { return false; }
375+
376+
// If combining UF, it may be beneficial to introduce the auxiliary ITE variables right away, especially when sat
377+
if (logic.hasUFs()) {
378+
// In UFLIA, it significantly improves
379+
if (logic.hasIntegers()) { return true; }
380+
// In UFLRA, it slightly improves, so it is still worth
381+
if (logic.hasReals()) { return true; }
382+
}
383+
384+
return false;
385+
}
369386
} // namespace opensmt
370387

371388
#endif // MAINSOLVER_H

0 commit comments

Comments
 (0)