Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
i7
peregrine
Commits
dda24412
Commit
dda24412
authored
May 06, 2014
by
Philipp Meyer
Browse files
Small changes to property and formula syntax
parent
d262f8ac
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/Main.hs
View file @
dda24412
...
...
@@ -5,9 +5,13 @@ import System.Environment (getArgs)
import
Parser
(
parseFile
)
import
PetriNet
import
Property
import
Solver
checkProperty
::
PetriNet
->
Property
->
Bool
checkProperty
net
p
=
True
checkProperty
::
PetriNet
->
Property
->
IO
String
checkProperty
net
p
=
do
r
<-
checkSat
net
p
return
(
if
r
then
"Property not satisfied"
else
"Property satisfied"
)
main
::
IO
()
main
=
do
...
...
@@ -19,6 +23,7 @@ main = do
putStrLn
$
"Analyzing "
++
showName
net
mapM_
(
\
p
->
do
putStrLn
$
"Checking "
++
show
p
putStrLn
$
show
$
checkProperty
net
p
r
<-
checkProperty
net
p
putStrLn
r
)
properties
src/Parser.hs
View file @
dda24412
...
...
@@ -22,7 +22,7 @@ languageDef =
Token
.
identLetter
=
alphaNum
<|>
char
'_'
,
Token
.
reservedNames
=
[]
,
Token
.
reservedOpNames
=
[
"->"
,
"<"
,
"<="
,
"="
,
">="
,
">"
,
"+"
,
"-"
,
"*"
,
"&"
,
"|"
,
"!"
]
"+"
,
"-"
,
"*"
,
"&
&
"
,
"|
|
"
,
"!"
]
}
lexer
::
Token
.
TokenParser
u
...
...
@@ -158,12 +158,12 @@ negation = (Neg <$> (reservedOp "!" *> negation)) <|> parensForm
conjunction
::
Parser
u
Formula
conjunction
=
do
lhs
<-
negation
option
lhs
((
lhs
:&:
)
<$>
(
reservedOp
"&"
*>
conjunction
))
option
lhs
((
lhs
:&:
)
<$>
(
reservedOp
"&
&
"
*>
conjunction
))
disjunction
::
Parser
u
Formula
disjunction
=
do
lhs
<-
conjunction
option
lhs
((
lhs
:|:
)
<$>
(
reservedOp
"|"
*>
disjunction
))
option
lhs
((
lhs
:|:
)
<$>
(
reservedOp
"|
|
"
*>
disjunction
))
formula
::
Parser
u
Formula
formula
=
disjunction
...
...
@@ -175,11 +175,11 @@ propertyType =
property
::
Parser
u
Property
property
=
do
pt
ype
<-
propertyType
pt
<-
propertyType
reserved
"property"
name
<-
option
""
ident
p
form
ulas
<-
braces
formula
return
$
Property
name
ptype
pformula
s
form
<-
braces
formula
return
Property
{
p
name
=
name
,
ptype
=
pt
,
pformula
=
form
}
parseContent
::
Parser
u
(
PetriNet
,[
Property
])
parseContent
=
do
...
...
src/Property.hs
View file @
dda24412
...
...
@@ -49,7 +49,7 @@ infixr 2 :|:
instance
Show
Formula
where
show
(
Atom
a
)
=
show
a
show
(
Neg
p
)
=
"¬"
++
show
p
show
(
Neg
p
)
=
"¬"
++
"("
++
show
p
++
")"
show
(
p
:&:
q
)
=
"("
++
show
p
++
" ∧ "
++
show
q
++
")"
show
(
p
:|:
q
)
=
"("
++
show
p
++
" ∨ "
++
show
q
++
")"
...
...
@@ -59,11 +59,15 @@ instance Show PropertyType where
show
Safety
=
"safety"
show
Liveness
=
"liveness"
data
Property
=
Property
String
PropertyType
Formula
data
Property
=
Property
{
pname
::
String
,
ptype
::
PropertyType
,
pformula
::
Formula
}
instance
Show
Property
where
show
(
Property
name
ptype
formula
)
=
show
ptype
++
" property "
++
(
if
null
name
then
""
else
show
name
++
" "
)
++
"{ "
++
show
formula
++
" }"
show
p
=
show
(
ptype
p
)
++
" property "
++
(
if
null
(
p
name
p
)
then
""
else
show
(
p
name
p
)
++
" "
)
++
"{ "
++
show
(
p
formula
p
)
++
" }"
src/Solver.hs
View file @
dda24412
...
...
@@ -48,9 +48,9 @@ buildModel net = do
return
$
M
.
fromList
(
vars
`
zip
`
syms
)
checkConstraints
::
PetriNet
->
Property
->
Symbolic
SBool
checkConstraints
net
(
Property
_
_
f
)
=
do
checkConstraints
net
p
=
do
model
<-
buildModel
net
evaluateFormula
model
f
evaluateFormula
model
(
pformula
p
)
checkSat
::
PetriNet
->
Property
->
IO
Bool
checkSat
net
p
=
do
...
...
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