private void EvaluatePredecessors(TransitionSystem transitionSystem, int state) { for (int i = 0; i < numStates; i++) { if (transitionSystem.HasTransition(i, state)) { Evaluate(transitionSystem, i); } } }
public void TransitionSystem() { const int numNodes = 7; const int numBits = 3; Assert.Less(numNodes, 1 << (numBits + 1)); var ts = new TransitionSystem(numNodes); ts.AddTransition(0, 1); ts.AddTransition(0, 2); ts.AddTransition(1, 3); ts.AddTransition(2, 4); ts.AddTransition(3, 3); ts.AddTransition(3, 5); ts.AddTransition(4, 4); ts.AddTransition(4, 5); ts.AddTransition(5, 5); ts.AddTransition(5, 6); ts.AddTransition(6, 6); var obdd = new OBDD(); var root = BDDNode.False; for (int i = 0; i < numNodes; i++) { for (int j = 0; j < numNodes; j++) { if (!ts.HasTransition(i, j)) { continue; } var transition = AddTransition(obdd, i, j, numBits); root = obdd.MakeOr(root, transition); } } using (var writer = new StringWriter()) { ts.ExportToGraphviz(writer, new IProposition[0]); Debug.Log(writer); } using (var writer = new StringWriter()) { root.ExportToGraphviz(writer); Debug.Log(writer); } using (var writer = new StringWriter()) { obdd.ExportToGraphviz(writer); Debug.Log(writer); } }
private bool Evaluate(TransitionSystem transitionSystem, bool[] checkedStates, bool[] markedStates, int state) { if (checkedStates[state]) { // we have already evaluated this state return(Get(state)); } if (markedStates[state]) { // we have reached a previously marked state // therefore detecting a cycle along which f holds return(true); } if (!f.Get(state)) { // f does not hold here (bad) return(false); } // check if there is a path starting in the current state along which f holds for every state markedStates[state] = true; for (int i = 0; i < numStates; i++) { if (transitionSystem.HasTransition(state, i)) { if (Evaluate(transitionSystem, checkedStates, markedStates, i)) { // found a path along which f holds for every state // therefore prepend the current state Set(state); break; } } } markedStates[state] = false; checkedStates[state] = true; return(Get(state)); }