Module ContractProver

A tool to prove pre- or postconditions via an SMT solver (Z3) and to remove the statically proven conditions from a program.

Author: Michael Hanus

Version: September 2019

Summary of exported operations:

:: String   
contractCheckerModule :: String   
main :: IO ()   
proveContracts :: Options -> String -> IO ()   
proveContractsInProg :: Options -> AProg TypeExpr -> IO ()   
writeTransformedFCY :: Options -> String -> Prog -> IO ()   
writeTransformedTFCY :: Options -> String -> AProg TypeExpr -> IO ()   
makeTransState :: Int -> [(Int,TypeExpr)] -> TransState   
incFreshVarIndex :: TransState -> TransState   
addVarTypes :: [(Int,TypeExpr)] -> TransState -> TransState   
addPreConditionCheck :: TypeExpr -> CombType -> (String,String) -> TypeExpr -> [AExpr TypeExpr] -> AExpr TypeExpr   
toNoCheckQName :: (String,String) -> (String,String)   
Transform a qualified name into a name of the corresponding function without precondition checking by adding the suffix "'NOCHECK".
fromNoCheckQName :: (String,String) -> (String,String)   
Drops a possible "'NOCHECK" suffix from a qualified name.
addPostConditionCheck :: (String,String) -> ARule TypeExpr -> AExpr TypeExpr   
addPreConditions :: Options -> AProg TypeExpr -> IORef VState -> IO (AProg TypeExpr)   
verifyPreConditions :: Options -> AProg TypeExpr -> IORef VState -> IO (AProg TypeExpr)   
provePreCondition :: Options -> IORef VState -> AFuncDecl TypeExpr -> IO (AFuncDecl TypeExpr)   
optPreConditionInRule :: Options -> VerifyInfo -> (String,String) -> ARule TypeExpr -> IORef VState -> IO (ARule TypeExpr)   
renamePatternVars :: TransState -> ABranchExpr TypeExpr -> (ABranchExpr TypeExpr,TransState)   
verifyPostConditions :: Options -> AProg TypeExpr -> IORef VState -> IO (AProg TypeExpr)   
provePostCondition :: Options -> VerifyInfo -> AFuncDecl TypeExpr -> [AFuncDecl TypeExpr] -> IORef VState -> IO [AFuncDecl TypeExpr]   
addPostConditionTo :: (String,String) -> AFuncDecl TypeExpr -> AFuncDecl TypeExpr   
extractPostConditionProofObligation :: VerifyInfo -> [Int] -> Int -> ARule TypeExpr -> (Term,TransState)   
preCondExpOf :: VerifyInfo -> (String,String) -> [(Int,TypeExpr)] -> TransState -> (Term,TransState)   
postCondExpOf :: VerifyInfo -> (String,String) -> [(Int,TypeExpr)] -> TransState -> (Term,TransState)   
applyFunc :: AFuncDecl TypeExpr -> [(Int,TypeExpr)] -> TransState -> (AExpr TypeExpr,TransState)   
pred2smt :: AExpr TypeExpr -> TransState -> (Term,TransState)   
binding2SMT :: Bool -> VerifyInfo -> (Int,AExpr TypeExpr) -> TransState -> (Term,TransState)   
normalizeArgs :: [AExpr TypeExpr] -> TransState -> (([(Int,AExpr TypeExpr)],[AExpr TypeExpr]),TransState)   
unzipBranches :: [ABranchExpr TypeExpr] -> ([APattern TypeExpr],[AExpr TypeExpr])   
checkImplication :: Options -> IORef VState -> String -> [(Int,TypeExpr)] -> Term -> Term -> Term -> IO (Maybe String)   
checkImplicationWithSMT :: Options -> IORef VState -> String -> [(Int,TypeExpr)] -> Term -> Term -> Term -> IO (Maybe String)   
genSMTTypes :: IORef VState -> [(Int,TypeExpr)] -> [AFuncDecl TypeExpr] -> [Term] -> IO [Command]   
callSMT :: Options -> String -> IO (Maybe String)   
nondetTrans :: [((String,String),Bool)] -> Int -> Term -> (Term,Int)   
nondetTransL :: [((String,String),Bool)] -> Int -> [Term] -> ([Term],Int)   
axiomatizedOps :: [String]   
typedVar2SMT :: (Int,TypeExpr) -> Command   
tconsOfTypeExpr :: TypeExpr -> [(String,String)]   
fileInPath :: String -> IO Bool   
Checks whether a file exists in one of the directories on the PATH.
showQNameNoDots :: (String,String) -> String   
showWithLineNums :: String -> String   
Shows a text with line numbers preceded:

