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
1c832a5d
Commit
1c832a5d
authored
Sep 28, 2017
by
Eugen Zalinescu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stronger invariant
parent
0485d936
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
61 deletions
+82
-61
src/main/scala/de/tum/workflows/ltl/LTL.scala
src/main/scala/de/tum/workflows/ltl/LTL.scala
+1
-1
src/test/scala/de/tum/workflows/ltl/tests/InvariantTest.scala
...test/scala/de/tum/workflows/ltl/tests/InvariantTest.scala
+81
-60
No files found.
src/main/scala/de/tum/workflows/ltl/LTL.scala
View file @
1c832a5d
...
...
@@ -55,7 +55,7 @@ object LTL extends LazyLogging {
def
eliminateUniversals
(
t
:
Formula
,
agents
:
List
[
Var
])
:
Formula
=
{
if
(
agents
.
isEmpty
)
{
logger
.
error
(
"Agent list should never be
empty"
)
logger
.
warn
(
"Agent list
empty"
)
}
val
universe
=
agents
.
groupBy
(
_
.
typ
)
...
...
src/test/scala/de/tum/workflows/ltl/tests/InvariantTest.scala
View file @
1c832a5d
...
...
@@ -16,78 +16,99 @@ class InvariantTest extends FlatSpec {
"InvariantChecker"
should
"prove simple things safe"
in
{
val
wf
=
ExampleWorkflows
.
parseExample
(
"tests/simpleChoiceNoOracle"
).
get
.
w
val
spec
=
ExampleWorkflows
.
parseExample
(
"nonomitting/conference"
).
get
val
inv
=
Forall
(
List
(
"a"
,
"b"
),
Eq
(
Fun
(
"R"
,
Some
(
"t1"
),
List
(
"a"
,
"b"
)),
Fun
(
"R"
,
Some
(
"t2"
),
List
(
"a"
,
"b"
))))
//
val inv = Forall(List("a", "b"), Eq(Fun("R", Some("t1"), List("a", "b")), Fun("R", Some("t2"), List("a", "b"))))
val
(
safe
,
msg
)
=
InvariantChecker
.
checkInvariant
(
wf
,
inv
,
true
)
safe
should
be
(
true
)
}
it
should
"fail to prove unsafe workflows safe"
in
{
val
inv
=
InvariantChecker
.
invariantNoninterStubbornBS
(
spec
)
val
wf
=
ExampleWorkflows
.
parseExample
(
"tests/simpleChoice"
).
get
.
w
val
inv
=
Forall
(
List
(
"a"
,
"b"
),
Eq
(
Fun
(
"R"
,
Some
(
"t1"
),
List
(
"a"
,
"b"
)),
Fun
(
"R"
,
Some
(
"t2"
),
List
(
"a"
,
"b"
))))
val
(
safe
,
msg
)
=
InvariantChecker
.
checkInvariant
(
wf
,
inv
,
true
)
safe
should
be
(
false
)
}
it
should
"prove the paper example"
in
{
val
wf
=
ExampleWorkflows
.
parseExample
(
"omitting/conference"
).
get
.
w
val
x
=
Var
(
"x"
,
"A"
)
val
y
=
Var
(
"y"
,
"A"
)
val
p
=
Var
(
"p"
,
"P"
)
val
r
=
Var
(
"r"
,
"R"
)
val
c
=
Fun
(
"Conf"
,
Some
(
"t1"
),
List
(
x
,
p
))
//
val
ceq
=
genEq
(
"Conf"
,
List
(
x
,
p
))
val
oeq
=
genEq
(
"O"
,
List
(
x
,
p
,
r
))
val
readeq
=
genEq
(
"Read"
,
List
(
x
,
p
,
r
))
val
assigneq
=
genEq
(
"Assign"
,
List
(
x
,
p
))
val
revieweq
=
genEq
(
"Review"
,
List
(
x
,
p
,
r
))
// val premise = And(Neg(c), oeq)
// val conclusion = And.make(ceq, readeq, assigneq, Forall(y, revieweq))
val
added
=
Or
(
Neg
(
Fun
(
"Assign"
,
List
(
Var
(
"x"
,
"A"
),
Var
(
"p"
,
"P"
)))),
Neg
(
Fun
(
"Conf"
,
List
(
Var
(
"x"
,
"A"
),
Var
(
"p"
,
"P"
)))))
val
premise
=
Forall
(
List
(
p
,
r
),
And
(
Neg
(
c
),
oeq
))
val
conclusion
=
Forall
(
List
(
p
,
r
),
And
.
make
(
ceq
,
readeq
,
assigneq
,
revieweq
))
val
both
=
Forall
(
List
(
Var
(
"x"
,
"A"
),
Var
(
"p"
,
"P"
)),
And
(
added
.
in
(
"t1"
),
added
.
in
(
"t2"
)))
val
inv
=
Forall
(
List
(
x
),
Implies
(
premise
,
conclusion
)
)
val
(
safe
,
msg
)
=
InvariantChecker
.
checkInvariant
(
wf
,
inv
,
true
)
val
newinv
=
And
(
inv
,
both
)
safe
should
be
(
true
)
val
(
safe
,
msg
)
=
InvariantChecker
.
checkInvariant
(
spec
.
w
,
newinv
,
true
)
println
(
msg
.
toString
())
safe
should
be
(
true
)
}
// "InvariantChecker" should "prove simple things safe" in {
//
// val wf = ExampleWorkflows.parseExample("tests/simpleChoiceNoOracle").get.w
//
// val inv = Forall(List("a", "b"), Eq(Fun("R", Some("t1"), List("a", "b")), Fun("R", Some("t2"), List("a", "b"))))
//
// val (safe, msg) = InvariantChecker.checkInvariant(wf, inv, true)
//
// safe should be(true)
// }
//
// it should "fail to prove unsafe workflows safe" in {
//
// val wf = ExampleWorkflows.parseExample("tests/simpleChoice").get.w
//
// val inv = Forall(List("a", "b"), Eq(Fun("R", Some("t1"), List("a", "b")), Fun("R", Some("t2"), List("a", "b"))))
//
// val (safe, msg) = InvariantChecker.checkInvariant(wf, inv, true)
//
// safe should be(false)
// }
//
// it should "prove the paper example" in {
// val wf = ExampleWorkflows.parseExample("omitting/conference").get.w
//
// val x = Var("x", "A")
// val y = Var("y", "A")
// val p = Var("p","P")
// val r = Var("r","R")
// val c = Fun("Conf", Some("t1"), List(x,p))
//
////
// val ceq = genEq("Conf", List(x,p))
// val oeq = genEq("O", List(x,p,r))
// val readeq = genEq("Read", List(x,p,r))
// val assigneq = genEq("Assign", List(x,p))
// val revieweq = genEq("Review", List(x,p,r))
//// val premise = And(Neg(c), oeq)
//// val conclusion = And.make(ceq, readeq, assigneq, Forall(y, revieweq))
//
// val premise = Forall(List(p,r), And(Neg(c), oeq))
// val conclusion = Forall(List(p,r), And.make(ceq, readeq, assigneq, revieweq))
//
// val inv = Forall(List(x),
// Implies(premise, conclusion)
// )
// val (safe, msg) = InvariantChecker.checkInvariant(wf, inv, true)
//
// safe should be (true)
// }
//
//
def
genEq
(
name
:
String
,
params
:
List
[
Var
])
=
{
val
o1
=
Fun
(
name
,
Some
(
"t1"
),
params
)
val
o2
=
Fun
(
name
,
Some
(
"t2"
),
params
)
Eq
(
o1
,
o2
)
}
it
should
"prove noninter invariants"
in
{
val
spec
=
ExampleWorkflows
.
parseExample
(
"tests/simpleChoice"
).
get
val
inv
=
InvariantChecker
.
invariantNoninterStubborn
(
spec
)
val
(
safe
,
msg
)
=
InvariantChecker
.
checkInvariant
(
spec
.
w
,
inv
,
true
)
safe
should
be
(
false
)
}
it
should
"prove the paper example as noninter invariant"
in
{
val
spec
=
ExampleWorkflows
.
parseExample
(
"omitting/conference"
).
get
val
inv
=
InvariantChecker
.
invariantNoninterStubborn
(
spec
)
val
(
safe
,
msg
)
=
InvariantChecker
.
checkInvariant
(
spec
.
w
,
inv
,
true
)
safe
should
be
(
true
)
}
//
//
it should "prove noninter invariants" in {
//
val spec = ExampleWorkflows.parseExample("tests/simpleChoice").get
//
//
val inv = InvariantChecker.invariantNoninterStubborn(spec)
//
val (safe, msg) = InvariantChecker.checkInvariant(spec.w, inv, true)
//
//
safe should be(false)
//
}
//
//
it should "prove the paper example as noninter invariant" in {
//
val spec = ExampleWorkflows.parseExample("omitting/conference").get
//
//
val inv = InvariantChecker.invariantNoninterStubborn(spec)
//
val (safe, msg) = InvariantChecker.checkInvariant(spec.w, inv,true)
//
//
safe should be(true)
//
}
}
\ 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