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

Bump nixpkgs #185

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions act.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ common common
deriving-compat,
async >= 2.2.4,
data-dword >= 0.3.2.1,
prettyprinter,
prettyprinter-ansi-terminal,
if flag(ci)
ghc-options: -O2 -Wall -Werror -Wno-orphans -Wno-unticked-promoted-constructors
else
Expand Down
165 changes: 100 additions & 65 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/f85a3c6af20f02135814867870deb419329e8297";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
hevmUpstream = {
url = "github:ethereum/hevm";
inputs.nixpkgs.follows = "nixpkgs";
Expand Down Expand Up @@ -57,4 +57,4 @@
};
}
);
}
}
22 changes: 11 additions & 11 deletions src/Act/CLI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Data.Map (Map)
import Data.Maybe
import qualified Data.Text as Text
import qualified Data.Text.IO as TIO
import Text.PrettyPrint.ANSI.Leijen hiding ((<$>))
import Prettyprinter hiding (annotate, line')
import GHC.Conc
import GHC.Natural
import Options.Generic
Expand Down Expand Up @@ -154,7 +154,7 @@ parseSolver s = case s of
Just s' -> case Text.unpack s' of
"z3" -> pure Solvers.Z3
"cvc5" -> pure Solvers.CVC5
input -> render (text $ "unrecognised solver: " <> input) >> exitFailure
input -> render (text $ "unrecognised solver: " <> Text.pack input) >> exitFailure

prove :: FilePath -> Solvers.Solver -> Maybe Integer -> Bool -> IO ()
prove file' solver' smttimeout' debug' = do
Expand All @@ -167,27 +167,27 @@ prove file' solver' smttimeout' debug' = do
catErrors results = [e | [email protected] {} <- results]
catUnknowns results = [u | [email protected] {} <- results]

(<->) :: Doc -> [Doc] -> Doc
(<->) :: DocAnsi -> [DocAnsi] -> DocAnsi
x <-> y = x <$$> line <> (indent 2 . vsep $ y)

failMsg :: [SMT.SMTResult] -> Doc
failMsg :: [SMT.SMTResult] -> DocAnsi
failMsg results
| not . null . catUnknowns $ results
= text "could not be proven due to a" <+> (yellow . text $ "solver timeout")
| not . null . catErrors $ results
= (red . text $ "failed") <+> "due to solver errors:" <-> ((fmap (text . show)) . catErrors $ results)
= (red . text $ "failed") <+> "due to solver errors:" <-> ((fmap viaShow) . catErrors $ results)
| otherwise
= (red . text $ "violated") <> colon <-> (fmap pretty . catModels $ results)
= (red . text $ "violated") <> colon <-> (fmap prettyAnsi . catModels $ results)

passMsg :: Doc
passMsg :: DocAnsi
passMsg = (green . text $ "holds") <+> (bold . text $ "∎")

accumulateResults :: (Bool, Doc) -> (Query, [SMT.SMTResult]) -> (Bool, Doc)
accumulateResults :: (Bool, DocAnsi) -> (Query, [SMT.SMTResult]) -> (Bool, DocAnsi)
accumulateResults (status, report) (query, results) = (status && holds, report <$$> msg <$$> smt)
where
holds = all isPass results
msg = identifier query <+> if holds then passMsg else failMsg results
smt = if debug' then line <> getSMT query else empty
smt = if debug' then line <> getSMT query else emptyDoc

solverInstance <- spawnSolver config
pcResults <- mapM (runQuery solverInstance) (mkPostconditionQueries claims)
Expand All @@ -196,10 +196,10 @@ prove file' solver' smttimeout' debug' = do

let
invTitle = line <> (underline . bold . text $ "Invariants:") <> line
invOutput = foldl' accumulateResults (True, empty) invResults
invOutput = foldl' accumulateResults (True, emptyDoc) invResults

pcTitle = line <> (underline . bold . text $ "Postconditions:") <> line
pcOutput = foldl' accumulateResults (True, empty) pcResults
pcOutput = foldl' accumulateResults (True, emptyDoc) pcResults

render $ vsep
[ ifExists invResults invTitle
Expand Down
Loading
Loading