Exported datatypes:


TransState

Constructors:

  • TransState :: Term -> Int -> [(Int,TypeExpr)] -> TransState

    Fields:

    • preCond :: Term
    • freshVar :: Int
    • varTypes :: [(Int,TypeExpr)]

Exported operations:

contractCheckerModule :: String   

main :: IO ()   

proveContracts :: Options -> String -> IO ()   

writeTransformedFCY :: Options -> String -> Prog -> IO ()   

writeTransformedTFCY :: Options -> String -> AProg TypeExpr -> IO ()   

makeTransState :: Int -> [(Int,TypeExpr)] -> TransState   

Further infos:
  • solution complete, i.e., able to compute all solutions

addVarTypes :: [(Int,TypeExpr)] -> TransState -> TransState   

Further infos:
  • solution complete, i.e., able to compute all solutions

addPreConditionCheck :: TypeExpr -> CombType -> (String,String) -> TypeExpr -> [AExpr TypeExpr] -> AExpr TypeExpr   

toNoCheckQName :: (String,String) -> (String,String)   

Transform a qualified name into a name of the corresponding function without precondition checking by adding the suffix "'NOCHECK".

Further infos:
  • solution complete, i.e., able to compute all solutions

fromNoCheckQName :: (String,String) -> (String,String)   

Drops a possible "'NOCHECK" suffix from a qualified name.

addPostConditionCheck :: (String,String) -> ARule TypeExpr -> AExpr TypeExpr   

optPreConditionInRule :: Options -> VerifyInfo -> (String,String) -> ARule TypeExpr -> IORef VState -> IO (ARule TypeExpr)   

addPostConditionTo :: (String,String) -> AFuncDecl TypeExpr -> AFuncDecl TypeExpr   

preCondExpOf :: VerifyInfo -> (String,String) -> [(Int,TypeExpr)] -> TransState -> (Term,TransState)   

postCondExpOf :: VerifyInfo -> (String,String) -> [(Int,TypeExpr)] -> TransState -> (Term,TransState)   

binding2SMT :: Bool -> VerifyInfo -> (Int,AExpr TypeExpr) -> TransState -> (Term,TransState)   

unzipBranches :: [ABranchExpr TypeExpr] -> ([APattern TypeExpr],[AExpr TypeExpr])   

Further infos:
  • solution complete, i.e., able to compute all solutions

checkImplication :: Options -> IORef VState -> String -> [(Int,TypeExpr)] -> Term -> Term -> Term -> IO (Maybe String)   

checkImplicationWithSMT :: Options -> IORef VState -> String -> [(Int,TypeExpr)] -> Term -> Term -> Term -> IO (Maybe String)   

genSMTTypes :: IORef VState -> [(Int,TypeExpr)] -> [AFuncDecl TypeExpr] -> [Term] -> IO [Command]   

callSMT :: Options -> String -> IO (Maybe String)   

nondetTrans :: [((String,String),Bool)] -> Int -> Term -> (Term,Int)   

nondetTransL :: [((String,String),Bool)] -> Int -> [Term] -> ([Term],Int)   

axiomatizedOps :: [String]   

Further infos:
  • solution complete, i.e., able to compute all solutions

typedVar2SMT :: (Int,TypeExpr) -> Command   

tconsOfTypeExpr :: TypeExpr -> [(String,String)]   

fileInPath :: String -> IO Bool   

Checks whether a file exists in one of the directories on the PATH.

showQNameNoDots :: (String,String) -> String   

showWithLineNums :: String -> String   

Shows a text with line numbers preceded: