public void FailuresDivergenceInclusionCheckDFS(DeterministicAutomata spec) { StringHashTable Visited = new StringHashTable(Ultility.Ultility.MC_INITIAL_SIZE); List <ConfigurationBase> toReturn = new List <ConfigurationBase>(); Stack <ConfigurationBase> pendingImpl = new Stack <ConfigurationBase>(1000); Stack <DeterministicFAState> pendingSpec = new Stack <DeterministicFAState>(1000); //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.TAU + 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 (currentSpec.IsDivergent) { VerificationOutput.NoOfStates = Visited.Count; VerificationOutput.VerificationResult = VerificationResultType.VALID; FailureType = RefinementCheckingResultType.Valid; return; } bool implIsDiv = currentImpl.IsDivergent(); if (implIsDiv) { VerificationOutput.NoOfStates = Visited.Count; VerificationOutput.CounterExampleTrace = toReturn; VerificationOutput.VerificationResult = VerificationResultType.INVALID; FailureType = RefinementCheckingResultType.DivCheckingFailure; return; } IEnumerable <ConfigurationBase> nextImpl = currentImpl.MakeOneMove(); VerificationOutput.Transitions += nextImpl.Count(); List <string> implRefusal = new List <string>(); bool hasTau = false; //for (int i = 0; i < nextImpl.Length; i++) foreach (ConfigurationBase next in nextImpl) { DeterministicFAState nextSpec = currentSpec; if (next.Event != Constants.TAU) { implRefusal.Add(next.Event); nextSpec = currentSpec.Next(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 == 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 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(implRefusal, 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; }
public void TraceInclusionCheckBFS(DeterministicAutomata spec) { StringHashTable Visited = new StringHashTable(Ultility.Ultility.MC_INITIAL_SIZE); Queue <ConfigurationBase> pendingImpl = new Queue <ConfigurationBase>(1024); Queue <DeterministicFAState> pendingSpec = new Queue <DeterministicFAState>(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); pendingSpec.Enqueue(spec.InitialState); string statestring = spec.InitialState.GetID() + Constants.SEPARATOR + InitialStep.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();//.Length; //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) { nextSpec = currentSpec.Next(next.Event); if (nextSpec == null) { currentPath.Add(next); VerificationOutput.NoOfStates = Visited.Count; VerificationOutput.CounterExampleTrace = currentPath; VerificationOutput.VerificationResult = VerificationResultType.INVALID; return; } } statestring = nextSpec.GetID() + Constants.SEPARATOR + next.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); } } } VerificationOutput.VerificationResult = VerificationResultType.VALID; VerificationOutput.NoOfStates = Visited.Count; }
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; }
public void TraceInclusionCheckDFS(DeterministicAutomata spec) { StringHashTable Visited = new StringHashTable(Ultility.Ultility.MC_INITIAL_SIZE); List <ConfigurationBase> toReturn = new List <ConfigurationBase>(); Stack <ConfigurationBase> pendingImpl = new Stack <ConfigurationBase>(1024); Stack <DeterministicFAState> pendingSpec = new Stack <DeterministicFAState>(1024); //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. //implementation initial state pendingImpl.Push(InitialStep); //specification initial state pendingSpec.Push(spec.InitialState); Visited.Add(InitialStep.GetID() + Constants.SEPARATOR + spec.InitialState.GetID()); while (pendingImpl.Count > 0) { if (CancelRequested) { VerificationOutput.NoOfStates = Visited.Count; // VisitedWithID.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); //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. 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]; DeterministicFAState nextSpec = currentSpec; if (next.Event != Constants.TAU) { nextSpec = currentSpec.Next(next.Event); if (nextSpec == null) { toReturn.Add(next); VerificationOutput.NoOfStates = Visited.Count; VerificationOutput.CounterExampleTrace = toReturn; VerificationOutput.VerificationResult = VerificationResultType.INVALID; return; } } string ID = next.GetID() + Constants.SEPARATOR + nextSpec.GetID(); if (!Visited.ContainsKey(ID)) { pendingImpl.Push(next); pendingSpec.Push(nextSpec); depthStack.Push(depth + 1); Visited.Add(ID); } } } VerificationOutput.NoOfStates = Visited.Count; VerificationOutput.VerificationResult = VerificationResultType.VALID; }