Пример #1
0
        public async Task Verify(FileInfo kplModelFile, IEnumerable <IProperty> properties, FileInfo verificationDirectory, IModelCheckingProgressMonitor monitor)
        {
            await Task.Run(() =>
            {
                try
                {
                    monitor.Start(4, string.Format("Verifying the {0} model using the SPIN modelchecker...", kplModelFile.Name));

                    monitor.LogProgress(0, "Generating the correspoding PROMELA model...");

                    var verificationModelFileName = string.Format("{0}\\{1}.pml", verificationDirectory.FullName, Path.GetFileNameWithoutExtension(kplModelFile.Name));
                    using (var fileWriter = new FileInfo(verificationModelFileName).CreateText())
                    {
                        //Old translator

                        /*
                         * var translationParameters = PromelaTranslationParams.Default();
                         * translationParameters.PrintRuleExecution = false;
                         * translationParameters.PrintConfiguration = false;
                         * translationParameters.PrintTargetSelection = false;
                         * translationParameters.PrintLinks = false;
                         */

                        var translationParameters = VerificationModelParams.Default();

                        KpModel kpModel = null;
                        try
                        {
                            kpModel = KP.FromKpl(kplModelFile.FullName);
                        }
                        catch (KplParseException kplException)
                        {
                            throw new Exception(string.Format("Failed to parse input file {0}. Reason: {1}", kplModelFile.Name, kplException.Message));
                        }

                        var experiment = new Experiment
                        {
                            LtlProperties = properties.Where(p => p is ILtlProperty).Cast <ILtlProperty>().ToList(),
                        };

                        //Old translator
                        //KP.WritePromela(kpModel.KPsystem, experiment, translationParameters, fileWriter);

                        KP.WriteVerificationPromelaModel(kpModel, experiment, translationParameters, fileWriter);
                    }

                    monitor.LogProgress(1, "Translating the PROMELA model into its computationally equivalent verification model...");
                    GenerateModel(verificationDirectory, verificationModelFileName);

                    monitor.LogProgress(2, "Compiling the verification model...");
                    CompileModel(verificationDirectory, verificationModelFileName);

                    monitor.LogProgress(3, "Performing model checking...");
                    ExecuteModel(verificationDirectory, verificationModelFileName);

                    //monitor.LogProgress(4, "Generating the output trail file...");
                    //GenerateTrail(verificationDirectory, verificationModelFileName);

                    monitor.Done("Finished the verification process");
                }
                catch (Exception e)
                {
                    monitor.Terminate("Verification failed: " + e.Message);
                }
            });
        }
Пример #2
0
        public async Task Verify(FileInfo kplModelFile, IEnumerable <IProperty> properties, FileInfo verificationDirectory, IModelCheckingProgressMonitor monitor)
        {
            await Task.Run(() =>
            {
                try
                {
                    monitor.Start(2, string.Format("Verifying the {0} model using the NuSMV modelchecker...", kplModelFile.Name));

                    monitor.LogProgress(0, "Generating the correspoding NuSMV model...");
                    KpModel kpModel = null;
                    try
                    {
                        kpModel = KP.FromKpl(kplModelFile.FullName);
                    }
                    catch (KplParseException kplException)
                    {
                        throw new Exception(string.Format("Failed to parse input file {0}. Reason: {1}", kplModelFile.Name, kplException.Message));
                    }

                    var experiment = new Experiment
                    {
                        LtlProperties = properties.Where(p => !(p is ICtlProperty)).Cast <ILtlProperty>().ToList(),
                        CtlProperties = properties.Where(p => p is ICtlProperty).Cast <ICtlProperty>().ToList(),
                    };

                    var verificationModelFileName = string.Format("{0}\\{1}.smv", verificationDirectory.FullName, Path.GetFileNameWithoutExtension(kplModelFile.Name));
                    TranslateSMV.Translate(kpModel, experiment, verificationModelFileName);

                    monitor.LogProgress(1, "Performing model checking...");
                    ExecuteModel(verificationDirectory, verificationModelFileName);

                    monitor.Done("Finished the verification process");
                }
                catch (Exception e)
                {
                    monitor.Terminate("Verification failed: " + e.Message);
                }
            });
        }
 public async Task Verify(FileInfo kplModelFile, IEnumerable <IProperty> properties, FileInfo verificationModelFile, ModelCheckingTarget target, IModelCheckingProgressMonitor monitor)
 {
     var executor = GetExecutor(target);
     await executor.Verify(kplModelFile, properties, verificationModelFile, monitor);
 }