-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic verification summary implementation (#767)
Implements the necessary plumbing to track everything verified within SAW and report a summary of it all after verification completes. It currently adds one experimental command, `summarize_verification`, which prints a summary of all `Theorem` or `*MethodSpec` values created along with various details about each. We should adapt the `SolverStats` tracking to include proofs done by rewriting and `trivial`, as well. Currently, proofs based entirely on rewriting are printed as axioms, which isn’t right.
- Loading branch information
Aaron Tomb
authored
Aug 18, 2020
1 parent
b8b4a63
commit 4d41587
Showing
9 changed files
with
157 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{- | | ||
Module : SAWScript.VerificationSummary | ||
Description : Summaries of verification for human consumption. | ||
License : BSD3 | ||
Maintainer : atomb | ||
-} | ||
|
||
module SAWScript.VerificationSummary | ||
( computeVerificationSummary | ||
, prettyVerificationSummary | ||
) where | ||
|
||
import Control.Lens | ||
import qualified Data.Set as Set | ||
import Data.String | ||
import Text.PrettyPrint.ANSI.Leijen | ||
|
||
import qualified Lang.Crucible.JVM as CJ | ||
import SAWScript.Crucible.Common.MethodSpec | ||
import qualified SAWScript.Crucible.Common.MethodSpec as CMS | ||
import qualified SAWScript.Crucible.LLVM.MethodSpecIR as CMSLLVM | ||
import qualified SAWScript.Crucible.JVM.MethodSpecIR as CMSJVM | ||
import SAWScript.Proof | ||
import SAWScript.Prover.SolverStats | ||
import qualified Verifier.SAW.Term.Pretty as PP | ||
|
||
type JVMTheorem = CMS.CrucibleMethodSpecIR CJ.JVM | ||
type LLVMTheorem = CMSLLVM.SomeLLVM CMS.CrucibleMethodSpecIR | ||
|
||
data VerificationSummary = | ||
VerificationSummary | ||
{ vsJVMMethodSpecs :: [JVMTheorem] | ||
, vsLLVMMethodSpecs :: [LLVMTheorem] | ||
, vsTheorems :: [Theorem] | ||
} | ||
|
||
vsVerifSolvers :: VerificationSummary -> Set.Set String | ||
vsVerifSolvers vs = | ||
Set.unions $ | ||
map (\ms -> solverStatsSolvers (ms ^. csSolverStats)) (vsJVMMethodSpecs vs) ++ | ||
map (\(CMSLLVM.SomeLLVM ms) -> solverStatsSolvers (ms ^. csSolverStats)) (vsLLVMMethodSpecs vs) | ||
|
||
vsTheoremSolvers :: VerificationSummary -> Set.Set String | ||
vsTheoremSolvers = Set.unions . map getSolvers . vsTheorems | ||
where getSolvers (Theorem _ ss) = solverStatsSolvers ss | ||
|
||
vsAllSolvers :: VerificationSummary -> Set.Set String | ||
vsAllSolvers vs = Set.union (vsVerifSolvers vs) (vsTheoremSolvers vs) | ||
|
||
computeVerificationSummary :: [JVMTheorem] -> [LLVMTheorem] -> [Theorem] -> VerificationSummary | ||
computeVerificationSummary = VerificationSummary | ||
|
||
prettyVerificationSummary :: VerificationSummary -> String | ||
prettyVerificationSummary vs@(VerificationSummary jspecs lspecs thms) = | ||
show $ vsep | ||
[ prettyJVMSpecs jspecs | ||
, prettyLLVMSpecs lspecs | ||
, prettyTheorems thms | ||
, prettySolvers (Set.toList (vsAllSolvers vs)) | ||
] where | ||
section nm = "#" <+> nm | ||
item txt = "*" <+> txt | ||
code txt = vsep ["~~~~", txt, "~~~~"] | ||
subitem = indent 4 . item | ||
sectionWithItems _ _ [] = mempty | ||
sectionWithItems nm prt items = | ||
vsep [section nm, "", vsep (map prt items)] | ||
verifStatus s = if Set.null (solverStatsSolvers (s ^. CMS.csSolverStats)) | ||
then "assumed" | ||
else "verified" | ||
-- TODO: ultimately the goal is for the following to summarize all | ||
-- preconditions made by this verification, but we need to extract | ||
-- a bunch more information for that to be meaningful. | ||
{- | ||
condStatus s = (if null (s ^. (CMS.csPreState . CMS.csConditions)) | ||
then "without" | ||
else "with") <+> "conditions" | ||
-} | ||
prettyJVMSpecs ss = | ||
sectionWithItems "JVM Methods Analyzed" prettyJVMSpec ss | ||
prettyJVMSpec s = | ||
vsep [ item (fromString (s ^. CMSJVM.csMethodName)) | ||
-- , subitem (condStatus s) | ||
, subitem (verifStatus s) | ||
] | ||
prettyLLVMSpecs ss = | ||
sectionWithItems "LLVM Functions Analyzed" prettyLLVMSpec ss | ||
prettyLLVMSpec (CMSLLVM.SomeLLVM s) = | ||
vsep [ item (fromString (s ^. CMSLLVM.csName)) | ||
-- , subitem (condStatus s) | ||
, subitem (verifStatus s) | ||
] | ||
prettyTheorems ts = | ||
sectionWithItems "Theorems Proved or Assumed" (item . prettyTheorem) ts | ||
prettyTheorem t = | ||
vsep [ if Set.null (solverStatsSolvers (thmStats t)) | ||
then "Axiom:" | ||
else "Theorem:" | ||
, code (indent 2 (PP.ppTerm PP.defaultPPOpts (unProp (thmProp t)))) | ||
, "" | ||
] | ||
prettySolvers ss = | ||
sectionWithItems "Solvers Used" (item . fromString) ss |