Ejemplo n.º 1
0
        private void FailuresDivergenceInclusionCheckBFSAntichain(Automata spec)
        {
            Stack <ConfigurationBase>         pendingImpl = new Stack <ConfigurationBase>(1000);
            Stack <NormalizedFAState>         pendingSpec = new Stack <NormalizedFAState>(1000);
            Queue <List <ConfigurationBase> > paths       = new Queue <List <ConfigurationBase> >(1024);

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

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

            //specification initial state
            pendingSpec.Push(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.Pop();
                NormalizedFAState        currentSpec = pendingSpec.Pop();
                List <ConfigurationBase> currentPath = paths.Dequeue();

                if (currentSpec.IsDiv())
                {
                    VerificationOutput.NoOfStates         = antichain.GetNoOfStates();
                    VerificationOutput.VerificationResult = VerificationResultType.VALID;
                    FailureType = RefinementCheckingResultType.Valid;
                    return;
                }

                bool implIsDiv = currentImpl.IsDivergent();

                if (implIsDiv)
                {
                    VerificationOutput.NoOfStates          = antichain.GetNoOfStates();
                    VerificationOutput.VerificationResult  = VerificationResultType.INVALID;
                    VerificationOutput.CounterExampleTrace = currentPath;
                    FailureType = RefinementCheckingResultType.DivCheckingFailure;
                    return;
                }

                IEnumerable <ConfigurationBase> nextImpl = currentImpl.MakeOneMove();
                VerificationOutput.Transitions += nextImpl.Count();

                List <string> negatedRefusal = new List <string>();
                bool          hasTau         = false;

                //for (int i = 0; i < nextImpl.Length; i++)
                foreach (ConfigurationBase next in nextImpl)
                {
                    NormalizedFAState nextSpec = currentSpec;

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


                        //The following checks if a violation is found.
                        //First, check for trace refinement, which is necessary for all other refinement as well.
                        if (nextSpec.States.Count == 0)
                        {
                            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.Push(next);
                        pendingSpec.Push(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()))
                    {
                        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;
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 3
0
        public void TraceInclusionCheckBFSAntiChain(Automata spec)
        {
            //StringHashTable Visited = new StringHashTable(Ultility.Ultility.MC_INITIAL_SIZE);
            AntiChain antichain = new AntiChain();
            Queue <ConfigurationBase>         pendingImpl = new Queue <ConfigurationBase>(1024);
            Queue <NormalizedFAState>         pendingSpec = new Queue <NormalizedFAState>(1024);
            Queue <List <ConfigurationBase> > paths       = new Queue <List <ConfigurationBase> >(1024);

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

            depthStack.Push(0);
            //The above are for identifying a counterexample trace.

            //implementation initial state
            pendingImpl.Enqueue(InitialStep);
            NormalizedFAState initialSpec = (new NormalizedFAState(spec.InitialState)).TauReachable();

            pendingSpec.Enqueue(initialSpec);

            //Visited.Add(statestring);
            antichain.Add(InitialStep.GetID(), initialSpec.States);

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

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

            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();

                //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)
                    {
                        nextSpec = currentSpec.NextWithTauReachable(next.Event);

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

                    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);
                    }
                }
            }

            VerificationOutput.VerificationResult = VerificationResultType.VALID;
            VerificationOutput.NoOfStates         = antichain.GetNoOfStates();
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 5
0
        public void TraceInclusionCheckDFSAntiChain(Automata spec)
        {
            //The following are for identifying a counterexample trace.
            Stack <int> depthStack = new Stack <int>(1024);

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

            Stack <ConfigurationBase> workingImpl = new Stack <ConfigurationBase>(1024);
            Stack <NormalizedFAState> workingSpec = new Stack <NormalizedFAState>(1024);

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

            workingImpl.Push(InitialStep);
            workingSpec.Push(initialSpec);

            AntiChain antichain = new AntiChain();

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

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

                ConfigurationBase currentImpl = workingImpl.Pop();
                NormalizedFAState currentSpec = workingSpec.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 (currentSpec.States.Count == 0)
                {
                    VerificationOutput.NoOfStates         += antichain.GetNoOfStates();
                    VerificationOutput.CounterExampleTrace = toReturn;
                    VerificationOutput.VerificationResult  = VerificationResultType.INVALID;
                    return;
                }

                IEnumerable <ConfigurationBase> implPosts = currentImpl.MakeOneMove();
                VerificationOutput.Transitions += implPosts.Count();

                foreach (ConfigurationBase evt in implPosts)
                {
                    NormalizedFAState specState = currentSpec;
                    if (evt.Event != Constants.TAU)
                    {
                        specState = specState.NextWithTauReachable(evt.Event);
                    }

                    if (!antichain.Add(evt.GetID(), specState.States))
                    {
                        workingImpl.Push(evt);
                        workingSpec.Push(specState);
                        depthStack.Push(depth + 1);
                    }
                }
            }

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