Module Main

A tool to verify Curry programs w.r.t. failing computations. Thus, a program successfully verified by this tool should never fail at run-time (apart from explicit error) provided that the call types are satisfied when invoking a function.

Author: Michael Hanus

Version: December 2023

Summary of exported operations:

:: String  Deterministic 
main :: IO ()  Non-deterministic 
verifyModule :: TermDomain a => Analysis a -> IORef (AnalysisStore a) -> Options -> String -> IO ()  Non-deterministic 
Verify a single module.
inferCallTypes :: TermDomain a => Options -> [[((String,String),Int)]] -> ((String,String) -> Bool) -> String -> Prog -> IO ([((String,String),Maybe [a])],Int,Int)  Non-deterministic 
Infer the initial (abstract) call types of all functions in a program and return them together with the number of all/public non-trivial call types.
inferIOTypes :: TermDomain a => Options -> Analysis a -> IORef (AnalysisStore a) -> ((String,String) -> Bool) -> Prog -> IO ([((String,String),InOutType a)],Int,Int)  Non-deterministic 
Infer the in/out types of all functions in a program and return them together with the number of all and public non-trivial in/out types.
showFunctionInfo :: TermDomain a => Options -> String -> VerifyState a -> IO ()  Deterministic 
tryVerifyProg :: TermDomain a => Options -> Int -> VerifyState a -> String -> Map (String,String) [FuncDecl] -> [FuncDecl] -> IO (Int,VerifyState a)  Deterministic 
showVerifyResult :: TermDomain a => Options -> VerifyState a -> String -> ((String,String) -> Bool) -> IO ()  Deterministic 
showIncompleteBranch :: (String,String) -> Expr -> [(String,String)] -> String  Deterministic 
initVerifyState :: TermDomain a => [FuncDecl] -> [[((String,String),Int)]] -> Map (String,String) (Maybe [a]) -> Map (String,String) (Maybe [a]) -> Map (String,String) (InOutType a) -> Options -> VerifyState a  Deterministic 
Initializes the verification state.
getCurrentFuncName :: TermDomain a => StateT (VerifyState a) IO (String,String)  Deterministic 
setCurrentFunc :: TermDomain a => (String,String) -> Int -> [Int] -> StateT (VerifyState a) IO ()  Deterministic 
getAllCons :: TermDomain a => StateT (VerifyState a) IO [[((String,String),Int)]]  Deterministic 
setFreshVarIndex :: TermDomain a => Int -> StateT (VerifyState a) IO ()  Deterministic 
newFreshVarIndex :: TermDomain a => StateT (VerifyState a) IO Int  Deterministic 
addCallTypeRestriction :: TermDomain a => (String,String) -> Maybe [a] -> StateT (VerifyState a) IO ()  Deterministic 
addFailedFunc :: TermDomain a => Expr -> Maybe [(Int,a)] -> StateT (VerifyState a) IO ()  Deterministic 
addMissingCase :: TermDomain a => Expr -> [(String,String)] -> StateT (VerifyState a) IO ()  Deterministic 
setVarExps :: TermDomain a => [(Int,Expr)] -> StateT (VerifyState a) IO ()  Deterministic 
addVarExps :: TermDomain a => [(Int,Expr)] -> StateT (VerifyState a) IO ()  Deterministic 
getVarTypes :: TermDomain a => StateT (VerifyState a) IO [(Int,[(InOutType a,[Int])])]  Deterministic 
getVarTypeOf :: TermDomain a => Int -> StateT (VerifyState a) IO [(InOutType a,[Int])]  Deterministic 
setVarTypes :: TermDomain a => [(Int,[(InOutType a,[Int])])] -> StateT (VerifyState a) IO ()  Deterministic 
addVarType :: TermDomain a => Int -> [(InOutType a,[Int])] -> StateT (VerifyState a) IO ()  Deterministic 
addVarTypes :: TermDomain a => [(Int,[(InOutType a,[Int])])] -> StateT (VerifyState a) IO ()  Deterministic 
addVarAnyType :: TermDomain a => Int -> StateT (VerifyState a) IO ()  Deterministic 
removeVarAnyType :: TermDomain a => Int -> StateT (VerifyState a) IO ()  Deterministic 
getCallType :: TermDomain a => (String,String) -> Int -> StateT (VerifyState a) IO (Maybe [a])  Deterministic 
getFuncType :: TermDomain a => (String,String) -> Int -> StateT (VerifyState a) IO (InOutType a)  Deterministic 
incrNonTrivialCall :: TermDomain a => StateT (VerifyState a) IO ()  Deterministic 
incrIncompleteCases :: TermDomain a => StateT (VerifyState a) IO ()  Deterministic 
getToolOptions :: TermDomain a => StateT (VerifyState a) IO Options  Deterministic 
printIfVerb :: TermDomain a => Int -> String -> StateT (VerifyState a) IO ()  Deterministic 
Prints a string with putStrLn if the verbosity is at least as the given one.
verifyFunc :: TermDomain a => FuncDecl -> StateT (VerifyState a) IO ()  Deterministic 
noVerifyFunctions :: [(String,String)]  Deterministic 
verifyFuncRule :: TermDomain a => [Int] -> Expr -> StateT (VerifyState a) IO ()  Deterministic 
showVarExpTypes :: TermDomain a => StateT (VerifyState a) IO ()  Deterministic 
showBindExp :: Int -> Expr -> String  Deterministic 
showExp :: Expr -> String  Deterministic 
ppExp :: Expr -> Doc  Deterministic 
verifyExpr :: TermDomain a => Bool -> Expr -> StateT (VerifyState a) IO Int  Deterministic 
verifyVarExpr :: TermDomain a => Int -> Expr -> StateT (VerifyState a) IO [(Int,[(InOutType a,[Int])])]  Deterministic 
verifyFuncCall :: TermDomain a => Bool -> Expr -> (String,String) -> [Int] -> StateT (VerifyState a) IO ()  Deterministic 
checkDivOpNonZero :: TermDomain a => Expr -> StateT (VerifyState a) IO [(Int,[(InOutType a,[Int])])] -> StateT (VerifyState a) IO [(Int,[(InOutType a,[Int])])]  Deterministic 
verifyMissingBranches :: TermDomain a => Expr -> Int -> [BranchExpr] -> StateT (VerifyState a) IO ()  Deterministic 
verifyBranch :: TermDomain a => Int -> Int -> BranchExpr -> StateT (VerifyState a) IO [(Int,[(InOutType a,[Int])])]  Deterministic 
getVarType :: TermDomain a => Int -> [(Int,[(InOutType a,[Int])])] -> a  Deterministic 
funcDecls2Usage :: String -> [FuncDecl] -> Map (String,String) [FuncDecl]  Deterministic 
Computes for a given set of function declarations in a module a mapping from module function names to the list of function declarations where these names are used in the right-hand side.
unionFDecls :: [FuncDecl] -> [FuncDecl] -> [FuncDecl]  Deterministic 
usedFuncsInFunc :: FuncDecl -> [(String,String)]  Deterministic 
Get function names used in the right-hand side of a function declaration.
usedFuncsInRule :: Rule -> [(String,String)]  Deterministic 
Get function names used in the right-hand side of a rule.
anyTypes :: TermDomain a => Int -> [a]  Deterministic 
A list of any types of a given length.
enforceNormalForm :: a -> IO ()  Deterministic 

