Ejemplo n.º 1
0
        public DiagnosisResult executeAssertion(SpecificationBase spec, String assertionName)
        {
            AssertionBase     assertion = spec.AssertionDatabase[assertionName];
            AssertionVerifier verifier  = new AssertionVerifier(assertion, 1, 0);

            return(verifier.Run());
        }
Ejemplo n.º 2
0
        private void StartVerification(ListViewItem item)
        {
            if (!ModuleSpecificCheckPassed())
            {
                return;
            }

            if (!Spec.GrabSharedDataLock())
            {
                MessageBox.Show(Resources.Please_wait_for_the_simulation_or_parsing_finished_before_verification, Common.Ultility.Ultility.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            DisableAllControls();


            try
            {
                Spec.LockSharedData(false);

                StatusLabel_Text.Text = Resources.ModelCheckingForm_StartVerification_Verification_Starts;



                item.ImageIndex = UNKNOWN_ICON;

                Assertion = Spec.AssertionDatabase[item.SubItems[2].Text];
                Assertion.UIInitialize(this, ComboBox_AdmissibleBehavior.SelectedIndex == -1 ? 0 : ComboBox_AdmissibleBehavior.SelectedIndex,
                                       ComboBox_VerificationEngine.SelectedIndex == -1 ? 0 : ComboBox_VerificationEngine.SelectedIndex);

                Assertion.VerificationOutput.GenerateCounterExample = CheckBox_GenerateWitnessTrace.Checked;

                Assertion.Action       += OnAction;
                Assertion.ReturnResult += VerificationFinished;
                Assertion.Cancelled    += Verification_Cancelled;
                Assertion.Failed       += MC_Failed;

                seconds           = 1;
                ProgressBar.Value = 0;
                MCTimer.Start();
                Assertion.Start();
            }
            catch (RuntimeException e)
            {
                Spec.UnLockSharedData();
                Common.Ultility.Ultility.LogRuntimeException(e);
                Button_Verify.Text = VERIFY;
                this.Close();
                return;
            }
            catch (Exception ex)
            {
                Spec.UnLockSharedData();
                Common.Ultility.Ultility.LogException(ex, Spec);
                Button_Verify.Text = VERIFY;
                this.Close();
                return;
            }
        }
Ejemplo n.º 3
0
        private void RunAssertion(AssertionBase assertion, int fairnessIndex, int engineIndex)
        {
            AssertionVerifier verifier = new AssertionVerifier(assertion, fairnessIndex, engineIndex);
            ThreadedExecuter <DiagnosisResult> executer = new ThreadedExecuter <DiagnosisResult>(verifier.Run, gatherResults);

            executer.Start();
        }
Ejemplo n.º 4
0
    public async Task <object> Invoke(dynamic input)
    {
        try
        {
            string specStr      = (string)input.spec;
            string assertionStr = (string)input.assertion;
            int    behavior     = (int)input.behavior;
            int    engine       = (int)input.engine;

            SpecificationBase spec      = new Specification(specStr);
            AssertionBase     assertion = spec.AssertionDatabase[assertionStr];

            assertion.UIInitialize(null, behavior, engine);
            assertion.VerificationOutput.GenerateCounterExample = true;
            // assertion.VerificationMode = false;
            assertion.InternalStart();

            return(new {
                statistics = assertion.GetResultString() + '\n' +
                             assertion.GetVerificationStatistics(),
                type = (int)assertion.VerificationOutput.VerificationResult
            });
        }
        catch (Exception e)
        {
            return(e.StackTrace);
            //return e.TargetSite.GetType().Name;
        }
    }
Ejemplo n.º 5
0
        public void startVerification(string assert)
        {
            do
            {
                mCurAssert = assert;
                if (!mListener.moduleSpecificCheckPassed())
                {
                    break;
                }

                if (!mSpec.GrabSharedDataLock())
                {
                    MessageBox.Show(Resources.Please_wait_for_the_simulation_or_parsing_finished_before_verification, Common.Utility.Utilities.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }

                mListener.disableAllControls();
                try
                {
                    mSpec.LockSharedData(false);

                    mListener.updateStatusLabel(Resources.ModelCheckingForm_StartVerification_Verification_Starts);
                    mListener.updateResStartVerify();

                    mAssertion = mSpec.AssertionDatabase[assert];

                    int admissibleIndex         = mListener.getCmbAdmissibleIndex();
                    int verificationEngineIndex = mListener.getCmbVerificationEngineIndex();
                    mAssertion.UIInitialize(mForm, admissibleIndex == -1 ? 0 : admissibleIndex,
                                            verificationEngineIndex == -1 ? 0 : verificationEngineIndex);

                    mAssertion.VerificationOutput.GenerateCounterExample = mListener.generateCounterExample();
                    mAssertion.Action       += mListener.onAction;
                    mAssertion.ReturnResult += VerificationFinished;
                    mAssertion.Cancelled    += Verification_Cancelled;
                    mAssertion.Failed       += MC_Failed;

                    mSeconds = 1;
                    mTimer.Start();
                    mAssertion.Start();
                }
                catch (RuntimeException e)
                {
                    mSpec.UnLockSharedData();
                    Common.Utility.Utilities.LogRuntimeException(e);
                    mListener.updateVerifyBtnLabel(LABEL_VERIFY);
                    mListener.closeForm();
                    return;
                }
                catch (Exception ex)
                {
                    mSpec.UnLockSharedData();
                    Common.Utility.Utilities.LogException(ex, mSpec);
                    mListener.updateVerifyBtnLabel(LABEL_VERIFY);
                    mListener.closeForm();
                    return;
                }
            } while (false);
        }
Ejemplo n.º 6
0
        protected virtual void MC_Failed(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            try
            {
                if (e.Exception is RuntimeException)
                {
                    Common.Ultility.Ultility.LogRuntimeException(e.Exception as RuntimeException);

                    string trace = "";
                    if (e.Exception.Data.Contains("trace"))
                    {
                        trace = Environment.NewLine + "Trace leads to exception:" + Environment.NewLine + e.Exception.Data["trace"].ToString();
                    }

                    if (Assertion != null)
                    {
                        TextBox_Output.Text = Resources.Total_transitions_visited_before_the_exception + Assertion.VerificationOutput.Transitions + Environment.NewLine + TextBox_Output.Text;
                    }
                    //TextBox_Output.Text += e.Exception.StackTrace + "\r\n" + TextBox_Output.Text;
                    TextBox_Output.Text = e.Exception.Message + trace + Environment.NewLine + TextBox_Output.Text;
                    TextBox_Output.Text = Resources.Exception_happened_during_the_verification + ":\r\n" + TextBox_Output.Text;


                    StatusLabel_Text.Text = Resources.Runtime_Exception_Happened;

                    //MessageBox.Show("Runtime exception!\r\n" +e.Exception.Message,// + "\r\n" + ex.StackTrace,"PAT", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //this.Close();
                    //return;
                }
                else
                {
                    //if the button is enabled -> the failure is not triggered by cancel action.
                    if (Button_Verify.Enabled)
                    {
                        Common.Ultility.Ultility.LogException(e.Exception, Spec);
                        Spec.UnLockSharedData();
                        this.Close();
                    }
                    else
                    {
                        this.StatusLabel_Text.Text = Resources.Verification_Cancelled;
                    }
                }
                Assertion.Clear();
                //remove the events
                Assertion.Action       -= OnAction;
                Assertion.ReturnResult -= VerificationFinished;
                Assertion.Cancelled    -= Verification_Cancelled;
                Assertion.Failed       -= MC_Failed;
                Assertion = null;

                EnableAllControls();
            }
            catch (Exception ex)
            {
                Common.Ultility.Ultility.LogException(ex, Spec);
                //MessageBox.Show("Exception happened: " + ex.Message + "\r\n", // + ex.StackTrace,"PAT", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 7
0
        public void executeAssertion(SpecificationBase spec, String assertionName)
        {
            AssertionBase     assertion = spec.AssertionDatabase[assertionName];
            AssertionVerifier verifier  = new AssertionVerifier(assertion, 1, 0);
            T stuffReturned             = (T)Convert.ChangeType(verifier.Run(), typeof(T));

            callback(stuffReturned);
        }
Ejemplo n.º 8
0
        protected virtual void MC_Failed(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            try
            {
                if (e.Exception is RuntimeException)
                {
                    string trace = "";
                    if (e.Exception.Data.Contains("trace"))
                    {
                        trace = Environment.NewLine + "Trace leads to exception:" + Environment.NewLine + e.Exception.Data["trace"].ToString();
                    }

                    this.OutputWriter.WriteLine("Runtime Exception happened during the verification:");
                    this.OutputWriter.WriteLine(e.Exception.Message + trace);

                    //Common.Ultility.Ultility.LogRuntimeException(e.Exception as RuntimeException);

                    if (Assertion != null)
                    {
                        this.OutputWriter.WriteLine("Total transitions visited before the exception:" + Assertion.VerificationOutput.Transitions);
                    }

                    StatusLabel_Text.Text = Resources.Runtime_Exception_Happened;
                }
                else
                {
                    this.OutputWriter.WriteLine("Exception happened during the verification:");
                    this.OutputWriter.WriteLine(e.Exception.Message);

                    ////if the button is enabled -> the failure is not triggered by cancel action.
                    //if(Button_Verify.Enabled)
                    //{
                    //    Common.Ultility.Ultility.LogException(e.Exception, Spec);
                    //    Spec.UnLockSharedData();
                    //    this.Close();
                    //}
                    //else
                    //{
                    //    this.StatusLabel_Text.Text = "Verification Cancelled";
                    //}
                }

                Assertion.Clear();
                //remove the events
                Assertion.Action       -= OnAction;
                Assertion.ReturnResult -= VerificationFinished;
                Assertion.Cancelled    -= Verification_Cancelled;
                Assertion.Failed       -= MC_Failed;
                Assertion = null;

                StartVerification(true, false);
            }
            catch (Exception ex)
            {
                Common.Utility.Utilities.LogException(ex, Spec);
            }
        }
Ejemplo n.º 9
0
        //void TextBox_DataPane_TextChanged(object sender, EventArgs e)
        //{
        //    TextBox_DataPane.Font = new Font(TextBox_DataPane.Font.FontFamily, 8, FontStyle.Regular);
        //    TextBox_DataPane.SelectAll();
        //    TextBox_DataPane.SelectionFont = TextBox_DataPane.Font;
        //    TextBox_DataPane.SelectionStart = 0;
        //    TextBox_DataPane.SelectionLength = 0;
        //}


        protected virtual void Verification_Cancelled(object sender, EventArgs e)
        {
            try
            {
                //cancel the verification
                if (Assertion.VerificationMode)
                {
                    TextBox_Output.Text = Assertion.GetVerificationStatistics() + TextBox_Output.Text;
                    TextBox_Output.Text = Assertion.VerificationOutput.ResultString + TextBox_Output.Text;

                    RnderingOutputTextbox();

                    Assertion.Clear();

                    //remove the events
                    Assertion.Action            -= OnAction;
                    Assertion.ReturnResult      -= VerificationFinished;
                    Assertion.Cancelled         -= Verification_Cancelled;
                    Assertion.Failed            -= MC_Failed;
                    Assertion.VerificationOutput = null;
                    Assertion = null;


                    StatusLabel_Text.Text = Resources.Verification_Cancelled;

                    //set the verification result to be unknow.
                    ListView_Assertions.SelectedItems[VerificationIndex].ImageIndex = UNKNOWN_ICON;
                }
                //cancel the result generation
                else
                {
                    TextBox_Output.Text = Assertion.VerificationOutput.ResultString + TextBox_Output.Text;

                    StatusLabel_Text.Text = Resources.Result_Generation_Cancelled;


                    RnderingOutputTextbox();

                    //ColorText(0);


                    //TextBox_Output.Select(0, 0);
                    //TextBox_Output.ScrollToCaret();

                    Assertion.VerificationOutput = null;
                }
                //TextBox_Output.Text = StatusLabel_Text.Text + "\r\n\r\n" + TextBox_Output.Text;

                EnableAllControls();
                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                Common.Ultility.Ultility.LogException(ex, Spec);
                //MessageBox.Show("Exception happened: " + ex.Message + "\r\n" + ex.StackTrace,"PAT", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 10
0
        public static void Initialize(AssertionBase Assertion, PetriNet Process, SpecificationBase spec)
        {
            Specification Spec = spec as Specification;

            //get the relevant global variables; remove irrelevant variables so as to save memory;
            Valuation GlobalEnv = Spec.SpecValuation.GetClone();

            //Initialize InitialStep
            Assertion.InitialStep = new PNConfiguration(Process, Constants.INITIAL_EVENT, null, GlobalEnv, false, spec);
        }
Ejemplo n.º 11
0
        private void ListView_Assertions_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            try
            {
                if (ListView_Assertions.SelectedItems.Count != 1)
                {
                    Assertion = null;

                    if (ListView_Assertions.SelectedItems.Count == 0)
                    {
                        //set text
                        Label_SelectedAssertion.Text        = "";
                        Button_BAGraph.Enabled              = false;
                        Button_SimulateWitnessTrace.Enabled = false;

                        Button_Verify.Enabled      = false;
                        this.StatusLabel_Text.Text = Resources.Select_an_assertion_to_start_with;

                        ComboBox_AdmissibleBehavior.Items.Clear();
                        ComboBox_VerificationEngine.Items.Clear();
                        ComboBox_AdmissibleBehavior.Enabled = false;
                        ComboBox_VerificationEngine.Enabled = false;
                    }
                    else
                    {
                        ResetUIOptions(null, true);

                        Button_Verify.Enabled      = true;
                        this.StatusLabel_Text.Text = Resources.Ready;
                    }
                }
                else
                {
                    //only check the selected item
                    //if (e.IsSelected)
                    {
                        ResetUIOptions(ListView_Assertions.SelectedItems[0], true);
                        this.StatusLabel_Text.Text = Resources.Ready;
                    }
                }
            }
            catch (RuntimeException ex)
            {
                Spec.UnLockSharedData();
                Common.Ultility.Ultility.LogRuntimeException(ex);
                this.Close();
            }
            catch (Exception ex)
            {
                Spec.UnLockSharedData();
                Common.Ultility.Ultility.LogException(ex, Spec);
                this.Close();
            }
        }
Ejemplo n.º 12
0
        public static void Initialize(AssertionBase Assertion, DefinitionRef Process, SpecificationBase spec)
        {
            Specification Spec = spec as Specification;

            //get the relevant global variables; remove irrelevant variables so as to save memory;
            Valuation GlobalEnv = Spec.SpecValuation.GetVariableChannelClone(Process.GetGlobalVariables(), Process.GetChannels());

            //Initialize InitialStep
            Assertion.InitialStep = new Configuration(Process, Constants.INITIAL_EVENT, null, GlobalEnv, false);

            Assertion.MustAbstract = Process.MustBeAbstracted();
        }
Ejemplo n.º 13
0
        protected virtual void MC_Failed(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            try
            {
                if (e.Exception is RuntimeException)
                {
                    Common.Utility.Utilities.LogRuntimeException(e.Exception as RuntimeException);
                    if (mAssertion != null)
                    {
                        mListener.onAction(mAssertion.GetVerificationStatistics());
                        mListener.onAction(mAssertion.VerificationOutput.ResultString);
                        //mListener.RnderingOutputTextbox();
                    }
                    mListener.updateStatusLabel(Resources.Runtime_Exception_Happened);
                }
                else
                {
                    //if the button is enabled -> the failure is not triggered by cancel action.
                    if (mListener.isVerifyBtnEnabled())
                    {
                        Common.Utility.Utilities.LogException(e.Exception, mSpec);
                        mSpec.UnLockSharedData();
                        mListener.closeForm();
                    }
                    else
                    {
                        mListener.updateStatusLabel(Resources.Verification_Cancelled);
                        // this.StatusLabel_Text.Text = Resources.Verification_Cancelled;
                    }
                }

                if (mAssertion != null)
                {
                    mAssertion.Clear();

                    //remove the events
                    mAssertion.Action       -= mListener.onAction;
                    mAssertion.ReturnResult -= VerificationFinished;
                    mAssertion.Cancelled    -= Verification_Cancelled;
                    mAssertion.Failed       -= MC_Failed;
                    mAssertion = null;
                }

                mListener.enableAllControls();
                mTimer.Stop();
            }
            catch (Exception ex)
            {
                Common.Utility.Utilities.LogException(ex, mSpec);
            }
        }
Ejemplo n.º 14
0
        public List <ADLResult> Verify(ADLRequest request)
        {
            System.Diagnostics.Debug.WriteLine("request : \n" + request.code);
            PAT.ADL.ModuleFacade modulebase = new PAT.ADL.ModuleFacade();

            SpecificationBase Spec = modulebase.ParseSpecification(request.code, string.Empty, string.Empty);

            System.Diagnostics.Debug.WriteLine("Specification Loaded...");

            //print assertion for debugging
            List <KeyValuePair <string, AssertionBase> > asrtlists = Spec.AssertionDatabase.ToList();
            List <ADLResult> results = new List <ADLResult>();

            foreach (KeyValuePair <string, AssertionBase> asrt in asrtlists)
            {
                System.Diagnostics.Debug.WriteLine("#" + asrt.Key + "#");
                // start run assertion
                AssertionBase assertion = asrt.Value;

                assertion.UIInitialize(null, 0, 0);

                assertion.VerificationMode = true;
                assertion.InternalStart();

                assertion.GetVerificationStatistics();

                // assertion.VerificationOutput.EstimateMemoryUsage;
                //System.Diagnostics.Debug.WriteLine(assertion.GetResultString());
                ADLResult rs = new ADLResult();
                rs.smell = asrt.Key.Substring(asrt.Key.IndexOf("-") + 1).Replace("free", "");
                rs.model = request.model;
                if (assertion.VerificationOutput.VerificationResult.Equals(VerificationResultType.VALID))
                {
                    rs.result = "valid";
                }
                else
                {
                    rs.result = "invalid";
                }

                rs.visitedStates    = assertion.VerificationOutput.NoOfStates;
                rs.verificationTime = assertion.VerificationOutput.VerificationTime;
                rs.fullResultString = assertion.GetResultString();

                results.Add(rs);
            }


            return(results);
        }
Ejemplo n.º 15
0
        protected virtual void Verification_Cancelled(object sender, EventArgs e)
        {
            try
            {
                //cancel the verification
                if (mAssertion.VerificationMode)
                {
                    mListener.onAction(mAssertion.GetVerificationStatistics());
                    mListener.onAction(mAssertion.VerificationOutput.ResultString);
                    mListener.updateLatexResult(mAssertion);

                    mListener.RnderingOutputTextbox();
                    mAssertion.Clear();

                    //remove the events
                    mAssertion.Action            -= mListener.onAction;
                    mAssertion.ReturnResult      -= VerificationFinished;
                    mAssertion.Cancelled         -= Verification_Cancelled;
                    mAssertion.Failed            -= MC_Failed;
                    mAssertion.VerificationOutput = null;
                    mAssertion = null;

                    mListener.updateStatusLabel(Resources.Verification_Cancelled);
                    //StatusLabel_Text.Text = Resources.Verification_Cancelled;

                    //set the verification result to be unknow.
                    mListener.eventCancel();
                    //ListView_Assertions.SelectedItems[VerificationIndex].ImageIndex = UNKNOWN_ICON;
                }
                //cancel the result generation
                else
                {
                    mListener.onAction(mAssertion.VerificationOutput.ResultString);
                    mListener.updateStatusLabel(Resources.Result_Generation_Cancelled);
                    mListener.updateLatexResult(mAssertion);
                    mListener.RnderingOutputTextbox();
                    mAssertion.VerificationOutput = null;
                }

                mListener.enableAllControls();
                mTimer.Stop();
                // Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                Common.Utility.Utilities.LogException(ex, mSpec);
            }
        }
Ejemplo n.º 16
0
 public void AddAssertion(AssertionExpr assertion, string options)
 {
     if (assertion.Type == AssertionExpr.AssertionType.deadlockfree)
     {
         AssertionBase asrt = createDeadlockAssertion(assertion);
         Spec.AssertionDatabase.Add(assertion.Target + "-deadlockfree", asrt);
     }
     else if (assertion.Type == AssertionExpr.AssertionType.circularfree)
     {
         AssertionBase asrt = createCircularAssertion(assertion);
         Spec.AssertionDatabase.Add(assertion.Target + "-circularfree", asrt);
     }
     else if (assertion.Type == AssertionExpr.AssertionType.bottleneckfree)
     {
         AssertionBase asrt = createBottleneckAssertion(assertion);
         Spec.AssertionDatabase.Add(assertion.Target + "-bottleneckfree", asrt);
     }
     else if (assertion.Type == AssertionExpr.AssertionType.ambiguousinterface)
     {
         AssertionBase asrt = createAmbiguousInterfaceAssertion(assertion);
         Spec.AssertionDatabase.Add(assertion.Target + "-ambiguousinterface", asrt);
     }
     else if (assertion.Type == AssertionExpr.AssertionType.lavaflow)
     {
         AssertionBase asrt = createLavaFlowAssertion(assertion);
         Spec.AssertionDatabase.Add(assertion.Target + "-lavaflow", asrt);
     }
     else if (assertion.Type == AssertionExpr.AssertionType.decomposition)
     {
         AssertionBase asrt = createDecompositionAssertion(assertion);
         Spec.AssertionDatabase.Add(assertion.Target + "-decomposition", asrt);
     }
     else if (assertion.Type == AssertionExpr.AssertionType.poltergeists)
     {
         AssertionBase asrt = createPoltergeistAssertion(assertion);
         Spec.AssertionDatabase.Add(assertion.Target + "-poltergeist", asrt);
     }
     else if (assertion.Type == AssertionExpr.AssertionType.LTL)
     {
         AssertionBase asrt = createLTLAssertion(assertion, options);
         Spec.AssertionDatabase.Add(assertion.Target + " " + assertion.Expression, asrt);
     }
     else if (assertion.Type == AssertionExpr.AssertionType.reachability)
     {
         AssertionBase asrt = createReachability(assertion);
         Spec.AssertionDatabase.Add(assertion.Target + " reaches " + assertion.Expression, asrt);
     }
 }
Ejemplo n.º 17
0
        public List <string> VerifyModel(string model)
        {
            SpecificationBase Spec             = modulebase.ParseSpecification(model, "", "");
            List <string>     RouteDescription = new List <string>();

            try
            {
                AssertionBase assertion = Spec.AssertionDatabase.Values.ElementAt(0);
                assertion.UIInitialize(null, FairnessType.NO_FAIRNESS, false, false, false, true, false, false);
                assertion.InternalStart();

                //if (assertion.VerificationOutput.VerificationResult.Equals(VerificationResultType.INVALID))
                //{
                //    RouteDescription.Add("NoSolution");
                //    return RouteDescription;
                //}
                foreach (ConfigurationBase step in assertion.VerificationOutput.CounterExampleTrace)
                {
                    if (step.Event != "init")
                    {
                        RouteDescription.Add(step.GetDisplayEvent());
                    }
                }
                return(RouteDescription);
            }
            catch (RuntimeException ex)
            {
                System.Console.Out.WriteLine("Runtime exception occurred: " + ex.Message);
                if (ex is OutOfMemoryException)
                {
                    System.Console.Out.WriteLine(
                        "This error suggests your model is too big to be verified. Please make sure all your variables are bounded. You can use domain range values to check it, e.g., \"var x:{1..100}=0;\". Alternatively you can simplify your model by using fewer events, simplier processes, and smaller constants and variables.");
                }
                else
                {
                    System.Console.Out.WriteLine("Check your input model for the possiblity of errors.");
                }
            }
            catch (Exception ex)
            {
                System.Console.Out.WriteLine("Error occurred: " + ex.Message);
            }

            return(null);
        }
Ejemplo n.º 18
0
        //engineIndex 0 for Depth First Search, 1 for Breadth First Search
        private DiagnosisResult RunAssertion(AssertionBase assertion, int fairnessIndex, int engineIndex)
        {
            System.Diagnostics.Debug.WriteLine(assertion);
            // return CreatedAtRoute("GetProduct", new { id = item.Id }, item);
            assertion.UIInitialize(null, fairnessIndex, engineIndex);

            assertion.VerificationMode = true;
            assertion.InternalStart();

            System.Diagnostics.Debug.WriteLine(assertion.GetVerificationStatistics());
            DiagnosisResult result = new DiagnosisResult();

            result.Assertion = assertion.ToString();

            System.Diagnostics.Debug.WriteLine("VALID? " + assertion.VerificationOutput.VerificationResult.Equals(VerificationResultType.VALID));
            string scenarioDesc = "";

            System.Diagnostics.Debug.WriteLine("loop: " + assertion.VerificationOutput.LoopIndex);

            result.MemoryUsage    = assertion.VerificationOutput.EstimateMemoryUsage;
            result.TotalTime      = assertion.VerificationOutput.VerificationTime;
            result.NumberOfStates = assertion.VerificationOutput.NoOfStates;
            result.LoopIndex      = assertion.VerificationOutput.LoopIndex;

            if (assertion.VerificationOutput.VerificationResult.Equals(VerificationResultType.VALID))
            {
                result.IsValid = true;
            }
            else
            {
                result.IsValid = false;
            }
            if (assertion.VerificationOutput.CounterExampleTrace != null)
            {
                foreach (ConfigurationBase step in assertion.VerificationOutput.CounterExampleTrace)
                {
                    scenarioDesc += " " + step.GetDisplayEvent();
                }
                result.Scenario = scenarioDesc;
                System.Diagnostics.Debug.WriteLine(scenarioDesc);
            }

            return(result);
        }
Ejemplo n.º 19
0
        //void TextBox_DataPane_TextChanged(object sender, EventArgs e)
        //{
        //    TextBox_DataPane.Font = new Font(TextBox_DataPane.Font.FontFamily, 8, FontStyle.Regular);
        //    TextBox_DataPane.SelectAll();
        //    TextBox_DataPane.SelectionFont = TextBox_DataPane.Font;
        //    TextBox_DataPane.SelectionStart = 0;
        //    TextBox_DataPane.SelectionLength = 0;
        //}


        protected virtual void Verification_Cancelled(object sender, EventArgs e)
        {
            try
            {
                //cancel the verification
                if (Assertion.VerificationMode)
                {
                    Assertion.Clear();

                    //remove the events
                    Assertion.Action       -= OnAction;
                    Assertion.ReturnResult -= VerificationFinished;
                    Assertion.Cancelled    -= Verification_Cancelled;
                    Assertion.Failed       -= MC_Failed;
                    Assertion = null;

                    StatusLabel_Text.Text = Resources.Verification_Cancelled;

                    //set the verification result to be unknow.
                    //ListView_Assertions.SelectedItems[0].ImageIndex = UNKNOWN_ICON;
                }
                //cancel the result generation
                else
                {
                    TextBox_Output.Text = Assertion.VerificationOutput.ResultString + TextBox_Output.Text;

                    StatusLabel_Text.Text = Resources.Result_Generation_Cancelled;
                }

                //TextBox_Output.Text = StatusLabel_Text.Text + "\r\n\r\n" + TextBox_Output.Text;

                StartVerification(false, false);
            }
            catch (Exception ex)
            {
                Common.Utility.Utilities.LogException(ex, Spec);
            }
        }
Ejemplo n.º 20
0
        protected virtual void ResetUIOptions(ListViewItem item, bool resetUIvalues)
        {
            if (item == null)
            {
                ComboBox_Fairness.SelectedIndex = 0;
                ComboBox_Fairness.Enabled       = false;
                Button_BAGraph.Enabled          = false;

                CheckBox_ShortestTrace.Checked = false;
                CheckBox_ShortestTrace.Enabled = false;

                CheckBox_CheckNonZenoness.Checked = false;
                CheckBox_CheckNonZenoness.Enabled = false;

                Button_SimulateWitnessTrace.Enabled = false;

                Button_Verify.Enabled        = true;
                Label_SelectedAssertion.Text = "";
                return;
            }

            //set text
            Label_SelectedAssertion.Text = item.SubItems[2].Text;
            Assertion = Spec.AssertionDatabase[Label_SelectedAssertion.Text];

            //the select property is an LTL property
            if ((AssertionType)item.Tag == AssertionType.LTL && !CheckBox_CheckNonZenoness.Checked)
            {
                SetFairnessChoices(Assertion.IsProcessLevelFairnessApplicable, resetUIvalues);
            }
            else
            {
                ComboBox_Fairness.SelectedIndex = 0;
                ComboBox_Fairness.Enabled       = false;
            }

            if ((AssertionType)item.Tag == AssertionType.LTL || (AssertionType)item.Tag == AssertionType.LTLSafety)
            {
                Button_BAGraph.Enabled = true;
            }
            else
            {
                Button_BAGraph.Enabled = false;
            }


            //if it is deadlock and reachability
            if ((AssertionType)item.Tag == AssertionType.LTL) //|| (AssertionType)item.Tag == AssertionType.Reachability || (AssertionType)item.Tag == AssertionType.LTLSafety
            {
                CheckBox_ShortestTrace.Checked = false;
                CheckBox_ShortestTrace.Enabled = false;
            }
            else
            {
                CheckBox_ShortestTrace.Enabled = true;
            }


            if ((AssertionType)item.Tag == AssertionType.LTL || (AssertionType)item.Tag == AssertionType.LTLSafety || (AssertionType)item.Tag == AssertionType.Deadlock)
            {
                CheckBox_CheckNonZenoness.Enabled = true;
            }
            else
            {
                CheckBox_CheckNonZenoness.Checked = false;
                CheckBox_CheckNonZenoness.Enabled = false;
            }



            //verification result handling.
            //if ((Assertion.VerificationResult == VerificationResultType.INVALID && Assertion.AssertionType != AssertionType.Reachability) || (Assertion.AssertionType == AssertionType.Reachability && Assertion.VerificationResult == VerificationResultType.VALID))
            if (Assertion.VerificationOutput != null && Assertion.VerificationOutput.CounterExampleTrace != null && Assertion.VerificationOutput.CounterExampleTrace.Count > 0)
            {
                Button_SimulateWitnessTrace.Enabled = true;
                Button_SimulateWitnessTrace.Tag     = Assertion.StartingProcess.ToString().Replace("()", "");
            }
            else
            {
                Button_SimulateWitnessTrace.Enabled = false;
            }


            Button_Verify.Enabled = true;
        }
Ejemplo n.º 21
0
 public void updateLatexResult(AssertionBase assertion)
 {
     mLatexWorker.Update(assertion);
 }
Ejemplo n.º 22
0
        private List <DiagnosisResult> executeVerification(List <ArchMatrix> matrix)
        {
            VerifyAsset verifyAsset = GenerateAsset(matrix);


            System.Diagnostics.Debug.WriteLine(verifyAsset.CSPCode);

            try
            {
                PAT.CSP.ModuleFacade modulebase = new PAT.CSP.ModuleFacade();

                SpecificationBase Spec = modulebase.ParseSpecification(verifyAsset.CSPCode, string.Empty, string.Empty);
                System.Diagnostics.Debug.WriteLine("Specification Loaded...");

                //print assertion for debugging
                List <KeyValuePair <string, AssertionBase> > asrtlists = Spec.AssertionDatabase.ToList();
                foreach (KeyValuePair <string, AssertionBase> asrt in asrtlists)
                {
                    System.Diagnostics.Debug.WriteLine("#" + asrt.Key + "#");
                }

                List <DiagnosisResult> diagnosisList = new List <DiagnosisResult>();

                // Verify deadlock loop
                bool deadlockFound = false;

                for (var i = 0; i < verifyAsset.deadloopCheck.Count; i++)
                {
                    AssertionBase   assertion = Spec.AssertionDatabase[verifyAsset.deadloopCheck[i]];
                    DiagnosisResult result    = RunAssertion(assertion, 1, 0);

                    if (!result.IsValid && result.Scenario != null && result.LoopIndex > -1)
                    {
                        deadlockFound  = true;
                        result.Symptom = "deadloop";
                        diagnosisList.Add(result);
                    }
                }

                // Verify livelock, if deadlock is not found

                if (!deadlockFound)
                {
                    bool   livelockFound              = false;
                    string prevScenario               = null;
                    bool   isAllSameScenario          = true;
                    List <DiagnosisResult> normalList = new List <DiagnosisResult>();
                    for (var i = 0; i < verifyAsset.livelockCheck.Count; i++)
                    {
                        AssertionBase   assertion = Spec.AssertionDatabase[verifyAsset.livelockCheck[i]];
                        DiagnosisResult result    = RunAssertion(assertion, 0, 0);

                        if (!result.IsValid && result.Scenario != null && hasDuplilcateInvoke(result.Scenario))
                        {
                            if (result.LoopIndex > -1)
                            {
                                result.Symptom = "deadloop";
                            }
                            else
                            {
                                result.Symptom = "livelock";
                            }
                            diagnosisList.Add(result);
                            livelockFound = true;
                        }
                        else if (!result.IsValid && result.Scenario != null)
                        {
                            result.Symptom = "normal";
                            normalList.Add(result);
                            if (prevScenario != null && !prevScenario.Equals(result.Scenario))
                            {
                                isAllSameScenario = false;
                            }
                        }
                        prevScenario = result.Scenario;
                        System.Diagnostics.Debug.WriteLine("prevScenario : " + prevScenario);
                    }

                    // in case normal and all same scenario, try to generate more simulation for normal case
                    if (!livelockFound)
                    {
                        diagnosisList.AddRange(normalList);
                        if (isAllSameScenario)
                        {
                            diagnosisList.AddRange(normalList);
                            string firstId = prevScenario.Substring(prevScenario.IndexOf(".") + 1, 3);
                            string lastId  = prevScenario.Substring(prevScenario.LastIndexOf(".") + 1);
                            System.Diagnostics.Debug.WriteLine("firstId : " + firstId);
                            System.Diagnostics.Debug.WriteLine("lastId : " + lastId);
                            verifyAsset = InsertMoreLivelockCheck(verifyAsset, matrix, firstId, lastId);
                            Spec        = modulebase.ParseSpecification(verifyAsset.CSPCode, string.Empty, string.Empty);
                            asrtlists   = Spec.AssertionDatabase.ToList();
                            foreach (KeyValuePair <string, AssertionBase> asrt in asrtlists)
                            {
                                System.Diagnostics.Debug.WriteLine("#" + asrt.Key + "#");
                            }
                            for (var i = 0; i < verifyAsset.livelockCheck.Count; i++)
                            {
                                AssertionBase   assertion = Spec.AssertionDatabase[verifyAsset.livelockCheck[i]];
                                DiagnosisResult result    = RunAssertion(assertion, 0, 0);
                                if (!result.IsValid && result.Scenario != null)
                                {
                                    result.Symptom = "normal";
                                    diagnosisList.Add(result);
                                }
                            }
                        }
                    }
                }
                List <DiagnosisResult> rs = checkLivelockBetweenResult(diagnosisList);
                if (rs.Count != 0)
                {
                    diagnosisList = rs;
                }
                return(diagnosisList);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.TraceError(ex.Message);
                System.Diagnostics.Trace.TraceError(ex.StackTrace);
            }
            return(null);
        }
Ejemplo n.º 23
0
 public AssertionVerifier(AssertionBase assertion, int fairnessIndex, int engineIndex)
 {
     this.assertion     = assertion;
     this.fairnessIndex = fairnessIndex;
     this.engineIndex   = engineIndex;
 }
Ejemplo n.º 24
0
        private void StartVerification(ListViewItem item)
        {
            if (!ModuleSpecificCheckPassed())
            {
                return;
            }

            if (!Spec.GrabSharedDataLock())
            {
                MessageBox.Show(Resources.Please_wait_for_the_simulation_or_parsing_finished_before_verification, Common.Ultility.Ultility.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            DisableAllControls();


            try
            {
                Spec.LockSharedData(false);

                StatusLabel_Text.Text = Resources.ModelCheckingForm_StartVerification_Verification_Starts;

                //these data will not change for SpecProcess.SharedData, so once it is created after parsing, there is no need to set them again.
                //SpecProcess.SharedData.VariableLowerBound = Valuation.VariableLowerBound;
                //SpecProcess.SharedData.VariableUpperLowerBound = Valuation.VariableUpperLowerBound;
                //SpecProcess.SharedData.AlphaDatabase = Specification.AlphaDatabase;
                //SpecProcess.SharedData.HasSyncrhonousChannel = Specification.HasSyncrhonousChannel;
                //SpecProcess.SharedData.SyncrhonousChannelNames = Specification.SyncrhonousChannelNames;


                //SpecProcess.SharedData.FairnessType = AssertionBase.FairnessType;
                //SpecProcess.SharedData.CalculateParticipatingProcess = AssertionBase.FairnessType == FairnessType.PROCESS_LEVEL_WEAK_FAIRNESS || AssertionBase.FairnessType == FairnessType.PROCESS_LEVEL_STRONG_FAIRNESS || Assertion.MustAbstract;
                //SpecProcess.SharedData.CalculateCreatedProcess = Assertion.MustAbstract;
                //SpecProcess.SharedData.DataManager = DataStore.DataManager;


                item.ImageIndex = UNKNOWN_ICON;

                Assertion = Spec.AssertionDatabase[item.SubItems[2].Text];
                Assertion.UIInitialize(this, Fairness, this.CheckBox_PartialOrderReduction.Checked, this.CheckBox_Verbose.Checked, this.CheckBox_Parallel.Checked, this.ShortestPath, this.CheckBox_BDD.Checked, this.CheckBox_CheckNonZenoness.Checked, GetParameters());


                Assertion.Action       += OnAction;
                Assertion.ReturnResult += VerificationFinished;
                Assertion.Cancelled    += Verification_Cancelled;
                Assertion.Failed       += MC_Failed;

                seconds           = 1;
                ProgressBar.Value = 0;
                //timer.Reset();
                //startMemroySize = GC.GetTotalMemory(true);
                MCTimer.Start();
                //timer.Start();
                Assertion.Start();
            }
            catch (RuntimeException e)
            {
                Common.Ultility.Ultility.LogRuntimeException(e);
                this.Close();
                return;
            }
            catch (Exception ex)
            {
                //TextBox_Output.Text += ex.Message + "\r\n" + ex.StackTrace;
                //EnableAllControls();
                Common.Ultility.Ultility.LogException(ex, Spec);
                this.Close();
                return;
            }
        }
Ejemplo n.º 25
0
        protected virtual void ResetUIOptions(ListViewItem item, bool resetUIvalues)
        {
            if (item == null)
            {
                ComboBox_AdmissibleBehavior.Items.Clear();
                ComboBox_AdmissibleBehavior.Enabled = false;

                ComboBox_VerificationEngine.Items.Clear();
                ComboBox_VerificationEngine.Enabled = false;

                Button_BAGraph.Enabled = false;


                Button_SimulateWitnessTrace.Enabled = false;

                Button_Verify.Enabled        = true;
                Label_SelectedAssertion.Text = "";
                return;
            }

            //set text
            Label_SelectedAssertion.Text = item.SubItems[2].Text;
            Assertion = Spec.AssertionDatabase[Label_SelectedAssertion.Text];

            if ((string)item.Tag == "LTL")
            {
                Button_BAGraph.Enabled = true;
            }
            else
            {
                Button_BAGraph.Enabled = false;
            }

            ComboBox_AdmissibleBehavior.Enabled = true;
            ComboBox_VerificationEngine.Enabled = true;

            Button_Verify.Enabled = true;

            if (resetUIvalues)
            {
                //System.Diagnostics.Debug.Assert(Assertion.ModelCheckingOptions.AddimissibleBehaviorsNames.Count > 0);
                ComboBox_AdmissibleBehavior.Items.Clear();

                if (Assertion.ModelCheckingOptions.AddimissibleBehaviorsNames.Count > 0)
                {
                    ComboBox_AdmissibleBehavior.Items.AddRange(Assertion.ModelCheckingOptions.AddimissibleBehaviorsNames.ToArray());
                    ComboBox_AdmissibleBehavior.SelectedIndex = 0;
                }
                else
                {
                    Button_Verify.Enabled = false;
                }
            }

            //ComboBox_VerificationEngine.Items.AddRange(Assertion.ModelCheckingOptions.AddimissibleBehaviors[0].VerificationEngines.ToArray());
            //ComboBox_VerificationEngine.SelectedIndex = 0;


            //verification result handling.
            if (Assertion.VerificationOutput != null && Assertion.VerificationOutput.CounterExampleTrace != null && Assertion.VerificationOutput.CounterExampleTrace.Count > 0)
            {
                Button_SimulateWitnessTrace.Enabled = true;
                Button_SimulateWitnessTrace.Tag     = Assertion.StartingProcess.ToString().Replace("()", "");
            }
            else
            {
                Button_SimulateWitnessTrace.Enabled = false;
            }
        }
Ejemplo n.º 26
0
        private void StartVerification(bool completed, bool correct)
        {
            FlushString();
            MCTimer.Stop();


            if (AssertionIndex == 0)
            {
                if (completed && FileIndex > 0)
                {
                    if (correct)
                    {
                        ListView_Assertions.Items[FileIndex - 1].ImageIndex = CORRECT_ICON;
                    }
                    else
                    {
                        ListView_Assertions.Items[FileIndex - 1].ImageIndex = WRONG_ICON;
                    }
                }

                if (FileIndex < ListView_Assertions.Items.Count)
                {
                    try
                    {
                        string file = ListView_Assertions.Items[FileIndex].SubItems[2].Text;
                        FileIndex++;

                        this.OutputWriter.WriteLine("*******************************************************");
                        this.OutputWriter.WriteLine("*" + file);
                        this.OutputWriter.WriteLine("**************************START************************");
                        StatusLabel_Text.Text = Resources.Checking_file_ + file;

                        StreamReader tr         = new StreamReader(file);
                        string       specString = tr.ReadToEnd();
                        tr.Close();

                        if (Spec != null)
                        {
                            Spec.UnLockSharedData();
                        }

                        string           modulefolder = Common.Utility.Utilities.ModuleFolderNames[this.ComboBox_Modules.SelectedIndex];
                        ModuleFacadeBase modulebase   = Common.Utility.Utilities.LoadModule(modulefolder);
                        Spec = modulebase.ParseSpecification(specString, "", file);

                        if (Spec != null)
                        {
                            Assertions = new List <string>(Spec.AssertionDatabase.Keys);
                        }
                        else
                        {
                            throw new Exception("ERROR Spec!");
                        }
                    }
                    catch (Exception ex)
                    {
                        if (FileIndex > 0)
                        {
                            ListView_Assertions.Items[FileIndex - 1].ImageIndex = WRONG_ICON;
                        }
                        this.OutputWriter.WriteLine("Error occurred: " + ex.Message + "\r\n" + ex.StackTrace);
                        StartVerification(false, false);
                    }
                }
                else
                {
                    EnableAllControls();
                    return;
                }
            }


            try
            {
                if (Assertions.Count > 0)
                {
                    OutputWriter.WriteLine("=======================================================");
                    OutputWriter.WriteLine("Assertion: " + Assertions[AssertionIndex]);
                    StatusLabel_Text.Text = Resources.Verifying_Assertion__ + Assertions[AssertionIndex];
                    FlushString();

                    Assertion = Spec.AssertionDatabase[Assertions[AssertionIndex]];
                    AssertionIndex++;
                    AssertionIndex = AssertionIndex % Assertions.Count;

                    //Assertion.UIInitialize(this, Fairness, this.CheckBox_PartialOrderReduction.Checked, this.CheckBox_Verbose.Checked, this.CheckBox_Parallel.Checked, this.ShortestPath, this.CheckBox_BDD.Checked, this.CheckBox_CheckNonZenoness.Checked, GetParameters());

                    Assertion.UIInitialize(this, (int)NUD_AdmissibleBehavior.Value, (int)NUD_VerificationEngine.Value);
                    Assertion.VerificationOutput.GenerateCounterExample = CheckBox_GenerateCounterexample.Checked;

                    Assertion.Action       += OnAction;
                    Assertion.ReturnResult += VerificationFinished;
                    Assertion.Cancelled    += Verification_Cancelled;
                    Assertion.Failed       += MC_Failed;

                    seconds           = 1;
                    ProgressBar.Value = 0;
                    //timer.Reset();
                    //startMemroySize = GC.GetTotalMemory(true);
                    MCTimer.Start();
                    //timer.Start();
                    Assertion.Start();
                }
                else
                {
                    StartVerification(true, true);
                }
            }
            catch (RuntimeException e)
            {
                EnableAllControls();
                Common.Utility.Utilities.LogRuntimeException(e);
                this.Close();
                return;
            }
            catch (Exception ex)
            {
                EnableAllControls();
                Common.Utility.Utilities.LogException(ex, Spec);
                this.Close();
                return;
            }
        }
Ejemplo n.º 27
0
        internal void Update(AssertionBase assertion)
        {
            // 2015-11-21-thu-update latex
            AssertType assertType = AssertType.NONE;
            string     non = "deadlockfree", channel = "_";
            string     assertion_text = assertion.ToString();

            if (assertion_text.Contains(non))
            {
                assertType = AssertType.DEADLOCK_FREE;
            }
            else if (assertion_text.Contains(channel))
            {
                assertType = AssertType.CONGESTION_CHANNEL;
            }
            else
            {
                assertType = AssertType.CONGESTION_SENSOR;
            }

            string result      = assertion.getResult();
            string resultlatex = "";

            // Get result of assersion
            do
            {
                if (assertType.Equals(AssertType.DEADLOCK_FREE))
                {
                    if (result.Equals("VALID"))
                    {
                        resultlatex = "\\vl";
                    }
                    else if (result.Equals("INVALID"))
                    {
                        resultlatex = "\\nv";
                    }
                    else
                    {
                        resultlatex = "\\unk";
                    }
                    break;
                }

                if (result.Equals("VALID"))
                {
                    resultlatex = "\\nv";
                }
                else if (result.Equals("INVALID"))
                {
                    resultlatex = "\\vl";
                }
                else
                {
                    resultlatex = "\\unk";
                }
            } while (false);

            // Mapping record to variable
            do
            {
                int posType = -1;
                if (assertType.Equals(AssertType.DEADLOCK_FREE))
                {
                    posType = 0;
                }
                else if (assertType.Equals(AssertType.CONGESTION_CHANNEL))
                {
                    posType = 1;
                }
                else if (assertType.Equals(AssertType.CONGESTION_SENSOR))
                {
                    posType = 2;
                }

                if (posType < 0)
                {
                    break;
                }

                mParseRes[posType].mTime       = assertion.getTimes();
                mParseRes[posType].mMemo       = (float)assertion.getMems();
                mParseRes[posType].mTransition = assertion.getTransitions();
                mParseRes[posType].mState      = assertion.getStates();
                mParseRes[posType].mClicked    = true;
                mParseRes[posType].mRes        = resultlatex;
            } while (false);
        }