Example #1
0
        /// <summary>
        ///   Initializes the model that should be analyzed.
        /// </summary>
        /// <param name="configuration">The configuration that should be used for the analyses.</param>
        /// <param name="hazard">The hazard that should be analyzed.</param>
        protected override void InitializeModel(AnalysisConfiguration configuration, Formula hazard)
        {
            var invariant = new UnaryFormula(hazard, UnaryOperator.Not);

            var checker = new QualitativeChecker <TExecutableModel>(RuntimeModelCreator)
            {
                Configuration = configuration
            };

            checker.Configuration.ProgressReportsOnly = false;


            var stateGraph = checker.GenerateStateGraph();



            var stateCapacity    = Math.Max(1024, (int)(stateGraph.StateCount * 1.5));
            var newModelCapacity = new ModelCapacityByModelDensity(stateCapacity, ModelDensityLimit.High);

            configuration.ModelCapacity = newModelCapacity;
            Func <AnalysisModel> createAnalysisModelFunc = () => new StateGraphModel <TExecutableModel>(stateGraph, configuration.SuccessorCapacity);
            var createAnalysisModel = new AnalysisModelCreator(createAnalysisModelFunc);

            _checker = new InvariantChecker(createAnalysisModel, configuration, invariant);
        }
        public override InvariantAnalysisResult[] CheckInvariants(CoupledExecutableModelCreator <SafetySharpRuntimeModel> createModel, params Formula[] invariants)
        {
            var checker = new QualitativeChecker <SafetySharpRuntimeModel>(createModel);

            checker.Configuration = _analysisConfiguration;
            return(checker.CheckInvariants(invariants));
        }
        /// <summary>
        ///   Checks whether the <paramref name="invariants" /> hold in all states of the <paramref name="model" />. The appropriate
        ///   model checker is chosen automatically.
        /// </summary>
        /// <param name="model">The model that should be checked.</param>
        /// <param name="invariants">The invariants that should be checked.</param>
        public static AnalysisResult <SafetySharpRuntimeModel>[] CheckInvariants(ModelBase model, params Formula[] invariants)
        {
            var createModel        = SafetySharpRuntimeModel.CreateExecutedModelFromFormulasCreator(model);
            var qualitativeChecker = new QualitativeChecker <SafetySharpRuntimeModel> {
                Configuration = TraversalConfiguration
            };

            return(qualitativeChecker.CheckInvariants(createModel, invariants));
        }
        /// <summary>
        ///   Checks whether the <paramref name="invariant" /> holds in all states of the <paramref name="model" />. The appropriate
        ///   model checker is chosen automatically.
        /// </summary>
        /// <param name="model">The model that should be checked.</param>
        /// <param name="invariant">The invariant that should be checked.</param>
        public static AnalysisResult <SafetySharpRuntimeModel> CheckInvariant(ModelBase model, Formula invariant)
        {
            var createModel        = SafetySharpRuntimeModel.CreateExecutedModelCreator(model, invariant);
            var qualitativeChecker = new QualitativeChecker <SafetySharpRuntimeModel> {
                Configuration = TraversalConfiguration
            };

            return(qualitativeChecker.CheckInvariant(createModel, formulaIndex: 0));
        }
Example #5
0
        public override void CreateModelChecker(bool suppressCounterExampleGeneration, Action <string> logAction)
        {
            // QualitativeChecker<SafetySharpRuntimeModel>
            // LtsMin
            modelChecker = new SafetySharpQualitativeChecker();
            modelChecker.OutputWritten += logAction;

            modelChecker.Configuration.ModelCapacity          = ModelCapacityByMemorySize.Small;
            modelChecker.Configuration.GenerateCounterExample = !suppressCounterExampleGeneration;
        }
        /// <summary>
        ///   Checks whether the <paramref name="invariant" /> holds in all states of the <paramref name="model" />. The appropriate
        ///   model checker is chosen automatically.
        /// </summary>
        /// <param name="model">The model that should be checked.</param>
        /// <param name="invariant">The invariant that should be checked.</param>
        public static SafetySharpInvariantAnalysisResult CheckInvariant(ModelBase model, Formula invariant)
        {
            var createModel        = SafetySharpRuntimeModel.CreateExecutedModelCreator(model, invariant);
            var qualitativeChecker = new QualitativeChecker <SafetySharpRuntimeModel>(createModel)
            {
                Configuration = TraversalConfiguration
            };
            var result = qualitativeChecker.CheckInvariant(formulaIndex: 0);

            return(SafetySharpInvariantAnalysisResult.FromInvariantAnalysisResult(result, createModel));
        }
        /// <summary>
        ///   Checks whether the <paramref name="invariants" /> hold in all states of the <paramref name="model" />. The appropriate
        ///   model checker is chosen automatically.
        /// </summary>
        /// <param name="model">The model that should be checked.</param>
        /// <param name="invariants">The invariants that should be checked.</param>
        public static SafetySharpInvariantAnalysisResult[] CheckInvariants(ModelBase model, params Formula[] invariants)
        {
            var createModel        = SafetySharpRuntimeModel.CreateExecutedModelCreator(model, invariants);
            var qualitativeChecker = new QualitativeChecker <SafetySharpRuntimeModel>(createModel)
            {
                Configuration = TraversalConfiguration
            };
            var results    = qualitativeChecker.CheckInvariants(invariants);
            var newResults = results.Select(result => SafetySharpInvariantAnalysisResult.FromInvariantAnalysisResult(result, createModel));

            return(newResults.ToArray());
        }
        public override InvariantAnalysisResult CheckInvariant(CoupledExecutableModelCreator <SafetySharpRuntimeModel> createModel, Formula formula)
        {
            var checker = new QualitativeChecker <SafetySharpRuntimeModel>(createModel);

            checker.Configuration = _analysisConfiguration;
            var formulaIndex = Array.FindIndex(createModel.StateFormulasToCheckInBaseModel, stateFormula =>
            {
                var isEqual = IsFormulasStructurallyEquivalentVisitor.Compare(stateFormula, formula);
                return(isEqual);
            }
                                               );

            if (formulaIndex == -1)
            {
                throw new Exception($"Input formula is not checked directly. Use {nameof(AnalysisTestsWithQualitative)} instead");
            }

            return(checker.CheckInvariant(formulaIndex));
        }