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
dda24412
Commit
dda24412
authored
May 06, 2014
by
Philipp Meyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small changes to property and formula syntax
parent
d262f8ac
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
17 deletions
+26
-17
src/Main.hs
src/Main.hs
+8
-3
src/Parser.hs
src/Parser.hs
+6
-6
src/Property.hs
src/Property.hs
+10
-6
src/Solver.hs
src/Solver.hs
+2
-2
No files found.
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
pformulas
<-
braces
formula
return
$
Property
name
ptype
pformulas
form
<-
braces
formula
return
Property
{
pname
=
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
(
pname
p
)
then
""
else
show
(
pname
p
)
++
" "
)
++
"{ "
++
show
(
pformula
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