Пример #1
0
        public void FailuresInclusionCheckBFS(DeterministicAutomata spec)
        {
            StringHashTable                   Visited     = new StringHashTable(Ultility.Ultility.MC_INITIAL_SIZE);
            Queue <ConfigurationBase>         pendingImpl = new Queue <ConfigurationBase>(1000);
            Queue <DeterministicFAState>      pendingSpec = new Queue <DeterministicFAState>(1000);
            Queue <List <ConfigurationBase> > paths       = new Queue <List <ConfigurationBase> >(1024);

            //implementation initial state
            pendingImpl.Enqueue(InitialStep);

            //specification initial state
            pendingSpec.Enqueue(spec.InitialState);

            string statestring = InitialStep.GetID() + Constants.SEPARATOR + spec.InitialState.GetID();

            Visited.Add(statestring);

            List <ConfigurationBase> path = new List <ConfigurationBase>();

            path.Add(InitialStep);
            paths.Enqueue(path);

            while (pendingImpl.Count > 0)
            {
                if (CancelRequested)
                {
                    VerificationOutput.NoOfStates = Visited.Count;
                    return;
                }

                ConfigurationBase        currentImpl = pendingImpl.Dequeue();
                DeterministicFAState     currentSpec = pendingSpec.Dequeue();
                List <ConfigurationBase> currentPath = paths.Dequeue();

                IEnumerable <ConfigurationBase> nextImpl = currentImpl.MakeOneMove();
                VerificationOutput.Transitions += nextImpl.Count();
                List <string> negatedRefusal = new List <string>();
                bool          hasTau         = false;

                //for (int k = 0; k < nextImpl.Length; k++)
                foreach (ConfigurationBase next in nextImpl)
                {
                    //ConfigurationBase next = nextImpl[k];

                    DeterministicFAState nextSpec = currentSpec;
                    if (next.Event != Constants.TAU)
                    {
                        negatedRefusal.Add(next.Event);
                        //nextSpec = currentSpec.Post[next.Event];
                        nextSpec = currentSpec.Next(next.Event);

                        if (nextSpec == null)
                        {
                            currentPath.Add(next);
                            VerificationOutput.NoOfStates          = Visited.Count;
                            VerificationOutput.CounterExampleTrace = currentPath;
                            VerificationOutput.VerificationResult  = VerificationResultType.INVALID;
                            FailureType = RefinementCheckingResultType.TraceRefinementFailure;
                            return;
                        }
                    }
                    else
                    {
                        hasTau = true;
                    }

                    statestring = next.GetID() + Constants.SEPARATOR + nextSpec.GetID();

                    if (!Visited.ContainsKey(statestring))
                    {
                        Visited.Add(statestring);
                        pendingImpl.Enqueue(next);
                        pendingSpec.Enqueue(nextSpec);
                        List <ConfigurationBase> newPath = new List <ConfigurationBase>(currentPath);
                        newPath.Add(next);
                        paths.Enqueue(newPath);
                    }
                }

                //if the implememtation state is stable, then check for failures inclusion
                if (!hasTau)
                {
                    //enabledS is empty if and only if the spec state is divergent.
                    if (!RefusalContainment(negatedRefusal, currentSpec.NegatedRefusals))
                    {
                        //return toReturn;
                        VerificationOutput.NoOfStates          = Visited.Count;
                        VerificationOutput.CounterExampleTrace = currentPath;
                        VerificationOutput.VerificationResult  = VerificationResultType.INVALID;
                        FailureType = RefinementCheckingResultType.FailuresRefinementFailure;
                        return;
                    }
                }
            }

            VerificationOutput.NoOfStates         = Visited.Count;
            VerificationOutput.VerificationResult = VerificationResultType.VALID;
            FailureType = RefinementCheckingResultType.Valid;
        }
