Skip to content

Commit

Permalink
Do not fail on Unknown pattern constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
geo2a committed Aug 1, 2024
1 parent 7501ba3 commit 1b82c66
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions booster/library/Booster/Pattern/ApplyEquations.hs
Original file line number Diff line number Diff line change
Expand Up @@ -444,19 +444,26 @@ evaluatePattern' pat@Pattern{term, ceilConditions} = withPatternContext pat $ do
throw . SideConditionFalse . collapseAndBools $ pat.constraints
Left unknwon@SMT.SMTSolverUnknown{} -> do
-- unlikely case of an Unknown response to a consistency check.
-- What to do here? fail hard for now.
liftIO $ Exception.throw unknwon
Left other -> liftIO $ Exception.throw other -- fail hard on other SMT errors
-- What to do here? continue for now to preserver the old behaviour.
withPatternContext pat . logWarn . Text.pack $
"Constraints consistency check returns: " <> show unknwon
continue
Left other ->
-- fail hard on SMT error other than @SMT.SMTSolverUnknown@
liftIO $ Exception.throw other
Right True -> do
-- constrains are consistent, continue
newTerm <- withTermContext term $ evaluateTerm' BottomUp term `catch_` keepTopLevelResults
-- after evaluating the term, evaluate all (existing and
-- newly-acquired) constraints, once
traverse_ simplifyAssumedPredicate . predicates =<< getState
-- this may yield additional new constraints, left unevaluated
evaluatedConstraints <- predicates <$> getState
pure Pattern{constraints = evaluatedConstraints, term = newTerm, ceilConditions}
continue
where
continue = do
newTerm <- withTermContext term $ evaluateTerm' BottomUp term `catch_` keepTopLevelResults
-- after evaluating the term, evaluate all (existing and
-- newly-acquired) constraints, once
traverse_ simplifyAssumedPredicate . predicates =<< getState
-- this may yield additional new constraints, left unevaluated
evaluatedConstraints <- predicates <$> getState
pure Pattern{constraints = evaluatedConstraints, term = newTerm, ceilConditions}

-- when TooManyIterations exception occurred while evaluating the top-level term,
-- i.e. not in a recursive evaluation of a side-condition,
-- it is safe to keep the partial result and ignore the exception.
Expand Down

0 comments on commit 1b82c66

Please sign in to comment.