@@ -50,6 +50,7 @@ import qualified Copilot.Core.Type as CT
5050import qualified Copilot.Theorem.What4 as CW4
5151
5252import qualified Copilot.Verifier.Log as Log
53+ import qualified Copilot.Verifier.Solver as Solver
5354
5455import Data.Parameterized.Ctx (EmptyCtx )
5556import Data.Parameterized.Context (pattern Empty )
@@ -160,7 +161,6 @@ import What4.InterpretedFloatingPoint
160161 )
161162import What4.ProgramLoc (ProgramLoc , mkProgramLoc , plFunction , Position (.. ))
162163import What4.Solver.Adapter (SolverAdapter (.. ))
163- import What4.Solver.Z3 (z3Adapter )
164164import What4.Symbol (safeSymbol )
165165
166166-- | @'verify' csettings props prefix spec@ verifies the Copilot specification
@@ -202,6 +202,8 @@ data VerifierOptions = VerifierOptions
202202 -- * @<solver>@ is the name of the SMT solver used to discharge the proof
203203 -- goal. Currently, this will always be @z3@, although we might make this
204204 -- configurable in the future.
205+ , smtSolver :: Solver. Solver
206+ -- ^ Which SMT solver to use when solving proof goals.
205207 } deriving stock Show
206208
207209-- | The default 'VerifierOptions':
@@ -212,11 +214,14 @@ data VerifierOptions = VerifierOptions
212214-- * Do not assume any side conditions related to partial operations.
213215--
214216-- * Do not log any SMT solver interactions.
217+ --
218+ -- * Use the Z3 SMT solver.
215219defaultVerifierOptions :: VerifierOptions
216220defaultVerifierOptions = VerifierOptions
217221 { verbosity = Default
218222 , assumePartialSideConds = False
219223 , logSmtInteractions = False
224+ , smtSolver = Solver. Z3
220225 }
221226
222227-- | Like 'defaultVerifierOptions', except that the verifier will assume side
@@ -332,7 +337,8 @@ verifyBitcode ::
332337verifyBitcode opts csettings properties spec cruxOpts llvmOpts cFile bcFile =
333338 do -- Set up the expression builder and symbolic backend
334339 halloc <- newHandleAllocator
335- sym <- newExprBuilder FloatUninterpretedRepr CopilotVerifierData globalNonceGenerator
340+ (sym :: ExprBuilder t st fs ) <-
341+ newExprBuilder FloatUninterpretedRepr CopilotVerifierData globalNonceGenerator
336342 bak <- newSimpleBackend sym
337343 -- turn on hash-consing
338344 startCaching sym
@@ -341,9 +347,10 @@ verifyBitcode opts csettings properties spec cruxOpts llvmOpts cFile bcFile =
341347 clRefs <- newCopilotLogRefs
342348 let ? recordLLVMAnnotation = recordLLVMAnnotation clRefs
343349
344- -- Set up the solver to use for verification. Right now we hard-code this to Z3.
345- let adapters = [z3Adapter] -- TODO? configurable
346- extendConfig (solver_adapter_config_options z3Adapter) (getConfiguration sym)
350+ -- Set up the solver to use for verification.
351+ let adapter :: SolverAdapter st
352+ adapter = Solver. solverAdapter (smtSolver opts)
353+ extendConfig (solver_adapter_config_options adapter) (getConfiguration sym)
347354
348355 -- Set up the Crucible/LLVM simulation context
349356 memVar <- mkMemVar " llvm_memory" halloc
@@ -386,13 +393,13 @@ verifyBitcode opts csettings properties spec cruxOpts llvmOpts cFile bcFile =
386393 -- segment of the associated Copilot streams.
387394 let cruxOptsInit = setCruxOfflineSolverOutput " initial-step" cruxOpts
388395 initGoals <-
389- verifyInitialState cruxOptsInit adapters clRefs simctx initialMem
396+ verifyInitialState cruxOptsInit [adapter] clRefs simctx initialMem
390397 (CW4. initialStreamState proofStateBundle)
391398
392399 -- Now, the real meat. Carry out the bisimulation step of the proof.
393400 let cruxOptsTrans = setCruxOfflineSolverOutput " transition-step" cruxOpts
394401 bisimGoals <-
395- verifyStepBisimulation opts cruxOptsTrans adapters csettings
402+ verifyStepBisimulation opts cruxOptsTrans [adapter] csettings
396403 clRefs simctx llvmMod trans memVar initialMem proofStateBundle
397404
398405 Log. sayCopilot $ Log. SuccessfulProofSummary cFile initGoals bisimGoals
0 commit comments