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
68ca8742
Commit
68ca8742
authored
Mar 26, 2019
by
Christian Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add trace to equalities
parent
20b88f00
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
24 deletions
+48
-24
src/main/scala/de/tum/niwo/Utils.scala
src/main/scala/de/tum/niwo/Utils.scala
+1
-0
src/main/scala/de/tum/niwo/blocks/Saturator.scala
src/main/scala/de/tum/niwo/blocks/Saturator.scala
+4
-4
src/main/scala/de/tum/niwo/foltl/FOTransformers.scala
src/main/scala/de/tum/niwo/foltl/FOTransformers.scala
+34
-11
src/main/scala/de/tum/niwo/foltl/FormulaFunctions.scala
src/main/scala/de/tum/niwo/foltl/FormulaFunctions.scala
+5
-5
src/test/scala/de/tum/niwo/tests/ParserTest.scala
src/test/scala/de/tum/niwo/tests/ParserTest.scala
+3
-3
src/test/scala/de/tum/niwo/tests/papertests/InvariantEasychairTest.scala
...de/tum/niwo/tests/papertests/InvariantEasychairTest.scala
+1
-1
No files found.
src/main/scala/de/tum/niwo/Utils.scala
View file @
68ca8742
...
...
@@ -15,6 +15,7 @@ object Utils extends LazyLogging {
val
RESULTSFOLDER
=
"results"
val
DEBUG_MODE
=
true
val
Z3CONTEXTELIM
=
false
val
APPROXELIM_MINSIZE
=
50
def
mkString
[
T
](
string
:
Iterable
[
T
],
start
:
String
,
mid
:
String
,
end
:
String
)
:
String
=
{
if
(
string
.
isEmpty
)
""
else
string
.
mkString
(
start
,
mid
,
end
)
...
...
src/main/scala/de/tum/niwo/blocks/Saturator.scala
View file @
68ca8742
package
de.tum.niwo.blocks
import
com.typesafe.scalalogging.LazyLogging
import
de.tum.niwo.Utils
import
de.tum.niwo.foltl.FOLTL._
import
de.tum.niwo.foltl.
FormulaFunctions
import
de.tum.niwo.foltl.
{
FormulaFunctions
,
Properties
}
import
de.tum.niwo.toz3.Z3BSFO
object
Saturator
extends
LazyLogging
{
...
...
@@ -20,8 +19,9 @@ object Saturator extends LazyLogging {
// FIXME: this may add too many eqs, since annotations T1, T2 are ignored
val
witheqs
=
for
(
c
<-
clauses
)
yield
{
val
ineqs
=
for
(
pred
<-
allpredicates
;
pos
<-
FormulaFunctions
.
getPositiveArguments
(
c
,
pred
.
name
);
neg
<-
FormulaFunctions
.
getNegativeArguments
(
c
,
pred
.
name
)
trace
<-
List
(
None
,
Some
(
Properties
.
T1
),
Some
(
Properties
.
T2
));
pos
<-
FormulaFunctions
.
getPositiveArguments
(
c
,
pred
.
name
,
trace
);
neg
<-
FormulaFunctions
.
getNegativeArguments
(
c
,
pred
.
name
,
trace
)
)
yield
{
FormulaFunctions
.
eq
(
pos
,
neg
)
}
...
...
src/main/scala/de/tum/niwo/foltl/FOTransformers.scala
View file @
68ca8742
...
...
@@ -57,11 +57,34 @@ object FOTransformers extends LazyLogging {
}
def
eliminateAuxiliaryPredicate
(
f
:
Formula
,
AUX
:
String
,
props
:
InvProperties
)
:
Formula
=
{
logger
.
debug
(
s
"Eliminating universal second order predicate $AUX"
)
val
cnf
=
if
(!
props
.
approxElim
)
f
.
toCNF
else
f
.
toNegNf
val
result
=
if
(!
props
.
approxElim
||
f
.
opsize
<
Utils
.
APPROXELIM_MINSIZE
)
{
logger
.
debug
(
s
"Eliminating universal second order predicate $AUX"
)
val
(
quants
,
clauses
)
=
FormulaFunctions
.
toCNFClauses
(
f
)
val
repld
=
cnf
everywhere
{
val
updatedclauses
=
for
(
clause
<-
clauses
)
yield
{
val
eqs
=
for
(
trace
<-
List
(
None
,
Some
(
Properties
.
T1
),
Some
(
Properties
.
T2
));
pos
<-
FormulaFunctions
.
getPositiveArguments
(
clause
,
AUX
,
trace
);
neg
<-
FormulaFunctions
.
getNegativeArguments
(
clause
,
AUX
,
trace
))
yield
{
FormulaFunctions
.
eq
(
pos
,
neg
)
}
if
(
eqs
.
nonEmpty
)
{
logger
.
trace
(
s
"Introducing equalities while eliminating $AUX"
)
}
clause
++
eqs
}
val
updatedcnf
=
And
.
make
(
updatedclauses
.
map
(
Or
.
make
))
FormulaFunctions
.
rewrapQuantifiers
(
quants
,
updatedcnf
)
}
else
{
logger
.
debug
(
s
"Approximating elimination of universal second order predicate $AUX"
)
// Saturated formula, no equalities anywhere
f
}
val
repld
=
result
everywhere
{
case
Neg
(
Fun
(
AUX
,
_
,
_
))
=>
False
case
Fun
(
AUX
,
_
,
_
)
=>
False
}
...
...
@@ -84,14 +107,14 @@ object FOTransformers extends LazyLogging {
val
(
quantifiers
,
clauses
)
=
FormulaFunctions
.
toCNFClauses
(
noannotation
)
// Group clauses by positive/negative occurences
val
getPositiveBArguments
=
FormulaFunctions
.
getPositiveArguments
(
_
,
NAME
)
val
getNegativeBArguments
=
FormulaFunctions
.
getNegativeArguments
(
_
,
NAME
)
val
positiveBArguments
=
FormulaFunctions
.
getPositiveArguments
(
_
,
NAME
,
None
)
val
negativeBArguments
=
FormulaFunctions
.
getNegativeArguments
(
_
,
NAME
,
None
)
def
ispositive
(
clause
:
List
[
Formula
])
=
getP
ositiveBArguments
(
clause
).
nonEmpty
p
ositiveBArguments
(
clause
).
nonEmpty
def
isnegative
(
clause
:
List
[
Formula
])
=
getN
egativeBArguments
(
clause
).
nonEmpty
n
egativeBArguments
(
clause
).
nonEmpty
def
pruneBs
(
clause
:
List
[
Formula
])
=
{
clause
filterNot
{
...
...
@@ -104,17 +127,17 @@ object FOTransformers extends LazyLogging {
val
E
=
clauses
.
filter
(
c
=>
!
ispositive
(
c
)
&&
!
isnegative
(
c
))
val
F
=
clauses
.
filter
(
c
=>
ispositive
(
c
)
&&
!
isnegative
(
c
))
// F \/ B z_1 ... B z_r
val
Fargs
=
F
.
map
(
getP
ositiveBArguments
)
val
Fargs
=
F
.
map
(
p
ositiveBArguments
)
val
G
=
clauses
.
filter
(
c
=>
isnegative
(
c
)
&&
!
ispositive
(
c
))
// G \/ !B z'_1 ... !B z'_j
val
Gargs
=
G
.
map
(
getN
egativeBArguments
)
val
Gargs
=
G
.
map
(
n
egativeBArguments
)
val
H
=
clauses
.
filter
(
c
=>
ispositive
(
c
)
&&
isnegative
(
c
))
// H \/ B u_1 .. B u_l \/ !B v_1 ... ! B v_n
val
HPositiveargs
=
H
.
map
(
getP
ositiveBArguments
)
val
HNegativeargs
=
H
.
map
(
getN
egativeBArguments
)
val
HPositiveargs
=
H
.
map
(
p
ositiveBArguments
)
val
HNegativeargs
=
H
.
map
(
n
egativeBArguments
)
if
(
H
.
nonEmpty
)
{
logger
.
debug
(
"BSFO SOQE: H is not empty, Ackermann not applicable"
)
...
...
src/main/scala/de/tum/niwo/foltl/FormulaFunctions.scala
View file @
68ca8742
...
...
@@ -592,7 +592,6 @@ object FormulaFunctions extends LazyLogging {
// } else {
// logger.warn("Using internal CNF conversion - may blow up")
// FIXME: can we do it without prenex? may be expensive later on
val
normalized
=
f
.
toPrenex
.
simplify
logger
.
debug
(
s
"Computing CNF of prenex formula of opsize ${normalized.opsize}"
)
...
...
@@ -695,15 +694,16 @@ object FormulaFunctions extends LazyLogging {
}
def
getPositiveArguments
(
clause
:
List
[
Formula
],
NAME
:
String
)
:
Set
[
List
[
Var
]]
=
{
// matches positive arguments of the function with the correct annotation
def
getPositiveArguments
(
clause
:
List
[
Formula
],
NAME
:
String
,
ANNOTATION
:
Option
[
String
]
=
None
)
:
Set
[
List
[
Var
]]
=
{
clause
flatMap
{
case
Fun
(
NAME
,
_
,
vars
)
=>
List
(
vars
)
case
Fun
(
NAME
,
ANNOTATION
,
vars
)
=>
List
(
vars
)
case
_
=>
List
()
}
toSet
}
def
getNegativeArguments
(
clause
:
List
[
Formula
],
NAME
:
String
)
:
Set
[
List
[
Var
]]
=
{
def
getNegativeArguments
(
clause
:
List
[
Formula
],
NAME
:
String
,
ANNOTATION
:
Option
[
String
]
=
None
)
:
Set
[
List
[
Var
]]
=
{
clause
flatMap
{
case
Neg
(
Fun
(
NAME
,
_
,
vars
))
=>
List
(
vars
)
case
Neg
(
Fun
(
NAME
,
ANNOTATION
,
vars
))
=>
List
(
vars
)
case
_
=>
List
()
}
toSet
}
...
...
src/test/scala/de/tum/niwo/tests/ParserTest.scala
View file @
68ca8742
...
...
@@ -12,7 +12,7 @@ import de.tum.niwo.parser.WorkflowParser
class
ParserTest
extends
FlatSpec
{
val
oxrxssig
=
Signature
(
Set
(
Fun
(
"O"
,
List
(
"x"
,
"s"
))),
Set
(),
Set
(),
Set
(
Fun
(
"R"
,
List
(
"x"
,
"s"
))),
Set
())
val
oxrxssig
=
Signature
(
Set
(
Fun
(
"O"
,
List
(
"x"
,
"s"
))
,
Fun
(
"choice0"
,
List
(
"x"
,
"s"
))
),
Set
(),
Set
(),
Set
(
Fun
(
"R"
,
List
(
"x"
,
"s"
))),
Set
())
def
testResult
(
s
:
String
,
sig
:
Signature
)
{
testResult
(
s
,
Workflow
(
sig
,
List
()))
...
...
@@ -91,7 +91,7 @@ class ParserTest extends FlatSpec {
"""
val
w
=
Workflow
(
Signature
(
Set
(
Fun
(
"O"
,
List
(
"s"
))),
Set
(
Fun
(
"O"
,
List
(
"s"
))
,
Fun
(
"choice0"
,
List
(
"x"
,
"s"
))
),
Set
(),
Set
(),
Set
(
...
...
@@ -157,7 +157,7 @@ class ParserTest extends FlatSpec {
val
x
=
Var
(
"x"
,
"Agent"
)
val
s
=
Var
(
"s"
,
"Paper"
)
val
typedsig
=
Signature
(
Set
(
Fun
(
"O"
,
List
(
x
))),
Set
(),
Set
(),
Set
(
Fun
(
"R"
,
List
(
x
,
s
))),
Set
())
val
typedsig
=
Signature
(
Set
(
Fun
(
"O"
,
List
(
x
))
,
Fun
(
"choice0"
,
List
(
x
))
),
Set
(),
Set
(),
Set
(
Fun
(
"R"
,
List
(
x
,
s
))),
Set
())
val
w
=
Workflow
(
typedsig
,
...
...
src/test/scala/de/tum/niwo/tests/papertests/InvariantEasychairTest.scala
View file @
68ca8742
...
...
@@ -115,7 +115,7 @@ class InvariantEasychairTest extends FlatSpec {
}
// Brittle against approx elim
it
should
"prove omitting/conference_fixed with auxelim approximation"
i
gnore
{
it
should
"prove omitting/conference_fixed with auxelim approximation"
i
n
{
val
name
=
"omitting/conference_fixed_stubborn"
val
inv
=
InvariantGenerator
.
invariantNoninterSingleBS
_
assert
(
checkSafe
(
name
,
""
,
inv
,
InvProperties
(
...
...
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