public void TestMobilizedWhenAllocGBA() { ILiteral alloc = new Proposition ("allocated"); ILiteral mob = new Proposition ("mobilized"); ILiteral nalloc = new Negation (alloc); ILiteral nmob = new Negation (mob); var lts = new BuchiAutomaton<AutomatonNode> (new AutomatonNodeFactory ()); var n0 = lts.AddNode ("i"); var n1 = lts.AddNode ("s0"); var n2 = lts.AddNode ("s1"); var n3 = lts.AddNode ("s2"); lts.SetInitialNode (n0); lts.AddTransition (n0, n1, new ILiteral [] { nalloc, nmob }); lts.AddTransition (n1, n2, new ILiteral [] { alloc, nmob }); lts.AddTransition (n2, n3, new ILiteral [] { alloc, mob }); lts.AddTransition (n3, n0, new ILiteral [] { nalloc, nmob }); lts.SetAcceptanceCondition (new BuchiAcceptance<AutomatonNode> (lts.Nodes)); var f = new StrongImplication (alloc, new Next (mob)).Negate (); var t = new GPVW (); var gba = t.GetGBA (f); var otfec = new OnTheFlyGBAEmptinessChecker (gba, lts); var e1 = otfec.EmptinessSearch (); Console.WriteLine (e1); }
public static MarkovChain<AutomatonNode> GetExampleFig101() { var p1 = new Proposition ("start"); var p2 = new Proposition ("try"); var p3 = new Proposition ("lost"); var p4 = new Proposition ("delivered"); var np1 = new Negation (p1); var np2 = new Negation (p2); var np3 = new Negation (p3); var np4 = new Negation (p4); var mc = new MarkovChain<AutomatonNode> (new AutomatonNodeFactory ()); var start = mc.AddNode ("start", new ILiteral[] { p1, np2, np3, np4 }); var ntry = mc.AddNode ("try", new ILiteral[] { np1, p2, np3, np4 }); var lost = mc.AddNode ("lost", new ILiteral[] { np1, p2, p3, np4 }); var delivered = mc.AddNode ("delivered", new ILiteral[] { np1, np2, np3, p4 }); mc.SetInitial (start, 1); mc.AddTransition (start, ntry); mc.AddTransition (ntry, .1d, lost); mc.AddTransition (lost, ntry); mc.AddTransition (ntry, .9d, delivered); mc.AddTransition (delivered, start); return mc; }
public void TestCraps() { var mc = TestMarkovChain.GetExample ("craps"); var s8 = new Proposition ("8"); var s9 = new Proposition ("9"); var s10 = new Proposition ("10"); var disj = new Disjunction (s8, new Disjunction (s9, s10)); var neg = new Negation (disj); var won = new Proposition ("won"); var p1 = new ProbabilisticOperator (new Until (neg, won), .32, 1); var p2 = new ProbabilisticOperator (new Until (neg, won, 5), .32, 1); var p3 = new ProbabilisticOperator (new Until (neg, new ProbabilisticOperator (new Globally (won), 1), 5), .32, 1); var checker = new PCTLModelChecker<AutomatonNode> (mc, p1, 1e-10); var sat = checker.Check (); Assert.That (sat.Contains (mc.GetVertex ("start"))); checker = new PCTLModelChecker<AutomatonNode> (mc, p2, 1e-10); sat = checker.Check (); Assert.That (sat.Contains (mc.GetVertex ("start"))); checker = new PCTLModelChecker<AutomatonNode> (mc, p3, 1e-10); sat = checker.Check (); Assert.That (sat.Contains (mc.GetVertex ("start"))); }
public void TestSafraExampleInPaper() { var ba = new BuchiAutomaton<AutomatonNode> (new AutomatonNodeFactory ()); var q = ba.AddNode ("qI"); var f = ba.AddNode ("f"); var g = ba.AddNode ("g"); var pa = new Proposition ("a"); var pb = new Proposition ("b"); var pc = new Proposition ("c"); var a = new ILiteral[] { pa }; var b = new ILiteral[] { pb }; var c = new ILiteral [] { pc }; // a,b from qI to qI ba.AddTransition (q, q, a); ba.AddTransition (q, q, b); // c from f to f ba.AddTransition (f, f, c); // a from qI to f ba.AddTransition (q, f, a); // a from f to g ba.AddTransition (f, g, a); // a from g to g ba.AddTransition (g, g, a); // a from g to f ba.AddTransition (g, f, a); ba.SetInitialNode (q); ba.SetAcceptanceCondition (new BuchiAcceptance<AutomatonNode> (new [] { f, g })); var rabin = ba.Determinize (); //var folder = new Fold<RabinAutomaton<AutomatonNode>, AutomatonNode> (); //rabin = folder.Transform (rabin); rabin.UnfoldTransitions (); Console.WriteLine (rabin.ToDot ()); }
public void TestMobilizedWhenAlloc() { ILiteral alloc = new Proposition ("allocated"); ILiteral mob = new Proposition ("mobilized"); ILiteral nalloc = new Negation (alloc); ILiteral nmob = new Negation (mob); var lts = new BuchiAutomaton<AutomatonNode> (new AutomatonNodeFactory ()); var n0 = lts.AddNode ("i"); var n1 = lts.AddNode ("s0"); var n2 = lts.AddNode ("s1"); var n3 = lts.AddNode ("s2"); lts.SetInitialNode (n0); lts.AddTransition (n0, n1, new ILiteral [] { nalloc, nmob }); lts.AddTransition (n1, n2, new ILiteral [] { alloc, nmob }); lts.AddTransition (n2, n3, new ILiteral [] { alloc, mob }); lts.AddTransition (n3, n0, new ILiteral [] { nalloc, nmob }); lts.SetAcceptanceCondition (new BuchiAcceptance<AutomatonNode> (lts.Nodes)); var f = new StrongImplication (alloc, new Next (mob)).Negate (); var t = new GPVW (); var gba = t.GetGBA (f); var ba = gba.ToBA (); var otfec = new OnTheFlyEmptinessChecker<AutomatonNode,AutomatonNode> (ba, lts); var e1 = otfec.Emptiness (); if (e1) { foreach (var i in otfec.counterexample_prefix) { Console.WriteLine (i.Name); } Console.WriteLine ("-- loop starts here --"); foreach (var i in otfec.counterexample_loop) { Console.WriteLine (i.Name); } Console.WriteLine ("-- loop ends here --"); } else { Console.WriteLine ("No trace found"); } }