![]() |
![]() |
|
READING:
A FSM = ⟨K, Σ, δ, s, A⟩. In math:
alphabet– the set of letters we'll see of the input.
transition function. (We could also write δ ∈ KxΣ → K, though this function-as-relation phrasing sets us up for non-determinstic automata later.)
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) Map< Pair<State,Character>, State> δ; // @pre States are all in K; Characters are all in Σ. // We could also use java.function.BiFunction // Or we could use a Set<ThreeTuple<State,Character,State>>, so long as that set (relation) represents a function. Set<State> A; // @pre: K.containsAll(A) } |
Example: All equivalent:
new FSM( Set.of( 0,1,2,3 ), new CharSet("ab"), 0, Map.of( new Pair(0,'a'), 1, new Pair(0,'b'), 3, ... ), Set.of(1) ) |
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 ![]() |