public void CheckDirect() { var m = new Model(); var formulaNotTwo = new UnaryFormula(Model.StateIsTwo, UnaryOperator.Not); var checker = new SimpleQualitativeChecker { Configuration = AnalysisConfiguration.Default }; checker.Configuration.ModelCapacity = ModelCapacityByMemorySize.Small; checker.OutputWritten += output => Output.Log(output); var result = checker.CheckInvariant(m, formulaNotTwo); var simulator = new Simulator <SimpleExecutableModel>(result.CounterExample); var simulatedModel = simulator.RuntimeModel.Model; simulatedModel.State.ShouldBe(0); simulator.IsCompleted.ShouldBe(false); simulator.SimulateStep(); simulatedModel.State.ShouldBe(1); simulator.IsCompleted.ShouldBe(false); simulator.SimulateStep(); simulatedModel.State.ShouldBe(2); simulator.IsCompleted.ShouldBe(true); }
public void CheckSaved() { var m = new Model(); var formulaNotTwo = new UnaryFormula(Model.StateIsTwo, UnaryOperator.Not); var checker = new SimpleQualitativeChecker { Configuration = AnalysisConfiguration.Default }; checker.Configuration.ModelCapacity = ModelCapacityByMemorySize.Small; checker.OutputWritten += output => Output.Log(output); var result = checker.CheckInvariant(m, formulaNotTwo); // save and load counterexample using (var file = new TemporaryFile(".ssharp")) { result.CounterExample.Save(file.FilePath); var counterExampleSerialization = new SimpleExecutableModelCounterExampleSerialization(); var simulator = new Simulator <SimpleExecutableModel>(counterExampleSerialization.Load(file.FilePath)); var simulatedModel = simulator.RuntimeModel.Model; simulatedModel.State.ShouldBe(0); simulator.IsCompleted.ShouldBe(false); simulator.SimulateStep(); simulatedModel.State.ShouldBe(1); simulator.IsCompleted.ShouldBe(false); simulator.SimulateStep(); simulatedModel.State.ShouldBe(2); simulator.IsCompleted.ShouldBe(true); } }
public void Check() { var m = new Model(); var formulaNotTwo = new UnaryFormula(Model.StateIsTwo, UnaryOperator.Not); var checker = new SimpleQualitativeChecker(m, formulaNotTwo) { Configuration = AnalysisConfiguration.Default }; checker.Configuration.ModelCapacity = ModelCapacityByMemorySize.Small; checker.Configuration.DefaultTraceOutput = Output.TextWriterAdapter(); var result = checker.CheckInvariant(formulaNotTwo); result.FormulaHolds.ShouldBe(true); }
public void Check() { var m = new Model(); //F != 2 && F != 3 && (G == 0 || G == 7 || G == 8 var formulaGIs078 = new BinaryFormula(new BinaryFormula(Model.GIs0, BinaryOperator.Or, Model.GIs7), BinaryOperator.Or, Model.GIs8); var formulaFNot2 = new UnaryFormula(Model.FIs2, UnaryOperator.Not); var formulaFNot3 = new UnaryFormula(Model.FIs3, UnaryOperator.Not); var formula = new BinaryFormula(new BinaryFormula(formulaFNot2, BinaryOperator.And, formulaFNot3), BinaryOperator.And, formulaGIs078); var checker = new SimpleQualitativeChecker(m, formula) { Configuration = AnalysisConfiguration.Default }; checker.Configuration.ModelCapacity = ModelCapacityByMemorySize.Small; checker.Configuration.DefaultTraceOutput = Output.TextWriterAdapter(); var result = checker.CheckInvariant(formula); result.FormulaHolds.ShouldBe(true); }