#include <search_fast.h>
Inheritance diagram for CVCL::SearchEngineFast:
This search engine is engineered for greater speed. It seeks to eliminate the use of recursion, and instead replace it with iterative procedures that have cleanly defined invariants. This will hopefully not only eliminate bugs or inefficiencies that have been difficult to track down in the default version, but it should also make it easier to trace, read, and understand. It strives to be in line with the most modern SAT techniques.
There are three other significant changes.
One, we want to improve the performance on heavily non-CNF problems. Unlike the older CVC, CVCL does not expand problems into CNF and solve, but rather uses decision procedures to effect the same thing, but often much more slowly. This search engine will leverage off knowledge gained from the DPs in the form of conflict clauses as much as possible.
Two, the solver has traditionally had a difficult time getting started on non-CNF problems. Modern satsolvers also have this problem, and so they employ "restarts" to try solving the problem again after gaining more knowledge about the problem at hand. This allows a more accurate choice of splitters, and in the case of non-CNF problems, the solver can immediately leverage off CNF conflict clauses that were not initially available.
Third, this code is specifically designed to deal with the new dependency tracking. Lazy maps will be eliminated in favor implicit conflict graphs, reducing computation time in two different ways.
Definition at line 77 of file search_fast.h.
|
The main Constructor.
Definition at line 79 of file search_fast.cpp. References d_clauses, d_conflictClauses, d_conflictClauseStack, d_decisionEngine, d_nonLiterals, CVCL::TheoryCore::getFlags(), and IF_DEBUG(). |
|
Destructor. We own the proof rules (d_rules) and the variable manager (d_vm); delete them. Definition at line 125 of file search_fast.cpp. References d_circuits, d_conflictClauseStack, and d_decisionEngine. |
|
Take a conflict in the form of Literal, or Theorem, and generate all the necessary conflict clauses.
|
|
Take a conflict in the form of Literal, or Theorem, and generate all the necessary conflict clauses.
|
|
Auxiliary function for unit propagation.
Definition at line 824 of file search_fast.cpp. References CVCL::SearchEngineRules::conflictRule(), d_conflictTheorem, CVCL::SearchEngine::d_rules, d_unitPropCount, CVCL::Clause::dir(), CVCL::Literal::getExpr(), CVCL::Clause::getTheorem(), CVCL::Literal::getValue(), CVCL::int2string(), CVCL::Expr::isAbsLiteral(), CVCL::Clause::markSat(), CVCL::Clause::size(), CVCL::Expr::toString(), CVCL::Clause::toString(), CVCL::TRACE, unitPropagation(), CVCL::Clause::watched(), wp(), and CVCL::Clause::wp(). Referenced by bcp(). |
|
Do the unit propagation for the clause.
Definition at line 923 of file search_fast.cpp. References d_literals, CVCL::SearchEngine::d_rules, enqueueFact(), CVCL::Theorem::getExpr(), CVCL::Clause::getTheorem(), CVCL::Literal::getValue(), CVCL::int2string(), CVCL::Theorem::isAbsLiteral(), CVCL::SearchImplBase::newLiteral(), CVCL::Clause::size(), CVCL::Literal::toString(), CVCL::Expr::toString(), CVCL::Clause::toString(), and CVCL::SearchEngineRules::unitProp(). Referenced by fixConflict(), and propagate(). |
|
Analyse the conflict, find the UIPs, etc. Finding UIPs (Unique Implication Pointers) This is basically the same as finding hammocks of the subset of the implication graph composed of only the nodes from the current scope. A hammock is a portion of the graph which has a single source and/or sink such that removing that single node makes the graph disconnected. Conceptually, the algorithm maintains four sets of nodes: literals (named lits), gamma, fringe, and pending. Literals are nodes whose expressions will become literals in the conflict clause of the current hammock, and the nodes in gamma are assumptions from which such conflict clause theorem is derived. Nodes in fringe are intermediate nodes which are ready to be "expanded" (see the algorithm description below). The pending nodes are those which are not yet ready to be processed (they later become literal or fringe nodes). These sets are maintained as vectors, and are updated in such a way that the nodes in the vectors never repeat. The exception is the pending set, for which only a size counter is maintained. A node belongs to the pending set if it has been visited (isFlagged() method), and its fan-out count is non-zero (stored in the cache, getCachedValue()). In other words, pending nodes are those that have been visited, but not sufficient number of times. Also, fringe is maintained as a pair of vectors. One vector is always the current fringe, and the other one is built when the current is processed. When processing of the current fringe is finished, it is cleared, and the other vector becomes the current fringe (that is, they swap roles). A node is expanded if it is marked for expansion (getExpandFlag()). If its fan-out count is not yet zero, it is added to the set of pending nodes. If a node has a literal flag (getLitFlag()), it goes into literals when its fan-out count reaches zero. Since this will be the last time the node is visited, it is added to the vector only once. A node neither marked for expansion nor with the literal flag goes into the gamma set. It is added the first time the node is visited (isFlagged() returns false), and therefore, is added to the vector only once. This is an important distinction from the other sets, since a gamma-node may be used by several conflict clauses. Clearing the gamma set after each UIP requires both clearing the vector and resetting all flags (clearAllFlags()). The algorithm
Definition at line 1274 of file search_fast.cpp. References CVCL::Assumptions::begin(), CVCL::Theorem::clearAllFlags(), CVCL::SearchEngineRules::conflictClause(), CVCL::Debug::counter(), CVCL::SearchImplBase::d_bottomScope, d_conflictClauseCount, d_conflictClauses, CVCL::SearchEngine::d_core, d_lastConflictClause, d_lastConflictScope, CVCL::SearchEngine::d_rules, d_unitConflictClauses, CVCL::SearchImplBase::d_vm, CVCL::debugger, CVCL::Assumptions::end(), std::endl(), CVCL::Theorem::getAssumptionsRef(), CVCL::Theorem::getExpr(), CVCL::Debug::getOS(), CVCL::Clause::getScope(), IF_DEBUG(), CVCL::int2string(), CVCL::Clause::isNull(), CVCL::Theorem::printDebug(), processNode(), CVCL::Clause::size(), CVCL::Debug::trace(), CVCL::TRACE, updateLitCounts(), CVCL::Clause::watched(), wp(), and CVCL::Clause::wp(). |
|
Go through all the clauses and check the watch pointers (for debugging).
Referenced by addNonLiteralFact(), analyzeUIPs(), bcp(), checkValidMain(), findSplitter(), fixConflict(), recordFact(), SearchEngineFast(), setInconsistent(), split(), and traceConflict(). |
|
Set up the watch pointers for the new clause.
Definition at line 1077 of file search_fast.cpp. References d_clauses, CVCL::CDList< T >::push_back(), CVCL::Clause::size(), updateLitCounts(), CVCL::Clause::watched(), wp(), and CVCL::Clause::wp(). Referenced by addNonLiteralFact(). |
|
Process a new derived fact (auxiliary function).
Definition at line 557 of file search_fast.cpp. References CVCL::CommonProofRules::contradictionRule(), CVCL::Debug::counter(), CVCL::SearchEngine::d_commonRules, d_unreportedLits, CVCL::debugger, CVCL::Literal::deriveTheorem(), CVCL::Literal::getExpr(), CVCL::Theorem::getExpr(), CVCL::Literal::getScope(), CVCL::Theorem::getScope(), CVCL::Literal::getValue(), IF_DEBUG(), CVCL::CDMap< Key, Data, HashFcn >::insert(), CVCL::Literal::isNegative(), CVCL::SearchImplBase::newLiteral(), setInconsistent(), and CVCL::Literal::setValue(). Referenced by CVCL::Circuit::propagate(). |
|
First pass in conflict analysis; takes a theorem of FALSE. The purpose of this method is to mark up the assumption graph of the FALSE Theorem (conflictThm) for the later UIP analysis. The required flags for each assumption in the graph are: ExpandFlag: whether to "expand" the node or not; that is, whether to consider the current node as a final assumption (either as a conflict clause literal, or a context assumption from ) LitFlag: the node (actually, its inverse) is a literal of the conflict clause CachedValue: the "fanout" count, how many nodes in the assumption graph are derived from the current node. INVARIANTS (after the method returns):
ASSUMPTIONS:
Algorithm: First, backtrack to the scope level of the conflict. Then, traverse the implication graph until we either hit a literal known to the SAT solver at a lower scope: newLiteral(e).getScope()<scopeLevel(), or a splitter (assumption), or a fact from the bottom scope. The literals from the first two categories are marked with LitFlag (they'll comprise the conflict clause), and the bottom scope facts will be the assumptions in the conflict clause's theorem. The traversed nodes are cached by the .isFlagged() flag, and subsequent hits only increase the fanout count of the node. Notice, that there can only be one literal in the conflict clause from the current scope. Also, even if some intermediate literals were delayed by the DPs and reported to the SAT solver at or below the conflict scope (which may be below their "true" Theorem scope), they will be skipped, and their assumptions will be used. In other words, it is safe to backtrack to the "true" conflict level, since, in the worst case, we traverse the graph all the way to the splitters, and make a conflict clause out of those. The hope is, however, that this wouldn't happen too often. Definition at line 1845 of file search_fast.cpp. References CVCL::Assumptions::begin(), CVCL::Theorem::clearAllFlags(), CVCL::SearchImplBase::d_bottomScope, d_decisionEngine, CVCL::Assumptions::end(), CVCL::Theorem::getAssumptionsRef(), CVCL::Theorem::getCachedValue(), CVCL::Theorem::getExpr(), CVCL::Literal::getScope(), CVCL::Theorem::getScope(), CVCL::Literal::getValue(), IF_DEBUG(), CVCL::int2string(), CVCL::Theorem::isAbsLiteral(), CVCL::Theorem::isAssump(), CVCL::Theorem::isFlagged(), CVCL::SearchImplBase::newLiteral(), CVCL::DecisionEngine::popTo(), CVCL::SearchImplBase::scopeLevel(), CVCL::Theorem::setCachedValue(), CVCL::Theorem::setExpandFlag(), CVCL::Theorem::setFlag(), CVCL::Theorem::setLitFlag(), CVCL::Theorem::toString(), CVCL::Expr::toString(), and CVCL::TRACE. Referenced by fixConflict(). |
|
|
Name of this search engine.
Implements CVCL::SearchEngine. Definition at line 381 of file search_fast.h. References d_name. |
|
|
Reruns last check with e as an additional assumption.
Implements CVCL::SearchImplBase. Definition at line 1758 of file search_fast.cpp. References CVCL::TheoryCore::addFact(), checkValidMain(), CVCL::CDMap< Key, Data, HashFcn >::count(), CVCL::SearchImplBase::d_assumptions, CVCL::SearchImplBase::d_bottomScope, CVCL::SearchEngine::d_core, d_factQueue, d_simplifiedThm, d_unitConflictClauses, CVCL::CDO< T >::get(), CVCL::TheoryCore::getCM(), CVCL::Theorem::getRHS(), CVCL::Expr::getType(), CVCL::Type::isBool(), CVCL::Expr::negate(), CVCL::SearchImplBase::newUserAssumption(), CVCL::ContextManager::popto(), CVCL::Type::toString(), CVCL::Expr::toString(), and CVCL::TRACE. |
|
Redefine the counterexample generation. FIXME: for now, it just dumps all the assumptions (same as getAssumptions()). Eventually, it will simplify the related formulas to TRUE, merge all the generated assumptions into d_lastCounterExample, and call the parent's method. Definition at line 1432 of file search_fast.cpp. References CVCL::SearchImplBase::getAssumptions(), and CVCL::SearchImplBase::getCounterExample(). |
|
Notify the search engine about a new literal fact. It should be called by TheoryCore::assertFactCore() Implements CVCL::SearchImplBase. Definition at line 1538 of file search_fast.cpp. References bcp(), CVCL::CommonProofRules::contradictionRule(), CVCL::SearchEngine::d_commonRules, d_inCheckSAT, d_literals, d_literalSet, d_useEnqueueFact, CVCL::Literal::deriveTheorem(), CVCL::Literal::getExpr(), CVCL::Theorem::getExpr(), CVCL::Literal::getValue(), CVCL::CDMap< Key, Data, HashFcn >::insert(), CVCL::Expr::isAbsLiteral(), CVCL::Theorem::isAbsLiteral(), CVCL::Literal::isNegative(), CVCL::SearchImplBase::newLiteral(), CVCL::SearchImplBase::scopeLevel(), setInconsistent(), CVCL::Literal::setValue(), CVCL::Literal::toString(), CVCL::Expr::toString(), CVCL::Theorem::toString(), and CVCL::TRACE. Referenced by enqueueFact(), and split(). |
|
|
Redefine newIntAssumption(): we need to add the new theorem to the appropriate Literal.
Reimplemented from CVCL::SearchImplBase. Definition at line 1581 of file search_fast.cpp. References d_literals, d_litsAlive, CVCL::Literal::getExpr(), CVCL::Theorem::getExpr(), CVCL::Literal::getValue(), CVCL::Expr::isAbsLiteral(), CVCL::Theorem::isAssump(), CVCL::SearchImplBase::newIntAssumption(), CVCL::SearchImplBase::newLiteral(), CVCL::CDList< T >::push_back(), CVCL::SearchImplBase::scopeLevel(), CVCL::Literal::setValue(), CVCL::Literal::toString(), CVCL::Theorem::toString(), and CVCL::TRACE. |
|
Check if the formula has been assumed.
Reimplemented from CVCL::SearchImplBase. Definition at line 1602 of file search_fast.cpp. References CVCL::CDMap< Key, Data, HashFcn >::count(), d_nonLiteralsSaved, and CVCL::SearchImplBase::isAssumption(). |
|
Suggest a splitter to the SearchEngine. The higher is the priority, the sooner the SAT solver will split on it. It can be positive or negative (default is 0). The set of suggested splitters is backtracking; that is, a splitter is "forgotten" once the scope is backtracked. This method can be used either to change the priority of existing splitters, or to introduce new splitters that DPs consider relevant, even though they do not appear in existing formulas. Reimplemented from CVCL::SearchImplBase. Definition at line 1609 of file search_fast.cpp. References CVCL::Literal::added(), compareLits(), CVCL::SearchImplBase::d_dpSplitters, d_litsByScores, d_litSortCount, CVCL::Expr::isAbsLiteral(), CVCL::SearchImplBase::newLiteral(), CVCL::CDList< T >::push_back(), CVCL::Literal::score(), CVCL::Expr::toString(), and CVCL::TRACE. |
|
Definition at line 79 of file search_fast.h. Referenced by addNonLiteralFact(). |