Commit d26cf842 authored by Philipp Meyer's avatar Philipp Meyer
Browse files

Added option to prove termination

parent e07881b0
...@@ -26,6 +26,7 @@ data Options = Options { inputFormat :: InputFormat ...@@ -26,6 +26,7 @@ data Options = Options { inputFormat :: InputFormat
, optVerbose :: Bool , optVerbose :: Bool
, optShowHelp :: Bool , optShowHelp :: Bool
, optShowVersion :: Bool , optShowVersion :: Bool
, proveTermination :: Bool
} }
startOptions :: Options startOptions :: Options
...@@ -33,6 +34,7 @@ startOptions = Options { inputFormat = PNET ...@@ -33,6 +34,7 @@ startOptions = Options { inputFormat = PNET
, optVerbose = False , optVerbose = False
, optShowHelp = False , optShowHelp = False
, optShowVersion = False , optShowVersion = False
, proveTermination = False
} }
options :: [ OptDescr (Options -> Either String Options) ] options :: [ OptDescr (Options -> Either String Options) ]
...@@ -46,6 +48,10 @@ options = ...@@ -46,6 +48,10 @@ options =
("Input format (possible values=\"pnet\", \"lola\", \"tpn\"\n" ++ ("Input format (possible values=\"pnet\", \"lola\", \"tpn\"\n" ++
" default=\"pnet\")") " default=\"pnet\")")
, Option "" ["termination"]
(NoArg (\opt -> Right opt { proveTermination = True }))
"Prove termination"
, Option "v" ["verbose"] , Option "v" ["verbose"]
(NoArg (\opt -> Right opt { optVerbose = True })) (NoArg (\opt -> Right opt { optVerbose = True }))
"Enable verbose messages" "Enable verbose messages"
...@@ -67,8 +73,9 @@ parseArgs = do ...@@ -67,8 +73,9 @@ parseArgs = do
return $ (,files) <$> foldl (>>=) (return startOptions) actions return $ (,files) <$> foldl (>>=) (return startOptions) actions
(_, _, errs) -> return $ Left $ concat errs (_, _, errs) -> return $ Left $ concat errs
checkFile :: Parser (PetriNet,[Property]) -> Bool -> String -> IO Bool checkFile :: Parser (PetriNet,[Property]) -> Bool -> [Property] ->
checkFile parser verbose file = do String -> IO Bool
checkFile parser verbose addedProperties file = do
putStrLn $ "Reading \"" ++ file ++ "\"" putStrLn $ "Reading \"" ++ file ++ "\""
(net,properties) <- parseFile parser file (net,properties) <- parseFile parser file
putStrLn $ "Analyzing " ++ showNetName net putStrLn $ "Analyzing " ++ showNetName net
...@@ -76,7 +83,7 @@ checkFile parser verbose file = do ...@@ -76,7 +83,7 @@ checkFile parser verbose file = do
putStrLn $ "Places: " ++ show (length $ places net) putStrLn $ "Places: " ++ show (length $ places net)
putStrLn $ "Transitions: " ++ show (length $ transitions net) putStrLn $ "Transitions: " ++ show (length $ transitions net)
) )
rs <- mapM (checkProperty verbose net) properties rs <- mapM (checkProperty verbose net) (addedProperties ++ properties)
putStrLn "" putStrLn ""
return $ and rs return $ and rs
...@@ -146,7 +153,9 @@ main = do ...@@ -146,7 +153,9 @@ main = do
PNET -> PNET.parseContent PNET -> PNET.parseContent
LOLA -> error "lola is not supported yet" LOLA -> error "lola is not supported yet"
TPN -> error "tpn is not supported yet" TPN -> error "tpn is not supported yet"
rs <- mapM (checkFile parser (optVerbose opts)) files let properties = [ Property "termination" Liveness FTrue
| proveTermination opts ]
rs <- mapM (checkFile parser (optVerbose opts) properties) files
if and rs then if and rs then
exitSuccessWith "All properties satisfied." exitSuccessWith "All properties satisfied."
else else
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment