| 38 | } |
| 39 | |
| 40 | bool Checker::checkNode( const UnsatCertificateNode *node ) |
| 41 | { |
| 42 | Vector<double> groundUpperBoundsBackup( _groundUpperBounds ); |
| 43 | Vector<double> groundLowerBoundsBackup( _groundLowerBounds ); |
| 44 | |
| 45 | _upperBoundChanges.push( {} ); |
| 46 | _lowerBoundChanges.push( {} ); |
| 47 | |
| 48 | // Update ground bounds according to head split |
| 49 | for ( const auto &tightening : node->getSplit().getBoundTightenings() ) |
| 50 | { |
| 51 | auto &temp = tightening._type == Tightening::UB ? _groundUpperBounds : _groundLowerBounds; |
| 52 | temp[tightening._variable] = tightening._value; |
| 53 | |
| 54 | tightening._type == Tightening::UB |
| 55 | ? _upperBoundChanges.top().insert( tightening._variable ) |
| 56 | : _lowerBoundChanges.top().insert( tightening._variable ); |
| 57 | } |
| 58 | |
| 59 | // Check all PLC bound propagations |
| 60 | if ( !checkAllPLCExplanations( node, GlobalConfiguration::LEMMA_CERTIFICATION_TOLERANCE ) ) |
| 61 | return false; |
| 62 | |
| 63 | // Save to file if marked |
| 64 | if ( node->getDelegationStatus() == DelegationStatus::DELEGATE_SAVE ) |
| 65 | writeToFile(); |
| 66 | |
| 67 | // Skip if leaf has the SAT solution, or if was marked to delegate |
| 68 | if ( node->getSATSolutionFlag() || |
| 69 | node->getDelegationStatus() != DelegationStatus::DONT_DELEGATE ) |
| 70 | return true; |
| 71 | |
| 72 | // Check if it is a leaf, and if so use contradiction to check |
| 73 | // return true iff it is certified |
| 74 | if ( node->isValidLeaf() ) |
| 75 | return checkContradiction( node ); |
| 76 | |
| 77 | // If not a valid leaf, skip only if it is leaf that was not visited |
| 78 | if ( !node->getVisited() && !node->getContradiction() && node->getChildren().empty() ) |
| 79 | return true; |
| 80 | |
| 81 | // Otherwise, should be a valid non-leaf node |
| 82 | if ( !node->isValidNonLeaf() ) |
| 83 | return false; |
| 84 | |
| 85 | // If so, check all children and return true iff all children are certified |
| 86 | // Also make sure that they are split correctly (i.e by ReLU constraint or by a single var) |
| 87 | bool answer = true; |
| 88 | List<PiecewiseLinearCaseSplit> childrenSplits; |
| 89 | |
| 90 | for ( const auto &child : node->getChildren() ) |
| 91 | childrenSplits.append( child->getSplit() ); |
| 92 | |
| 93 | PiecewiseLinearConstraint *childrenSplitConstraint = |
| 94 | getCorrespondingConstraint( childrenSplits ); |
| 95 | |
| 96 | if ( !checkSingleVarSplits( childrenSplits ) && !childrenSplitConstraint ) |
| 97 | return false; |
nothing calls this directly
no test coverage detected