10 #include <carl-arith/interval/SetTheory.h>
11 #include <carl-arith/poly/umvpoly/functions/SturmSequence.h>
15 #include <carl-arith/poly/umvpoly/functions/RootBounds.h>
16 #include <carl-arith/poly/umvpoly/functions/RootCounting.h>
17 #include <carl-arith/constraint/IntervalEvaluation.h>
18 #include <carl-arith/poly/umvpoly/functions/Evaluation.h>
30 State::State( carl::IDPool* _conditionIdAllocator,
bool _withVariableBounds ):
31 mConditionsSimplified( false ),
32 mHasChildrenToInsert( false ),
33 mHasRecentlyAddedConditions( false ),
34 mInconsistent( false ),
35 mMarkedAsDeleted( false ),
36 mSubResultsSimplified( false ),
37 mTakeSubResultCombAgain( false ),
38 mTestCandidateCheckedForBounds( false ),
39 mCannotBeSolved( false ),
40 mCannotBeSolvedLazy( false ),
41 mTryToRefreshIndex( false ),
42 mBackendCallValuation( 0 ),
45 mType( TEST_CANDIDATE_TO_GENERATE ),
46 mIndex(
carl::Variable::NO_VARIABLE ),
47 mpOriginalCondition( NULL ),
49 mpSubstitution( NULL ),
50 mpSubstitutionResults( NULL ),
51 mpSubResultCombination( NULL ),
54 mpChildren( new std::list<
State* >() ),
55 mpTooHighDegreeConditions( new
carl::PointerSet<
Condition>() ),
57 mpInfinityChild( NULL ),
60 mCurrentIntRange( 0 ),
61 mpConditionIdAllocator( _conditionIdAllocator ),
65 #ifdef SMTRAT_DEVOPTION_Statistics
66 , mpStatistics( nullptr )
71 mConditionsSimplified( false ),
72 mHasChildrenToInsert( false ),
73 mHasRecentlyAddedConditions( false ),
74 mInconsistent( false ),
75 mMarkedAsDeleted( false ),
76 mSubResultsSimplified( false ),
77 mTakeSubResultCombAgain( false ),
78 mTestCandidateCheckedForBounds( false ),
79 mCannotBeSolved( false ),
80 mCannotBeSolvedLazy( false ),
81 mTryToRefreshIndex( false ),
82 mBackendCallValuation( 0 ),
85 mType( SUBSTITUTION_TO_APPLY ),
86 mIndex(
carl::Variable::NO_VARIABLE ),
87 mpOriginalCondition( NULL ),
90 mpSubstitutionResults( NULL ),
91 mpSubResultCombination( NULL ),
94 mpChildren( new std::list<
State* >() ),
95 mpTooHighDegreeConditions( new
carl::PointerSet<
Condition>() ),
97 mpInfinityChild( NULL ),
100 mCurrentIntRange( 0 ),
101 mpConditionIdAllocator( _conditionIdAllocator ),
105 #ifdef SMTRAT_DEVOPTION_Statistics
106 , mpStatistics( nullptr )
118 if( sub != NULL && sub->
type() == Substitution::Type::INVALID )
173 _ranking.erase( key );
182 child->resetCannotBeSolvedLazyFlags();
188 const State* currentDT =
this;
189 while( !(*currentDT).isRoot() )
192 currentDT = (*currentDT).
pFather();
212 if( _constraint.variables().has(
substitution().variable() ))
222 if( (*cond)->flag() )
236 if( child->substitution().originalConditions().find( _condition ) != child->substitution().originalConditions().end() && !child->isInconsistent() )
247 if( (*child)->id() == 0 )
257 if(
this == _state )
return true;
259 if( child->containsState( _state ) )
269 if( (*child)->isInconsistent() )
280 if( (*cond)->constraint().relation() ==
carl::Relation::EQ && (*cond)->constraint().variables().has( _variable ) )
292 if( !(**cond).flag() )
301 auto vars = (**cond).constraint().variables();
302 _variables.insert(
vars.begin(),
vars.end() );
310 result += (**child).numberOfNodes();
316 State* currentDT =
this;
317 while( !(*currentDT).isRoot() )
318 currentDT = (*currentDT).
pFather();
324 assert( _maxIntRange > 0 );
331 --_nextIntTestCandidate;
336 ++_nextIntTestCandidate;
338 assert( carl::is_integer( _nextIntTestCandidate ) );
345 State* minusInfChild = NULL;
346 State* plusInfChild = NULL;
353 assert( minusInfChild == NULL );
354 minusInfChild = child;
358 assert( plusInfChild == NULL );
359 plusInfChild = child;
361 else if( child->substitution().term().is_integer() )
368 bool anythingChanged =
false;
372 if( minusInfChild != NULL )
374 anythingChanged =
true;
379 if( plusInfChild != NULL )
381 anythingChanged =
true;
383 return anythingChanged;
389 while( !_unfinAnt->
isRoot() )
393 _unfinAnt = _unfinAnt->
pFather();
403 assert(
index() != carl::Variable::NO_VARIABLE );
405 _bestCondition = *cond;
407 double bestConditionValuation = _bestCondition->
valuate(
index(), _numberOfAllVariables, _preferEquation );
408 double currentConditionValuation = 0;
411 if( !(**cond).flag() )
413 if( (*_bestCondition).flag() )
415 _bestCondition = *cond;
416 bestConditionValuation = _bestCondition->
valuate(
index(), _numberOfAllVariables, _preferEquation );
420 currentConditionValuation = (**cond).valuate(
index(), _numberOfAllVariables, _preferEquation );
421 if( currentConditionValuation != 0 && ( currentConditionValuation < bestConditionValuation || bestConditionValuation == 0 ) )
423 _bestCondition = *cond;
424 bestConditionValuation = currentConditionValuation;
432 return !(*_bestCondition).
flag();
438 if( (**cond).constraint() == _constraint )
451 unsigned subResultIndex = 0;
456 assert( !subResult->empty() );
457 auto condConjunction = subResult->begin();
458 bool containsEmptyCase =
false;
459 while( condConjunction != subResult->end() && subResult->size() > 1 )
462 if( !
simplify( condConjunction->first, conflictingConditionPairs, _ranking ) )
464 while( !condConjunction->first.empty() )
466 const Condition* rpCond = condConjunction->first.back();
467 condConjunction->first.pop_back();
472 condConjunction = subResult->erase( condConjunction );
476 if( condConjunction->first.empty() )
477 containsEmptyCase =
true;
481 if( containsEmptyCase )
488 if( subResComb->first == subResultIndex )
490 else if( subResComb->first > subResultIndex )
492 --(subResComb->first);
500 while( !subResult->empty() )
502 while( !subResult->back().first.empty() )
504 const Condition* rpCond = subResult->back().first.back();
505 subResult->back().first.pop_back();
510 subResult->pop_back();
524 if( subResult->size() == 1 )
528 fixedConditions = subResult;
534 fixedConditions->back().first.insert( fixedConditions->back().first.end(),
535 subResult->back().first.begin(),
536 subResult->back().first.end() );
542 if( subResComb->first == subResultIndex )
544 else if( subResComb->first > subResultIndex )
546 --(subResComb->first);
588 carl::PointerSet<Condition> redundantConditionSet;
592 for(
auto iter = _conditionVectorToSimplify.begin(); iter != _conditionVectorToSimplify.end(); ++iter )
595 if( !carl::is_bound(constr) )
597 carl::Relation stricterRelation = constr.relation();
598 switch( consistent_with(constr.constr(), varIntervals, stricterRelation ) )
603 carl::PointerSet<Condition> condSet(tmp.begin(), tmp.end());
604 condSet.insert( *iter );
605 _conflictSet.insert( std::move( condSet ) );
610 redundantConditionSet.insert( *iter );
611 #ifdef SMTRAT_DEVOPTION_Statistics
612 mpStatistics->omittedConstraintByVB();
618 if( stricterRelation != constr.relation() )
621 carl::PointerSet<Condition> vbcondSet(tmp.begin(), tmp.end());
622 size_t nValuation = (*iter)->valuation();
623 bool nFlag = (*iter)->flag();
625 unsigned nConstraintConsistency = nConstraint.is_consistent();
626 if( nConstraintConsistency == 2 )
628 if( _stateConditions )
630 carl::PointerSet<Condition> oConds = (*iter)->originalConditions();
631 for(
const Condition* vbcond : vbcondSet )
632 oConds.insert( vbcond->originalConditions().begin(), vbcond->originalConditions().end() );
633 addCondition( nConstraint, oConds, nValuation,
true, _ranking );
638 for(
const Condition* vbcond : vbcondSet )
639 cond->
pOriginalConditions()->insert( vbcond->originalConditions().begin(), vbcond->originalConditions().end() );
640 _conditionVectorToSimplify.push_back( cond );
642 redundantConditionSet.insert( *iter );
644 else if( nConstraint.is_consistent() == 0 )
647 carl::PointerSet<Condition> condSet(tmp.begin(), tmp.end());
648 condSet.insert( *iter );
649 _conflictSet.insert( std::move( condSet ) );
657 if( _conditionVectorToSimplify.size() > 1 )
659 auto iterA = _conditionVectorToSimplify.begin();
661 while( iterA != _conditionVectorToSimplify.end() )
665 while( iterB != _conditionVectorToSimplify.end() )
671 if( strongProp == 2 )
685 redundantConditionSet.insert( condB );
688 else if( strongProp == 1 )
689 redundantConditionSet.insert( condB );
691 else if( strongProp == -3 )
696 size_t nValuation = 0;
698 if( (constraintA.relation() == carl::Relation::GEQ && constraintB.relation() == carl::Relation::GEQ)
699 || (constraintA.relation() == carl::Relation::GEQ && constraintB.relation() == carl::Relation::LEQ)
700 || (constraintA.relation() == carl::Relation::LEQ && constraintB.relation() == carl::Relation::GEQ)
701 || (constraintA.relation() == carl::Relation::LEQ && constraintB.relation() == carl::Relation::LEQ) )
705 nFlag = condB->
flag();
707 else if( (constraintA.relation() == carl::Relation::NEQ && constraintB.relation() == carl::Relation::GEQ) )
711 nFlag = condB->
flag();
713 else if( (constraintA.relation() == carl::Relation::GEQ && constraintB.relation() == carl::Relation::NEQ) )
717 nFlag = condA->
flag();
719 else if( (constraintA.relation() == carl::Relation::NEQ && constraintB.relation() == carl::Relation::LEQ) )
723 nFlag = condB->
flag();
725 else if( (constraintA.relation() == carl::Relation::LEQ && constraintB.relation() == carl::Relation::NEQ) )
729 nFlag = condA->
flag();
733 unsigned nConstraintConsistency = nConstraint.is_consistent();
734 if( nConstraintConsistency == 2 )
736 if( _stateConditions )
740 addCondition( nConstraint, oConds, nValuation,
true, _ranking );
746 _conditionVectorToSimplify.push_back( cond );
748 redundantConditionSet.insert( condA );
749 redundantConditionSet.insert( condB );
751 else if( nConstraint.is_consistent() == 0 )
753 carl::PointerSet<Condition> condSet;
754 condSet.insert( condA );
755 condSet.insert( condB );
756 _conflictSet.insert( condSet );
760 else if( strongProp == -1 )
761 redundantConditionSet.insert( condA );
763 else if( strongProp == -2 || strongProp == -4 )
765 carl::PointerSet<Condition> condSet;
766 condSet.insert( condA );
767 condSet.insert( condB );
768 _conflictSet.insert( condSet );
775 auto condSet = _conflictSet.begin();
776 while( condSet != _conflictSet.end() )
778 auto cond = condSet->begin();
779 while( cond != condSet->end() )
781 redundantConditionSet.erase( *cond );
786 if( _stateConditions )
791 auto cond = _conditionVectorToSimplify.begin();
792 while( cond != _conditionVectorToSimplify.end() )
794 auto iter = redundantConditionSet.find( *cond );
795 if( iter != redundantConditionSet.end() )
797 redundantConditionSet.erase( iter );
799 cond = _conditionVectorToSimplify.erase( cond );
809 return _conflictSet.empty();
823 iter->second.insert( std::move(_condSetSet) );
824 if( _substitution != NULL && _substitution->
type() == Substitution::Type::INVALID )
826 delete _substitution;
832 condSetSetSet.insert( std::move(_condSetSet) );
833 mpConflictSets->insert( std::pair<const Substitution*, ConditionSetSetSet>( _substitution, std::move(condSetSetSet) ) );
835 if( _substitution == NULL )
845 for(
auto condSetSet = iter->second.begin(); condSetSet != iter->second.end(); ++condSetSet )
848 newCondSetSet.insert( condSetSet->begin(), condSetSet->end() );
849 newCondSetSet.insert( _condSetSet.begin(), _condSetSet.end() );
850 newCondSetSetSet.insert( std::move(newCondSetSet) );
852 iter->second = std::move(newCondSetSetSet);
857 condSetSetSet.insert( std::move(_condSetSet) );
858 mpConflictSets->insert( std::pair<const Substitution*, ConditionSetSetSet>( _substitution, std::move(condSetSetSet) ) );
867 if( conflictSet->first == NULL )
881 if( (**child).substitution() == _substitution )
891 else if(
index().type() == carl::VariableType::VT_INT && _substitution.
term().is_integer() )
898 (**child).resetCurrentRangeSize();
899 _reactivatedStates.push_back( *child );
906 (**child).resetCurrentRangeSize();
907 _reactivatedStates.push_back( *child );
920 for(
auto disjunction = _disjunctionsOfCondConj.begin(); disjunction != _disjunctionsOfCondConj.end(); ++disjunction )
923 for(
auto conjunction = disjunction->begin(); conjunction != disjunction->end(); ++conjunction )
924 mpSubstitutionResults->back().push_back( std::pair<ConditionList, bool>( std::move(*conjunction),
false ) );
940 unsigned bestSubResultIndex = 0;
941 bool notConsideredSubResultFound =
false;
942 unsigned subResultIndex = 0;
943 while( subResultIndex < mpSubstitutionResults->size() )
949 condConj->second =
false;
953 bool subResultAlreadyConsidered =
false;
957 if( subResComb->first == subResultIndex )
959 subResultAlreadyConsidered =
true;
965 if( !subResultAlreadyConsidered )
967 if( notConsideredSubResultFound )
972 bestSubResultIndex = subResultIndex;
978 bestSubResultIndex = subResultIndex;
979 notConsideredSubResultFound =
true;
1023 SubResultCombination::const_reverse_iterator rIterTemp = rIter;
1036 condConj->second =
false;
1063 size_t numOfPrefixCombinations = 1;
1068 size_t numOfCurrentCombination = 1;
1071 numOfCurrentCombination *= src.second;
1073 return numOfPrefixCombinations + numOfCurrentCombination;
1093 return currentSubresultCombination;
1099 bool conditionsChanged =
false;
1106 if( !
simplify( newCombination, conflictingConditionPairs, _ranking ) )
1109 carl::PointerSet<Condition> condsToDelete;
1115 bool condOccursInNewConds =
false;
1116 auto newCond = newCombination.begin();
1117 while( newCond != newCombination.end() )
1119 if( (**cond).constraint() == (**newCond).constraint() )
1122 if( !(**cond).originalConditions().empty() &&!(**newCond).originalConditions().empty() )
1125 if( (**newCond).valuation() < (**cond).valuation() )
1127 *(**cond).pOriginalConditions() = carl::PointerSet<Condition>( (**newCond).originalConditions() );
1128 (**cond).rValuation() = (**newCond).valuation();
1132 (**cond).pOriginalConditions()->insert( (**newCond).originalConditions().begin(), (**newCond).originalConditions().end() );
1134 newCond = newCombination.erase( newCond );
1138 condOccursInNewConds =
true;
1145 if( !condOccursInNewConds )
1147 condsToDelete.insert( *cond );
1151 if( !newCombination.empty() )
1152 conditionsChanged =
true;
1154 if( !condsToDelete.empty() )
1156 conditionsChanged =
true;
1160 for(
auto newCond = newCombination.begin(); newCond != newCombination.end(); ++newCond )
1161 addCondition( (**newCond).constraint(), (**newCond).originalConditions(), (**newCond).valuation(),
true, _ranking );
1162 while( !newCombination.empty() )
1164 const Condition* rpCond = newCombination.back();
1165 newCombination.pop_back();
1172 if( conditionsChanged )
1184 assert(
index() != carl::Variable::NO_VARIABLE );
1187 (**cond).rFlag() = !(**cond).constraint().variables().has(
index() );
1196 if( _allVariables.size() == 1 )
1198 if(
index() != *_allVariables.begin() )
1200 setIndex( *_allVariables.begin() );
1205 if( _tryDifferentVarOrder )
1212 assert(
index() != varVals[bestVar].first );
1213 setIndex( varVals[bestVar].first );
1219 for(
auto var = _allVariables.begin();
var != _allVariables.end(); ++
var )
1221 if(
var->type() == carl::VariableType::VT_INT )
1222 mIntVarVals.push_back( std::pair<carl::Variable, std::multiset<double> >( *
var, std::multiset<double>() ) );
1224 mRealVarVals.push_back( std::pair<carl::Variable, std::multiset<double> >( *
var, std::multiset<double>() ) );
1231 for(
auto var = varValsB.begin();
var != varValsB.end(); ++
var )
1233 double varInConsVal = (**cond).valuate(
var->first, _allVariables.size(), _preferEquation );
1234 if( varInConsVal != 0 )
1235 var->second.insert( varInConsVal );
1239 #ifdef VS_DEBUG_VARIABLE_VALUATIONS
1240 for(
auto var = varVals.begin();
var != varVals.end(); ++
var )
1242 std::cout <<
var->first <<
": ";
1243 for(
auto varVal =
var->second.begin(); varVal !=
var->second.end(); ++varVal )
1244 std::cout << setprecision(10) << *varVal <<
" | ";
1245 std::cout << std::endl;
1250 if( _useFixedVariableOrder )
1252 for(
const auto& varValPair : varVals )
1254 if( !varValPair.second.empty() )
1256 if(
index() != varValPair.first )
1283 if(
index() != varVals[bestVar].first )
1285 setIndex( varVals[bestVar].first );
1293 assert( _varVals.size() > 1 );
1296 while(
var < _varVals.size() )
1298 const auto& vv = _varVals[
var];
1300 if( !vv.second.empty() && !bv.second.empty() )
1302 if( vv.second.size() == 1 && bv.second.size() == 1 )
1304 if( *vv.second.begin() < *bv.second.begin() )
1309 else if( *vv.second.begin() == *bv.second.begin() )
1314 auto varInConsVal = vv.second.begin();
1315 auto bestVarInConsVal = bv.second.begin();
1316 while( varInConsVal != vv.second.end() && bestVarInConsVal != bv.second.end() )
1318 if( *varInConsVal < *bestVarInConsVal )
1324 else if( *varInConsVal > *bestVarInConsVal )
1329 if( varInConsVal == vv.second.end() )
1331 if( bestVarInConsVal == bv.second.end() )
1341 else if( !vv.second.empty() && bv.second.empty() )
1352 assert( _varVals.size() > 1 );
1353 std::size_t
var = 0;
1355 double bestAvgVal = 0;
1356 const std::multiset<double>& vals = _varVals[
var].second;
1359 bestAvgVal = std::accumulate(vals.begin(), vals.end(), 0.0) /
static_cast<double>(vals.size());
1362 for(;
var < _varVals.size(); ++
var )
1364 const std::multiset<double>& valsB = _varVals[
var].second;
1365 if( !valsB.empty() )
1367 double curAvgVal = std::accumulate(valsB.begin(), valsB.end(), 0.0) /
static_cast<double>(valsB.size());
1368 if( curAvgVal > 0 && (bestAvgVal == 0 || curAvgVal < bestAvgVal) )
1373 else if( curAvgVal == bestAvgVal )
1381 assert( _varVals.size() > 1 );
1384 while(
var < _varVals.size() )
1386 const auto& vv = _varVals[
var];
1388 if( !vv.second.empty() && !bv.second.empty() )
1390 if( vv.second.size() == 1 && bv.second.size() == 1 )
1392 if( *vv.second.begin() < *bv.second.begin() )
1397 else if( *vv.second.begin() == *bv.second.begin() )
1402 auto varInConsVal = vv.second.rbegin();
1403 auto bestVarInConsVal = bv.second.rbegin();
1404 while( varInConsVal != vv.second.rend() && bestVarInConsVal != bv.second.rend() )
1406 if( *varInConsVal < *bestVarInConsVal )
1412 else if( *varInConsVal > *bestVarInConsVal )
1417 if( varInConsVal == vv.second.rend() )
1419 if( bestVarInConsVal == bv.second.rend() )
1429 else if( !vv.second.empty() && bv.second.empty() )
1441 unsigned constraintConsistency = _constraint.is_consistent();
1442 assert( constraintConsistency != 0 );
1443 if( constraintConsistency != 1 )
1450 if(
index() != carl::Variable::NO_VARIABLE )
1452 if( _recentlyAdded )
1454 bool constraintWithFinitlyManySolutionCandidatesInIndexExists =
false;
1457 if( (**child).pOriginalCondition() != NULL )
1458 constraintWithFinitlyManySolutionCandidatesInIndexExists =
true;
1462 if( !_constraint.variables().has(
index() )
1463 || constraintWithFinitlyManySolutionCandidatesInIndexExists )
1512 if( _originsToDelete.empty() )
return 1;
1516 for(
auto condToDel = _originsToDelete.begin(); condToDel != _originsToDelete.end(); ++condToDel )
1519 while( oCondInSub !=
substitution().originalConditions().end() )
1521 if( *oCondInSub == *condToDel )
1537 bool conditionDeleted =
false;
1538 bool recentlyAddedConditionLeft =
false;
1539 carl::PointerSet<Condition> deletedConditions;
1540 carl::PointerSet<Condition> originsToRemove;
1541 for(
auto originToDelete = _originsToDelete.begin(); originToDelete != _originsToDelete.end(); ++originToDelete )
1546 if( (*condition)->originalConditions().find( *originToDelete ) != (*condition)->originalConditions().end() )
1550 carl::Variable* changedVar;
1552 if( boundRemoved == 2 )
1556 if( (*condB)->constraint().variables().has( *changedVar ) )
1558 originsToRemove.insert( *condB );
1559 (*condB)->rRecentlyAdded() =
true;
1560 recentlyAddedConditionLeft =
true;
1561 if(
index() != carl::Variable::NO_VARIABLE )
1562 (*condB)->rFlag() = !(*condB)->constraint().variables().has(
index() );
1571 deletedConditions.insert( *condition );
1572 originsToRemove.insert( *condition );
1574 conditionDeleted =
true;
1578 if( (*condition)->recentlyAdded() ) recentlyAddedConditionLeft =
true;
1583 if( conditionDeleted )
1596 while( !deletedConditions.empty() )
1598 const Condition* pCond = *deletedConditions.begin();
1599 deletedConditions.erase( deletedConditions.begin() );
1612 if( _conditionsToDelete.empty() )
return;
1615 for(
auto cond = _conditionsToDelete.begin(); cond != _conditionsToDelete.end(); ++cond )
1620 bool conditionDeleted =
false;
1621 bool recentlyAddedConditionLeft =
false;
1622 std::vector<const Condition* > condsToDelete;
1623 carl::PointerSet<Condition> originsToRemove;
1627 if( _conditionsToDelete.find( *cond ) != _conditionsToDelete.end() )
1631 carl::Variable* changedVar;
1633 if( boundRemoved == 2 )
1637 if( (*condB)->constraint().variables().has( *changedVar ) )
1639 originsToRemove.insert( *condB );
1640 (*condB)->rRecentlyAdded() =
true;
1641 recentlyAddedConditionLeft =
true;
1642 if(
index() != carl::Variable::NO_VARIABLE )
1643 (*condB)->rFlag() = !(*condB)->constraint().variables().has(
index() );
1649 conditionDeleted =
true;
1650 condsToDelete.push_back( *cond );
1655 if( (*cond)->recentlyAdded() ) recentlyAddedConditionLeft =
true;
1659 if( conditionDeleted )
1664 originsToRemove.insert( _conditionsToDelete.begin(), _conditionsToDelete.end() );
1669 while( !condsToDelete.empty() )
1671 const Condition* condToDel = condsToDelete.back();
1672 condsToDelete.pop_back();
1684 bool childWithIntTcDeleted =
false;
1688 int result = (*child)->deleteOrigins( _originsToDelete, _ranking );
1696 childWithIntTcDeleted =
true;
1698 auto conflictSet =
rConflictSets().find( (*child)->pSubstitution() );
1701 State* toDelete = *child;
1710 if( childWithIntTcDeleted )
1720 auto condSetSet = conflictSet->second.begin();
1721 bool emptyReasonOccured =
false;
1722 while( condSetSet != conflictSet->second.end() )
1725 auto condSet = condSetSet->begin();
1726 while( condSet != condSetSet->end() )
1728 carl::PointerSet<Condition> updatedCondSet;
1729 auto cond = condSet->begin();
1730 bool condToDelOccured =
false;
1731 while( cond != condSet->end() )
1733 if( _originsAreCurrentConditions )
1735 if( _originsToDelete.find( *cond ) != _originsToDelete.end() )
1737 condToDelOccured =
true;
1741 updatedCondSet.insert( *cond );
1745 auto condToDel = _originsToDelete.begin();
1746 while( condToDel != _originsToDelete.end() )
1748 if( (*cond)->originalConditions().find( *condToDel ) != (*cond)->originalConditions().end() )
1752 if( condToDel == _originsToDelete.end() )
1753 updatedCondSet.insert( *cond );
1756 condToDelOccured =
true;
1762 if( !condToDelOccured )
1763 updatedCondSetSet.insert( updatedCondSet );
1766 if( !updatedCondSetSet.empty() )
1767 updatedCondSetSetSet.insert( updatedCondSetSet );
1770 emptyReasonOccured =
true;
1775 if( !emptyReasonOccured )
1777 conflictSet->second = updatedCondSetSetSet;
1782 if( conflictSet->first == NULL )
1786 for(
auto oCond = conflictSet->first->originalConditions().begin(); oCond != conflictSet->first->originalConditions().end(); ++oCond )
1788 (*oCond)->rFlag() =
false;
1807 if( (*child)->hasSubstitutionResults() )
1809 if( (*child)->hasSubResultsCombination() )
1811 auto subResComb = (**child).rSubResultCombination().begin();
1812 while( subResComb != (*child)->subResultCombination().end() )
1814 subResComb->second = 0;
1818 auto subResult = (*child)->rSubstitutionResults().begin();
1819 while( subResult != (*child)->substitutionResults().end() )
1821 auto condConj = subResult->begin();
1822 while( condConj != subResult->end() )
1824 condConj->second =
false;
1833 if( (*child)->hasSubstitutionResults() && (*child)->hasSubResultsCombination() )
1835 (*child)->rTakeSubResultCombAgain() =
true;
1838 (*child)->rTakeSubResultCombAgain() =
false;
1840 (*child)->rInconsistent() =
false;
1850 unsigned subResultIndex = 0;
1854 unsigned subResultConjunctionIndex = 0;
1855 auto condConj = subResult->begin();
1856 while( condConj != subResult->end() )
1859 auto cond = condConj->first.begin();
1860 while( cond != condConj->first.end() )
1862 bool oCondsDeleted =
false;
1863 auto oCond = (**cond).pOriginalConditions()->begin();
1864 while( oCond != (**cond).originalConditions().end() )
1866 if( _originsToDelete.find( *oCond ) != _originsToDelete.end() )
1868 (**cond).pOriginalConditions()->erase( oCond++ );
1869 oCondsDeleted =
true;
1876 oCond = (**cond).pOriginalConditions()->begin();
1877 while( oCond != (**cond).originalConditions().end() )
1879 carl::PointerSet<Condition> oConds;
1880 oConds.insert( *oCond );
1885 cond = condConj->first.erase( cond );
1886 condConj->second =
false;
1897 condConj->first.insert( condConj->first.end(), conditionsToAdd.begin(), conditionsToAdd.end() );
1898 if( condConj->first.empty() )
1910 if( subResComb->second == subResultConjunctionIndex )
1915 else if( subResComb->second > subResultConjunctionIndex )
1916 --(subResComb->second);
1918 if( subResult->size() == 1 )
1923 if( subResCombB->first > subResultIndex )
1924 --(subResCombB->first);
1929 condConj = subResult->erase( condConj );
1934 ++subResultConjunctionIndex;
1938 if( subResult->empty() )
1959 std::vector<State*>
result;
1975 #ifdef SMTRAT_DEVOPTION_Statistics
1976 state->setStatistics( mpStatistics );
1977 mpStatistics->createTestCandidate();
1980 for(
auto sideCond = sideConds.begin(); sideCond != sideConds.end(); ++sideCond )
1984 std::vector<DisjunctionOfConditionConjunctions> subResults;
1985 subResults.emplace_back();
1986 subResults.back().emplace_back();
2018 result.push_back( state );
2062 carl::Variables occuringVars = carl::Variables();
2063 std::set<carl::Relation> relationSymbols = std::set<carl::Relation>();
2066 auto vars = (*cond)->constraint().variables();
2067 occuringVars.insert(
vars.begin(),
vars.end() );
2068 relationSymbols.insert( (*cond)->constraint().relation() );
2075 else if( relationSymbols.find( carl::Relation::LEQ ) != relationSymbols.end() || relationSymbols.find( carl::Relation::GEQ ) != relationSymbols.end() )
2085 bool coverSetOCondsContainIndexOfFather =
false;
2089 carl::PointerSet<Condition> covSet;
2092 if( nullConfSet !=
conflictSets().end() && !_includeInconsistentTestCandidates )
2094 confSets.insert( nullConfSet->second.begin(), nullConfSet->second.end() );
2099 confSets.insert( confSet->second.begin(), confSet->second.end() );
2102 #ifdef SMTRAT_DEVOPTION_Statistics
2103 mpStatistics->coveringSet( covSet.size(),
conditions().size() );
2105 #ifdef VS_LOG_INFSUBSETS
2107 for(
auto cond = covSet.begin(); cond != covSet.end(); ++cond )
2108 constraints.insert( (**cond).constraint() );
2112 carl::PointerSet<Condition> coverSetOConds;
2115 for(
auto cond = covSet.begin(); cond != covSet.end(); ++cond )
2118 if( !(**cond).originalConditions().empty() )
2120 auto oCond = (**cond).originalConditions().begin();
2121 while( oCond != (**cond).originalConditions().end() )
2123 assert(
father().
index() != carl::Variable::NO_VARIABLE );
2124 if( (**oCond).constraint().variables().has(
father().
index() ) )
2125 coverSetOCondsContainIndexOfFather =
true;
2126 coverSetOConds.insert( *oCond );
2130 sideConditionIsPartOfConflict |= subsSideConds.find( (*cond)->constraint() ) != subsSideConds.end();
2132 if( !sideConditionIsPartOfConflict )
2135 (*cond)->rFlag() =
true;
2144 coverSetOCondsContainIndexOfFather =
true;
2147 assert( !coverSetOConds.empty() );
2148 conflictSet.insert( std::move(coverSetOConds) );
2150 if( _useBackjumping || coverSetOCondsContainIndexOfFather )
2154 #ifdef SMTRAT_DEVOPTION_Statistics
2155 mpStatistics->backjumping( numberOfUnusedConditions() );
2185 bool fixedConditions =
false;
2192 fixedConditions =
true;
2193 if( coverSetOCondsContainIndexOfFather && !fixedConditions )
2204 #ifdef VS_DEBUG_LOCAL_CONFLICT_SEARCH
2209 carl::PointerSet<Condition> localConflictSet;
2212 if( (*cond)->flag() ) localConflictSet.insert( *cond );
2216 #ifdef VS_DEBUG_LOCAL_CONFLICT_SEARCH
2217 std::cout <<
"local conflict: { ";
2218 for(
auto iter = localConflictSet.begin(); iter != localConflictSet.end(); ++iter )
2219 std::cout << (*iter)->constraint() <<
" ";
2220 std::cout <<
"}" << std::endl;
2222 carl::PointerSet<Condition> infSubset;
2223 bool containsConflictToCover =
false;
2226 containsConflictToCover =
true;
2227 for(
auto condSetSet = conflict->second.begin(); condSetSet != conflict->second.end(); ++condSetSet )
2229 auto condSet = condSetSet->begin();
2230 for( ; condSet != condSetSet->end(); ++condSet )
2232 auto condA = condSet->begin();
2233 auto condB = localConflictSet.begin();
2234 assert( condA != condSet->end() );
2235 #ifdef VS_DEBUG_LOCAL_CONFLICT_SEARCH
2236 std::cout <<
"covers: { ";
2237 for(
auto iter = condSet->begin(); iter != condSet->end(); ++iter )
2238 std::cout << (*iter)->constraint() <<
" ";
2239 std::cout <<
"} ??";
2241 while( condA != condSet->end() && condB != localConflictSet.end() )
2243 if( (*condB) < (*condA) )
2245 else if( (*condA) < (*condB) )
2253 if( condA == condSet->end() )
2255 infSubset.insert( condSet->begin(), condSet->end() );
2256 #ifdef VS_DEBUG_LOCAL_CONFLICT_SEARCH
2257 std::cout <<
" Yes!" << std::endl;
2263 #ifdef VS_DEBUG_LOCAL_CONFLICT_SEARCH
2264 std::cout <<
" No!" << std::endl;
2268 if( condSet == condSetSet->end() )
2270 #ifdef VS_DEBUG_LOCAL_CONFLICT_SEARCH
2271 std::cout <<
"No conflict set in conflict is covered!" << std::endl;
2275 #ifdef VS_DEBUG_LOCAL_CONFLICT_SEARCH
2278 std::cout <<
"A conflict set in conflict is covered!" << std::endl;
2283 if( containsConflictToCover )
2286 localConflict.insert( infSubset );
2288 #ifdef SMTRAT_DEVOPTION_Statistics
2289 mpStatistics->localConflict( numberOfUnusedConditions() );
2304 #ifdef VS_DEBUG_VARIABLE_BOUNDS
2305 std::cout <<
">>> Check test candidate " <<
substitution() <<
" against:" << std::endl;
2308 carl::PointerSet<Condition> conflict;
2309 std::vector< smtrat::DoubleInterval > solutionSpaces =
solutionSpace( conflict );
2310 if( solutionSpaces.empty() )
2313 conflicts.insert( std::move(conflict) );
2315 #ifdef SMTRAT_DEVOPTION_Statistics
2316 mpStatistics->omittedTestCandidateWithVB( numberOfUnusedConditions() );
2326 std::vector< smtrat::DoubleInterval >
result;
2331 result.push_back( smtrat::DoubleInterval::unbounded_interval() );
2335 _conflictReason.insert( conflictBounds.begin(), conflictBounds.end() );
2342 result.push_back( smtrat::DoubleInterval::unbounded_interval() );
2346 assert( !conflictBounds.empty() );
2347 _conflictReason.insert( conflictBounds.begin(), conflictBounds.end() );
2361 #ifdef VS_DEBUG_VARIABLE_BOUNDS
2362 std::cout <<
">>> Results in:" << std::endl;
2363 std::cout <<
">>> constant part : " << solutionSpaceConst << std::endl;
2364 std::cout <<
">>> factor part : " << solutionSpaceFactor << std::endl;
2365 std::cout <<
">>> radicand part : " << solutionSpaceRadicand << std::endl;
2366 std::cout <<
">>> square root part : " << solutionSpaceSqrt << std::endl;
2367 std::cout <<
">>> denominator part : " << solutionSpaceDenom << std::endl;
2368 std::cout <<
">>> numerator part : " <<
solutionSpace << std::endl;
2372 bool splitOccurred =
solutionSpace.div_ext( solutionSpaceDenom, resA, resB );
2376 if( resA.upper_bound_type() == carl::BoundType::INFTY || resA.upper() == DBL_MAX )
2378 resA =
smtrat::DoubleInterval( resA.lower(), carl::BoundType::STRICT, (
double)0, carl::BoundType::INFTY );
2380 resB =
smtrat::DoubleInterval( resB.lower(), carl::BoundType::STRICT, (
double)0, carl::BoundType::INFTY );
2384 resA =
smtrat::DoubleInterval( resA.lower(), carl::BoundType::STRICT, std::nextafter( resA.upper(), INFINITY ), carl::BoundType::WEAK );
2386 resB =
smtrat::DoubleInterval( resB.lower(), carl::BoundType::STRICT, std::nextafter( resB.upper(), INFINITY ), carl::BoundType::WEAK );
2389 #ifdef VS_DEBUG_VARIABLE_BOUNDS
2390 std::cout <<
">>> division part 1 : " << std::setprecision(100) << resA << std::endl;
2391 std::cout <<
">>> subVarInterval : " << std::setprecision(100) << subVarInterval << std::endl;
2393 resA = carl::set_intersection(resA, subVarInterval);
2394 #ifdef VS_DEBUG_VARIABLE_BOUNDS
2395 std::cout <<
">>> intersection part 1: " << std::setprecision(100) << resA << std::endl;
2397 if( !resA.is_empty() )
2398 result.push_back( resA );
2401 #ifdef VS_DEBUG_VARIABLE_BOUNDS
2402 std::cout <<
">>> division part 2: " << resB << std::endl;
2404 resB = carl::set_intersection(resB, subVarInterval );
2405 #ifdef VS_DEBUG_VARIABLE_BOUNDS
2406 std::cout <<
">>> intersection part 1: " << resB << std::endl;
2408 if( !resB.is_empty() )
2409 result.push_back( resB );
2416 _conflictReason.insert( conflictBounds.begin(), conflictBounds.end() );
2425 #ifdef VS_DEBUG_ROOTS_CHECK
2426 std::cout << __func__ <<
": " << _condition->
constraint() << std::endl;
2428 assert(
index() != carl::Variable::NO_VARIABLE );
2431 if( cons.lhs().is_univariate() )
2434 smtrat::Rational cb = carl::cauchyBound(carl::to_univariate_polynomial(cons.lhs()));
2435 #ifdef VS_DEBUG_ROOTS_CHECK
2436 std::cout <<
"Cauchy bound of " << cons.lhs() <<
" is " << cb <<
"." << std::endl;
2439 varDomain = carl::set_intersection(varDomain, cbInterval );
2440 #ifdef VS_DEBUG_ROOTS_CHECK
2441 std::cout << varDomain << std::endl;
2443 intervals[
index()] = varDomain;
2447 carl::Relation rel = cons.relation();
2448 if( rel == carl::Relation::GREATER || rel == carl::Relation::LESS || rel == carl::Relation::NEQ )
2450 auto indexDomain = intervals.find(
index() );
2451 if( indexDomain->second.lower_bound_type() == carl::BoundType::STRICT )
2452 indexDomain->second.set_lower_bound_type( carl::BoundType::WEAK );
2457 #ifdef VS_DEBUG_ROOTS_CHECK
2458 std::cout <<
"solutionSpace: " <<
solutionSpace << std::endl;
2462 if( _useSturmSequence && cons.variables().size() == 1 )
2464 carl::UnivariatePolynomial<smtrat::Rational> rup = carl::to_univariate_polynomial(cons.lhs());
2465 auto seq = carl::sturm_sequence(rup);
2466 smtrat::Rational leftBound = carl::rationalize<smtrat::Rational>( intervals.begin()->second.lower() );
2467 smtrat::Rational rightBound = carl::rationalize<smtrat::Rational>( intervals.begin()->second.upper() );
2469 int numberOfRoots = carl::count_real_roots( seq, interv );
2470 assert(
index() != carl::Variable::NO_VARIABLE );
2473 if( imageOfLeftBound ==
Rational(0) )
2475 if( imageOfRightBound ==
Rational(0) )
2477 if( intervals.begin()->second.upper_bound_type() == carl::BoundType::STRICT && numberOfRoots != 0 )
2479 if( intervals.begin()->second.upper_bound_type() == carl::BoundType::WEAK )
2482 #ifdef VS_DEBUG_ROOTS_CHECK
2483 std::cout <<
"Image of left bound : " << imageOfLeftBound << std::endl;
2484 std::cout <<
"Image of right bound : " << imageOfRightBound << std::endl;
2485 std::cout <<
"Number of roots according sturm sequence: " << numberOfRoots << std::endl;
2487 bool constraintInconsistent =
false;
2488 if( numberOfRoots == 0 )
2491 constraintInconsistent =
true;
2492 else if( imageOfLeftBound > 0 && (cons.relation() == carl::Relation::LESS || cons.relation() == carl::Relation::LEQ) )
2493 constraintInconsistent =
true;
2494 else if( imageOfLeftBound < 0 && (cons.relation() == carl::Relation::GREATER || cons.relation() == carl::Relation::GEQ) )
2495 constraintInconsistent =
true;
2497 else if( numberOfRoots == 1 )
2499 if( imageOfLeftBound >
Rational(0) && imageOfRightBound >
Rational(0) && cons.relation() == carl::Relation::LESS )
2500 constraintInconsistent =
true;
2501 if( imageOfLeftBound <
Rational(0) && imageOfRightBound <
Rational(0) && cons.relation() == carl::Relation::GREATER )
2502 constraintInconsistent =
true;
2504 if( constraintInconsistent )
2506 carl::PointerSet<Condition> origins;
2507 origins.insert( _condition );
2509 origins.insert( conflictingBounds.begin(), conflictingBounds.end() );
2511 conflicts.insert( std::move(origins) );
2514 #ifdef VS_DEBUG_ROOTS_CHECK
2515 std::cout <<
" -> false (1)" << std::endl;
2519 if( numberOfRoots > 0 )
2521 #ifdef VS_DEBUG_ROOTS_CHECK
2522 std::cout <<
" -> true (1)" << std::endl;
2529 #ifdef VS_DEBUG_ROOTS_CHECK
2530 std::cout <<
" -> true (3)" << std::endl;
2535 bool constraintInconsistent =
false;
2537 constraintInconsistent =
true;
2538 else if(
solutionSpace.lower() > 0 && cons.relation() == carl::Relation::LEQ )
2539 constraintInconsistent =
true;
2540 else if(
solutionSpace.upper() < 0 && cons.relation() == carl::Relation::GEQ )
2541 constraintInconsistent =
true;
2542 else if(
solutionSpace.lower() >= 0 && cons.relation() == carl::Relation::LESS )
2543 constraintInconsistent =
true;
2544 else if(
solutionSpace.upper() <= 0 && cons.relation() == carl::Relation::GREATER )
2545 constraintInconsistent =
true;
2546 carl::PointerSet<Condition> origins;
2547 origins.insert( _condition );
2549 origins.insert( conflictingBounds.begin(), conflictingBounds.end() );
2551 conflicts.insert( std::move(origins) );
2553 if( !constraintInconsistent )
2556 constraints.insert( _condition->
constraint() );
2557 carl::PointerSet<Condition> subsOrigins;
2558 subsOrigins.insert( _condition );
2562 #ifdef VS_DEBUG_ROOTS_CHECK
2563 std::cout <<
" -> false (2)" << std::endl;
2568 #ifdef VS_STATE_DEBUG_METHODS
2570 void State::print(
const std::string _initiation, std::ostream& _out )
const
2573 _out << _initiation <<
" " <<
"Children:" << std::endl;
2576 (**child).print( _initiation +
" ", _out );
2577 else _out << _initiation <<
" no" << std::endl;
2582 _out << _initiation <<
" State: ( reference: " <<
this << std::endl;
2583 _out << _initiation <<
" valuation: " <<
valuation() << std::endl;
2584 _out << _initiation <<
" ID: " <<
mID << std::endl;
2588 _out << _initiation <<
" state type: COMBINE_SUBRESULTS" << std::endl;
2591 _out << _initiation <<
" state type: SUBSTITUTION_TO_APPLY" << std::endl;
2594 _out << _initiation <<
" state type: TEST_CANDIDATE_TO_GENERATE" << std::endl;
2597 _out << _initiation <<
" state type: Undefined" << std::endl;
2601 _out << _initiation <<
" hasRecentlyAddedConditions: yes" << std::endl;
2603 _out << _initiation <<
" hasRecentlyAddedConditions: no" << std::endl;
2605 _out << _initiation <<
" isInconsistent: yes" << std::endl;
2607 _out << _initiation <<
" isInconsistent: no" << std::endl;
2609 _out << _initiation <<
" cannotBeSolved: yes" << std::endl;
2611 _out << _initiation <<
" cannotBeSolved: no" << std::endl;
2613 _out << _initiation <<
" conditionsSimplified: yes" << std::endl;
2615 _out << _initiation <<
" conditionsSimplified: no" << std::endl;
2617 _out << _initiation <<
" subResultsSimplified: yes" << std::endl;
2619 _out << _initiation <<
" subResultsSimplified: no" << std::endl;
2621 _out << _initiation <<
" takeSubResultCombAgain: yes" << std::endl;
2623 _out << _initiation <<
" takeSubResultCombAgain: no" << std::endl;
2625 _out << _initiation <<
" tryToRefreshIndex: yes" << std::endl;
2627 _out << _initiation <<
" tryToRefreshIndex: no" << std::endl;
2629 _out << _initiation <<
" toHighDegree: yes" << std::endl;
2631 _out << _initiation <<
" toHighDegree: no" << std::endl;
2633 _out << _initiation <<
" markedAsDeleted: yes" << std::endl;
2635 _out << _initiation <<
" markedAsDeleted: no" << std::endl;
2638 _out << _initiation <<
" original condition: ";
2644 _out << _initiation <<
" infinity child: " <<
mpInfinityChild << std::endl;
2646 _out << _initiation <<
" index: " <<
index() <<
" " <<
index().type() <<
" )" << std::endl;
2650 _out << _initiation +
" " <<
"Substitution: ";
2654 _out << _initiation << std::endl;
2656 _out << _initiation << std::endl;
2660 _out << _initiation << std::endl;
2662 _out << _initiation << std::endl;
2668 _out << _initiation <<
"Condititons:" << std::endl;
2671 _out << _initiation <<
" ";
2672 if( _onlyAsConstraints )
2673 _out << (**cond).constraint();
2675 (**cond).print( _out );
2687 _out << _initiation <<
" [ ";
2689 _out << _initiation <<
" and [ ";
2690 for(
auto condConjunction = subResult->begin(); condConjunction != subResult->end(); ++condConjunction )
2692 if( condConjunction == subResult->begin() )
2695 _out << _initiation <<
" or ( ";
2697 for(
auto cond = condConjunction->first.begin(); cond != condConjunction->first.end(); ++cond )
2699 if( cond != condConjunction->first.begin() ) _out <<
" and ";
2700 std::cout << (*cond)->constraint();
2703 auto nextCondConjunction = condConjunction;
2704 ++nextCondConjunction;
2705 if( nextCondConjunction != subResult->end() ) _out << std::endl;
2707 _out <<
" ]" << std::endl;
2718 _out << _initiation <<
"Substitution result combination:" << std::endl;
2721 _out << _initiation <<
" ( ";
2722 for(
auto cond =
mpSubstitutionResults->at( subResComb->first ).at( subResComb->second ).first.begin();
2723 cond !=
mpSubstitutionResults->at( subResComb->first ).at( subResComb->second ).first.end(); ++cond )
2727 _out << (**cond).constraint();
2729 _out <<
" )" << std::endl;
2741 _out << _initiation <<
"Substitution result combination: ";
2743 _out <<
"(" << subResComb->first <<
", " << subResComb->second <<
") ";
2751 _out << _initiation <<
"Conflict sets: " << std::endl;
2754 if( conflictSet->first != NULL )
2755 conflictSet->first->print(
true,
true, _out, _initiation +
" " );
2757 _out << _initiation <<
" NULL" << std::endl;
2758 for(
auto condSetSet = conflictSet->second.begin(); condSetSet != conflictSet->second.end(); ++condSetSet )
2760 auto condSet = condSetSet->begin();
2761 if( condSet != condSetSet->end() )
2763 _out << _initiation <<
" {";
2764 auto cond = (*condSet).begin();
2765 if( cond != (*condSet).end() )
2768 _out << (**cond).constraint();
2769 _out <<
"]" <<
"_" << (**cond).valuation();
2771 while( cond != (*condSet).end() )
2774 _out << (**cond).constraint();
2775 _out <<
"]" <<
"_" << (**cond).valuation();
2783 while( condSet != condSetSet->end() )
2785 _out <<
"," << std::endl;
2786 _out << _initiation <<
" ";
2787 auto cond = (*condSet).begin();
2788 if( cond != (*condSet).end() )
2791 _out << (**cond).constraint();
2792 _out <<
"]" <<
"_" << (**cond).valuation();
2794 while( cond != (*condSet).end() )
2797 _out << (**cond).constraint();
2798 _out <<
"]" <<
"_" << (**cond).valuation();
2807 _out <<
" }" << std::endl;
2810 _out << _initiation <<
" {}" << std::endl;
2820 size_t greatestTreeDepth = 0;
2821 for(
auto conflictSet = _conflictSets.begin(); conflictSet != _conflictSets.end(); ++conflictSet )
2823 if( !conflictSet->empty() )
2826 size_t greatestTreeDepthConflictSet = 0;
2828 size_t numUncovCondsConflictSet = 0;
2829 auto bestConditionSet = conflictSet->begin();
2830 for(
auto conditionSet = conflictSet->begin(); conditionSet != conflictSet->end(); ++conditionSet )
2832 size_t numUncovCondsCondSet = 0;
2833 size_t greatestTreeDepthCondSet = 0;
2834 bool justEmptyOConds =
true;
2835 for(
auto condition = conditionSet->begin(); condition != conditionSet->end(); ++condition )
2837 if( _coveringSet.find( *condition ) == _coveringSet.end() )
2838 numUncovCondsCondSet++;
2839 assert( *condition != NULL );
2840 for(
auto oCond = (**condition).originalConditions().begin(); oCond != (**condition).originalConditions().end(); ++oCond )
2842 assert( *oCond != NULL );
2843 justEmptyOConds =
false;
2844 if( (**oCond).valuation() > greatestTreeDepthCondSet )
2845 greatestTreeDepthCondSet = (**oCond).valuation();
2848 if( justEmptyOConds )
2849 greatestTreeDepthCondSet = _currentTreeDepth - 1;
2850 if( conditionSet == conflictSet->begin() || (greatestTreeDepthCondSet < greatestTreeDepthConflictSet)
2851 || ((greatestTreeDepthCondSet == greatestTreeDepthConflictSet && numUncovCondsCondSet < numUncovCondsConflictSet)) )
2853 bestConditionSet = conditionSet;
2854 greatestTreeDepthConflictSet = greatestTreeDepthCondSet;
2855 numUncovCondsConflictSet = numUncovCondsCondSet;
2858 if( greatestTreeDepthConflictSet > greatestTreeDepth )
2859 greatestTreeDepth = greatestTreeDepthConflictSet;
2860 _coveringSet.insert( bestConditionSet->begin(), bestConditionSet->end() );
2863 return greatestTreeDepth;
#define SMTRAT_VALIDATION_ADD(channel, name, formula, consistent)
Class to manage the bounds of a variable.
void print(std::ostream &_out=std::cout, const std::string _init="", bool _printAllBounds=false) const
Prints the variable bounds.
const smtrat::EvalDoubleIntervalMap & getIntervalMap() const
Creates an interval map corresponding to the variable bounds.
unsigned removeBound(const ConstraintT &_constraint, const T &_origin)
Removes all effects the given constraint has on the variable bounds.
const carl::Interval< double > & getDoubleInterval(const carl::Variable &_var) const
Creates a double interval corresponding to the variable bounds of the given variable.
bool isConflicting() const
bool addBound(const ConstraintT &_constraint, const T &_origin)
Updates the variable bounds by the given constraint.
std::vector< T > getOriginsOfBounds(const carl::Variable &_var) const
const smtrat::ConstraintT & constraint() const
double valuate(const carl::Variable &, size_t, bool) const
Valuates the constraint according to a variable (it possibly not contains).
carl::PointerSet< Condition > * pOriginalConditions() const
size_t & rValuation() const
const carl::PointerSet< Condition > & originalConditions() const
void printSubstitutionResults(const std::string _initiation="***", std::ostream &_out=std::cout) const
Prints the substitution results of this state.
const std::list< State * > & children() const
bool hasSubstitutionResults() const
const Substitution * pSubstitution() const
ConditionList & rConditions()
bool refreshConditions(ValuationMap &_ranking)
Determines the condition vector corresponding to the current combination of the conjunctions of condi...
ConflictSets * mpConflictSets
Stores for each already considered and failed test candidate all conflicts which have been found for ...
bool hasFurtherUncheckedTestCandidates() const
Checks whether there exist more than one test candidate, which has still not been checked.
const smtrat::Rational & minIntTestCandidate() const
void printSubstitutionResultCombination(const std::string _initiation="***", std::ostream &_out=std::cout) const
Prints the combination of substitution results used in this state.
void resetCurrentRangeSize()
void deleteOriginsFromSubstitutionResults(carl::PointerSet< Condition > &_originsToDelete)
Deletes everything originated by the given conditions in the substitution results of this state.
SubResultCombination * mpSubResultCombination
The currently considered combination of conjunctions of constraints in the substitution result vector...
bool mMarkedAsDeleted
A flag indicating whether this state has already marked as deleted, which means that there is no need...
size_t mID
A unique id identifying this state.
smtrat::Rational mMinIntTestCanidate
bool mInconsistent
A flag that indicates whether this state is already inconsistent.
bool hasNoninvolvedCondition() const
Checks whether a condition exists, which was not involved in an elimination step.
size_t mValuation
A heuristically determined value stating the expected difficulty of this state's considered condition...
bool mSubResultsSimplified
A flag indicating whether the substitution results this state are simplified.
bool mHasRecentlyAddedConditions
A flag that indicates whether this state has conditions in its considered list of conditions,...
unsigned treeDepth() const
smtrat::Rational mMaxIntTestCanidate
std::list< State * > & rChildren()
void printConflictSets(const std::string _initiation="***", std::ostream &_out=std::cout) const
Prints the conflict sets of this state.
void variables(carl::Variables &_variables) const
Finds the variables, which occur in this state.
const SubResultCombination & subResultCombination() const
void updateBackendCallValuation()
Valuates the state's currently considered conditions according to a backend call.
bool hasChildWithID() const
Checks whether a child exists, which has no ID (!=0).
void setIndex(const carl::Variable &_index)
Sets the index of this state.
std::vector< size_t > mBestVarVals
std::vector< std::pair< unsigned, unsigned > > SubResultCombination
SubstitutionResults * mpSubstitutionResults
The vector storing the substitution results, that is for each application of the substitution in this...
bool hasLocalConflict()
Checks whether the currently considered conditions, which have been considered for test candidate con...
bool unfinishedAncestor(State *&_unfinAnt)
Determines (if it exists) a ancestor node, which is unfinished, that is it has still substitution res...
static void removeStatesFromRanking(const State &toRemove, ValuationMap &_ranking)
Type mType
The type of this state, which states whether this state has still a substitution to apply or either t...
bool mTryToRefreshIndex
A flag indicating whether the index (the variable to eliminate in this state) should be reconsidered ...
void simplify(ValuationMap &_ranking)
Cleans up all conditions in this state according to comparison between the corresponding constraints.
bool getNextIntTestCandidate(smtrat::Rational &_nextIntTestCandidate, size_t _maxIntRange)
bool & rTakeSubResultCombAgain()
SubResultCombination & rSubResultCombination()
bool mTakeSubResultCombAgain
A flag indicating whether to take the current combination of substitution results once again.
bool hasSubResultsCombination() const
bool nextSubResultCombination()
If the state contains a substitution result, which is a conjunction of disjunctions of conjunctions o...
carl::Variable::Arg index() const
void worstConstraintValuation(const std::vector< std::pair< carl::Variable, std::multiset< double >>> &_varVals)
bool conditionsSimplified() const
const ConflictSets & conflictSets() const
ConditionList getCurrentSubresultCombination() const
Gets the current substitution result combination as condition vector.
bool hasOnlyInconsistentChildren() const
Checks whether a child exists, which is not yet marked as inconsistent.
const smtrat::Rational & maxIntTestCandidate() const
const VariableBoundsCond & variableBounds() const
void printAlone(const std::string="***", std::ostream &_out=std::cout) const
Prints the conditions, the substitution and the substitution results of this state.
std::vector< std::pair< carl::Variable, std::multiset< double > > > mRealVarVals
void initConditionFlags()
Sets all flags of the conditions to true, if it contains the variable given by the states index.
bool & rMarkedAsDeleted()
bool extendSubResultCombination()
Extends the currently considered combination of conjunctions in the substitution results.
unsigned numberOfNodes() const
Determines the number of nodes in the tree with this state as root.
std::vector< SubstitutionResult > SubstitutionResults
State(carl::IDPool *_conditionIdAllocator, bool _withVariableBounds)
Constructs an empty state (no conditions yet) being the root (hence neither a substitution) of the st...
carl::IDPool * mpConditionIdAllocator
bool takeSubResultCombAgain() const
void bestConstraintValuation(const std::vector< std::pair< carl::Variable, std::multiset< double >>> &_varVals)
const Substitution & substitution() const
void deleteConditions(carl::PointerSet< Condition > &_conditionsToDelete, ValuationMap &_ranking)
Delete everything originated by the given conditions from the entire subtree with this state as root.
void resetCannotBeSolvedLazyFlags()
bool markedAsDeleted() const
void deleteOriginsFromConflictSets(carl::PointerSet< Condition > &_originsToDelete, bool _originsAreCurrentConditions)
Deletes everything originated by the given conditions in the conflict sets of this state.
bool updateIntTestCandidates()
carl::FastPointerMapB< Substitution, ConditionSetSetSet > ConflictSets
static size_t coveringSet(const ConditionSetSetSet &_conflictSets, carl::PointerSet< Condition > &_minCovSet, unsigned _currentTreeDepth)
Finds a covering set of a vector of sets of sets due to some heuristics.
std::vector< State * > addChild(const Substitution &_substitution)
Adds a state as child to this state with the given substitution.
void resetConflictSets()
Clears the conflict sets.
bool subResultsSimplified() const
ConditionList * mpConditions
The currently considered conditions of this state, for which the satisfiability must be checked.
void printConditions(const std::string _initiation="***", std::ostream &_out=std::cout, bool=false) const
Prints the conditions of this state.
const State & father() const
bool isInconsistent() const
size_t getNumberOfCurrentSubresultCombination() const
void updateValuation(bool _lazy)
Updates the valuation of this state.
const Condition * pOriginalCondition() const
bool bestCondition(const Condition *&_bestCondition, size_t _numberOfAllVariables, bool _preferEquation)
Determines the most adequate condition and in it the most adequate variable in the state to generate ...
bool containsState(const State *_state) const
std::vector< smtrat::DoubleInterval > solutionSpace(carl::PointerSet< Condition > &_conflictReason) const
Determines the solution space of the test candidate of this state regarding to the variable bounds of...
bool & rHasRecentlyAddedConditions()
size_t backendCallValuation() const
Substitution & rSubstitution()
carl::Variable mIndex
The variable which is going to be eliminated from this state's considered conditions.
SubstitutionResults & rSubstitutionResults()
void print(const std::string _initiation="***", std::ostream &_out=std::cout) const
Prints the conditions, the substitution and the substitution results of this state and all its childr...
void addConflictSet(const Substitution *_substitution, ConditionSetSet &&_condSetSet)
Adds a conflict set to the map of substitutions to conflict sets.
void addCondition(const smtrat::ConstraintT &_constraint, const carl::PointerSet< Condition > &_originalConditions, size_t _valutation, bool _recentlyAdded, ValuationMap &_ranking)
Adds a constraint to the conditions of this state.
Substitution * mpSubstitution
The substitution this state considers. Note that it is NULL if this state is the root.
void addSubstitutionResults(std::vector< DisjunctionOfConditionConjunctions > &&_disjunctionsOfCondConj)
Adds the given substitution results to this state.
bool tryToRefreshIndex() const
bool checkTestCandidatesForBounds()
Checks whether the test candidate of this state is valid against the variable intervals in the father...
bool occursInEquation(const carl::Variable &) const
Checks whether the given variable occurs in a equation.
bool updateOCondsOfSubstitutions(const Substitution &_substitution, std::vector< State * > &_reactivatedStates)
Updates the original conditions of substitutions having the same test candidate as the given.
carl::PointerSet< Condition > * mpTooHighDegreeConditions
The conditions of this state, which cannot be solved by the virtual substitution.
void passConflictToFather(bool _checkConflictForSideCondition, bool _useBackjumping=true, bool _includeInconsistentTestCandidates=false)
Passes the original conditions of the covering set of the conflicts of this state to its father.
void averageConstraintValuation(const std::vector< std::pair< carl::Variable, std::multiset< double >>> &_varVals)
bool substitutionApplicable() const
Checks if a substitution can be applied.
bool mConditionsSimplified
A flag indicating whether the conditions this state considers are simplified.
bool mTestCandidateCheckedForBounds
A flag indicating whether the test candidate contained by this state has already been check for the b...
void addConflicts(const Substitution *_substitution, ConditionSetSet &&_condSetSet)
Adds all conflicts to all sets of the conflict set of the given substitution.
const SubstitutionResults & substitutionResults() const
std::list< State * > * mpChildren
The children states of this state.
void deleteOriginsFromChildren(carl::PointerSet< Condition > &_originsToDelete, ValuationMap &_ranking)
Deletes everything originated by the given conditions in the children of this state.
int deleteOrigins(carl::PointerSet< Condition > &_originsToDelete, ValuationMap &_ranking)
Removes everything in this state originated by the given vector of conditions.
bool & rSubResultsSimplified()
bool checkSubresultCombinations() const
This is just for debug purpose.
ConditionList::iterator constraintExists(const smtrat::ConstraintT &_constraint)
Checks if the given constraint already exists as condition in the state.
bool initIndex(const carl::Variables &_allVariables, const smtrat::VariableValuationStrategy &_vvstrat, bool _preferEquation, bool _tryDifferentVarOrder=false, bool _useFixedVariableOrder=false)
Sets, if it has not already happened, the index of the state to the name of the most adequate variabl...
size_t mBackendCallValuation
A heuristically determined value stating the expected difficulty of this state's considered condition...
const Condition & originalCondition() const
bool hasRootsInVariableBounds(const Condition *_condition, bool _useSturmSequence)
Checks whether there are no zeros for the left-hand side of the constraint of the given condition.
void printSubstitutionResultCombinationAsNumbers(const std::string _initiation="***", std::ostream &_out=std::cout) const
Prints the combination of substitution results, expressed in numbers, used in this state.
bool hasRecentlyAddedConditions() const
const ConditionList & conditions() const
ConflictSets & rConflictSets()
@ TEST_CANDIDATE_TO_GENERATE
const carl::PointerSet< Condition > & tooHighDegreeConditions() const
bool cannotBeSolved(bool _lazy) const
bool mCannotBeSolved
A flag indicating whether this state has been progressed until a point where a condition must be invo...
bool allTestCandidatesInvalidated(const Condition *_condition) const
VariableBoundsCond * mpVariableBounds
A pointer to an object which manages and stores the bounds on the variables occurring in this state.
std::vector< std::pair< carl::Variable, std::multiset< double > > > mIntVarVals
const carl::Variables & termVariables() const
carl::PointerSet< Condition > & rOriginalConditions()
void print(bool _withOrigins=false, bool _withSideConditions=false, std::ostream &_out=std::cout, const std::string &_init="") const
Prints this substitution on the given stream, with some additional information.
const smtrat::SqrtEx & term() const
const smtrat::ConstraintsT & sideCondition() const
const carl::Variable & variable() const
const carl::PointerSet< Condition > & originalConditions() const
unsigned valuate(bool _preferMinusInf=true) const
const Type & type() const
static bool find(V &ts, const T &t)
Rational evaluate(carl::Variable v, const Poly &p, const Rational &r)
std::vector< carl::Variable > vars(const std::pair< QuantifierType, std::vector< carl::Variable >> &p)
std::pair< size_t, std::pair< size_t, size_t > > UnsignedTriple
std::set< ConditionSetSet > ConditionSetSetSet
std::list< const Condition * > ConditionList
std::set< carl::PointerSet< Condition > > ConditionSetSet
std::map< UnsignedTriple, vs::State *, unsignedTripleCmp > ValuationMap
Class to create the formulas for axioms.
carl::Constraints< Poly > ConstraintsT
VariableValuationStrategy
carl::Interval< double > DoubleInterval
carl::Interval< Rational > RationalInterval
carl::Constraint< Poly > ConstraintT
std::map< carl::Variable, DoubleInterval > EvalDoubleIntervalMap