Пример #2
0
        private void FailuresInclusionCheckBFSAntiChain(Automata spec)
        {
            Queue <ConfigurationBase>         pendingImpl = new Queue <ConfigurationBase>(1000);
            Queue <NormalizedFAState>         pendingSpec = new Queue <NormalizedFAState>(1000);
            Queue <List <ConfigurationBase> > paths       = new Queue <List <ConfigurationBase> >(1024);

            NormalizedFAState initialSpec = (new NormalizedFAState(spec.InitialState)).TauReachable();

            //implementation initial state
            pendingImpl.Enqueue(InitialStep);

            //specification initial state
            pendingSpec.Enqueue(initialSpec);

            List <ConfigurationBase> path = new List <ConfigurationBase>();

            path.Add(InitialStep);
            paths.Enqueue(path);

            AntiChain antichain = new AntiChain();

            antichain.Add(InitialStep.GetID(), initialSpec.States);

            while (pendingImpl.Count > 0)
            {
                if (CancelRequested)
                {
                    VerificationOutput.NoOfStates = antichain.GetNoOfStates();
                    return;
                }

                ConfigurationBase        currentImpl = pendingImpl.Dequeue();
                NormalizedFAState        currentSpec = pendingSpec.Dequeue();
                List <ConfigurationBase> currentPath = paths.Dequeue();

                IEnumerable <ConfigurationBase> nextImpl = currentImpl.MakeOneMove();
                VerificationOutput.Transitions += nextImpl.Count();
                List <string> negatedRefusal = new List <string>();
                bool          hasTau         = false;

                //for (int k = 0; k < nextImpl.Length; k++)
                foreach (ConfigurationBase next in nextImpl)
                {
                    //ConfigurationBase next = nextImpl[k];

                    NormalizedFAState nextSpec = currentSpec;
                    if (next.Event != Constants.TAU)
                    {
                        negatedRefusal.Add(next.Event);
                        nextSpec = currentSpec.NextWithTauReachable(next.Event);

                        if (nextSpec.States.Count == 0)
                        {
                            currentPath.Add(next);
                            VerificationOutput.NoOfStates          = antichain.GetNoOfStates();
                            VerificationOutput.CounterExampleTrace = currentPath;
                            VerificationOutput.VerificationResult  = VerificationResultType.INVALID;
                            FailureType = RefinementCheckingResultType.TraceRefinementFailure;
                            return;
                        }
                    }
                    else
                    {
                        hasTau = true;
                    }


                    if (!antichain.Add(next.GetID(), nextSpec.States))
                    {
                        pendingImpl.Enqueue(next);
                        pendingSpec.Enqueue(nextSpec);
                        List <ConfigurationBase> newPath = new List <ConfigurationBase>(currentPath);
                        newPath.Add(next);
                        paths.Enqueue(newPath);
                    }
                }

                //if the implememtation state is stable, then check for failures inclusion
                if (!hasTau)
                {
                    //enabledS is empty if and only if the spec state is divergent.
                    if (!RefusalContainment(negatedRefusal, currentSpec.GetFailuresNegate()))
                    {
                        //return toReturn;
                        VerificationOutput.NoOfStates          = antichain.GetNoOfStates();
                        VerificationOutput.CounterExampleTrace = currentPath;
                        VerificationOutput.VerificationResult  = VerificationResultType.INVALID;
                        FailureType = RefinementCheckingResultType.FailuresRefinementFailure;
                        return;
                    }
                }
            }

            VerificationOutput.NoOfStates         = antichain.GetNoOfStates();
            VerificationOutput.VerificationResult = VerificationResultType.VALID;
            FailureType = RefinementCheckingResultType.Valid;
        }
Пример #3
0
        public void FailuresInclusionCheckDFS(DeterministicAutomata spec)
        {
            StringHashTable              Visited     = new StringHashTable(Ultility.Ultility.MC_INITIAL_SIZE);
            Stack <ConfigurationBase>    pendingImpl = new Stack <ConfigurationBase>(1000);
            Stack <DeterministicFAState> pendingSpec = new Stack <DeterministicFAState>(1000);
            List <ConfigurationBase>     toReturn    = new List <ConfigurationBase>();

            //The following are for identifying a counterexample trace.
            Stack <int> depthStack = new Stack <int>(1000);

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

            //The above are for identifying a counterexample trace.

            //implementation initial state
            pendingImpl.Push(InitialStep);

            //specification initial state
            pendingSpec.Push(spec.InitialState);

            string statestring = InitialStep.GetID() + Constants.SEPARATOR + spec.InitialState.GetID();

            Visited.Add(statestring);

            while (pendingImpl.Count > 0)
            {
                if (CancelRequested)
                {
                    VerificationOutput.NoOfStates = Visited.Count;
                    return;
                }

                ConfigurationBase    currentImpl = pendingImpl.Pop();
                DeterministicFAState currentSpec = pendingSpec.Pop();

                //The following are for identifying a counterexample trace.
                int depth = depthStack.Pop();

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

                toReturn.Add(currentImpl);
                depthList.Add(depth);
                //The above are for identifying a counterexample trace.

                //if the implememtation state is stable, then check for failures inclusion
                IEnumerable <ConfigurationBase> nextImpl = currentImpl.MakeOneMove();
                VerificationOutput.Transitions += nextImpl.Count();
                List <string> negatedRefusal = new List <string>();
                bool          hasTau         = false;

                //for (int k = 0; k < nextImpl.Length; k++)
                foreach (ConfigurationBase next in nextImpl)
                {
                    //ConfigurationBase next = nextImpl[k];

                    DeterministicFAState nextSpec = currentSpec;

                    if (next.Event != Constants.TAU)
                    {
                        negatedRefusal.Add(next.Event);
                        nextSpec = currentSpec.Next(next.Event);
                        //If the specification has no corresponding state, then it implies that the trace is allowed by the
                        //implementation but not the specification -- which means trace-refinement is failed.
                        if (nextSpec == null)
                        {
                            toReturn.Add(next);
                            VerificationOutput.NoOfStates          = Visited.Count;
                            VerificationOutput.CounterExampleTrace = toReturn;
                            VerificationOutput.VerificationResult  = VerificationResultType.INVALID;
                            FailureType = RefinementCheckingResultType.TraceRefinementFailure;
                            return;
                        }
                    }
                    else
                    {
                        hasTau = true;
                    }

                    statestring = next.GetID() + Constants.SEPARATOR + nextSpec.GetID();

                    if (!Visited.ContainsKey(statestring))
                    {
                        Visited.Add(statestring);
                        pendingImpl.Push(next);
                        pendingSpec.Push(nextSpec);
                        depthStack.Push(depth + 1);
                    }
                }

                if (!hasTau)
                {
                    //enabledS is empty if and only if the spec state is divergent.
                    if (!RefusalContainment(negatedRefusal, currentSpec.NegatedRefusals))
                    {
                        VerificationOutput.NoOfStates          = Visited.Count;
                        VerificationOutput.CounterExampleTrace = toReturn;
                        VerificationOutput.VerificationResult  = VerificationResultType.INVALID;
                        FailureType = RefinementCheckingResultType.FailuresRefinementFailure;
                        return;
                    }
                }
            }

            VerificationOutput.NoOfStates         = Visited.Count;
            VerificationOutput.VerificationResult = VerificationResultType.VALID;
            FailureType = RefinementCheckingResultType.Valid;
        }
