Skip to content
Merged
Show file tree
Hide file tree
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
40 changes: 36 additions & 4 deletions copilot-verifier/src/Copilot/Verifier.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import qualified Data.BitVector.Sized as BV
import GHC.Generics (Generic)
import qualified Prettyprinter as PP
import System.Exit (exitFailure)
import System.FilePath ((</>))
import System.FilePath ((</>), (<.>))

import Copilot.Compile.C99 (CSettings(..), compileWith)
import Copilot.Core
Expand Down Expand Up @@ -177,17 +177,37 @@ data VerifierOptions = VerifierOptions
-- to partial operations in the Copilot specification. As a result, any
-- use of a partial operation in the generated C code will cause
-- verification to fail unless the user adds their own assumptions.
, logSmtInteractions :: Bool
-- ^ If 'True', create log files corresponding to the SMT solver
-- interactions used to discharge each proof goal. The file will be named
-- @<step>-<goal number>-<solver>.smt2@, where:
--
-- * @<step>@ will be either @initial-step@ or @transition-step@, depending
-- on which step of the proof the goal corresponds to.
--
-- * @<goal number>@ will be the number of the goal, starting at 0 and
-- counting up. Note that each step of the proof has its own goal
-- numbers. This means that there can be both an
-- @initial-step-0-<solver>.smt2@ and a @transition-step-0-<solver>.smt2@,
-- and similarly for other numbers.
--
-- * @<solver>@ is the name of the SMT solver used to discharge the proof
-- goal. Currently, this will always be @z3@, although we might make this
-- configurable in the future.
} deriving stock Show

-- | The default 'VerifierOptions':
--
-- * Produce diagnostics as verification proceeds ('Noisy').
--
-- * Do not assume any side conditions related to partial operations.
--
-- * Do not log any SMT solver interactions.
defaultVerifierOptions :: VerifierOptions
defaultVerifierOptions = VerifierOptions
{ verbosity = Noisy
, assumePartialSideConds = False
, logSmtInteractions = False
}

-- | Like 'defaultVerifierOptions', except that the verifier will assume side
Expand Down Expand Up @@ -336,13 +356,25 @@ verifyBitcode opts csettings properties spec cruxOpts llvmOpts bcFile =

-- First check that the initial state of the program matches the starting
-- segment of the associated Copilot streams.
verifyInitialState cruxOpts adapters bbMapRef simctx initialMem
let cruxOptsInit = setCruxOfflineSolverOutput "initial-step" cruxOpts
verifyInitialState cruxOptsInit adapters bbMapRef simctx initialMem
(CW4.initialStreamState proofStateBundle)

-- Now, the real meat. Carry out the bisimulation step of the proof.
verifyStepBisimulation opts cruxOpts adapters csettings
let cruxOptsTrans = setCruxOfflineSolverOutput "transition-step" cruxOpts
verifyStepBisimulation opts cruxOptsTrans adapters csettings
bbMapRef simctx llvmMod trans memVar initialMem proofStateBundle

where
-- If @logSmtInteractions@ is enabled, enable offline solver output in the
-- supplied 'CruxOptions' with the supplied file template. Otherwise, return
-- the supplied 'CruxOptions' unaltered.
setCruxOfflineSolverOutput :: FilePath -> CruxOptions -> CruxOptions
setCruxOfflineSolverOutput template cruxOpts'
| logSmtInteractions opts
= cruxOpts'
{ offlineSolverOutput = Just $ outDir cruxOpts' </> template <.> "smt2" }
| otherwise
= cruxOpts'

-- | Prove that the state of the global variables at program startup
-- matches the expected initial segments of the associated Copilot
Expand Down
2 changes: 1 addition & 1 deletion deps/crucible
Submodule crucible updated 52 files
+1 −0 cabal.project
+4 −2 crucible-concurrency/src/Cruces/CrucesMain.hs
+2 −3 crucible-concurrency/src/Cruces/ExploreCrux.hs
+14 −15 crucible-concurrency/src/Crucibles/Explore.hs
+12 −10 crucible-concurrency/src/Crucibles/Primitives.hs
+3 −0 crucible-llvm/CHANGELOG.md
+9 −5 crucible-llvm/doc/limitations.md
+9 −0 crucible-llvm/src/Lang/Crucible/LLVM/Intrinsics.hs
+23 −16 crucible-llvm/src/Lang/Crucible/LLVM/Intrinsics/Common.hs
+92 −0 crucible-llvm/src/Lang/Crucible/LLVM/Intrinsics/LLVM.hs
+2 −1 crucible-llvm/src/Lang/Crucible/LLVM/Intrinsics/Libc.hs
+45 −22 crucible-llvm/src/Lang/Crucible/LLVM/Printf.hs
+3 −0 crucible-mir/CHANGELOG.md
+30 −0 crucible-mir/LICENSE
+6 −0 crucible-mir/README.md
+56 −0 crucible-mir/crucible-mir.cabal
+0 −0 crucible-mir/src/Mir/DefId.hs
+0 −0 crucible-mir/src/Mir/FancyMuxTree.hs
+0 −0 crucible-mir/src/Mir/Generator.hs
+0 −0 crucible-mir/src/Mir/GenericOps.hs
+0 −0 crucible-mir/src/Mir/Intrinsics.hs
+4 −8 crucible-mir/src/Mir/JSON.hs
+0 −0 crucible-mir/src/Mir/Mir.hs
+2 −2 crucible-mir/src/Mir/PP.hs
+76 −0 crucible-mir/src/Mir/ParseTranslate.hs
+3 −10 crucible-mir/src/Mir/Pass.hs
+3 −8 crucible-mir/src/Mir/Pass/AllocateEnum.hs
+0 −0 crucible-mir/src/Mir/Trans.hs
+4 −14 crucible-mir/src/Mir/TransCustom.hs
+9 −14 crucible-mir/src/Mir/TransTy.hs
+5 −2 crucible-syntax/CHANGELOG.md
+16 −0 crucible-syntax/README.txt
+2 −1 crucible-syntax/src/Lang/Crucible/Syntax/Atoms.hs
+85 −58 crucible-syntax/src/Lang/Crucible/Syntax/Concrete.hs
+21 −2 crucible-syntax/src/Lang/Crucible/Syntax/Prog.hs
+7 −0 crucible-syntax/test-data/extern-tests/main.cbl
+4 −0 crucible-syntax/test-data/extern-tests/main.out.good
+33 −0 crucible-syntax/test/Tests.hs
+10 −1 crux-llvm/src/Crux/LLVM/Compile.hs
+1 −0 crux-llvm/test-data/golden/golden/T974.at-least-clang12.z3.good
+58 −0 crux-llvm/test-data/golden/golden/T974.c.orig
+148 −0 crux-llvm/test-data/golden/golden/T974.ll
+45 −44 crux-llvm/test-data/golden/golden/invoke-test.at-least-clang12.z3.good
+18 −0 crux-mir/CHANGELOG.md
+3 −28 crux-mir/crux-mir.cabal
+1 −8 crux-mir/src/Mir/Concurrency.hs
+6 −64 crux-mir/src/Mir/Generate.hs
+2 −1 crux-mir/src/Mir/Language.hs
+7 −27 crux-mir/src/Mir/Overrides.hs
+21 −1 crux/src/Crux/Config/Common.hs
+33 −6 crux/src/Crux/Goal.hs
+1 −0 uc-crux-llvm/test/Utils.hs