Skip to content

Retry SMT queries in Booster when deciding predicates #3889

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

Merged
merged 54 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
2c8b6b5
Print reason unknown in error message
geo2a May 22, 2024
e8b8b1f
Factor-out SMT prelude execution
geo2a May 22, 2024
4069659
Factor-out initSolver
geo2a May 22, 2024
8d62232
Refactor fail on unknown
geo2a May 23, 2024
486fdba
Use StateT in SMT
geo2a May 23, 2024
0dd79f5
Factor-out interctWithSolver
geo2a May 23, 2024
4f583b5
Add function to retry SMT query once
geo2a May 23, 2024
a7a7979
Add function to reinitialise solver
geo2a May 23, 2024
4f2ccca
Retry SMT query once when deciding predicates
geo2a May 23, 2024
4e42aed
Remove spurious where
geo2a May 23, 2024
cfe7424
Check prelude using default SMT timeout
geo2a May 27, 2024
5f85d23
Refactor getModel to be more like checkPredicates
geo2a May 27, 2024
c7de816
Add type signatures in checkPredicates
geo2a May 28, 2024
9e63720
Further refactoring in getModelFor
geo2a May 28, 2024
3f440b3
Factor-out extractModel
geo2a May 28, 2024
92d2910
Reinitialise solver once in gerModelFor
geo2a May 28, 2024
00282e3
Rename reinitSolver to restartSolver
geo2a May 28, 2024
d93e32a
Store prelude in SMTContext
geo2a May 28, 2024
b162f6a
Log setting when starting solver, add comment
geo2a May 28, 2024
8f5bd13
Rename closeSolver to finaliseSolver
geo2a May 28, 2024
73c00ca
Use closeContext in restartSolver, tweak logs
geo2a May 28, 2024
c804414
Add result log message
geo2a May 28, 2024
636f805
Remove obsolete comments, redundant code
geo2a May 28, 2024
fd790e8
Consolidate SMT context handling
geo2a May 28, 2024
ef570ed
Fix imports
geo2a May 28, 2024
c788a13
Fix unit tests
geo2a May 28, 2024
ef45a51
Only close the solver transcript in the very end
geo2a May 28, 2024
730c411
Close server permanently
geo2a May 29, 2024
91b9792
Retry when checking predicates
geo2a May 29, 2024
7b9c8e6
Move SMTOptions to SMT.Runner
geo2a May 29, 2024
f6ea277
Add missing import
geo2a May 29, 2024
01777a4
Store solver options in solver context
geo2a May 29, 2024
7897518
Fix unit tests
geo2a May 29, 2024
f0a8d83
Format with fourmolu
invalid-email-address May 29, 2024
a5d8ae7
Add integration test with non-linear constraint
geo2a May 29, 2024
d070611
Add kompile file and run with booster-dev
geo2a May 29, 2024
ca79544
Propagate Nothing in checkPredicates
geo2a May 29, 2024
5ede3d6
Add comment
geo2a May 29, 2024
1d5d78a
Do not hard-reset the solver when updating timeout
geo2a May 29, 2024
b22c9f8
Only declare variables once
geo2a May 29, 2024
72d786e
Paranoically hard-reset the solver
geo2a May 29, 2024
9b81bf1
Prepare to merge master
geo2a May 31, 2024
72311db
Merge remote-tracking branch 'origin/master' into georgy-retry-smt-in…
geo2a May 31, 2024
3f17f82
Remove logs at `LevelOther "Simplify"`
geo2a May 31, 2024
0026a66
Revert "Remove logs at `LevelOther "Simplify"`"
geo2a May 31, 2024
e867eed
Wait for server to stop before diffing output
geo2a Jun 3, 2024
dade038
Add comments
geo2a Jun 3, 2024
b1d8db9
Throw pure exception in checkPredicates.interactWithSolver
geo2a Jun 3, 2024
c87d846
Refactor `interactWithSolver` in `getModelFor`
geo2a Jun 3, 2024
a11ac63
Merge branch 'master' into georgy-retry-smt-in-booster
rv-jenkins Jun 3, 2024
046f7f2
Report solver close in SMT transcript
geo2a Jun 4, 2024
234e4b1
Pretty-print json response
geo2a Jun 4, 2024
501aea8
Merge branch 'master' into georgy-retry-smt-in-booster
geo2a Jun 4, 2024
771be73
Merge branch 'master' into georgy-retry-smt-in-booster
rv-jenkins Jun 4, 2024
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
19 changes: 10 additions & 9 deletions booster/library/Booster/JsonRpc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module Booster.JsonRpc (

import Control.Applicative ((<|>))
import Control.Concurrent (MVar, putMVar, readMVar, takeMVar)
import Control.Exception qualified as Exception
import Control.Monad
import Control.Monad.Extra (whenJust)
import Control.Monad.IO.Class
Expand Down Expand Up @@ -148,7 +149,7 @@ respond stateVar =
solver <- traverse (SMT.initSolver def) mSMTOptions
result <-
performRewrite doTracing def mLlvmLibrary solver mbDepth cutPoints terminals substPat
whenJust solver SMT.closeSolver
whenJust solver SMT.finaliseSolver
stop <- liftIO $ getTime Monotonic
let duration =
if fromMaybe False req.logTiming
Expand Down Expand Up @@ -309,7 +310,7 @@ respond stateVar =
pure $ Right (addHeader $ Syntax.KJAnd predicateSort result)
(Left something, _) ->
pure . Left . RpcError.backendError $ RpcError.Aborted $ renderText $ pretty something
whenJust solver SMT.closeSolver
whenJust solver SMT.finaliseSolver
stop <- liftIO $ getTime Monotonic

let duration =
Expand Down Expand Up @@ -389,12 +390,12 @@ respond stateVar =
"No predicates or substitutions given, returning Unknown"
pure $ Left SMT.Unknown
else do
solver <-
SMT.initSolver def smtOptions
smtResult <-
SMT.getModelFor solver boolPs suppliedSubst
SMT.closeSolver solver
pure smtResult
solver <- SMT.initSolver def smtOptions
result <- SMT.getModelFor solver boolPs suppliedSubst
SMT.finaliseSolver solver
case result of
Left err -> liftIO $ Exception.throw err -- fail hard on SMT errors
Right response -> pure response
Log.logOtherNS "booster" (Log.LevelOther "SMT") $
"SMT result: " <> pack (either show (("Subst: " <>) . show . Map.size) smtResult)
pure . Right . RpcTypes.GetModel $ case smtResult of
Expand Down Expand Up @@ -573,7 +574,7 @@ handleSmtError = JsonRpcHandler $ \case
SMT.GeneralSMTError err -> runtimeError "problem" err
SMT.SMTTranslationError err -> runtimeError "translation" err
SMT.SMTSolverUnknown reason premises preds -> do
Log.logErrorNS "booster" "SMT returned `Unknown'"
Log.logErrorNS "booster" ("SMT returned `Unknown' with reason " <> reason)

let bool = externaliseSort Pattern.SortBool -- predicates are terms of sort Bool
externalise = Syntax.KJAnd bool . map (externalisePredicate bool) . Set.toList
Expand Down
Loading
Loading