Пример #1
0
        private List<ConfigurationBase> MakeOneMove(ConfigurationBase currentStep)
        {
            List<ConfigurationBase> listResult = new List<ConfigurationBase>();
            IEnumerable<ConfigurationBase> list = currentStep.MakeOneMove();

            foreach (ConfigurationBase step in list)
            {
                bool contains = false;
                foreach (ConfigurationBase dest in listResult)
                {
                    if (dest.Event == step.Event)
                    {
                        contains = true;
                        break;
                    }
                }

                //duplicated steps should not be added in.
                if (!contains)
                {
                    listResult.Add(step);
                }
            }

            return listResult;
        }
Пример #2
0
        /// <summary>
        /// This method checks whether the found counterexample is spurious or not.
        /// This checking only works for abstraction for parameterized systems.
        /// </summary>
        /// <returns></returns>
        protected virtual bool IsCounterExampleSpurious()
        {
            Stack <ConfigurationBase> working = new Stack <ConfigurationBase>(1024);
            List <ConfigurationBase>  ConcreteCounterExampleTrace = new List <ConfigurationBase>(64);

            working.Push(InitialStep);
            Stack <int> depthStack = new Stack <int>(1024);

            depthStack.Push(0);
            List <int>      depthList = new List <int>(1024);
            StringHashTable visited   = new StringHashTable(1024);

            visited.Add("0-" + InitialStep.GetID());

            do
            {
                ConfigurationBase current = working.Pop();
                int depth = depthStack.Pop();

                if (depth > 0)
                {
                    while (depthList[depthList.Count - 1] >= depth)
                    {
                        int lastIndex = depthList.Count - 1;
                        depthList.RemoveAt(lastIndex);
                        ConcreteCounterExampleTrace.RemoveAt(lastIndex);
                    }
                }

                ConcreteCounterExampleTrace.Add(current);
                depthList.Add(depth);

                if (ConcreteCounterExampleTrace.Count == VerificationOutput.CounterExampleTrace.Count)
                {
                    VerificationOutput.CounterExampleTrace = ConcreteCounterExampleTrace;
                    Ultility.Ultility.CutNumber            = 2;
                    return(false);
                }
                else
                {
                    ConfigurationBase abstractStep = VerificationOutput.CounterExampleTrace[depth + 1];

                    IEnumerable <ConfigurationBase> steps = current.MakeOneMove(abstractStep.Event);
                    //for (int j = 0; j < steps.Length; j++)
                    foreach (ConfigurationBase step in steps)
                    {
                        if (abstractStep.EqualsV(step))
                        {
                            string tmp = (depth + 1) + "-" + step.GetID();
                            if (!visited.ContainsKey(tmp))
                            {
                                working.Push(step);
                                depthStack.Push(depth + 1);
                                visited.Add(tmp);
                            }
                        }
                    }
                }
            } while (working.Count > 0);

            return(true);
        }
Пример #3
0
        public bool IsDivergent()
        {
            Stack <ConfigurationBase> working = new Stack <ConfigurationBase>();
            List <string>             path    = new List <string>(100);
            StringHashTable           visited = new StringHashTable(100);

            //The following are for identifying the current path.
            Stack <int> depthStack = new Stack <int>(1024);

            depthStack.Push(0);
            List <int> depthList = new List <int>(1024);

            //The above are for identifying the current path.

            working.Push(this);
            visited.Add(GetID());

            while (working.Count > 0)
            {
                ConfigurationBase current = working.Pop();
                IEnumerable <ConfigurationBase> nextStates = current.MakeOneMove(Constants.TAU);

                //The following are for identifying the current path.
                int depth = depthStack.Pop();

                if (depth > 0)
                {
                    while (depthList[depthList.Count - 1] >= depth)
                    {
                        int lastIndex = depthList.Count - 1;
                        depthList.RemoveAt(lastIndex);
                        path.RemoveAt(lastIndex);
                    }
                }

                path.Add(current.GetID());
                depthList.Add(depth);

                if (nextStates != null)
                {
                    //for (int i = 0; i < nextStates.Length; i++)
                    foreach (ConfigurationBase next in nextStates)
                    {
                        //ConfigurationBase next = nextStates[i];
                        string ID = next.GetID();
                        if (path.Contains(ID))
                        {
                            return(true);
                        }
                        else
                        {
                            if (!visited.ContainsKey(ID))
                            {
                                visited.Add(ID);
                                working.Push(next);
                                depthStack.Push(depth + 1);
                            }
                        }
                    }
                }
            }

            return(false);
        }