Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
curry-packages
currycheck
Commits
c35604ff
Commit
c35604ff
authored
Oct 31, 2018
by
Michael Hanus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Loads only module-relevant proof files
parent
c3aee946
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
11 deletions
+28
-11
src/CurryCheck.curry
src/CurryCheck.curry
+11
-8
src/TheoremUsage.curry
src/TheoremUsage.curry
+17
-3
No files found.
src/CurryCheck.curry
View file @
c35604ff
...
@@ -37,22 +37,23 @@ import qualified FlatCurry.Types as FC
...
@@ -37,22 +37,23 @@ import qualified FlatCurry.Types as FC
import FlatCurry.Files
import FlatCurry.Files
import qualified FlatCurry.Goodies as FCG
import qualified FlatCurry.Goodies as FCG
import CC.Config
( packagePath, packageVersion )
import CC.Config ( packagePath, packageVersion )
import CC.Options
import CC.Options
import CheckDetUsage
( checkDetUse, containsDetOperations)
import CheckDetUsage ( checkDetUse, containsDetOperations)
import ContractUsage
import ContractUsage
import DefaultRuleUsage
( checkDefaultRules, containsDefaultRules )
import DefaultRuleUsage ( checkDefaultRules, containsDefaultRules )
import PropertyUsage
import PropertyUsage
import SimplifyPostConds ( simplifyPostConditionsWithTheorems )
import SimplifyPostConds ( simplifyPostConditionsWithTheorems )
import TheoremUsage
import TheoremUsage ( determinismTheoremFor, existsProofFor
import UsageCheck ( checkBlacklistUse, checkSetUse )
, getModuleProofFiles, getTheoremFunctions )
import UsageCheck ( checkBlacklistUse, checkSetUse )
-- Banner of this tool:
-- Banner of this tool:
ccBanner :: String
ccBanner :: String
ccBanner = unlines [bannerLine,bannerText,bannerLine]
ccBanner = unlines [bannerLine,bannerText,bannerLine]
where
where
bannerText = "CurryCheck: a tool for testing Curry programs (Version " ++
bannerText = "CurryCheck: a tool for testing Curry programs (Version " ++
packageVersion ++ " of 3
0
/10/2018)"
packageVersion ++ " of 3
1
/10/2018)"
bannerLine = take (length bannerText) (repeat '-')
bannerLine = take (length bannerText) (repeat '-')
-- Help text
-- Help text
...
@@ -661,7 +662,9 @@ analyseCurryProg opts modname orgprog = do
...
@@ -661,7 +662,9 @@ analyseCurryProg opts modname orgprog = do
maybe (error $ "Source file of module '"++modname++"' not found!") id
maybe (error $ "Source file of module '"++modname++"' not found!") id
let srcdir = takeDirectory srcfilename
let srcdir = takeDirectory srcfilename
putStrLnIfDebug opts $ "Source file: " ++ srcfilename
putStrLnIfDebug opts $ "Source file: " ++ srcfilename
prooffiles <- if optProof opts then getProofFiles srcdir else return []
prooffiles <- if optProof opts
then getModuleProofFiles srcdir modname
else return []
unless (null prooffiles) $ putStrIfDetails opts $
unless (null prooffiles) $ putStrIfDetails opts $
unlines ("Proof files found:" : map ("- " ++) prooffiles)
unlines ("Proof files found:" : map ("- " ++) prooffiles)
progtxt <- readFile srcfilename
progtxt <- readFile srcfilename
...
...
src/TheoremUsage.curry
View file @
c35604ff
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
module TheoremUsage
module TheoremUsage
( determinismTheoremFor
( determinismTheoremFor
, getProofFiles, existsProofFor,
isProofFileName,
isProofFileNameFor
, get
Module
ProofFiles, existsProofFor, isProofFileNameFor
, getTheoremFunctions
, getTheoremFunctions
) where
) where
...
@@ -56,6 +56,13 @@ getProofFiles dir = do
...
@@ -56,6 +56,13 @@ getProofFiles dir = do
files <- getDirectoryContents dir
files <- getDirectoryContents dir
return (filter isProofFileName files)
return (filter isProofFileName files)
--- Get the names of all files in the directory (first argument) containing
--- proofs of theorems of the module (second argument).
getModuleProofFiles :: String -> String -> IO [String]
getModuleProofFiles dir mod = do
files <- getDirectoryContents dir
return (filter (isModuleProofFileName mod) files)
--- Does the list of file names (second argument) contain a proof of the
--- Does the list of file names (second argument) contain a proof of the
--- qualified theorem name given as the first argument?
--- qualified theorem name given as the first argument?
existsProofFor :: QName -> [String] -> Bool
existsProofFor :: QName -> [String] -> Bool
...
@@ -66,6 +73,13 @@ existsProofFor qpropname filenames =
...
@@ -66,6 +73,13 @@ existsProofFor qpropname filenames =
isProofFileName :: String -> Bool
isProofFileName :: String -> Bool
isProofFileName fn = "proof" `isPrefixOf` (map toLower fn)
isProofFileName fn = "proof" `isPrefixOf` (map toLower fn)
--- Is the second argument a file name with a proof of some theorem of a module
--- (first argument), i.e., start it with `proof` and the module name?
isModuleProofFileName :: String -> String -> Bool
isModuleProofFileName mn fn =
deleteNonAlphanNum ("proof" ++ map toLower mn)
`isPrefixOf` deleteNonAlphanNum (map toLower fn)
--- Is this the file name of a proof of property `prop`?
--- Is this the file name of a proof of property `prop`?
isProofFileNameFor :: QName -> String -> Bool
isProofFileNameFor :: QName -> String -> Bool
isProofFileNameFor (mn,prop) fname =
isProofFileNameFor (mn,prop) fname =
...
@@ -84,9 +98,9 @@ deleteNonAlphanNum = filter isAlphaNum
...
@@ -84,9 +98,9 @@ deleteNonAlphanNum = filter isAlphaNum
--- A theorem is a property for which a proof file exists in the
--- A theorem is a property for which a proof file exists in the
--- directory provided as first argument.
--- directory provided as first argument.
getTheoremFunctions :: String -> CurryProg -> IO [CFuncDecl]
getTheoremFunctions :: String -> CurryProg -> IO [CFuncDecl]
getTheoremFunctions proofdir (CurryProg
_
_ _ functions _) = do
getTheoremFunctions proofdir (CurryProg
mn
_ _ functions _) = do
let propfuncs = filter isProperty functions -- all properties
let propfuncs = filter isProperty functions -- all properties
prooffiles <- getProofFiles proofdir
prooffiles <- get
Module
ProofFiles proofdir
mn
return $ filter (\fd -> existsProofFor (funcName fd) prooffiles)
return $ filter (\fd -> existsProofFor (funcName fd) prooffiles)
propfuncs
propfuncs
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment