/// <summary> /// Creates a new simple symbolic automaton. /// </summary> /// <param name="initialState">Initial state.</param> /// <param name="finalStates">Final states.</param> /// <param name="moves">Moves (aka transitions).</param> /// <param name="alphabet">Alphabet (derived from transition labels if <c>null</c>).</param> /// <param name="name">Name (optional).</param> /// <param name="stateNames">State names (optional).</param> public SSA(int initialState, IEnumerable <int> finalStates, IEnumerable <Move <Predicate <SYMBOL> > > moves, Set <SYMBOL> alphabet = null, string name = null, Dictionary <int, string> stateNames = null) { Set <SYMBOL> symbols = moves.Aggregate( new Set <SYMBOL>(), (syms, move) => move.IsEpsilon ? syms : (syms | move.Label.Symbols) ); if (alphabet == null) { alphabet = symbols; } else if (symbols > alphabet) { throw AutomatonException.UnknownSymbolsInTransitions(Type); } PredicateAlgebra <SYMBOL> algebra; if (!algebras.TryGetValue(alphabet, out algebra)) { algebra = algebras[alphabet] = new PredicateAlgebra <SYMBOL>(alphabet); } this.automaton = Automaton <Predicate <SYMBOL> > .Create( algebra, initialState, finalStates, moves, eliminateUnrreachableStates : true, eliminateDeadStates : true ); this.Name = name; this.StateNames = stateNames; }
/// <summary> /// Creates a new simple symbolic transducer. /// </summary> /// <param name="initialState">Initial state.</param> /// <param name="finalStates">Final states.</param> /// <param name="moves">Moves (aka transitions).</param> /// <param name="alphabet">Alphabet (derived from transition labels if <c>null</c>).</param> /// <param name="name">Name (optional).</param> /// <param name="stateNames">State names (optional).</param> public SST(int initialState, IEnumerable <int> finalStates, IEnumerable <Move <Label <SYMBOL> > > moves, Set <SYMBOL> alphabet = null, string name = null, Dictionary <int, string> stateNames = null) { Set <SYMBOL> symbols = moves.Aggregate( new Set <SYMBOL>(), (syms, move) => syms | move.Label.Symbols ); if (alphabet == null) { alphabet = symbols; } else if (symbols > alphabet) { throw AutomatonException.UnknownSymbolsInTransitions(Type); } this.automaton = Automaton <Label <SYMBOL> > .Create( new LabelAlgebra <SYMBOL>(alphabet), initialState, finalStates, moves, eliminateUnrreachableStates : true, eliminateDeadStates : true ); this.Name = name; this.StateNames = stateNames; }