Beispiel #1
0
        private void GenerateDRAGraph(bool isRabin)
        {
            try
            {
                EnableDisableUI(false);

                string ltl = TextBox_Prop.Text;
                if (!isRabin)
                {
                    ltl = "! " + ltl;
                }
                BuchiAutomata BA          = LTL2BA.FormulaToBA(ltl, options, new CommonToken(0, ""));
                ltl2ba.Node   LTLHeadNode = LTL2BA.ParseLTL(ltl, options, new CommonToken(0, ""));

                timer.Reset();
                timer.Start();
                bool islive = LivenessChecking.isLiveness(BA);
                timer.Stop();

                this.Label_IsSafety.Tag = timer.Elapsed.TotalSeconds;

                if (!islive)
                {
                    //this.Label_IsSafety.Text = "The formula is a safety property (checked in " + timer.Elapsed.TotalSeconds + "s).";
                    this.Label_IsSafety.Text = string.Format(Resources.The_formula_is_a_safety_property__checked_in__0__s__, timer.Elapsed.TotalSeconds);
                }
                timer.Reset();
                timer.Start();
                DRA dra = BA2DRAConverter.ConvertBA2DRA(BA, LTLHeadNode);
                timer.Stop();

                gViewer.Graph    = dra.AutomatonToDot();
                gViewer.AutoSize = true;

                this.StatusLabel_Status.Tag = timer.Elapsed.TotalSeconds;

                if (isRabin)
                {
                    this.StatusLabel_Status.Text = string.Format(Resources.Rabin_Automata_Generated_with__0__Nodes__1__Edges__checked_in__2_s__, (gViewer.Graph.NodeCount - 1), (gViewer.Graph.EdgeCount - 1), timer.Elapsed.TotalSeconds);
                }
                else
                {
                    this.StatusLabel_Status.Text = string.Format(Resources.Streett_Automata_Generated_with__0__Nodes__1__Edges__checked_in__2_s__, (gViewer.Graph.NodeCount - 1), (gViewer.Graph.EdgeCount - 1), timer.Elapsed.TotalSeconds);
                }
                StatusLabel_Accept.Visible = false;

                if (this.TextBox_Prop.Items.Contains(TextBox_Prop.Text))
                {
                    this.TextBox_Prop.Items.Add(TextBox_Prop.Text);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Resources.The_input_LTL_is_not_correct__ + ex.Message, PAT.Common.Ultility.Ultility.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            EnableDisableUI(true);
        }
        public Graph GenerateBAGraph(string assert)
        {
            if (AssertionDatabase.ContainsKey(assert))
            {
                AssertionLTL ass = AssertionDatabase[assert] as AssertionLTL;
                if (ass != null)
                {
                    Graph g = LTL2BA.AutomatonToDot(ass.BA);
                    g.UserData = "!(" + ass.LTLString + ")";
                    return(g);
                }
            }

            return(null);
        }
Beispiel #3
0
        private void Button_Generate_Click(object sender, System.EventArgs e)
        {
            try
            {
                EnableDisableUI(false);
                timer.Reset();
                timer.Start();
                BuchiAutomata BA = LTL2BA.FormulaToBA(TextBox_Prop.Text, options, new CommonToken(0, ""));
                timer.Stop();

                gViewer.Graph    = LTL2BA.AutomatonToDot(BA);
                gViewer.AutoSize = true;

                //this.StatusLabel_Status.Text = "Büchi Automata Generated with " + (gViewer.Graph.NodeCount - 1) + " Nodes " + (gViewer.Graph.EdgeCount - 1) + " Edges (checked in " + timer.Elapsed.TotalSeconds + "s).";
                this.StatusLabel_Status.Text = string.Format(Resources.Büchi_Automata_Generated_with__0__Nodes__1__Edges__checked_in__2__s__, (gViewer.Graph.NodeCount - 1), (gViewer.Graph.EdgeCount - 1), timer.Elapsed.TotalSeconds);
                this.StatusLabel_Status.Tag  = timer.Elapsed.TotalSeconds;


                timer.Reset();
                timer.Start();
                bool islive = LivenessChecking.isLiveness(BA);
                timer.Stop();

                this.Label_IsSafety.Tag = timer.Elapsed.TotalSeconds;

                if (!islive)
                {
                    this.Label_IsSafety.Text = string.Format(Resources.The_formula_is_a_safety_property__checked_in__0__s__, timer.Elapsed.TotalSeconds);
                }

                if (this.TextBox_Prop.Items.Contains(TextBox_Prop.Text))
                {
                    this.TextBox_Prop.Items.Add(TextBox_Prop.Text);
                }

                StatusLabel_Accept.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(Resources.The_input_LTL_is_not_correct__ + ex.Message, PAT.Common.Ultility.Ultility.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            EnableDisableUI(true);
        }
Beispiel #4
0
        private AssertionBase createLTLAssertion(AssertionExpr assertion, string options)
        {
            Spec.ExecProcessDatabase.TryGetValue(assertion.Target, out DefinitionRef execProc);
            ADLAssertionLTL assertLTL = null;

            if (execProc != null)
            {
                String ltl = assertion.Expression.Trim();
                // Update LTL state
                if (ltl.IndexOf(".") != -1)
                {
                    ltl = ltl.Replace('.', '_');
                }


                // create ADLAssertionLTL
                assertLTL = new ADLAssertionLTL(execProc, ltl);
                BuchiAutomata PositiveBA = LTL2BA.FormulaToBA(ltl, options, null);
                // default to false for x operator U X V T F R  NOT SUPPORTED for now
                bool hasXoperator = false;
                PositiveBA.HasXOperator = hasXoperator;
                if (!LivenessChecking.isLiveness(PositiveBA))
                {
                    assertLTL.SeteBAs(null, PositiveBA);
                }
                else
                {
                    BuchiAutomata BA = LTL2BA.FormulaToBA("!(" + ltl + ")", options, null); //.Replace(".", Ultility.Ultility.DOT_PREFIX)
                    BA.HasXOperator = hasXoperator;
                    assertLTL.SeteBAs(BA, PositiveBA);
                }
            }
            else
            {
                throw new Exception("Unknown target process for assertion");
            }

            return(assertLTL);
        }