public SCC(FiniteAutomaton fa) { this.fa = fa; foreach (FAState st in fa.states) { if (!v_index.ContainsKey(st.id)) { tarjan(st); } } }
////UPGRADE_ISSUE: The following fragment of code could not be parsed and was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1156'" //public Set < FAState > getNext(String a) ////UPGRADE_ISSUE: The following fragment of code could not be parsed and was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1156'" //public Set < FAState > getPre(String a) public virtual void addNext(System.String a, FAState b, FiniteAutomaton auto) { if (!next.ContainsKey(a)) { //UPGRADE_ISSUE: The following fragment of code could not be parsed and was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1156'" HashSet<FAState> S = new HashSet<FAState>(); S.Add(b); next.Add(a, S); } else next[a].Add(b); }
/** * Simplify a finite automaton by merging simulation equivalent states * @param fa: a finite automaton * @param Sim: some simulation rel_specation over states in the spec automaton * * @return an equivalent finite automaton */ private FiniteAutomaton quotient(FiniteAutomaton fa, HashSet<Pair<FAState,FAState>> rel) { FiniteAutomaton result=new FiniteAutomaton(); Dictionary<FAState,FAState> map=new Dictionary<FAState,FAState>(); Dictionary<FAState,FAState> reducedMap=new Dictionary<FAState,FAState>(); foreach (FAState state in fa.states) { map.Add(state, state); foreach (FAState state2 in fa.states) { if(rel.Contains(new Pair<FAState,FAState>(state,state2)) && rel.Contains(new Pair<FAState,FAState>(state2,state))){ map.Add(state,state2); } } } FAState init=result.createState(); reducedMap.Add(map[fa.InitialState], init); result.InitialState = init; foreach (FAState state in fa.states) { if(!reducedMap.ContainsKey(map[state])){ reducedMap.Add(map[state], result.createState()); } if(fa.F.Contains(state)){ result.F.Add(reducedMap[map[state]]); } foreach (KeyValuePair<string, HashSet<FAState>> sym_it in state.next) { String sym=sym_it.Key; foreach (FAState to in sym_it.Value) { if(!reducedMap.ContainsKey(map[to])){ reducedMap.Add(map[to], result.createState()); } result.addTransition(reducedMap[map[state]], reducedMap[map[to]], sym); } } } HashSet<Pair<FAState,FAState>> newrel_spec=new HashSet<Pair<FAState,FAState>>(); foreach (Pair<FAState, FAState> sim in rel) { newrel_spec.Add(new Pair<FAState,FAState>(reducedMap[map[sim.Left]],reducedMap[map[sim.Right]])); } rel.Clear(); rel = new HashSet<Pair<FAState,FAState>>(newrel_spec); return result; }
public InclusionOpt(FiniteAutomaton system, FiniteAutomaton spec){ this.spec=spec; this.system=system; }
public bool inclusionTest(){ this.computeSim(); if(quotient_var){ spec=quotient(spec, rel_spec); system=quotient(system, rel_system); } //debug("Spec.:"); //debug(spec.ToString()); //debug("Sim="+showSim(rel_spec)); //debug("System:"); //debug(system.ToString()); //debug("Sim="+showSim(rel_system)); return included(); }
private bool lasso_finding_test(HashSet<Arc> g, HashSet<Arc> h, int init){ if(!Head.ContainsKey(g.ToString())){ HashSet<int> H=new HashSet<int>(); foreach (Arc arc_g in g) { if(arc_g.From==init){ H.Add(arc_g.To); } } Head.Add(g.ToString(), H); } if(!Tail.ContainsKey(h.ToString())){ FiniteAutomaton fa=new FiniteAutomaton(); OneToOneTreeMap<int,FAState> st=new OneToOneTreeMap<int,FAState>(); foreach (Arc arc_h in h) { if(!st.containsKey(arc_h.From)) st.put(arc_h.From, fa.createState()); if(!st.containsKey(arc_h.To)) st.put(arc_h.To, fa.createState()); fa.addTransition(st.getValue(arc_h.From), st.getValue(arc_h.To), arc_h.Label?"1":"0"); } SCC s=new SCC(fa); HashSet<int> T=new HashSet<int>(); foreach (FAState state in s.getResult()) { T.Add(st.getKey(state)); } int TailSize=0; HashSet<Arc> isolatedArcs=h; while(TailSize!=T.Count){ TailSize = T.Count; HashSet<Arc> isolatedArcsTemp=new HashSet<Arc>(); foreach (Arc arc in isolatedArcs) { if(!T.Contains(arc.To)){ isolatedArcsTemp.Add(arc); }else{ T.Add(arc.From); } } isolatedArcs=isolatedArcsTemp; } Tail.Add(h.ToString(), T); } HashSet<int> intersection = new HashSet<int>(Head[g.ToString()]); //intersection.retainAll(Tail[h.ToString()]); intersection.IntersectWith(Tail[h.ToString()]); //if(debug){ // if(intersection.isEmpty()){ // //debug("g_graph:"+g+", Head: "+Head.get(g.ToString())); // //debug("h_graph:"+h+", Tail: "+Tail.get(h.ToString())); // } //} return intersection.Count > 0; }