![]() |
![]() |
|
READING:
A FSM = ⟨K, Σ, δ, s, A⟩. In math:
alphabet– the set of letters we'll see of the input.
transition function.
typedef State String; // okay, this isn't legal Java, but fine: we're representing States by Strings (their name); using `int` is common too. (Really: we should have `class FSM<StateType>`.) class FSM { Set<State> K; CharSet Σ; State s; // @pre: K.contains(s) Set<State> A; // @pre: K.containsAll(A) Map< Pair<State,Character>, State> δ; // @pre States are all in K; Characters are all in Σ. // We could also use java.function.BiFunction } |
Example: All equivalent:
new FSM( Set.of( 0,1,2,3 ), new CharSet("ab"), 0, Set.of(1), Map.of( new Pair(0,'a'), 1, new Pair(0,'b'), 3, ... ) ) |
in a current state, w/ the remaining input)
This page licensed CC-BY 4.0 Ian Barland Page last generated | Please mail any suggestions (incl. typos, broken links) to ibarland ![]() |