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
f70cb03f
Commit
f70cb03f
authored
Aug 04, 2014
by
Philipp Meyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added printer for spec target
parent
e4d99b4a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
1 deletion
+59
-1
src/Main.hs
src/Main.hs
+11
-1
src/Printer/LOLA.hs
src/Printer/LOLA.hs
+1
-0
src/Printer/SPEC.hs
src/Printer/SPEC.hs
+47
-0
No files found.
src/Main.hs
View file @
f70cb03f
...
@@ -21,6 +21,7 @@ import PetriNet
...
@@ -21,6 +21,7 @@ import PetriNet
import
Printer
import
Printer
import
qualified
Printer.LOLA
as
LOLAPrinter
import
qualified
Printer.LOLA
as
LOLAPrinter
import
qualified
Printer.SARA
as
SARAPrinter
import
qualified
Printer.SARA
as
SARAPrinter
import
qualified
Printer.SPEC
as
SPECPrinter
import
Property
import
Property
import
Solver
import
Solver
import
Solver.StateEquation
import
Solver.StateEquation
...
@@ -197,6 +198,12 @@ writeFiles verbosity basename net props = do
...
@@ -197,6 +198,12 @@ writeFiles verbosity basename net props = do
verbosePut
verbosity
1
$
"Writing properties to "
++
basename
++
".sara"
verbosePut
verbosity
1
$
"Writing properties to "
++
basename
++
".sara"
L
.
writeFile
(
basename
++
".sara"
)
$
L
.
writeFile
(
basename
++
".sara"
)
$
SARAPrinter
.
printProperties
basename
net
props
SARAPrinter
.
printProperties
basename
net
props
mapM_
(
\
(
p
,
i
)
->
do
let
file
=
basename
++
".target"
++
show
i
verbosePut
verbosity
1
$
"Writing "
++
showPropertyName
p
++
" to "
++
file
L
.
writeFile
file
$
SPECPrinter
.
printProperty
p
)
(
zip
props
[(
1
::
Integer
)
..
])
structuralAnalysis
::
PetriNet
->
IO
()
structuralAnalysis
::
PetriNet
->
IO
()
structuralAnalysis
net
=
do
structuralAnalysis
net
=
do
...
@@ -236,6 +243,7 @@ checkFile parser verbosity refine implicitProperties transformations
...
@@ -236,6 +243,7 @@ checkFile parser verbosity refine implicitProperties transformations
case
output
of
case
output
of
Just
outputfile
->
writeFiles
verbosity
outputfile
net'
props'''
Just
outputfile
->
writeFiles
verbosity
outputfile
net'
props'''
Nothing
->
return
()
Nothing
->
return
()
-- TODO: short-circuit?
rs
<-
mapM
(
checkProperty
verbosity
net'
refine
)
props'''
rs
<-
mapM
(
checkProperty
verbosity
net'
refine
)
props'''
verbosePut
verbosity
0
""
verbosePut
verbosity
0
""
return
$
and
rs
return
$
and
rs
...
@@ -307,7 +315,7 @@ makeImplicitProperty net DeadlockFreeUnlessFinal =
...
@@ -307,7 +315,7 @@ makeImplicitProperty net DeadlockFreeUnlessFinal =
makeImplicitProperty
net
(
Bounded
k
)
=
makeImplicitProperty
net
(
Bounded
k
)
=
Property
(
show
k
++
"-bounded"
)
Safety
$
Property
(
show
k
++
"-bounded"
)
Safety
$
foldl
(
:|:
)
FFalse
foldl
(
:|:
)
FFalse
(
map
(
\
p
->
placeOp
G
t
(
p
,
k
))
(
map
(
\
p
->
placeOp
G
e
(
p
,
k
+
1
))
(
filter
(`
notElem
`
concatMap
(
post
net
)
(
ghostTransitions
net
))
(
filter
(`
notElem
`
concatMap
(
post
net
)
(
ghostTransitions
net
))
(
places
net
)))
(
places
net
)))
makeImplicitProperty
net
Safe
=
makeImplicitProperty
net
Safe
=
...
@@ -406,11 +414,13 @@ main = do
...
@@ -406,11 +414,13 @@ main = do
rs
<-
mapM
(
checkFile
parser
verbosity
refinement
properties
rs
<-
mapM
(
checkFile
parser
verbosity
refinement
properties
transformations
(
optUseProperties
opts
)
(
optOutput
opts
)
transformations
(
optUseProperties
opts
)
(
optOutput
opts
)
(
optPrintStructure
opts
))
files
(
optPrintStructure
opts
))
files
-- TODO: short-circuit with Control.Monad.Loops?
if
and
rs
then
if
and
rs
then
exitSuccessWith
"All properties satisfied."
exitSuccessWith
"All properties satisfied."
else
else
exitFailureWith
"Some properties may not be satisfied."
exitFailureWith
"Some properties may not be satisfied."
-- TODO: Always exit with exit code 0 unless an error occured
exitSuccessWith
::
String
->
IO
()
exitSuccessWith
::
String
->
IO
()
exitSuccessWith
msg
=
do
exitSuccessWith
msg
=
do
putStrLn
msg
putStrLn
msg
...
...
src/Printer/LOLA.hs
View file @
f70cb03f
...
@@ -52,6 +52,7 @@ renderLinIneq :: LinearInequation -> Builder
...
@@ -52,6 +52,7 @@ renderLinIneq :: LinearInequation -> Builder
renderLinIneq
(
LinIneq
lhs
op
rhs
)
=
renderLinIneq
(
LinIneq
lhs
op
rhs
)
=
renderTerm
lhs
<>
renderOp
op
<>
renderTerm
rhs
renderTerm
lhs
<>
renderOp
op
<>
renderTerm
rhs
-- TODO: reduce parantheses in built formula
renderFormula
::
Formula
->
Builder
renderFormula
::
Formula
->
Builder
renderFormula
FTrue
=
"TRUE"
renderFormula
FTrue
=
"TRUE"
renderFormula
FFalse
=
"FALSE"
renderFormula
FFalse
=
"FALSE"
...
...
src/Printer/SPEC.hs
0 → 100644
View file @
f70cb03f
{-# LANGUAGE OverloadedStrings #-}
module
Printer.SPEC
(
printProperty
)
where
import
qualified
Data.ByteString.Lazy
as
L
import
Data.ByteString.Builder
import
Data.Monoid
import
Property
renderOp
::
Op
->
Builder
renderOp
Ge
=
">="
renderOp
op
=
error
$
"operand not supported for spec: "
<>
show
op
renderLinIneq
::
LinearInequation
->
Builder
renderLinIneq
(
LinIneq
(
Var
x
)
op
(
Const
c
))
=
stringUtf8
x
<>
renderOp
op
<>
integerDec
c
renderLinIneq
l
=
error
$
"linear inequation not supported for spe: "
<>
show
l
renderConjunction
::
Formula
->
Builder
renderConjunction
(
Atom
a
)
=
renderLinIneq
a
renderConjunction
(
Neg
_
)
=
error
"negation not supported for spec"
renderConjunction
(
FTrue
:&:
p
)
=
renderConjunction
p
renderConjunction
(
p
:&:
FTrue
)
=
renderConjunction
p
renderConjunction
(
p
:&:
q
)
=
renderConjunction
p
<>
", "
<>
renderConjunction
q
renderConjunction
f
=
error
$
"formula not supported for spec: "
<>
show
f
renderDisjunction
::
Formula
->
Builder
renderDisjunction
(
FFalse
:|:
p
)
=
renderDisjunction
p
renderDisjunction
(
p
:|:
FFalse
)
=
renderDisjunction
p
renderDisjunction
(
p
:|:
q
)
=
renderDisjunction
p
<>
"
\n
"
<>
renderDisjunction
q
renderDisjunction
f
=
renderConjunction
f
renderFormula
::
Formula
->
Builder
renderFormula
=
renderDisjunction
renderProperty
::
Property
->
Builder
renderProperty
(
Property
_
Safety
f
)
=
renderFormula
f
renderProperty
(
Property
_
Liveness
_
)
=
error
"liveness property not supported for spec"
printProperty
::
Property
->
L
.
ByteString
printProperty
prop
=
toLazyByteString
$
renderProperty
prop
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