Exported datatypes:


VerifyState

Constructors:


VerifyStateM

Type synonym: VerifyStateM a b = StateT (VerifyState a) IO b


Exported operations:

main :: IO ()  Non-deterministic 

verifyModule :: TermDomain a => Analysis a -> IORef (AnalysisStore a) -> Options -> String -> IO ()  Non-deterministic 

Verify a single module.

inferCallTypes :: TermDomain a => Options -> [[((String,String),Int)]] -> ((String,String) -> Bool) -> String -> Prog -> IO ([((String,String),Maybe [a])],Int,Int)  Non-deterministic 

Infer the initial (abstract) call types of all functions in a program and return them together with the number of all/public non-trivial call types.

inferIOTypes :: TermDomain a => Options -> Analysis a -> IORef (AnalysisStore a) -> ((String,String) -> Bool) -> Prog -> IO ([((String,String),InOutType a)],Int,Int)  Non-deterministic 

Infer the in/out types of all functions in a program and return them together with the number of all and public non-trivial in/out types.

showFunctionInfo :: TermDomain a => Options -> String -> VerifyState a -> IO ()  Deterministic 

tryVerifyProg :: TermDomain a => Options -> Int -> VerifyState a -> String -> Map (String,String) [FuncDecl] -> [FuncDecl] -> IO (Int,VerifyState a)  Deterministic 

showVerifyResult :: TermDomain a => Options -> VerifyState a -> String -> ((String,String) -> Bool) -> IO ()  Deterministic 

showIncompleteBranch :: (String,String) -> Expr -> [(String,String)] -> String  Deterministic 

initVerifyState :: TermDomain a => [FuncDecl] -> [[((String,String),Int)]] -> Map (String,String) (Maybe [a]) -> Map (String,String) (Maybe [a]) -> Map (String,String) (InOutType a) -> Options -> VerifyState a  Deterministic 

Initializes the verification state.

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

getCurrentFuncName :: TermDomain a => StateT (VerifyState a) IO (String,String)  Deterministic 

setCurrentFunc :: TermDomain a => (String,String) -> Int -> [Int] -> StateT (VerifyState a) IO ()  Deterministic 

