Commit 0f390288 authored by Christian Müller's avatar Christian Müller

Merge branch 'master' of versioncontrolseidl.in.tum.de:mueller/loopingworkflows

parents 582ced11 2e9e706a
......@@ -31,6 +31,11 @@ build
results/*.ltl
results/*.ppltl
results/*.foltl
results/*.png
results/*.metrics
# aalta
cnf.dimacs
# Z3
lib/com.microsoft.z3.jar
......@@ -5,19 +5,19 @@ forallmay x:A,p:P
forallmay x:A,p:P
!Conf(x,p) → Assign += (x,p)
forall x:A,p:P,r:R
(Assign(x,p) ∧ O(x,p,r)) → Review += (x,p,r)
(Assign(x,p) ∧ Oracle(x,p,r)) → Review += (x,p,r)
loop {
forall x:A,y:A,p:P,r:R (Assign(x,p) ∧ Review(y,p,r)) → Read += (x,p,r)
forall xa:A,xb:A,p:P,r:R (Assign(xa,p) ∧ Review(xb,p,r)) → Read += (xa,r)
forallmay x:A,p:P,r:R (Assign(x,p)) → Review += (x,p,r)
}
Declassify
O(x:A,p:P,r:R): ¬ Conf(xt:A,p:P)
Oracle(x:A,p:P,r:R): ¬ Conf(xat:A,p:P)
Target
Read(xt:A, rt:R)
Read(xat:A, rt:R)
Causality
......
......@@ -9,9 +9,9 @@ class Test {
public static void main(String[] args) {
System.out.println("Test");
var owlform = BooleanConstant.FALSE;
BooleanConstant owlform = BooleanConstant.FALSE;
var checksat = LanguageAnalysis.isSatisfiable(owlform);
boolean checksat = LanguageAnalysis.isSatisfiable(owlform);
System.out.println(checksat);
}
......
package de.tum.workflows
import foltl.FOLTL._
import blocks.Workflow._
import Implicits._
import com.typesafe.scalalogging.LazyLogging
import de.tum.workflows.foltl.FOTransformers
import de.tum.workflows.Utils._
import de.tum.workflows.foltl.Stubborn
import de.tum.workflows.foltl.Properties
import java.io.PrintWriter
import java.io.File
import de.tum.workflows.blocks.Workflow
import de.tum.workflows.blocks.Spec
import de.tum.workflows.foltl.FormulaFunctions
import de.tum.workflows.toz3.InvariantChecker
import de.tum.workflows.toz3.InvariantGenerator
import de.tum.workflows.toz3.InvProperties
import de.tum.workflows.toz3.Z3QFree
object InvariantInspector extends App with LazyLogging {
def inspect(name: String) {
logger.info(s"Generating $name")
val optspec = ExampleWorkflows.parseExample(name)
if (!optspec.isDefined) {
logger.error(s"Not a valid spec: $name")
}
val spec = optspec.get
logger.info(s"Encoding Spec:\n$spec")
def invariant =
InvariantGenerator.invariantNoninterSingleBS _
// InvariantGenerator.invariantNoninterStubbornBS _
// InvariantChecker.invariantNoninterStubborn _
// InvariantChecker.invariantAllEqual _
val (t, (res, dot)) = time {
// InvariantChecker.checkInvariantOnce(spec.w, inv(spec), true)
val props = InvProperties(stubborn = false, eliminateAux = true)
val (result, graph, afterlabels, proven, dot, time) =
InvariantChecker.checkInvariantFPLabelling(spec, invariant(spec), props)
// non-omitting conference linear inspection
val lastlabels = afterlabels.last
val inv = lastlabels(2)
val emptyinv = inv.assumeEmpty(List("informed", "Read", "Comm")).simplify()
logger.info(s"empty: ${emptyinv.pretty()}")
// val auxes = List("O", "choice2")
// Different Os
val diffos = emptyinv everywhere {
case Fun("O", Some(t), vars) => Fun(s"O$t", vars)
}
val auxes = List("Ot1", "Ot2")
// val auxes = List()
val auxless = auxes.foldLeft(diffos)((inv, p) =>
FOTransformers.eliminateAuxiliaryPredicate(inv, p)
)
val simped = auxless.toCNF.simplify()
logger.info(s"auxless: ${simped.pretty()}")
logger.info("Computing with B now")
val withB = simped everywhere {
case Fun("Assign",t,vars) => And(Fun("Assign",t,vars), Neg(Fun("B",vars)))
// case Fun("Assign",t,vars) => Fun("B",vars)
}
logger.info(s"withB: ${withB.simplify().pretty()}")
logger.info(s"withB CNF: ${withB.toCNF.simplify().pretty()}")
logger.info(s"Graph: $graph")
logger.info(s"Final Invariants:\n${afterlabels.last}")
(result, dot)
}
val msg = s"Invariant was ${if (res) "" else "not "}proven (took $t ms)\n"
write(s"${name}.inv", msg)
for ((s, i) <- dot.zipWithIndex) {
write(s"${name}_${i}.dot", s)
}
}
inspect("nonomitting/conference_linear")
// inspect("tests/loopexampleNoOracle")
// generateAllExamples()
}
\ No newline at end of file
......@@ -54,6 +54,7 @@ object MainInvariants extends App with LazyLogging {
clear()
// generateExample("nonomitting/conference")
generateExample("tests/loopexampleNoOracle")
generateExample("omitting/conference")
// generateExample("tests/loopexampleNoOracle")
// generateAllExamples()
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ import de.tum.workflows.Utils._
import de.tum.workflows.foltl.Properties
import de.tum.workflows.blocks.Spec
import de.tum.workflows.foltl.FormulaFunctions
import de.tum.workflows.foltl.FOTransformers
import de.tum.workflows.owltransformer.OwlTransformer
import owl.ltl.algorithms.LanguageAnalysis
import owl.ltl.rewriter.SimplifierFactory
......
......@@ -52,17 +52,8 @@ object FOTransformers extends LazyLogging {
def eliminateAuxiliaryPredicate(f:Formula, AUX:String) = {
val (quantifiers, clauses) = FormulaFunctions.toCNFClauses(f)
// Inspect clauses
val simped =
for (c <- clauses;
removeclause = (for (c1 <- c if (c.contains(Neg(c1)))) yield true)
if (removeclause.isEmpty)
) yield {
c
}
// TODO: improve
val form = And.make(simped.map(Or.make))
val form = And.make(clauses.map(Or.make))
val newform = quantifiers.foldRight(form)((q, inner) => if(q._1) Exists(q._2, inner) else Forall(q._2, inner))
// TODO: add equalities?
......@@ -70,8 +61,8 @@ object FOTransformers extends LazyLogging {
case Neg(Fun(AUX, _, _)) => False
case Fun(AUX, _, _) => False
}
repld.simplify()
// TODO: improve runtime here
repld.toCNF.simplify()
}
/**
......
......@@ -42,6 +42,8 @@ object InvariantGenerator {
val conclusion = genEq(spec.target, spec.target.params)
Forall(spec.target.params, conclusion).simplify()
// Constants
// conclusion
}
// def invariantNoninterStubbornBS(spec: Spec) = {
......
......@@ -10,7 +10,6 @@ import com.typesafe.scalalogging.LazyLogging
import de.tum.workflows.Utils
import de.tum.workflows.foltl.FOTransformers
import de.tum.workflows.foltl.FormulaFunctions
import it.unimi.dsi.fastutil.longs.Long2BooleanArrayMap
object Z3QFree extends LazyLogging {
......
......@@ -6,6 +6,7 @@ import org.scalatest.Inspectors._
import de.tum.workflows.foltl.FOLTL._
import de.tum.workflows.Implicits._
import de.tum.workflows.foltl.FOLTL
import de.tum.workflows.foltl.FormulaFunctions
class FOLTLTest extends FlatSpec {
"Formulas" should "be constructed correctly" in {
......@@ -150,4 +151,20 @@ class FOLTLTest extends FlatSpec {
))
)
}
it should "not fail at doing so" in {
val f = Forall(List("xt","pt","yt","p"), And.make(
Neg(Fun("B", List("xt","pt"))),
Neg(Fun("B", List("yt","p"))),
Neg(Fun("B", List("yt","pt"))),
Neg(Fun("Conf",Some("t1"),List("xt","p")))
))
f.toCNF should be (f)
}
"quantifier pushing" should "work" in {
val f = Forall("x", And(Fun("f","x"), Fun("f","c")))
FormulaFunctions.pushQuantifiers(f) should be (And(Forall("x", Fun("f","x")),Fun("f","c")))
}
}
\ No newline at end of file
......@@ -151,4 +151,5 @@ class FOTransformSpec extends FlatSpec {
)
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment