Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HOTFIX abort rewrite when SMT solver times out #4078

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions booster/library/Booster/Pattern/Rewrite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -590,15 +590,18 @@ applyRule pat@Pattern{ceilConditions} rule =
-- check unclear requires-clauses in the context of known constraints (priorKnowledge)
solver <- lift $ RewriteT $ (.smtSolver) <$> ask
SMT.checkPredicates solver pat.constraints pat.substitution (Set.fromList stillUnclear) >>= \case
SMT.IsUnknown reason -> do
withContext CtxWarn $ logMessage reason
-- return unclear rewrite rule condition if the condition is indeterminate
withContext CtxConstraint . withContext CtxWarn . logMessage $
SMT.IsUnknown SMT.ImplicationIndeterminate -> do
-- return unclear conditions if SMT solver reports the condition indeterminate
withContexts [CtxConstraint, CtxSMT] . logMessage $
WithJsonMessage (object ["conditions" .= (externaliseTerm . coerce <$> stillUnclear)]) $
renderOneLineText $
"Uncertain about condition(s) in a rule:"
"Indeterminate condition(s) after SMT solver:"
<+> (hsep . punctuate comma . map (pretty' @mods) $ stillUnclear)
pure unclearRequires
pure stillUnclear
SMT.IsUnknown reason -> do
-- abort on unclear predicates due to SMT solver timeout or inconsistent ground truth
withContexts [CtxConstraint, CtxSMT, CtxWarn] $ logMessage reason
smtUnclear stillUnclear
SMT.IsInvalid -> do
-- requires is actually false given the prior
withContext CtxFailure $ logMessage ("Required clauses evaluated to #Bottom." :: Text)
Expand Down Expand Up @@ -649,7 +652,7 @@ applyRule pat@Pattern{ceilConditions} rule =

pure newConstraints

smtUnclear :: [Predicate] -> RewriteRuleAppT (RewriteT io) ()
smtUnclear :: [Predicate] -> RewriteRuleAppT (RewriteT io) a
smtUnclear predicates = do
ModifiersRep (_ :: FromModifiersT mods => Proxy mods) <- getPrettyModifiers
withContext CtxConstraint . withContext CtxAbort . logMessage $
Expand Down
Loading