Commit e998e442 authored by Christian Müller's avatar Christian Müller

ts converter

parent bb32d548
...@@ -4,11 +4,10 @@ import scala.io.Source ...@@ -4,11 +4,10 @@ import scala.io.Source
import com.typesafe.scalalogging.LazyLogging import com.typesafe.scalalogging.LazyLogging
import de.tum.niwo.Utils._ import de.tum.niwo.Utils._
import de.tum.niwo.blocks.NISpec import de.tum.niwo.blocks.NISpec
import de.tum.niwo.toz3.InvariantChecker import de.tum.niwo.invariants.InvariantChecker
import de.tum.niwo.toz3.InvariantGenerator
import de.tum.niwo.toz3.InvProperties
import java.io.File import java.io.File
import de.tum.niwo.invariants.{InvProperties, InvariantGenerator}
import de.tum.niwo.parser.WorkflowParser import de.tum.niwo.parser.WorkflowParser
object InvariantCLI extends App with LazyLogging { object InvariantCLI extends App with LazyLogging {
...@@ -58,7 +57,7 @@ object InvariantCLI extends App with LazyLogging { ...@@ -58,7 +57,7 @@ object InvariantCLI extends App with LazyLogging {
def generate(name: String, spec: NISpec, properties: InvProperties) { def generate(name: String, spec: NISpec, properties: InvProperties) {
logger.info(s"Encoding Spec:\n$spec") logger.info(s"Encoding Spec:\n$spec")
def invariant = InvariantGenerator.invariantNoninterSingleBS(spec) def invariant = InvariantGenerator.invariantNoninterSingleBS _
Utils.check(name, "", invariant, spec, properties) Utils.check(name, "", invariant, spec, properties)
} }
......
...@@ -10,12 +10,10 @@ import de.tum.niwo.foltl.Stubborn ...@@ -10,12 +10,10 @@ import de.tum.niwo.foltl.Stubborn
import de.tum.niwo.foltl.Properties import de.tum.niwo.foltl.Properties
import java.io.PrintWriter import java.io.PrintWriter
import java.io.File import java.io.File
import de.tum.niwo.blocks.Workflow
import de.tum.niwo.blocks.NISpec import de.tum.niwo.blocks.{NISpec, TSConverter, Workflow}
import de.tum.niwo.foltl.FormulaFunctions import de.tum.niwo.foltl.FormulaFunctions
import de.tum.niwo.toz3.InvariantChecker import de.tum.niwo.invariants.{InvProperties, InvariantChecker, InvariantGenerator}
import de.tum.niwo.toz3.InvariantGenerator
import de.tum.niwo.toz3.InvProperties
import de.tum.niwo.toz3.Z3QFree import de.tum.niwo.toz3.Z3QFree
object InvariantInspector extends App with LazyLogging { object InvariantInspector extends App with LazyLogging {
...@@ -36,11 +34,13 @@ object InvariantInspector extends App with LazyLogging { ...@@ -36,11 +34,13 @@ object InvariantInspector extends App with LazyLogging {
// InvariantChecker.invariantNoninterStubborn _ // InvariantChecker.invariantNoninterStubborn _
// InvariantChecker.invariantAllEqual _ // InvariantChecker.invariantAllEqual _
val props = InvProperties(stubborn = false, eliminateA = true)
val invspec = TSConverter.toInvariantSpec(spec, props, invariant)
val (t, (res, dot)) = time { val (t, (res, dot)) = time {
// InvariantChecker.checkInvariantOnce(spec.w, inv(spec), true) // InvariantChecker.checkInvariantOnce(spec.w, inv(spec), true)
val props = InvProperties(stubborn = false, eliminateA = true) val (result, graph, afterlabels, proven, dot, time) =
val (result, graph, afterlabels, proven, dot, time) = InvariantChecker.checkInvariantFPLabelling(invspec, props)
InvariantChecker.checkInvariantFPLabelling(spec, invariant(spec), props)
// non-omitting conference linear inspection // non-omitting conference linear inspection
val lastlabels = afterlabels.last val lastlabels = afterlabels.last
......
...@@ -7,11 +7,10 @@ import com.typesafe.scalalogging.LazyLogging ...@@ -7,11 +7,10 @@ import com.typesafe.scalalogging.LazyLogging
import de.tum.niwo.Utils._ import de.tum.niwo.Utils._
import java.io.PrintWriter import java.io.PrintWriter
import java.io.File import java.io.File
import de.tum.niwo.blocks.Workflow
import de.tum.niwo.blocks.NISpec import de.tum.niwo.blocks.{InvariantSpec, NISpec, TSConverter, Workflow}
import de.tum.niwo.foltl.FormulaFunctions import de.tum.niwo.foltl.FormulaFunctions
import de.tum.niwo.toz3.InvariantChecker import de.tum.niwo.invariants.{InvProperties, InvariantChecker, InvariantGenerator}
import de.tum.niwo.toz3.InvariantGenerator
object MainInvariants extends App with LazyLogging { object MainInvariants extends App with LazyLogging {
...@@ -24,7 +23,10 @@ object MainInvariants extends App with LazyLogging { ...@@ -24,7 +23,10 @@ object MainInvariants extends App with LazyLogging {
// InvariantChecker.invariantNoninterStubborn _ // InvariantChecker.invariantNoninterStubborn _
// InvariantChecker.invariantAllEqual _ // InvariantChecker.invariantAllEqual _
val (res, dot, t) = InvariantChecker.checkInvariantFPDot(spec, invariant(spec)) val props = InvProperties.DEFAULT
val s = TSConverter.toInvariantSpec(spec, props, invariant)
val (res, dot, t) = InvariantChecker.checkInvariantFPDot(s, props)
val msg = s"Invariant was ${if (res) "" else "not "}proven (took $t ms)\n" val msg = s"Invariant was ${if (res) "" else "not "}proven (took $t ms)\n"
write(name, s"$name.inv", msg) write(name, s"$name.inv", msg)
......
...@@ -4,12 +4,13 @@ import com.typesafe.scalalogging.LazyLogging ...@@ -4,12 +4,13 @@ import com.typesafe.scalalogging.LazyLogging
import com.microsoft.z3.Status import com.microsoft.z3.Status
import com.typesafe.scalalogging.LazyLogging import com.typesafe.scalalogging.LazyLogging
import de.tum.niwo.Utils._ import de.tum.niwo.Utils._
import de.tum.niwo.blocks.{SimpleWFBlock, NISpec} import de.tum.niwo.blocks.{NISpec, SimpleWFBlock}
import de.tum.niwo.foltl.FOLTL._ import de.tum.niwo.foltl.FOLTL._
import de.tum.niwo.foltl.FOTransformers import de.tum.niwo.foltl.FOTransformers
import de.tum.niwo.synth.Model import de.tum.niwo.synth.Model
import de.tum.niwo.toz3._ import de.tum.niwo.toz3._
import de.tum.niwo.foltl.Properties import de.tum.niwo.foltl.Properties
import de.tum.niwo.invariants.{InvProperties, InvariantGenerator}
// Labelled Edge to Block // Labelled Edge to Block
import Implicits._ import Implicits._
...@@ -34,9 +35,8 @@ object MainInvariantsInference extends App with LazyLogging { ...@@ -34,9 +35,8 @@ object MainInvariantsInference extends App with LazyLogging {
eliminateB = true eliminateB = true
) )
val inv = invariant(spec)
// val (res, graph, labels, t) = InvariantChecker.checkInvariantFPHeadLabel(spec, inv, props) // val (res, graph, labels, t) = InvariantChecker.checkInvariantFPHeadLabel(spec, inv, props)
val res = Utils.check(name, "elimB", inv, props) val res = Utils.check(name, "elimB", invariant, props)
} }
......
...@@ -3,12 +3,14 @@ package de.tum.niwo ...@@ -3,12 +3,14 @@ package de.tum.niwo
import com.microsoft.z3.Status import com.microsoft.z3.Status
import com.typesafe.scalalogging.LazyLogging import com.typesafe.scalalogging.LazyLogging
import de.tum.niwo.Utils._ import de.tum.niwo.Utils._
import de.tum.niwo.blocks.{SimpleWFBlock, NISpec} import de.tum.niwo.blocks.{NISpec, SimpleWFBlock, TSConverter}
import de.tum.niwo.foltl.FOLTL._ import de.tum.niwo.foltl.FOLTL._
import de.tum.niwo.foltl.FOTransformers import de.tum.niwo.foltl.FOTransformers
import de.tum.niwo.synth.Model import de.tum.niwo.synth.Model
import de.tum.niwo.toz3._ import de.tum.niwo.toz3._
import de.tum.niwo.foltl.Properties import de.tum.niwo.foltl.Properties
import de.tum.niwo.graphs.TSGraphEncoding
import de.tum.niwo.invariants.{InvProperties, InvariantChecker, InvariantGenerator}
// Labelled Edge to Block // Labelled Edge to Block
import de.tum.niwo.graphs.WFGraphEncoding.EdgeImplicits._ import de.tum.niwo.graphs.WFGraphEncoding.EdgeImplicits._
...@@ -25,10 +27,10 @@ object MainInvariantsInterpolation extends App with LazyLogging { ...@@ -25,10 +27,10 @@ object MainInvariantsInterpolation extends App with LazyLogging {
// InvariantChecker.invariantAllEqual _ // InvariantChecker.invariantAllEqual _
val props = InvProperties(stubborn = false, eliminateA = true) val props = InvProperties(stubborn = false, eliminateA = true)
val inv = invariant(spec) val invspec = TSConverter.toInvariantSpec(spec, props, invariant)
val (res, graph, labels, t) = InvariantChecker.checkInvariantFPHeadLabel(spec, inv, props) val (res, graph, labels, t) = InvariantChecker.checkInvariantFPHeadLabel(invspec, props)
logger.info(s"Invariant was ${inv}") logger.info(s"Invariant was ${invspec.inv}")
logger.info(s"Invariant was ${if (res) "" else "not "}proven (took $t ms)\n") logger.info(s"Invariant was ${if (res) "" else "not "}proven (took $t ms)\n")
...@@ -80,7 +82,7 @@ object MainInvariantsInterpolation extends App with LazyLogging { ...@@ -80,7 +82,7 @@ object MainInvariantsInterpolation extends App with LazyLogging {
logger.info(s"Path from source to target: $path") logger.info(s"Path from source to target: $path")
val newmodel = path.edges.foldLeft(model)((m, e) => m.warp(e, spec, props)) val newmodel = path.edges.foldLeft(model)((m, e) => m.warp(TSGraphEncoding.toBlock(e), invspec, props))
logger.info(s"Warped Model: ${newmodel.prettyprint}") logger.info(s"Warped Model: ${newmodel.prettyprint}")
......
...@@ -5,7 +5,8 @@ import blocks._ ...@@ -5,7 +5,8 @@ import blocks._
import de.tum.niwo.foltl.{FOLTL, FOTransformers, FormulaFunctions, Properties} import de.tum.niwo.foltl.{FOLTL, FOTransformers, FormulaFunctions, Properties}
import de.tum.niwo.foltl.FOLTL._ import de.tum.niwo.foltl.FOLTL._
import de.tum.niwo.foltl.Properties._ import de.tum.niwo.foltl.Properties._
import de.tum.niwo.toz3.{InvProperties, Z3BSFO} import de.tum.niwo.invariants.InvProperties
import de.tum.niwo.toz3.Z3BSFO
object Preconditions extends LazyLogging { object Preconditions extends LazyLogging {
...@@ -46,7 +47,7 @@ object Preconditions extends LazyLogging { ...@@ -46,7 +47,7 @@ object Preconditions extends LazyLogging {
// precond // precond
// } // }
private def weakestPrecondition(f: Formula, b:SimpleTSBlock, spec: InvariantSpec, properties: InvProperties) = { def weakestPrecondition(f: Formula, b:SimpleTSBlock, spec: InvariantSpec, properties: InvProperties) = {
val updates = for (s <- b.steps) yield { val updates = for (s <- b.steps) yield {
s.fun -> (s.tuple, { s.fun -> (s.tuple, {
......
...@@ -5,9 +5,10 @@ import de.tum.niwo.foltl.FOLTL._ ...@@ -5,9 +5,10 @@ import de.tum.niwo.foltl.FOLTL._
import java.io.File import java.io.File
import java.io.PrintWriter import java.io.PrintWriter
import de.tum.niwo.toz3.{InvProperties, InvariantChecker, Z3BSFO} import de.tum.niwo.toz3.Z3BSFO
import com.typesafe.scalalogging.LazyLogging import com.typesafe.scalalogging.LazyLogging
import de.tum.niwo.graphs.WFGraphEncoding import de.tum.niwo.graphs.WFGraphEncoding
import de.tum.niwo.invariants.{InvProperties, InvariantChecker}
object Utils extends LazyLogging { object Utils extends LazyLogging {
...@@ -66,17 +67,22 @@ object Utils extends LazyLogging { ...@@ -66,17 +67,22 @@ object Utils extends LazyLogging {
writer.close() writer.close()
logger.info(s"Written $file") logger.info(s"Written $file")
} }
def check(name: String, desc:String, inv:NISpec => Formula, spec:NISpec, properties: InvProperties):Boolean = {
val invspec = TSConverter.toInvariantSpec(spec, properties, inv)
check(name, desc, invspec, properties)
}
def check(name:String, desc:String, inv:Formula, spec:NISpec, properties:InvProperties) = { def check(name:String, desc:String, spec:InvariantSpec, properties:InvProperties):Boolean = {
val model = if (properties.stubborn) "stubborn" else "causal" val model = if (properties.stubborn) "stubborn" else "causal"
val basename = name.split("/").last val basename = name.split("/").last
val filenames = s"${basename}_$model${if (desc.isEmpty()) "" else s"_$desc"}" val filenames = s"${basename}_$model${if (desc.isEmpty()) "" else s"_$desc"}"
val (res, graph, labelling, provens, dot, time) = val (res, graph, labelling, provens, dot, time) =
InvariantChecker.checkInvariantFPLabelling(spec, inv, properties) InvariantChecker.checkInvariantFPLabelling(spec, properties)
logger.info(s"Invariant was ${inv}") logger.info(s"Invariant was ${spec.inv}")
logger.info(s"Invariant was ${if (res) "" else "not "}proven (took $time ms)\n") logger.info(s"Invariant was ${if (res) "" else "not "}proven (took $time ms)\n")
if (!res) { if (!res) {
...@@ -108,21 +114,22 @@ object Utils extends LazyLogging { ...@@ -108,21 +114,22 @@ object Utils extends LazyLogging {
val avgsize = invsizes.sum / invsizes.size val avgsize = invsizes.sum / invsizes.size
Utils.write(name, s"$filenames.metrics", Utils.write(name, s"$filenames.metrics",
s"""Name: $name s"""Name: $name
Description: $desc |Description: $desc
Invariant: | Invariant:
${inv.pretty.lines.map(s => " " + s).mkString("\n")} |${spec.inv.pretty.lines.map(s => " " + s).mkString("\n")}
Model: $model | Model: $model
Result: ${if (!res) "not " else ""}inductive | Result: ${if (!res) "not " else ""}inductive
WF size: $wfsize | WF size: $wfsize
Time: $time ms | Time: $time ms
Proof steps: ${dot.size} | Proof steps: ${dot.size}
Strengthenings: ${strengthenings.size} | Strengthenings: ${strengthenings.size}
Largest Inv: $maxsize | Largest Inv: $maxsize
Average Inv: $avgsize""") | Average Inv: $avgsize""".stripMargin
)
res res
} }
def check(name:String, desc:String, inv:Formula, properties:InvProperties):Boolean = { def check(name:String, desc:String, inv:NISpec => Formula, properties:InvProperties):Boolean = {
val spec = Examples.parseExampleWF(name).get val spec = Examples.parseExampleWF(name).get
check(name, desc, inv, spec, properties) check(name, desc, inv, spec, properties)
} }
......
package de.tum.niwo package de.tum.niwo.blocks
import com.typesafe.scalalogging.LazyLogging import com.typesafe.scalalogging.LazyLogging
import de.tum.niwo.blocks._ import de.tum.niwo.blocks._
import de.tum.niwo.foltl.FOLTL._ import de.tum.niwo.foltl.FOLTL._
import de.tum.niwo.foltl.Properties.{INFNAME, T1, T2} import de.tum.niwo.foltl.Properties.{INFNAME, T1, T2}
import de.tum.niwo.toz3.InvProperties import de.tum.niwo.invariants.{InvProperties, InvariantGenerator}
object TSConverter extends LazyLogging { object TSConverter extends LazyLogging {
def toInvariantSpec(spec:NISpec):InvariantSpec = { // TODO: move stubbornness flag out of properties
def toInvariantSpec(spec:NISpec,
properties:InvProperties,
invgen:NISpec => Formula
):InvariantSpec = {
val w = spec.w
// Elaborate all statements to Hyperproperty updates with informedness depending on stubbornness // Elaborate all statements to Hyperproperty updates with informedness depending on stubbornness
// (maybe add causal switch into spec) val elaboratefun = (b:SimpleWFBlock[_]) => elaborate(b, spec, properties)
val elaborated = everywhere(w.steps, elaboratefun)
// Map WFLoop/Nondet to TSLoop/TSNondet // Map WFLoop/Nondet to TSLoop/TSNondet
// Map Add/Remove statements to SetStmt // Map Add/Remove statements to SetStmt
val frees = s.guard.freeVars -- s.tuple.toSet -- spec.constants val steps = elaborated.map(s => toTSBlock(s)(w.sig, properties))
// TODO: Make 2-trace elaboration optional
val steps = elaborate(outerb, spec, properties) // Add causals to constants?
val newsig = w.sig.copy(
preds = w.sig.preds + Fun(INFNAME, List(spec.target.params.head)),
constants = spec.causals.toSet ++ w.sig.constants
)
val ts = TransitionSystem(newsig, steps)
InvariantSpec(ts, spec.axioms, invgen(spec))
}
private def everywhere(list: List[WFBlock],
update: SimpleWFBlock[_] => List[SimpleWFBlock[_]]):List[WFBlock] = {
list match {
case (l:WFLoop) :: xs => l.update(everywhere(l.steps, update)) :: everywhere(xs, update)
case (nd:WFNondetChoice) :: xs => nd.update(
everywhere(nd.left, update),
everywhere(nd.right, update)
) :: everywhere(xs, update)
case (s:SimpleWFBlock[_]) :: xs => update(s) ++ everywhere(xs, update)
case Nil => Nil
}
} }
private def toTSBlock(b:WFBlock)(implicit sig:Signature, properties:InvProperties):TSBlock = {
b match {
case WFLoop(steps) =>
TSLoop(steps.map(toTSBlock))
case WFNondetChoice(left, right) =>
TSNondetChoice(left.map(toTSBlock), right.map(toTSBlock))
case s:SimpleWFBlock[_] =>
SimpleTSBlock(s.steps.map(s => toSetStmt(s, sig, properties)))
}
}
def getUpdate(s:Statement[_], spec:InvariantSpec, properties:InvProperties): Formula = { def toSetStmt(s:Statement[_], sig:Signature, properties:InvProperties): SetStmt = {
val frees = s.guard.freeVars -- s.tuple.toSet -- spec.ts.sig.constants val frees = s.guard.freeVars -- s.tuple.toSet -- sig.constants
val form = s match { // Quantify free, non-const variables
val guard = s match {
case Add(_, _, _) => { case Add(_, _, _) => {
Or(Fun(s.fun, s.tuple), Exists(frees.toList, s.guard)).simplify Or(Fun(s.fun, s.tuple), Exists(frees.toList, s.guard)).simplify
} }
case Remove(_, _, _) => { case Remove(_, _, _) => {
And(Fun(s.fun, s.tuple), Forall(frees.toList, Neg(s.guard))).simplify And(Fun(s.fun, s.tuple), Forall(frees.toList, Neg(s.guard))).simplify
} }
case st:SetStmt => Exists(frees.toList, s.guard).simplify
} }
form SetStmt(guard, s.fun, s.tuple)
True
} }
def elaborate(block: SimpleWFBlock[_], spec:NISpec, properties:InvProperties): List[SimpleWFBlock[_]] = { def elaborate(block: SimpleWFBlock[_], spec:NISpec, properties:InvProperties): List[SimpleWFBlock[_]] = {
val stepOne = elaborateSteps(block, spec, properties) val stepOne = elaborateSteps(block, spec, properties)
stepOne map { b => elaborateOraclyBlock(b, spec) } stepOne map { b => elaborateOraclyBlock(b, spec) }
} }
// For oracly blocks, remove O from guard and add to ForallMay choice predicate
private def elaborateOraclyBlock(b: SimpleWFBlock[_], spec: NISpec) = {
if (b.isoracly) {
val stmt = b.steps.head // can only be one
def findOracle(f: Formula) = {
f.collect {
case f: Fun if f.isOracle => List(f.name)
}
}
val oracles = findOracle(stmt.guard)
val name = oracles.head
if (oracles.size != 1) {
logger.error(s"Found oracly block $b with more than one oracle")
}
val choice = Fun(name, b.agents)
def fixguard(f: Formula, choice:Fun) = {
val nooracles = f.everywhere {
case f: Fun if f.isOracle => True
}
val decl = spec.declass.getOrElse(name, (List(), False))._2
// FIXME: substitutions?
// FIXME: decl in T2?
And(nooracles, Or(And(decl.in(T1), choice.in(T1)), And(Neg(decl.in(T1)), choice)))
}
val newstmt = stmt match {
case Add(guard, fun, tuple) => Add(fixguard(guard, choice).simplify, fun, tuple)
case Remove(guard, fun, tuple) => Remove(fixguard(guard, choice).simplify, fun, tuple)
}
ForallMayWFBlock(b.agents, name, List(newstmt))
} else b
}
private def elaborateSteps(b: SimpleWFBlock[_], spec: NISpec, properties: InvProperties):List[SimpleWFBlock[_]] = { private def elaborateSteps(b: SimpleWFBlock[_], spec: NISpec, properties: InvProperties):List[SimpleWFBlock[_]] = {
val guardfix = if (!b.isoracly && b.pred.isDefined) { val guardfix = if (!b.isoracly && b.pred.isDefined) {
...@@ -138,4 +127,42 @@ object TSConverter extends LazyLogging { ...@@ -138,4 +127,42 @@ object TSConverter extends LazyLogging {
list.asInstanceOf[List[SimpleWFBlock[_]]] list.asInstanceOf[List[SimpleWFBlock[_]]]
} }
// For oracly blocks, remove O from guard and add to ForallMay choice predicate
private def elaborateOraclyBlock(b: SimpleWFBlock[_], spec: NISpec) = {
if (b.isoracly) {
val stmt = b.steps.head // can only be one
def findOracle(f: Formula) = {
f.collect {
case f: Fun if f.isOracle => List(f.name)
}
}
val oracles = findOracle(stmt.guard)
val name = oracles.head
if (oracles.size != 1) {
logger.error(s"Found oracly block $b with more than one oracle")
}
val choice = Fun(name, b.agents)
def fixguard(f: Formula, choice:Fun) = {
val nooracles = f.everywhere {
case f: Fun if f.isOracle => True
}
val decl = spec.declass.getOrElse(name, (List(), False))._2
// FIXME: substitutions?
// FIXME: decl in T2?
And(nooracles, Or(And(decl.in(T1), choice.in(T1)), And(Neg(decl.in(T1)), choice)))
}
val newstmt = stmt match {
case Add(guard, fun, tuple) => Add(fixguard(guard, choice).simplify, fun, tuple)
case Remove(guard, fun, tuple) => Remove(fixguard(guard, choice).simplify, fun, tuple)
}
ForallMayWFBlock(b.agents, name, List(newstmt))
} else b
}
} }
...@@ -47,14 +47,14 @@ trait Spec { ...@@ -47,14 +47,14 @@ trait Spec {
case class InvariantSpec(ts:TransitionSystem, axioms:Formula, inv:Formula) extends Spec { case class InvariantSpec(ts:TransitionSystem, axioms:Formula, inv:Formula) extends Spec {
override def toString: String = { override def toString: String = {
s"InvSpec\nTransition System:\n$ts\n\nAxioms:\n$axioms\n\nInvariant:$inv" s"InvSpec\nTransition System:\n$ts\n\nAxioms:\n$axioms\n\nInvariant:$inv\n"
} }
def addAxiom(k:Formula) = { def addAxiom(k:Formula) = {
InvariantSpec(ts, And.make(axioms, k), inv) copy(axioms = And.make(axioms, k))
}
def addInv(k:Formula) = {
InvariantSpec(ts, axioms, And.make(inv, k))
} }
// def addInv(k:Formula) = {
// InvariantSpec(ts, axioms, And.make(inv, k))
// }
def isSane: Boolean = { def isSane: Boolean = {
// TODO: add sanity checking for axioms and invariant signatures // TODO: add sanity checking for axioms and invariant signatures
ts.isSane() ts.isSane()
......
...@@ -21,6 +21,7 @@ object Workflow { ...@@ -21,6 +21,7 @@ object Workflow {
val EMPTY = Workflow(Signature.EMPTY, List()) val EMPTY = Workflow(Signature.EMPTY, List())
} }
// TODO: make causals a set
case class NISpec(w: Workflow, declass: Map[String, (List[Var], Formula)], axioms: Formula, target: Fun, causals:List[Var]) extends Spec with LazyLogging { case class NISpec(w: Workflow, declass: Map[String, (List[Var], Formula)], axioms: Formula, target: Fun, causals:List[Var]) extends Spec with LazyLogging {
override def toString: String = { override def toString: String = {
s"NISpec\nWorkflow:\n$w\nDeclass:$declass\nTarget:$target" s"NISpec\nWorkflow:\n$w\nDeclass:$declass\nTarget:$target"
......
...@@ -66,8 +66,7 @@ object Causal { ...@@ -66,8 +66,7 @@ object Causal {
} }
object Noninterference extends LazyLogging { object Noninterference extends LazyLogging {
def buildViolations(vars:List[Var], t:Formula, causals:List[Var]) = { def buildViolations(vars:List[Var], t:Formula, causals:List[Var]) = {
val univ = causals.groupBy(_.typ).withDefault(_ => List()) val univ = causals.groupBy(_.typ).withDefault(_ => List())
......
...@@ -5,7 +5,7 @@ import de.tum.niwo.blocks._ ...@@ -5,7 +5,7 @@ import de.tum.niwo.blocks._
import de.tum.niwo.foltl.FOLTL.Fun import de.tum.niwo.foltl.FOLTL.Fun
import de.tum.niwo.foltl.Properties import de.tum.niwo.foltl.Properties
import de.tum.niwo.graphs.WFGraphEncoding.WorkflowGraph import de.tum.niwo.graphs.WFGraphEncoding.WorkflowGraph
import de.tum.niwo.toz3.InvProperties import de.tum.niwo.invariants.InvProperties
import scalax.collection.Graph import scalax.collection.Graph
import scalax.collection.GraphTraversal.BreadthFirst import scalax.collection.GraphTraversal.BreadthFirst
import scalax.collection.edge.LBase.LEdgeImplicits import scalax.collection.edge.LBase.LEdgeImplicits
......
...@@ -5,11 +5,11 @@ import de.tum.niwo.Preconditions ...@@ -5,11 +5,11 @@ import de.tum.niwo.Preconditions
import de.tum.niwo.blocks._ import de.tum.niwo.blocks._
import de.tum.niwo.foltl.FOLTL._ import de.tum.niwo.foltl.FOLTL._
import de.tum.niwo.foltl.Properties import de.tum.niwo.foltl.Properties
import de.tum.niwo.toz3.InvProperties
import scalax.collection.Graph import scalax.collection.Graph
import scalax.collection.GraphTraversal.BreadthFirst import scalax.collection.GraphTraversal.BreadthFirst
import scalax.collection.edge.LDiEdge import scalax.collection.edge.LDiEdge
import de.tum.niwo.Implicits._ import de.tum.niwo.Implicits._
import de.tum.niwo.invariants.InvProperties
import scalax.collection.edge.LBase.LEdgeImplicits import scalax.collection.edge.LBase.LEdgeImplicits
object WFGraphEncoding extends GraphBuilder with LazyLogging { object WFGraphEncoding extends GraphBuilder with LazyLogging {
......
package de.tum.niwo.toz3 package de.tum.niwo.invariants
import scala.annotation.tailrec
import com.microsoft.z3.{Solver, Status} import com.microsoft.z3.{Solver, Status}
import com.typesafe.scalalogging.LazyLogging import com.typesafe.scalalogging.LazyLogging
import de.tum.niwo.Preconditions
import de.tum.niwo.blocks._ import de.tum.niwo.blocks._
import de.tum.niwo.foltl.FOLTL._ import de.tum.niwo.foltl.FOLTL._
import de.tum.niwo.foltl.FormulaFunctions import de.tum.niwo.foltl.FormulaFunctions
import de.tum.niwo.Utils
import de.tum.niwo.graphs.{TSGraphEncoding, WFGraphEncoding}
import de.tum.niwo.graphs.WFGraphEncoding.WorkflowGraph import de.tum.niwo.graphs.WFGraphEncoding.WorkflowGraph
import de.tum.niwo.graphs.{TSGraphEncoding, WFGraphEncoding}
import de.tum.niwo.toz3.{Z3BSFO, Z3FOEncoding}
import de.tum.niwo.{Preconditions, Utils}
import scala.annotation.tailrec
case class InvProperties(stubborn:Boolean, eliminateA:Boolean, eliminateB:Boolean = false) { } case class InvProperties(stubborn:Boolean, eliminateA:Boolean, eliminateB:Boolean = false) { }
object InvProperties { object InvProperties {
val DEFAULT = InvProperties(stubborn = true, eliminateA = true, eliminateB = true) val DEFAULT = InvProperties(
stubborn = true,
eliminateA = true,
eliminateB = true
)
} }
object InvariantChecker extends LazyLogging {