protected override void Check() { var intValue = 7; { var actual = ((CtlFormula)false).EquivalentTo(intValue < 7); var expected = new BinaryFormula( new StateFormula(new BooleanLiteralExpression(false)), BinaryFormulaOperator.Equivalence, PathQuantifier.None, new StateFormula(new BinaryExpression(BinaryOperator.Less, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7)))); Check(actual, expected); } { var actual = ((CtlFormula)false).EquivalentTo(Ctl.AF(intValue < 7)); var expected = new BinaryFormula( new StateFormula(new BooleanLiteralExpression(false)), BinaryFormulaOperator.Equivalence, PathQuantifier.None, new UnaryFormula( new StateFormula(new BinaryExpression(BinaryOperator.Less, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7))), UnaryFormulaOperator.Finally, PathQuantifier.All)); Check(actual, expected); } }
protected override void Check() { var intValue = 7; { var actual = Ltl.U(intValue < 7, false); var expected = new BinaryFormula( new StateFormula(new BinaryExpression(BinaryOperator.Less, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7))), BinaryFormulaOperator.Until, PathQuantifier.None, new StateFormula(new BooleanLiteralExpression(false))); Check(actual, expected); } { var actual = Ltl.U(Ltl.G(intValue >= 7), false); var expected = new BinaryFormula( new UnaryFormula( new StateFormula(new BinaryExpression(BinaryOperator.GreaterEqual, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7))), UnaryFormulaOperator.Globally, PathQuantifier.None), BinaryFormulaOperator.Until, PathQuantifier.None, new StateFormula(new BooleanLiteralExpression(false))); Check(actual, expected); } { var actual = Ltl.U(intValue >= 7, Ltl.F(false)); var expected = new BinaryFormula( new StateFormula(new BinaryExpression(BinaryOperator.GreaterEqual, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7))), BinaryFormulaOperator.Until, PathQuantifier.None, new UnaryFormula(new StateFormula(new BooleanLiteralExpression(false)), UnaryFormulaOperator.Finally, PathQuantifier.None)); Check(actual, expected); } { var actual = Ltl.U(Ltl.G(intValue >= 7), Ltl.F(false)); var expected = new BinaryFormula( new UnaryFormula( new StateFormula(new BinaryExpression(BinaryOperator.GreaterEqual, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7))), UnaryFormulaOperator.Globally, PathQuantifier.None), BinaryFormulaOperator.Until, PathQuantifier.None, new UnaryFormula(new StateFormula(new BooleanLiteralExpression(false)), UnaryFormulaOperator.Finally, PathQuantifier.None)); Check(actual, expected); } }
protected override void Check() { var c = new C(); var m = new Model(); m.AddRootComponents(c); m.Seal(); var actual = Ltl.IsOccurring<C.F1>(c) | Ltl.IsOccurring<C.F2>(c); var expected = new BinaryFormula( new FaultOccurrenceFormula(c.Metadata.Faults[0]), BinaryFormulaOperator.Or, PathQuantifier.None, new FaultOccurrenceFormula(c.Metadata.Faults[1])); Check(actual, expected); }
protected override void Check() { var intValue = 7; { var actual = ((Formula)false).EquivalentTo(intValue < 7); var expected = new BinaryFormula( new StateFormula(() => false), BinaryOperator.Equivalence, new StateFormula(() => intValue < 7)); Check(actual, expected); } { var actual = ((Formula)false).EquivalentTo(F(intValue < 7)); var expected = new BinaryFormula( new StateFormula(() => false), BinaryOperator.Equivalence, new UnaryFormula(new StateFormula(() => intValue < 7), UnaryOperator.Finally)); Check(actual, expected); } { Formula actual = false.EquivalentTo(intValue < 7); var expected = new StateFormula(() => (false && intValue < 7) || (true && intValue >= 7)); Check(actual, expected); } { var actual = false.EquivalentTo(F(intValue < 7)); var expected = new BinaryFormula( new StateFormula(() => false), BinaryOperator.Equivalence, new UnaryFormula(new StateFormula(() => intValue < 7), UnaryOperator.Finally)); Check(actual, expected); } true.EquivalentTo(true).ShouldBe(true); false.EquivalentTo(true).ShouldBe(false); true.EquivalentTo(false).ShouldBe(false); false.EquivalentTo(false).ShouldBe(true); }
protected override void Check() { var intValue = 7; { var actual = ((Formula)false).Implies(intValue < 7); var expected = new BinaryFormula( new StateFormula(() => false), BinaryOperator.Implication, new StateFormula(() => intValue < 7)); Check(actual, expected); } { var actual = ((Formula)false).Implies(F(intValue < 7)); var expected = new BinaryFormula( new StateFormula(() => false), BinaryOperator.Implication, new UnaryFormula(new StateFormula(() => intValue < 7), UnaryOperator.Finally)); Check(actual, expected); } { var actual = false.Implies(intValue < 7); var expected = new StateFormula(() => !false || intValue < 7); Check(actual, expected); } { var actual = false.Implies(F(intValue < 7)); var expected = new BinaryFormula( new StateFormula(() => false), BinaryOperator.Implication, new UnaryFormula(new StateFormula(() => intValue < 7), UnaryOperator.Finally)); Check(actual, expected); } true.Implies(true).ShouldBe(true); false.Implies(true).ShouldBe(true); true.Implies(false).ShouldBe(false); false.Implies(false).ShouldBe(true); }
protected override void Check() { var c1 = new C1(); var c2 = new C2(); var m = new Model(); m.AddRootComponents(c1, c2); m.Seal(); var actual = (LtlFormula)c1.F & +c1.C2.F != -c2.F; var expected = new BinaryFormula( new StateFormula(new FieldExpression(m.Metadata.RootComponent.Subcomponents[0].Fields[0])), BinaryFormulaOperator.And, PathQuantifier.None, new StateFormula(new BinaryExpression(BinaryOperator.NotEquals, new FieldExpression(m.Metadata.RootComponent.Subcomponents[0].Subcomponents[0].Fields[0]), new UnaryExpression(UnaryOperator.Minus, new FieldExpression(m.Metadata.RootComponent.Subcomponents[1].Fields[0]))) )); Check(actual, expected); }
protected override void Check() { var x = 0; var f = ((Formula)(x == 2) && x == 3) || x == 4; var expected = new BinaryFormula( new BinaryFormula(new StateFormula(() => x == 2), BinaryOperator.And, new StateFormula(() => x == 3)), BinaryOperator.Or, new StateFormula(() => x == 4)); Check(f, expected); x = 2; Check(f, expected); x = 3; Check(f, expected); x = 4; Check(f, expected); }
protected override void Check() { var intValue = 7; var boolValue = false; var actual = AF(intValue > 7 && boolValue && X(!boolValue) | intValue < 4) && AF(boolValue); var expected = new BinaryFormula( new UnaryFormula( new UnaryFormula( new BinaryFormula( new StateFormula(() => intValue > 7 && boolValue), BinaryOperator.And, new BinaryFormula( new UnaryFormula(new StateFormula(() => !boolValue), UnaryOperator.Next), BinaryOperator.Or, new StateFormula(() => intValue < 4))), UnaryOperator.Finally), UnaryOperator.All), BinaryOperator.And, new UnaryFormula(new UnaryFormula(new StateFormula(() => boolValue), UnaryOperator.Finally), UnaryOperator.All)); Check(actual, expected); }
protected override void Check() { var intValue = 7; { var actual = ((LtlFormula)false) & (intValue < 7); var expected = new BinaryFormula( new StateFormula(new BooleanLiteralExpression(false)), BinaryFormulaOperator.And, PathQuantifier.None, new StateFormula(new BinaryExpression(BinaryOperator.Less, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7)))); Check(actual, expected); } { var actual = Ltl.X(true) & intValue < 7; var expected = new BinaryFormula( new UnaryFormula(new StateFormula(new BooleanLiteralExpression(true)), UnaryFormulaOperator.Next, PathQuantifier.None), BinaryFormulaOperator.And, PathQuantifier.None, new StateFormula(new BinaryExpression(BinaryOperator.Less, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7)))); Check(actual, expected); } { var actual = intValue < 7 & Ltl.X(true); var expected = new BinaryFormula( new StateFormula(new BinaryExpression(BinaryOperator.Less, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7))), BinaryFormulaOperator.And, PathQuantifier.None, new UnaryFormula(new StateFormula(new BooleanLiteralExpression(true)), UnaryFormulaOperator.Next, PathQuantifier.None)); Check(actual, expected); } { var actual = false & (Ltl.F(intValue < 7)); var expected = new BinaryFormula( new StateFormula(new BooleanLiteralExpression(false)), BinaryFormulaOperator.And, PathQuantifier.None, new UnaryFormula( new StateFormula(new BinaryExpression(BinaryOperator.Less, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7))), UnaryFormulaOperator.Finally, PathQuantifier.None)); Check(actual, expected); } { var actual = false & Ltl.F(intValue < 7); var expected = new BinaryFormula( new StateFormula(new BooleanLiteralExpression(false)), BinaryFormulaOperator.And, PathQuantifier.None, new UnaryFormula( new StateFormula(new BinaryExpression(BinaryOperator.Less, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7))), UnaryFormulaOperator.Finally, PathQuantifier.None)); Check(actual, expected); } }
protected override void Check() { var intValue = 7; { var actual = ((Formula)false) | (intValue < 7); var expected = new BinaryFormula( new StateFormula(() => false), BinaryOperator.Or, new StateFormula(() => intValue < 7)); Check(actual, expected); } { var actual = X(true) | intValue < 7; var expected = new BinaryFormula( new UnaryFormula(new StateFormula(() => true), UnaryOperator.Next), BinaryOperator.Or, new StateFormula(() => intValue < 7)); Check(actual, expected); } { var actual = intValue < 7 | X(true); var expected = new BinaryFormula( new StateFormula(() => intValue < 7), BinaryOperator.Or, new UnaryFormula(new StateFormula(() => true), UnaryOperator.Next)); Check(actual, expected); } { var actual = false | (F(intValue < 7)); var expected = new BinaryFormula( new StateFormula(() => false), BinaryOperator.Or, new UnaryFormula( new StateFormula(() => intValue < 7), UnaryOperator.Finally)); Check(actual, expected); } { var actual = ((Formula)false) || (intValue < 7); var expected = new BinaryFormula( new StateFormula(() => false), BinaryOperator.Or, new StateFormula(() => intValue < 7)); Check(actual, expected); } { var actual = X(true) || intValue < 7; var expected = new BinaryFormula( new UnaryFormula(new StateFormula(() => true), UnaryOperator.Next), BinaryOperator.Or, new StateFormula(() => intValue < 7)); Check(actual, expected); } { var actual = intValue < 7 || X(true); var expected = new BinaryFormula( new StateFormula(() => intValue < 7), BinaryOperator.Or, new UnaryFormula(new StateFormula(() => true), UnaryOperator.Next)); Check(actual, expected); } { var actual = intValue < 4 || (F(intValue < 7)); var expected = new BinaryFormula( new StateFormula(() => intValue < 4), BinaryOperator.Or, new UnaryFormula( new StateFormula(() => intValue < 7), UnaryOperator.Finally)); Check(actual, expected); } }
protected override void Check() { var intValue = 7; { var actual = U(intValue < 7, false); var expected = new BinaryFormula( new StateFormula(() => intValue < 7), BinaryOperator.Until, new StateFormula(() => false)); Check(actual, expected); } { var actual = U(G(intValue >= 7), false); var expected = new BinaryFormula( new UnaryFormula( new StateFormula(() => intValue >= 7), UnaryOperator.Globally), BinaryOperator.Until, new StateFormula(() => false)); Check(actual, expected); } { var actual = U(intValue >= 7, F(false)); var expected = new BinaryFormula( new StateFormula(() => intValue >= 7), BinaryOperator.Until, new UnaryFormula(new StateFormula(() => false), UnaryOperator.Finally)); Check(actual, expected); } { var actual = U(G(intValue >= 7), F(false)); var expected = new BinaryFormula( new UnaryFormula( new StateFormula(() => intValue >= 7), UnaryOperator.Globally), BinaryOperator.Until, new UnaryFormula(new StateFormula(() => false), UnaryOperator.Finally)); Check(actual, expected); } { var actual = AU(G(intValue >= 7), F(false)); var expected = new UnaryFormula( new BinaryFormula( new UnaryFormula( new StateFormula(() => intValue >= 7), UnaryOperator.Globally), BinaryOperator.Until, new UnaryFormula(new StateFormula(() => false), UnaryOperator.Finally)), UnaryOperator.All); Check(actual, expected); } { var actual = EU(G(intValue >= 7), F(false)); var expected = new UnaryFormula( new BinaryFormula( new UnaryFormula( new StateFormula(() => intValue >= 7), UnaryOperator.Globally), BinaryOperator.Until, new UnaryFormula(new StateFormula(() => false), UnaryOperator.Finally)), UnaryOperator.Exists); Check(actual, expected); } }
protected override void Check() { var intValue = 7; { var actual = ((Formula)false) & (intValue < 7); var expected = new BinaryFormula( new StateFormula(() => false), BinaryOperator.And, new StateFormula(() => intValue < 7)); Check(actual, expected); } { var actual = X(true) & intValue < 7; var expected = new BinaryFormula( new UnaryFormula(new StateFormula(() => true), UnaryOperator.Next), BinaryOperator.And, new StateFormula(() => intValue < 7)); Check(actual, expected); } { var actual = intValue < 7 & X(true); var expected = new BinaryFormula( new StateFormula(() => intValue < 7), BinaryOperator.And, new UnaryFormula(new StateFormula(() => true), UnaryOperator.Next)); Check(actual, expected); } { var actual = false & (F(intValue < 7)); var expected = new BinaryFormula( new StateFormula(() => false), BinaryOperator.And, new UnaryFormula( new StateFormula(() => intValue < 7), UnaryOperator.Finally)); Check(actual, expected); } { var actual = ((Formula)false) && (intValue < 7); var expected = new BinaryFormula( new StateFormula(() => false), BinaryOperator.And, new StateFormula(() => intValue < 7)); Check(actual, expected); } { var actual = X(true) && intValue < 7; var expected = new BinaryFormula( new UnaryFormula(new StateFormula(() => true), UnaryOperator.Next), BinaryOperator.And, new StateFormula(() => intValue < 7)); Check(actual, expected); } { var actual = intValue < 7 && X(true); var expected = new BinaryFormula( new StateFormula(() => intValue < 7), BinaryOperator.And, new UnaryFormula(new StateFormula(() => true), UnaryOperator.Next)); Check(actual, expected); } { var actual = intValue < 3 && (F(intValue < 7)); var expected = new BinaryFormula( new StateFormula(() => intValue < 3), BinaryOperator.And, new UnaryFormula( new StateFormula(() => intValue < 7), UnaryOperator.Finally)); Check(actual, expected); } }
protected override void Check() { var intValue = 7; { var actual = ((CtlFormula)false) | (intValue < 7); var expected = new BinaryFormula( new StateFormula(new BooleanLiteralExpression(false)), BinaryFormulaOperator.Or, PathQuantifier.None, new StateFormula(new BinaryExpression(BinaryOperator.Less, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7)))); Check(actual, expected); } { var actual = Ctl.AX(true) | intValue < 7; var expected = new BinaryFormula( new UnaryFormula(new StateFormula(new BooleanLiteralExpression(true)), UnaryFormulaOperator.Next, PathQuantifier.All), BinaryFormulaOperator.Or, PathQuantifier.None, new StateFormula(new BinaryExpression(BinaryOperator.Less, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7)))); Check(actual, expected); } { var actual = intValue < 7 | Ctl.AF(true); var expected = new BinaryFormula( new StateFormula(new BinaryExpression(BinaryOperator.Less, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7))), BinaryFormulaOperator.Or, PathQuantifier.None, new UnaryFormula(new StateFormula(new BooleanLiteralExpression(true)), UnaryFormulaOperator.Finally, PathQuantifier.All)); Check(actual, expected); } { var actual = (false) | (Ctl.EF(intValue < 7)); var expected = new BinaryFormula( new StateFormula(new BooleanLiteralExpression(false)), BinaryFormulaOperator.Or, PathQuantifier.None, new UnaryFormula( new StateFormula(new BinaryExpression(BinaryOperator.Less, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7))), UnaryFormulaOperator.Finally, PathQuantifier.Exists)); Check(actual, expected); } { var actual = ((CtlFormula)false) | Ctl.EF(intValue < 7); var expected = new BinaryFormula( new StateFormula(new BooleanLiteralExpression(false)), BinaryFormulaOperator.Or, PathQuantifier.None, new UnaryFormula( new StateFormula(new BinaryExpression(BinaryOperator.Less, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7))), UnaryFormulaOperator.Finally, PathQuantifier.Exists)); Check(actual, expected); } { var actual = ((CtlFormula)false) | Ctl.EF(intValue < 7 | Ctl.AX(true)); var expected = new BinaryFormula( new StateFormula(new BooleanLiteralExpression(false)), BinaryFormulaOperator.Or, PathQuantifier.None, new UnaryFormula( new BinaryFormula( new StateFormula(new BinaryExpression(BinaryOperator.Less, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7))), BinaryFormulaOperator.Or, PathQuantifier.None, new UnaryFormula(new StateFormula(new BooleanLiteralExpression(true)), UnaryFormulaOperator.Next, PathQuantifier.All)), UnaryFormulaOperator.Finally, PathQuantifier.Exists)); Check(actual, expected); } }
protected override void Check() { var intValue = 7; { var actual = Ctl.AU(intValue < 7, false); var expected = new BinaryFormula( new StateFormula(new BinaryExpression(BinaryOperator.Less, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7))), BinaryFormulaOperator.Until, PathQuantifier.All, new StateFormula(new BooleanLiteralExpression(false))); Check(actual, expected); } { var actual = Ctl.AU(Ctl.AG(intValue >= 7), false); var expected = new BinaryFormula( new UnaryFormula( new StateFormula(new BinaryExpression(BinaryOperator.GreaterEqual, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7))), UnaryFormulaOperator.Globally, PathQuantifier.All), BinaryFormulaOperator.Until, PathQuantifier.All, new StateFormula(new BooleanLiteralExpression(false))); Check(actual, expected); } { var actual = Ctl.AU(intValue >= 7, Ctl.AF(false)); var expected = new BinaryFormula( new StateFormula(new BinaryExpression(BinaryOperator.GreaterEqual, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7))), BinaryFormulaOperator.Until, PathQuantifier.All, new UnaryFormula(new StateFormula(new BooleanLiteralExpression(false)), UnaryFormulaOperator.Finally, PathQuantifier.All)); Check(actual, expected); } { var actual = Ctl.AU(Ctl.AG(intValue >= 7), Ctl.AF(false)); var expected = new BinaryFormula( new UnaryFormula( new StateFormula(new BinaryExpression(BinaryOperator.GreaterEqual, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7))), UnaryFormulaOperator.Globally, PathQuantifier.All), BinaryFormulaOperator.Until, PathQuantifier.All, new UnaryFormula(new StateFormula(new BooleanLiteralExpression(false)), UnaryFormulaOperator.Finally, PathQuantifier.All)); Check(actual, expected); } { var actual = Ctl.EU(intValue < 7, false); var expected = new BinaryFormula( new StateFormula(new BinaryExpression(BinaryOperator.Less, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7))), BinaryFormulaOperator.Until, PathQuantifier.Exists, new StateFormula(new BooleanLiteralExpression(false))); Check(actual, expected); } { var actual = Ctl.EU(Ctl.EG(intValue >= 7), false); var expected = new BinaryFormula( new UnaryFormula( new StateFormula(new BinaryExpression(BinaryOperator.GreaterEqual, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7))), UnaryFormulaOperator.Globally, PathQuantifier.Exists), BinaryFormulaOperator.Until, PathQuantifier.Exists, new StateFormula(new BooleanLiteralExpression(false))); Check(actual, expected); } { var actual = Ctl.EU(intValue >= 7, Ctl.EF(false)); var expected = new BinaryFormula( new StateFormula(new BinaryExpression(BinaryOperator.GreaterEqual, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7))), BinaryFormulaOperator.Until, PathQuantifier.Exists, new UnaryFormula(new StateFormula(new BooleanLiteralExpression(false)), UnaryFormulaOperator.Finally, PathQuantifier.Exists)); Check(actual, expected); } { var actual = Ctl.EU(Ctl.EG(intValue >= 7), Ctl.EF(false)); var expected = new BinaryFormula( new UnaryFormula( new StateFormula(new BinaryExpression(BinaryOperator.GreaterEqual, new IntegerLiteralExpression(7), new IntegerLiteralExpression(7))), UnaryFormulaOperator.Globally, PathQuantifier.Exists), BinaryFormulaOperator.Until, PathQuantifier.Exists, new UnaryFormula(new StateFormula(new BooleanLiteralExpression(false)), UnaryFormulaOperator.Finally, PathQuantifier.Exists)); Check(actual, expected); } }