Пример #4
0
        private void FailuresInclusionCheckDFSAntiChain(Automata spec)
        {
            Stack <ConfigurationBase> pendingImpl = new Stack <ConfigurationBase>(1024);
            Stack <NormalizedFAState> pendingSpec = new Stack <NormalizedFAState>(1024);
            List <ConfigurationBase>  toReturn    = new List <ConfigurationBase>();

            //The following are for identifying a counterexample trace.
            Stack <int> depthStack = new Stack <int>(1000);

            depthStack.Push(0);
            List <int> depthList = new List <int>(1000);
            //The above are for identifying a counterexample trace.

            NormalizedFAState initialSpec = (new NormalizedFAState(spec.InitialState)).TauReachable();

            //implementation initial state
            pendingImpl.Push(InitialStep);

            //specification initial state
            pendingSpec.Push(initialSpec);

            AntiChain antichain = new AntiChain();

            antichain.Add(InitialStep.GetID(), initialSpec.States);

            while (pendingImpl.Count > 0)
            {
                if (CancelRequested)
                {
                    VerificationOutput.NoOfStates = antichain.GetNoOfStates();
                    return;
                }

                ConfigurationBase currentImpl = pendingImpl.Pop();
                NormalizedFAState currentSpec = pendingSpec.Pop();

                //The following are for identifying a counterexample trace.
                int depth = depthStack.Pop();

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

                toReturn.Add(currentImpl);
                depthList.Add(depth);
                //The above are for identifying a counterexample trace.

                //if the implememtation state is stable, then check for failures inclusion
                IEnumerable <ConfigurationBase> nextImpl = currentImpl.MakeOneMove();
                VerificationOutput.Transitions += nextImpl.Count();
                List <string> negatedRefusal = new List <string>();
                bool          hasTau         = false;

                //for (int k = 0; k < nextImpl.Length; k++)
                foreach (ConfigurationBase next in nextImpl)
                {
                    //ConfigurationBase next = nextImpl[k];

                    NormalizedFAState nextSpec = currentSpec;

                    if (next.Event != Constants.TAU)
                    {
                        negatedRefusal.Add(next.Event);
                        nextSpec = currentSpec.NextWithTauReachable(next.Event);
                        //If the specification has no corresponding state, then it implies that the trace is allowed by the
                        //implementation but not the specification -- which means trace-refinement is failed.
                        if (nextSpec.States.Count == 0)
                        {
                            toReturn.Add(next);
                            VerificationOutput.NoOfStates          = antichain.GetNoOfStates();
                            VerificationOutput.CounterExampleTrace = toReturn;
                            VerificationOutput.VerificationResult  = VerificationResultType.INVALID;
                            FailureType = RefinementCheckingResultType.TraceRefinementFailure;
                            return;
                        }
                    }
                    else
                    {
                        hasTau = true;
                    }

                    if (!antichain.Add(next.GetID(), nextSpec.States))
                    {
                        pendingImpl.Push(next);
                        pendingSpec.Push(nextSpec);
                        depthStack.Push(depth + 1);
                    }
                }

                if (!hasTau)
                {
                    if (!RefusalContainment(negatedRefusal, currentSpec.GetFailuresNegate()))
                    {
                        VerificationOutput.NoOfStates          = antichain.GetNoOfStates();
                        VerificationOutput.CounterExampleTrace = toReturn;
                        VerificationOutput.VerificationResult  = VerificationResultType.INVALID;
                        FailureType = RefinementCheckingResultType.FailuresRefinementFailure;
                        return;
                    }
                }
            }

            VerificationOutput.NoOfStates         = antichain.GetNoOfStates();
            VerificationOutput.VerificationResult = VerificationResultType.VALID;
            FailureType = RefinementCheckingResultType.Valid;
        }