internal static BTrans emalloc_btrans() { BTrans result = new BTrans(); result.pos = set.new_set(1); result.neg = set.new_set(1); return result; }
internal static BTrans emalloc_btrans() { BTrans result = new BTrans(); result.pos = set.new_set(1); result.neg = set.new_set(1); return(result); }
internal static void free_btrans(BTrans t, BTrans sentinel, int fly) { }
/// <summary> Builds the output objects from the internal state list.</summary> /// <throws> IllegalArgumentException if formula has invalid syntax </throws> private static BuchiAutomata BuildBA() { List <string> initial = new List <string>(4); PAT.Common.Classes.DataStructure.Set <string> states = new PAT.Common.Classes.DataStructure.Set <string>(); List <Transition> transitions = new List <Transition>(); List <string> accept = new List <string>(); Dictionary <String, string> statesHash = new Dictionary <String, string>(); //in the following, all "System.IntPtr" values are actually pointers in C ! //dummy node in the circular list of states BState root = ltl2ba.main.GetBstates(); //int count = 0; //if there was no error and so we have states if (root != null) { int id = ltl2ba.main.GetSymtemID(); string[] allLabels = new string[id]; for (int i = 0; i < id; i++) { allLabels[i] = ltl2ba.main.GetSystemString(i).Trim('"'); } //iterate over state list for (BState pSourceState = root.nxt; pSourceState != ltl2ba.main.GetBstates(); pSourceState = pSourceState.nxt) { bool isInitial = (pSourceState.id == STATE_ID_INITIAL_STATE); bool isFinal = pSourceState.final == ltl2ba.main.GetAccept(); string label = pSourceState.id + (isInitial ? Constants.INIT_STATE : "") + (isFinal ? Constants.ACCEPT_STATE : ""); string sourceState; //take care that equal states are unique if (statesHash.ContainsKey(label)) { sourceState = statesHash[label]; } else { sourceState = label; //new State(, isFinal, isInitial); statesHash.Add(label, sourceState); states.Add(sourceState); if (isInitial) { initial.Add(sourceState); } if (isFinal) { accept.Add(sourceState); } } BTrans troot = pSourceState.trans; for (BTrans pTransition = troot.nxt; pTransition != troot; pTransition = pTransition.nxt) { BState pTargetState = pTransition.to; isInitial = (pTargetState.id == STATE_ID_INITIAL_STATE); isFinal = (pTargetState.final == ltl2ba.main.GetAccept()); label = pTargetState.id + (isInitial ? Constants.INIT_STATE : "") + (isFinal ? Constants.ACCEPT_STATE : ""); string targetState; //take care that equal states are unique if (statesHash.ContainsKey(label)) { targetState = statesHash[label]; } else { targetState = label; // new State(label, isFinal, isInitial); statesHash.Add(label, targetState); states.Add(targetState); if (isInitial) { initial.Add(targetState); } if (isFinal) { accept.Add(targetState); } } //it is hashset in java before PAT.Common.Classes.DataStructure.Set <Proposition> labels = new PAT.Common.Classes.DataStructure.Set <Proposition>(); if (ltl2ba.main.BtransPos(pTransition) == 0 && ltl2ba.main.BtransNeg(pTransition) == 0) { // we have a "Sigma" edge labels.Add(SIGMA_PROPOSITION); } else { for (int i = 0; i < allLabels.Length; i++) { if ((ltl2ba.main.BtransPos(pTransition) & (1 << i)) > 0) { labels.Add(new Proposition(allLabels[i], false)); } if ((ltl2ba.main.BtransNeg(pTransition) & (1 << i)) > 0) { Proposition l = new Proposition(allLabels[i], true); labels.Add(l); } } } PersonComparer p = new PersonComparer(); labels.Sort(p); Transition transition = new Transition(labels, sourceState, targetState); transitions.Add(transition); } } } else { throw new ArgumentException("invalid formula"); } //fair.Add(accept); return(new BuchiAutomata(initial, states.ToArray(), transitions.ToArray(), accept.ToArray())); }
public static int BtransPos(BTrans p) { return ((p).pos)[0]; }
public static int BtransNeg(BTrans p) { return p.neg[0]; }
internal static void copy_btrans(BTrans from, BTrans to) { to.to = from.to; set.copy_set(from.pos, to.pos, 1); set.copy_set(from.neg, to.neg, 1); }
/* returns 1 if the transitions are identical */ internal static int same_btrans(BTrans s, BTrans t) { return ((s.to == t.to) && set.same_sets(s.pos, t.pos, 1) != 0 && set.same_sets(s.neg, t.neg, 1) != 0) ? 1 : 0; }