getAllCons :: TermDomain a => StateT (VerifyState a) IO [[((String,String),Int)]]  Deterministic 

setFreshVarIndex :: TermDomain a => Int -> StateT (VerifyState a) IO ()  Deterministic 

newFreshVarIndex :: TermDomain a => StateT (VerifyState a) IO Int  Deterministic 

addCallTypeRestriction :: TermDomain a => (String,String) -> Maybe [a] -> StateT (VerifyState a) IO ()  Deterministic 

addFailedFunc :: TermDomain a => Expr -> Maybe [(Int,a)] -> StateT (VerifyState a) IO ()  Deterministic 

addMissingCase :: TermDomain a => Expr -> [(String,String)] -> StateT (VerifyState a) IO ()  Deterministic 

setVarExps :: TermDomain a => [(Int,Expr)] -> StateT (VerifyState a) IO ()  Deterministic 

addVarExps :: TermDomain a => [(Int,Expr)] -> StateT (VerifyState a) IO ()  Deterministic 

getVarTypes :: TermDomain a => StateT (VerifyState a) IO [(Int,[(InOutType a,[Int])])]  Deterministic 

getVarTypeOf :: TermDomain a => Int -> StateT (VerifyState a) IO [(InOutType a,[Int])]  Deterministic 

setVarTypes :: TermDomain a => [(Int,[(InOutType a,[Int])])] -> StateT (VerifyState a) IO ()  Deterministic 

addVarType :: TermDomain a => Int -> [(InOutType a,[Int])] -> StateT (VerifyState a) IO ()  Deterministic 

addVarTypes :: TermDomain a => [(Int,[(InOutType a,[Int])])] -> StateT (VerifyState a) IO ()  Deterministic 

addVarAnyType :: TermDomain a => Int -> StateT (VerifyState a) IO ()  Deterministic 

removeVarAnyType :: TermDomain a => Int -> StateT (VerifyState a) IO ()  Deterministic 

getCallType :: TermDomain a => (String,String) -> Int -> StateT (VerifyState a) IO (Maybe [a])  Deterministic 

getFuncType :: TermDomain a => (String,String) -> Int -> StateT (VerifyState a) IO (InOutType a)  Deterministic 

printIfVerb :: TermDomain a => Int -> String -> StateT (VerifyState a) IO ()  Deterministic 

Prints a string with putStrLn if the verbosity is at least as the given one.

verifyFunc :: TermDomain a => FuncDecl -> StateT (VerifyState a) IO ()  Deterministic 

noVerifyFunctions :: [(String,String)]  Deterministic 

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

verifyFuncRule :: TermDomain a => [Int] -> Expr -> StateT (VerifyState a) IO ()  Deterministic 

showVarExpTypes :: TermDomain a => StateT (VerifyState a) IO ()  Deterministic 

showBindExp :: Int -> Expr -> String  Deterministic 

showExp :: Expr -> String  Deterministic 

ppExp :: Expr -> Doc  Deterministic 

verifyExpr :: TermDomain a => Bool -> Expr -> StateT (VerifyState a) IO Int  Deterministic 

verifyVarExpr :: TermDomain a => Int -> Expr -> StateT (VerifyState a) IO [(Int,[(InOutType a,[Int])])]  Deterministic 

verifyFuncCall :: TermDomain a => Bool -> Expr -> (String,String) -> [Int] -> StateT (VerifyState a) IO ()  Deterministic 

checkDivOpNonZero :: TermDomain a => Expr -> StateT (VerifyState a) IO [(Int,[(InOutType a,[Int])])] -> StateT (VerifyState a) IO [(Int,[(InOutType a,[Int])])]  Deterministic 

verifyMissingBranches :: TermDomain a => Expr -> Int -> [BranchExpr] -> StateT (VerifyState a) IO ()  Deterministic 

verifyBranch :: TermDomain a => Int -> Int -> BranchExpr -> StateT (VerifyState a) IO [(Int,[(InOutType a,[Int])])]  Deterministic 

getVarType :: TermDomain a => Int -> [(Int,[(InOutType a,[Int])])] -> a  Deterministic 

funcDecls2Usage :: String -> [FuncDecl] -> Map (String,String) [FuncDecl]  Deterministic 

Computes for a given set of function declarations in a module a mapping from module function names to the list of function declarations where these names are used in the right-hand side.

unionFDecls :: [FuncDecl] -> [FuncDecl] -> [FuncDecl]  Deterministic 

usedFuncsInFunc :: FuncDecl -> [(String,String)]  Deterministic 

Get function names used in the right-hand side of a function declaration.

usedFuncsInRule :: Rule -> [(String,String)]  Deterministic 

Get function names used in the right-hand side of a rule.

anyTypes :: TermDomain a => Int -> [a]  Deterministic 

A list of any types of a given length.

enforceNormalForm :: a -> IO ()  Deterministic