001/* Copyright (C) 2013 TU Dortmund
002 * This file is part of AutomataLib, http://www.automatalib.net/.
003 * 
004 * AutomataLib is free software; you can redistribute it and/or
005 * modify it under the terms of the GNU Lesser General Public
006 * License version 3.0 as published by the Free Software Foundation.
007 * 
008 * AutomataLib is distributed in the hope that it will be useful,
009 * but WITHOUT ANY WARRANTY; without even the implied warranty of
010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
011 * Lesser General Public License for more details.
012 * 
013 * You should have received a copy of the GNU Lesser General Public
014 * License along with AutomataLib; if not, see
015 * http://www.gnu.de/documents/lgpl.en.html.
016 */
017package net.automatalib.ts.simple;
018
019import java.util.Collection;
020import java.util.Set;
021
022import net.automatalib.commons.util.mappings.MutableMapping;
023
024/**
025 * A simple transition system. A transition system is a (not necessarily finite) collection
026 * of states. For an arbitrary input symbol, each state has a set of successors.
027 * 
028 * @author Malte Isberner <malte.isberner@cs.uni-dortmund.de>
029 *
030 * @param <S> state class.
031 * @param <I> symbol class.
032 */
033public interface SimpleTS<S, I> {
034        
035        /**
036         * Retrieves the set of initial states of the transition system.
037         * @return the initial states.
038         */
039        public Set<S> getInitialStates();
040        
041        /**
042         * Retrieves the set of successors for the given input symbol. 
043         * 
044         * @param state the source state.
045         * @param input the input symbol.
046         * @return the set of successors reachable by this input, or
047         * <code>null</code> if no successor states are reachable by this input.
048         */
049        public Set<S> getSuccessors(S state, I input);
050        
051        /**
052         * Retrieves the set of successors for the given sequence of input symbols.
053         * 
054         * @param state the source state.
055         * @param input the sequence of input symbols.
056         * @return the set of successors reachable by this input, or
057         * <code>null</code> if no successor states are reachable by this input.
058         */
059        public Set<S> getSuccessors(S state, Iterable<I> input);
060        
061        /**
062         * Retrieves the set of all successors that can be reached from any
063         * of the given source states by the specified sequence of input symbols.
064         *  
065         * @param states the source states.
066         * @param input the sequence of input symbols.
067         * @return the set of successors reachable by this input, or <code>null</code>
068         * if no successor states are reachable.
069         */
070        public Set<S> getSuccessors(Collection<S> states, Iterable<I> input);
071
072        /**
073         * Retrieves the set of all states reachable by the given sequence of input
074         * symbols from an initial state. Calling this method is equivalent to
075         * <code>getSuccessors(getInitialStates(), input)</code>.
076         * 
077         * @param input the sequence of input symbols.
078         * @return the set of states reachable by this input from an initial state,
079         * or <code>null</code> if no successor state is reachable.
080         */
081        public Set<S> getStates(Iterable<I> input);
082        
083        /**
084         * Creates a {@link MutableMapping} allowing to associate arbitrary data
085         * with this transition system's states. The returned mapping is however
086         * only guaranteed to work correctly if the transition system is not
087         * modified.
088         * @return the mutable mapping
089         */
090        public <V> MutableMapping<S,V> createStaticStateMapping();
091        
092        /**
093         * Creates a {@link MutableMapping} allowing to associate arbitrary data
094         * with this transition system's states. The returned mapping maintains
095         * the association even when the transition system is modified.
096         * @return the mutable mapping
097         */
098        public <V> MutableMapping<S,V> createDynamicStateMapping();
099        
100}