/** * Returns a state reached from this state with the given symbol. If more than one state can be reached with the given symbol, an arbitrary one is returned. * * @param symbol * @return a state reached from this state with the given symbol, <code>null</code> otherwise */ public State<T> move(final T symbol) { for (final Transition<T> t : _transitions) if (t.hasName(symbol)) return t.getTo(); return null; }
public void addTransition(final State<T> begin, final State<T> end) { begin.addTransition(end); }
public Set<State<T>> epsilonClosure(final State<T> s, final Set<State<T>> init) { Set<State<T>> result = init; // s is in the epsilon closure of itself result.add(s); // for each edge from s for (final Transition<T> e : s.getTransitions()) // if this is an epsilon transition and the result // does not contain 'to' state then add the epsilon // closure of 'to' state to the result set if (e.isEpsilon() && !result.contains(e.getTo())) result = epsilonClosure(e.getTo(), result); return result; }
private State<Role> copyState(final State<Role> oldState, final TransitionGraph<Role> newTG, final Map<State<Role>, State<Role>> newStates) { State<Role> newState = newStates.get(oldState); if (newState == null) { newState = newTG.newState(); newStates.put(oldState, newState); for (final Transition<Role> t : oldState.getTransitions()) { final State<Role> oldTo = t.getTo(); final State<Role> newFrom = copyState(oldTo, newTG, newStates); if (t.isEpsilon()) newTG.addTransition(newFrom, newState); else newTG.addTransition(newFrom, t.getName().getInverse(), newState); } } return newState; } }
public Set<State<T>> move(final Set<State<T>> stateSet, final T c) { final Set<State<T>> result = new HashSet<>(); // for all the states in the set SS for (final State<T> st : stateSet) // for all the edges from state st for (final Transition<T> e : st.getTransitions()) // add the 'to' state if transition matches if (e.hasName(c)) result.add(e.getTo()); return result; }
private static boolean isAllValuesSafe(final KnowledgeBase kb, final Individual parent, final Role role, final ATermAppl term) { final Role s = kb.getRole(term.getArgument(0)); if (!s.hasComplexSubRole()) { final ATermAppl c = (ATermAppl) term.getArgument(1); if (role.isSubRoleOf(s) && !parent.hasType(c)) return false; } else { final TransitionGraph<Role> tg = s.getFSM(); for (final Transition<Role> t : tg.getInitialState().getTransitions()) if (role.isSubRoleOf(t.getName())) return false; } return true; }
public TransitionGraph<T> renumber() { final Set<State<T>> processed = new HashSet<>(); final LinkedList<State<T>> workList = new LinkedList<>(); int val = 0; workList.addFirst(_initialState); while (workList.size() > 0) { final State<T> s = workList.removeFirst(); s.setName(val++); processed.add(s); for (final Transition<T> e : s.getTransitions()) if (processed.add(e.getTo())) workList.addLast(e.getTo()); } return this; }
public Set<State<T>> epsilonClosure(final Set<State<T>> stateSet) { Set<State<T>> result = new HashSet<>(); // for each state in SS add their epsilon closure to the result for (final State<T> s : stateSet) result = epsilonClosure(s, result); return result; }
@Override public String toString() { return (_name == EPSILON ? "epsilon" : _name.toString()) + " -> " + _to.getName(); } }
public State<T> newState() { final State<T> s = new State<>(); _allStates.add(s); return s; }
private State<Role> copyState(final State<Role> oldState, final TransitionGraph<Role> newTG, final Map<State<Role>, State<Role>> newStates) { State<Role> newState = newStates.get(oldState); if (newState == null) { newState = newTG.newState(); newStates.put(oldState, newState); for (final Transition<Role> t : oldState.getTransitions()) { final State<Role> oldTo = t.getTo(); final State<Role> newFrom = copyState(oldTo, newTG, newStates); if (t.isEpsilon()) newTG.addTransition(newFrom, newState); else newTG.addTransition(newFrom, t.getName().getInverse(), newState); } } return newState; } }
public Set<State<T>> epsilonClosure(final State<T> s, final Set<State<T>> init) { Set<State<T>> result = init; // s is in the epsilon closure of itself result.add(s); // for each edge from s for (final Transition<T> e : s.getTransitions()) // if this is an epsilon transition and the result // does not contain 'to' state then add the epsilon // closure of 'to' state to the result set if (e.isEpsilon() && !result.contains(e.getTo())) result = epsilonClosure(e.getTo(), result); return result; }
public Set<State<T>> move(final Set<State<T>> stateSet, final T c) { final Set<State<T>> result = new HashSet<>(); // for all the states in the set SS for (final State<T> st : stateSet) // for all the edges from state st for (final Transition<T> e : st.getTransitions()) // add the 'to' state if transition matches if (e.hasName(c)) result.add(e.getTo()); return result; }
private static boolean isAllValuesSafe(final KnowledgeBase kb, final Individual parent, final Role role, final ATermAppl term) { final Role s = kb.getRole(term.getArgument(0)); if (!s.hasComplexSubRole()) { final ATermAppl c = (ATermAppl) term.getArgument(1); if (role.isSubRoleOf(s) && !parent.hasType(c)) return false; } else { final TransitionGraph<Role> tg = s.getFSM(); for (final Transition<Role> t : tg.getInitialState().getTransitions()) if (role.isSubRoleOf(t.getName())) return false; } return true; }
/** * Returns a state reached from this state with the given symbol. If more than one state can be reached with the given symbol, an arbitrary one is returned. * * @param symbol * @return a state reached from this state with the given symbol, <code>null</code> otherwise */ public State<T> move(final T symbol) { for (final Transition<T> t : _transitions) if (t.hasName(symbol)) return t.getTo(); return null; }
public void addTransition(final State<T> begin, final State<T> end) { begin.addTransition(end); }
public Set<State<T>> epsilonClosure(final Set<State<T>> stateSet) { Set<State<T>> result = new HashSet<>(); // for each state in SS add their epsilon closure to the result for (final State<T> s : stateSet) result = epsilonClosure(s, result); return result; }
@Override public String toString() { return (_name == EPSILON ? "epsilon" : _name.toString()) + " -> " + _to.getName(); } }
public State<T> newState() { final State<T> s = new State<>(); _allStates.add(s); return s; }
public void addTransition(final State<T> begin, final T transition, final State<T> end) { if (transition == null) throw new NullPointerException(); begin.addTransition(transition, end); _alphabet.add(transition); }