Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
peregrine
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
i7
peregrine
Commits
1363ee6d
Commit
1363ee6d
authored
Jul 15, 2014
by
Philipp Meyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added output of petri net and formula in lola format
parent
9faade58
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
3 deletions
+84
-3
src/Main.hs
src/Main.hs
+29
-3
src/Printer.hs
src/Printer.hs
+55
-0
No files found.
src/Main.hs
View file @
1363ee6d
...
@@ -15,6 +15,7 @@ import qualified Parser.PNET as PNET
...
@@ -15,6 +15,7 @@ import qualified Parser.PNET as PNET
import
qualified
Parser.LOLA
as
LOLA
import
qualified
Parser.LOLA
as
LOLA
import
qualified
Parser.TPN
as
TPN
import
qualified
Parser.TPN
as
TPN
import
PetriNet
import
PetriNet
import
Printer
import
Property
import
Property
import
Solver
import
Solver
import
Solver.StateEquation
import
Solver.StateEquation
...
@@ -39,6 +40,7 @@ data Options = Options { inputFormat :: InputFormat
...
@@ -39,6 +40,7 @@ data Options = Options { inputFormat :: InputFormat
,
optProperties
::
[
ImplicitProperty
]
,
optProperties
::
[
ImplicitProperty
]
,
optTransformations
::
[
NetTransformation
]
,
optTransformations
::
[
NetTransformation
]
,
optRefine
::
Bool
,
optRefine
::
Bool
,
optOutput
::
Maybe
String
}
}
startOptions
::
Options
startOptions
::
Options
...
@@ -49,6 +51,7 @@ startOptions = Options { inputFormat = PNET
...
@@ -49,6 +51,7 @@ startOptions = Options { inputFormat = PNET
,
optProperties
=
[]
,
optProperties
=
[]
,
optTransformations
=
[]
,
optTransformations
=
[]
,
optRefine
=
True
,
optRefine
=
True
,
optOutput
=
Nothing
}
}
options
::
[
OptDescr
(
Options
->
Either
String
Options
)
]
options
::
[
OptDescr
(
Options
->
Either
String
Options
)
]
...
@@ -115,6 +118,13 @@ options =
...
@@ -115,6 +118,13 @@ options =
(
NoArg
(
\
opt
->
Right
opt
{
optRefine
=
False
}))
(
NoArg
(
\
opt
->
Right
opt
{
optRefine
=
False
}))
"Don't use refinement"
"Don't use refinement"
,
Option
"o"
[
"output"
]
(
ReqArg
(
\
arg
opt
->
Right
opt
{
optOutput
=
Just
arg
})
"FILE"
)
"Write net and properties to FILE"
,
Option
"v"
[
"verbose"
]
,
Option
"v"
[
"verbose"
]
(
NoArg
(
\
opt
->
Right
opt
{
optVerbosity
=
optVerbosity
opt
+
1
}))
(
NoArg
(
\
opt
->
Right
opt
{
optVerbosity
=
optVerbosity
opt
+
1
}))
"Increase verbosity (may be specified more than once)"
"Increase verbosity (may be specified more than once)"
...
@@ -144,9 +154,22 @@ parseArgs = do
...
@@ -144,9 +154,22 @@ parseArgs = do
return
$
(,
files
)
<$>
foldl
(
>>=
)
(
return
startOptions
)
actions
return
$
(,
files
)
<$>
foldl
(
>>=
)
(
return
startOptions
)
actions
(
_
,
_
,
errs
)
->
return
$
Left
$
concat
errs
(
_
,
_
,
errs
)
->
return
$
Left
$
concat
errs
writeFiles
::
Int
->
String
->
PetriNet
->
[
Property
]
->
IO
()
writeFiles
verbosity
basename
net
props
=
do
verbosePut
verbosity
1
$
"Writing "
++
showNetName
net
++
" to "
++
basename
writeFile
basename
$
printNet
net
mapM_
(
\
(
p
,
i
)
->
do
let
file
=
basename
++
".task"
++
show
i
verbosePut
verbosity
1
$
"Writing "
++
showPropertyName
p
++
" to "
++
file
writeFile
file
$
printProperty
p
)
(
zip
props
[(
1
::
Integer
)
..
])
checkFile
::
Parser
(
PetriNet
,[
Property
])
->
Int
->
Bool
->
checkFile
::
Parser
(
PetriNet
,[
Property
])
->
Int
->
Bool
->
[
ImplicitProperty
]
->
[
NetTransformation
]
->
String
->
IO
Bool
[
ImplicitProperty
]
->
[
NetTransformation
]
->
checkFile
parser
verbosity
refine
implicitProperties
transformations
file
=
do
Maybe
String
->
String
->
IO
Bool
checkFile
parser
verbosity
refine
implicitProperties
transformations
output
file
=
do
verbosePut
verbosity
0
$
"Reading
\"
"
++
file
++
"
\"
"
verbosePut
verbosity
0
$
"Reading
\"
"
++
file
++
"
\"
"
(
net
,
props
)
<-
parseFile
parser
file
(
net
,
props
)
<-
parseFile
parser
file
let
props'
=
props
++
map
(
makeImplicitProperty
net
)
implicitProperties
let
props'
=
props
++
map
(
makeImplicitProperty
net
)
implicitProperties
...
@@ -157,6 +180,9 @@ checkFile parser verbosity refine implicitProperties transformations file = do
...
@@ -157,6 +180,9 @@ checkFile parser verbosity refine implicitProperties transformations file = do
"Transitions: "
++
show
(
length
$
transitions
net'
)
"Transitions: "
++
show
(
length
$
transitions
net'
)
verbosePut
verbosity
3
$
show
net'
verbosePut
verbosity
3
$
show
net'
rs
<-
mapM
(
checkProperty
verbosity
net'
refine
)
props''
rs
<-
mapM
(
checkProperty
verbosity
net'
refine
)
props''
case
output
of
Just
outputfile
->
writeFiles
verbosity
outputfile
net'
props''
Nothing
->
return
()
verbosePut
verbosity
0
""
verbosePut
verbosity
0
""
return
$
and
rs
return
$
and
rs
...
@@ -305,7 +331,7 @@ main = do
...
@@ -305,7 +331,7 @@ main = do
let
properties
=
reverse
$
optProperties
opts
let
properties
=
reverse
$
optProperties
opts
let
transformations
=
reverse
$
optTransformations
opts
let
transformations
=
reverse
$
optTransformations
opts
rs
<-
mapM
(
checkFile
parser
verbosity
refinement
properties
rs
<-
mapM
(
checkFile
parser
verbosity
refinement
properties
transformations
)
files
transformations
(
optOutput
opts
)
)
files
if
and
rs
then
if
and
rs
then
exitSuccessWith
"All properties satisfied."
exitSuccessWith
"All properties satisfied."
else
else
...
...
src/Printer.hs
0 → 100644
View file @
1363ee6d
module
Printer
(
printNet
,
printProperty
)
where
import
Data.List
(
intercalate
)
import
PetriNet
import
Property
printNet
::
PetriNet
->
String
printNet
net
=
let
showWeight
(
p
,
x
)
=
p
++
":"
++
show
x
ps
=
"PLACE "
++
intercalate
","
(
places
net
)
++
";
\n
"
is
=
"MARKING "
++
intercalate
","
(
map
showWeight
(
initials
net
))
++
";
\n
"
makeTransition
t
=
let
(
preT
,
postT
)
=
context
net
t
preS
=
"CONSUME "
++
intercalate
","
(
map
showWeight
preT
)
++
";
\n
"
postS
=
"PRODUCE "
++
intercalate
","
(
map
showWeight
postT
)
++
";
\n
"
in
"TRANSITION "
++
t
++
"
\n
"
++
preS
++
postS
ts
=
map
makeTransition
(
transitions
net
)
in
unlines
(
ps
:
is
:
ts
)
printTerm
::
Term
->
String
printTerm
(
Var
x
)
=
x
printTerm
(
Const
c
)
=
show
c
printTerm
(
Minus
t
)
=
"-"
++
printTerm
t
printTerm
(
t
:+:
u
)
=
"("
++
printTerm
t
++
" + "
++
printTerm
u
++
")"
printTerm
(
t
:-:
u
)
=
"("
++
printTerm
t
++
" - "
++
printTerm
u
++
")"
printTerm
(
t
:*:
u
)
=
printTerm
t
++
" * "
++
printTerm
u
printOp
::
Op
->
String
printOp
Gt
=
" > "
printOp
Ge
=
" >= "
printOp
Eq
=
" = "
printOp
Ne
=
" != "
printOp
Le
=
" <= "
printOp
Lt
=
" < "
printLinIneq
::
LinearInequation
->
String
printLinIneq
(
LinIneq
lhs
op
rhs
)
=
printTerm
lhs
++
printOp
op
++
printTerm
rhs
printFormula
::
Formula
->
String
printFormula
FTrue
=
"TRUE"
printFormula
FFalse
=
"FALSE"
printFormula
(
Atom
a
)
=
printLinIneq
a
printFormula
(
Neg
p
)
=
"NOT "
++
"("
++
printFormula
p
++
")"
printFormula
(
p
:&:
q
)
=
"("
++
printFormula
p
++
" AND "
++
printFormula
q
++
")"
printFormula
(
p
:|:
q
)
=
"("
++
printFormula
p
++
" OR "
++
printFormula
q
++
")"
printProperty
::
Property
->
String
printProperty
(
Property
_
Safety
f
)
=
"EF ("
++
printFormula
f
++
")
\n
"
printProperty
(
Property
_
Liveness
_
)
=
error
"Liveness property not supported"
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