Skip to content

Commit

Permalink
Rewriting: Do not collect rewritten arithmetic inequalities
Browse files Browse the repository at this point in the history
The information about which inequalities originated from arithmetic
equalities were recorded during preprocessing. However, this makes it
difficult to separate preprocessing passes and make them more
independent, i.e., so we can run them on single formula as well as on
group of formulas.
If this information is needed, it should be obtain in a different way.
At the moment, this information is only used by the lookahead solver for
partitioning, where the strategy is to not split on such inequalities.
However, I do not see benefit in such strategy.
Since the need to record this information is blocking further
refactoring that has the potential to unlock performance improvements in
incremental solving, I propose to just not record this information
anymore.
  • Loading branch information
blishko committed Feb 24, 2024
1 parent 6a875a6 commit b95e90d
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 17 deletions.
3 changes: 0 additions & 3 deletions src/logics/LATheory.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class LATheory : public Theory
protected:
LinAlgLogic& lalogic;
LinAlgTHandler latshandler;
std::unique_ptr<Map<PTRef,bool,PTRefHash>> notOkToPartition;
public:
LATheory(SMTConfig & c, LinAlgLogic & logic)
: Theory(c)
Expand All @@ -26,7 +25,6 @@ class LATheory : public Theory
virtual const LinAlgLogic& getLogic() const override { return lalogic; }
virtual LinAlgTHandler& getTSolverHandler() override { return latshandler; }
virtual bool simplify(const vec<PFRef>&, PartitionManager& pmanager, int) override; // Theory specific simplifications
virtual bool okToPartition(PTRef tr) const override { return !notOkToPartition->has(tr); }
};

namespace {
Expand Down Expand Up @@ -69,7 +67,6 @@ bool LATheory<LinAlgLogic,LinAlgTSHandler>::simplify(const vec<PFRef>& formulas,
finalFla = rewriteDivMod<LinAlgLogic>(lalogic, finalFla);
currentFrame.root = equalityRewriter.rewrite(finalFla);
}
notOkToPartition = equalityRewriter.getAndClearNotOkToPartition();
return true;
}

Expand Down
1 change: 0 additions & 1 deletion src/logics/Theory.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ class Theory
virtual bool simplify(const vec<PFRef>&, PartitionManager& pmanager, int) = 0; // Simplify a vector of PushFrames in an incrementality-aware manner
SubstitutionResult computeSubstitutions(PTRef fla);
void printFramesAsQuery(const vec<PFRef> & frames, std::ostream & s) const;
virtual bool okToPartition(PTRef) const { return true; }
virtual ~Theory() = default;
};

Expand Down
14 changes: 2 additions & 12 deletions src/rewriters/ArithmeticEqualityRewriter.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2023, Martin Blicha <[email protected]>
* Copyright (c) 2021-2024, Martin Blicha <[email protected]>
*
* SPDX-License-Identifier: MIT
*
Expand All @@ -12,14 +12,9 @@

class EqualityRewriterConfig : public DefaultRewriterConfig {
ArithLogic & logic;
std::unique_ptr<Map<PTRef, bool, PTRefHash>> notOkToPartition;

public:
EqualityRewriterConfig(ArithLogic & logic) : logic(logic), notOkToPartition(new Map<PTRef, bool, PTRefHash>()) {}

std::unique_ptr<Map<PTRef, bool, PTRefHash>> getAndClearNotOkToPartition() {
return std::exchange(notOkToPartition, std::make_unique<Map<PTRef, bool, PTRefHash>>());
}
explicit EqualityRewriterConfig(ArithLogic & logic) : logic(logic) {}

bool previsit(PTRef term) override { return logic.hasSortBool(term) and not logic.isIte(term); }

Expand All @@ -30,8 +25,6 @@ class EqualityRewriterConfig : public DefaultRewriterConfig {
PTRef a2 = p[1];
PTRef i1 = logic.mkLeq(a1, a2);
PTRef i2 = logic.mkGeq(a1, a2);
notOkToPartition->insert(i1, true);
notOkToPartition->insert(i2, true);
term = logic.mkAnd(i1, i2);
}
return term;
Expand All @@ -44,9 +37,6 @@ class ArithmeticEqualityRewriter : public Rewriter<EqualityRewriterConfig> {
public:
explicit ArithmeticEqualityRewriter(ArithLogic & logic)
: Rewriter<EqualityRewriterConfig>(logic, config), config(logic) {}
std::unique_ptr<Map<PTRef, bool, PTRefHash>> getAndClearNotOkToPartition() {
return config.getAndClearNotOkToPartition();
}
};

#endif // OPENSMT_ARITHMETICEQUALITYREWRITER_H
2 changes: 1 addition & 1 deletion src/smtsolvers/LookaheadSMTSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class LookaheadSMTSolver : public SimpSMTSolver {
laresult expandTree(LANode & n, std::unique_ptr<LANode> c1,
std::unique_ptr<LANode> c2); // Do lookahead. On success write the new children to c1 and c2
std::unique_ptr<LookaheadScore> score;
bool okToPartition(Var v) const { return theory_handler.getTheory().okToPartition(theory_handler.varToTerm(v)); };
bool okToPartition(Var) const { return true; }

public:
LookaheadSMTSolver(SMTConfig &, THandler &);
Expand Down

0 comments on commit b95e90d

Please sign in to comment.