diff options
author | Andres Noetzli <andres.noetzli@gmail.com> | 2020-06-05 05:22:18 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-05 07:22:18 -0500 |
commit | 60746dc3ac7806475b5b6dab03123df024bf613e (patch) | |
tree | f773abd7da047b72f89bae37637b999e5b70f291 /src/decision/justification_heuristic.h | |
parent | 8b5ffcd602730db5bba135b557f60ca181b8af1f (diff) |
Fix handling of Boolean term variables (#4550)
Fixes #4446. This commit fixes two issues related to the handling of
Boolean term variables:
Removing Boolean subterms and replacing them with a Boolean term
variable introduces an equality of the form (= v t) where v is the
Boolean term variable and t is the term. It is important that these
equalities do not get removed. This commit changes
Theory::isLegalElimination() to take this into account.
The incorrect model reported in the issue was caused by some of the
Boolean term variables not being assigned values by the SAT solver
when we decided that the benchmark is satisfiable. Our justification
heuristic (correctly) decided that it is enough to satisfy one of the
disjuncts in the assertion to satisfy the whole assertion. However,
the assignments that we received from the SAT solver restricted us to
pick a specific value for one of the Boolean constants:
Literal | Value | Expr
---------------------------------------------------------
'7 ' 0 c
'0 ' 1 true
'1 ' 0 false
'2 ' 0 (a BOOLEAN_TERM_VARIABLE_274)
'5 ' _ b
'3 ' 1 (a BOOLEAN_TERM_VARIABLE_277)
'4 ' _ BOOLEAN_TERM_VARIABLE_274
'6 ' 0 BOOLEAN_TERM_VARIABLE_277
This meant that we had to pick true for BOOLEAN_TERM_VARIABLE_274
but we picked false since we simply treated it as an unassigned
variable. In general, the justification heuristic handles embedded
skolems introduced by term removal first and asks the SAT solver to
decide on Boolean term variables. However, for some logics, such as
QF_AUFLIA, we use the justification heuristic not for decisions but
only to decide when to stop, so those decisions were not done. This
commit introduces a conservative fix that adds a check after
satsifying all the assertions that makes sure that the equalities
introduced for Boolean terms are satisfied as well. Due to the eager
treatment of Boolean term variables when we use the justification
heuristic also for decisions, it is likely that we don't really have
the problem in that case but it doesn't hurt to enable the fix. It is
also possible that this fix is only required with models but it is
definitely safer to just always enable it (there could be tricky
corner cases involving the theory combination between UF and Boolean
terms). Additionally, this commit changes the ITE-specific naming in
the justification heuristic to reflect more accurately that we are in
general dealing with skolems introduced by term removals and not only
due to ITE removal.
Diffstat (limited to 'src/decision/justification_heuristic.h')
-rw-r--r-- | src/decision/justification_heuristic.h | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/decision/justification_heuristic.h b/src/decision/justification_heuristic.h index bb426ad1e..9e6765438 100644 --- a/src/decision/justification_heuristic.h +++ b/src/decision/justification_heuristic.h @@ -42,8 +42,8 @@ class JustificationHeuristic : public ITEDecisionStrategy { // TRUE FALSE MEH enum SearchResult {FOUND_SPLITTER, NO_SPLITTER, DONT_KNOW}; - typedef std::vector<pair<TNode,TNode> > IteList; - typedef context::CDHashMap<TNode,IteList,TNodeHashFunction> IteCache; + typedef std::vector<pair<TNode, TNode> > SkolemList; + typedef context::CDHashMap<TNode, SkolemList, TNodeHashFunction> SkolemCache; typedef std::vector<TNode> ChildList; typedef context::CDHashMap<TNode,pair<ChildList,ChildList>,TNodeHashFunction> ChildCache; typedef context::CDHashMap<TNode,TNode,TNodeHashFunction> SkolemMap; @@ -63,18 +63,19 @@ class JustificationHeuristic : public ITEDecisionStrategy { /** * A copy of the assertions that need to be justified - * directly. Doesn't have ones introduced during during ITE-removal. + * directly. Doesn't have ones introduced during during term removal. */ context::CDList<TNode> d_assertions; //TNode is fine since decisionEngine has them too - /** map from ite-rewrite skolem to a boolean-ite assertion */ - SkolemMap d_iteAssertions; + /** map from skolems introduced in term removal to the corresponding assertion + */ + SkolemMap d_skolemAssertions; // 'key' being TNode is fine since if a skolem didn't exist anywhere, // we won't look it up. as for 'value', same reason as d_assertions - /** Cache for ITE skolems present in a atomic formula */ - IteCache d_iteCache; + /** Cache for skolems present in a atomic formula */ + SkolemCache d_skolemCache; /** * This is used to prevent infinite loop when trying to find a @@ -84,10 +85,10 @@ class JustificationHeuristic : public ITEDecisionStrategy { std::unordered_set<TNode,TNodeHashFunction> d_visited; /** - * Set to track visited nodes in a dfs search done in computeITE + * Set to track visited nodes in a dfs search done in computeSkolems * function */ - std::unordered_set<TNode,TNodeHashFunction> d_visitedComputeITE; + std::unordered_set<TNode, TNodeHashFunction> d_visitedComputeSkolems; /** current decision for the recursive call */ SatLiteral d_curDecision; @@ -153,8 +154,7 @@ public: SatValue tryGetSatValue(Node n); /* Get list of all term-ITEs for the atomic formula v */ - JustificationHeuristic::IteList getITEs(TNode n); - + JustificationHeuristic::SkolemList getSkolems(TNode n); /** * For big and/or nodes, a cache to save starting index into children @@ -165,8 +165,8 @@ public: int getStartIndex(TNode node); void saveStartIndex(TNode node, int val); - /* Compute all term-ITEs in a node recursively */ - void computeITEs(TNode n, IteList &l); + /* Compute all term-removal skolems in a node recursively */ + void computeSkolems(TNode n, SkolemList& l); SearchResult handleAndOrEasy(TNode node, SatValue desiredVal); SearchResult handleAndOrHard(TNode node, SatValue desiredVal); @@ -175,7 +175,7 @@ public: SearchResult handleBinaryHard(TNode node1, SatValue desiredVal1, TNode node2, SatValue desiredVal2); SearchResult handleITE(TNode node, SatValue desiredVal); - SearchResult handleEmbeddedITEs(TNode node); + SearchResult handleEmbeddedSkolems(TNode node); };/* class JustificationHeuristic */ }/* namespace decision */ |