-
Notifications
You must be signed in to change notification settings - Fork 0
/
ParserNuXmv.hs
46 lines (43 loc) · 2.21 KB
/
ParserNuXmv.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module ParserNuXmv where
import Core(smvOutput, KripkeS(..), PathF, State, StateF)
import ParserForms(pathFormsToFile, stateFormsToFile)
writeNuXmv::KripkeS->[State]->[State]->[String]->Either [PathF] [StateF]->Int->(Int,Int,Int,Int)->IO ()
writeNuXmv (KS (r, l)) states inits vars forms lforms (ranInit, ranNumInit, ranKS, ranF) =
writeFile smvOutput $
("-- init seed: " ++ show ranInit) ++
("\n-- NumInit seed: " ++ show ranNumInit) ++
("\n-- KS seed: " ++ show ranKS) ++
("\n-- F seed: " ++ show ranF) ++
("\n-- Depth of the formulas: " ++ show lforms) ++ "\n\n\n" ++
"MODULE main\n\n" ++
"VAR\n" ++
let f vs = case vs of
[v] -> v ++ ": boolean;\n\n\n"
w:ws -> w ++ ": boolean;\n" ++ f ws
_ -> "" in
f vars ++
"DEFINE\n" ++ let g s vs = case vs of
[v] -> if l s v
then " " ++ v ++ ";\n"
else "!" ++ v ++ ";\n"
w:ws -> if l s w
then " " ++ w ++ " & " ++ g s ws
else "!" ++ w ++ " & " ++ g s ws
_ -> "" in
concat ["s" ++ show s ++ ":= " ++ g s vars | s <- states] ++ "\n\n" ++
"INIT\n" ++ let f' sts = case sts of
[s] -> "s" ++ show s ++ ";\n\n"
s':ss -> "s" ++ show s' ++ " | " ++ f' ss
_ -> "" in
f' inits ++
"TRANS\n" ++ let g' sts = case sts of
[s] -> "s" ++ show s
s':ss -> "s" ++ show s' ++ "|" ++ g' ss
_ -> ""
f'' sts = case sts of
[s] -> "(s" ++ show s ++ " & next(" ++ (g' . r) s ++ "))\n\n"
s':ss -> "(s" ++ show s' ++ " & next(" ++ (g' . r) s' ++ ")) |\n" ++ f'' ss
_ -> "" in
f'' states ++ (case forms of
Left ltl_forms -> pathFormsToFile ltl_forms
Right ctl_forms -> stateFormsToFile ctl_forms)