Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
NIWO
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Christian Müller
NIWO
Commits
9efcecbe
Commit
9efcecbe
authored
Sep 21, 2017
by
Christian Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add invariants
parent
81b7e2b3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
41 deletions
+64
-41
src/main/scala/de/tum/workflows/Main.scala
src/main/scala/de/tum/workflows/Main.scala
+58
-41
src/main/scala/de/tum/workflows/toz3/InvariantChecker.scala
src/main/scala/de/tum/workflows/toz3/InvariantChecker.scala
+6
-0
No files found.
src/main/scala/de/tum/workflows/Main.scala
View file @
9efcecbe
...
...
@@ -16,26 +16,26 @@ import de.tum.workflows.foltl.FormulaFunctions
import
de.tum.workflows.toz3.InvariantChecker
object
Main
extends
App
with
LazyLogging
{
val
MAXAGENTS
=
8
val
FOLDER
=
"results"
val
checkinvariants
=
true
def
clear
()
{
def
recclear
(
folder
:
File
)
{
def
recclear
(
folder
:
File
)
{
for
(
fol
<-
folder
.
listFiles
()
if
fol
.
isDirectory
())
{
recclear
(
fol
)
}
folder
.
listFiles
().
foreach
(
_
.
delete
())
}
val
fol
=
new
File
(
FOLDER
)
fol
.
mkdirs
()
recclear
(
fol
)
}
def
write
(
name
:
String
,
prop
:
String
)
{
def
write
(
name
:
String
,
prop
:
String
)
{
val
file
=
new
File
(
name
)
file
.
getParentFile
.
mkdirs
()
val
writer
=
new
PrintWriter
(
file
)
...
...
@@ -43,48 +43,64 @@ object Main extends App with LazyLogging {
writer
.
close
()
}
def
writeExample
(
name
:
String
,
spec
:
Spec
,
prop
:
Formula
)
{
def
timeNoninter
(
spec
:
Spec
)
=
{
val
inv
=
InvariantChecker
.
invariantNoninterStubborn
(
spec
)
val
(
t
,
(
safe
,
msg
))
=
time
{
InvariantChecker
.
checkInvariant
(
spec
.
w
,
inv
,
true
)
}
s
"Noninterference Invariant (took $t ms):\n$msg\n"
}
def
timeAllEqual
(
spec
:
Spec
)
=
{
val
inv
=
InvariantChecker
.
invariantAllEqual
(
spec
)
val
(
t
,
(
safe
,
msg
))
=
time
{
InvariantChecker
.
checkInvariant
(
spec
.
w
,
inv
,
true
)
}
s
"All Equal Invariant (took $t ms):\n$msg\n"
}
def
writeExample
(
name
:
String
,
spec
:
Spec
,
prop
:
Formula
)
{
var
metrics
=
List
[
String
]()
write
(
s
"${name}.foltl"
,
prop
.
pretty
())
metrics
:+=
s
"${name}.foltl: ${prop.opsize()}"
if
(!
FormulaFunctions
.
checkSanity
(
prop
))
{
logger
.
error
(
"Property didn't pass sanity check"
)
return
}
// Do FOLTL to LTL
if
(
spec
.
w
.
isomitting
)
{
logger
.
info
(
"Omitting spec - no embedding in LTL possible"
)
}
else
{
logger
.
info
(
"Nonomitting spec - embedding FOLTL formula in LTL"
)
val
(
agents
,
res
)
=
LTL
.
eliminateExistentials
(
prop
)
val
universe
=
agents
.
map
(
_
.
withType
()).
mkString
(
", "
)
logger
.
info
(
s
"Using universe $universe"
)
if
(
agents
.
groupBy
(
_
.
typ
).
exists
(
_
.
_2
.
size
>
MAXAGENTS
))
{
logger
.
error
(
s
"Universe has more than $MAXAGENTS agents for a single type. Aborting."
)
return
}
val
quantfree
=
LTL
.
eliminateUniversals
(
res
,
agents
)
val
ltlprop
=
LTL
.
eliminatePredicates
(
quantfree
)
metrics
:+=
s
"${name}.ltl: ${ltlprop.opsize()}"
metrics
:+=
s
"Universe: $universe"
metrics
:+=
s
"Universe: $universe"
write
(
s
"${name}.ltl"
,
ltlprop
.
toString
())
write
(
s
"${name}.ppltl"
,
ltlprop
.
pretty
())
}
write
(
s
"${name}.metrics"
,
metrics
.
mkString
(
""
,
"\n"
,
"\n"
))
logger
.
info
(
s
"Written all files for $name"
)
}
def
generate
(
name
:
String
,
spec
:
Spec
)
{
def
generate
(
name
:
String
,
spec
:
Spec
)
{
logger
.
info
(
s
"Encoding Spec:\n$spec"
)
val
t1
=
"pi1"
val
t2
=
"pi2"
...
...
@@ -97,40 +113,41 @@ object Main extends App with LazyLogging {
val
cprop
=
Properties
.
noninterCausal
(
spec
)
writeExample
(
s
"$FOLDER/${name}_causal"
,
spec
,
cprop
)
}
if
(
checkinvariants
)
{
val
inv
=
InvariantChecker
.
invariantNoninterStubborn
(
spec
)
val
(
t
,(
safe
,
msg
))
=
time
{
InvariantChecker
.
checkInvariant
(
spec
.
w
,
inv
,
true
)
}
val
noninter
=
s
"Noninterference Invariant (took $t ms):\n$msg"
write
(
s
"$FOLDER/${name}.inv"
,
noninter
)
def
invariants
=
List
(
timeNoninter
_
,
timeAllEqual
_
)
def
msgs
=
invariants
.
map
(
_
(
spec
))
write
(
s
"$FOLDER/${name}.inv"
,
msgs
.
mkString
(
"\n"
))
}
}
def
generateExample
(
name
:
String
)
{
logger
.
info
(
s
"Generating $name"
)
val
spec
=
ExampleWorkflows
.
parseExample
(
name
)
if
(!
spec
.
isDefined
)
{
logger
.
error
(
s
"Not a valid spec: $name"
)
}
spec
.
map
(
generate
(
name
,
_
))
logger
.
info
(
s
"Generating $name"
)
val
spec
=
ExampleWorkflows
.
parseExample
(
name
)
if
(!
spec
.
isDefined
)
{
logger
.
error
(
s
"Not a valid spec: $name"
)
}
spec
.
map
(
generate
(
name
,
_
))
}
def
generateAllExamples
()
{
clear
()
// Fill results alphabetically
for
(
k
<-
ExampleWorkflows
.
examples
.
keys
.
toList
.
sorted
)
{
generateExample
(
k
)
generateExample
(
k
)
}
}
// clear()
// generateExample("omitting/conference")
// generateExample("tests/declasstest")
// clear()
// generateExample("omitting/conference")
// generateExample("tests/declasstest")
generateAllExamples
()
}
\ No newline at end of file
src/main/scala/de/tum/workflows/toz3/InvariantChecker.scala
View file @
9efcecbe
...
...
@@ -115,4 +115,10 @@ object InvariantChecker extends LazyLogging {
Forall
(
agent
,
premise
→
conclusion
).
simplify
()
}
def
invariantAllEqual
(
spec
:
Spec
)
=
{
And
.
make
(
for
(
r
<-
spec
.
w
.
sig
.
preds
.
toList
)
yield
{
Forall
(
r
.
params
,
genEq
(
r
,
r
.
params
))
})
}
}
\ No newline at end of file
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