class FSM { Set S; // the states String s₀; // start state s₀ ∈ S S.contains(s₀) Set Σ; // the input alphabet BiFunction τ; /* Note: #allowable inputs is: S.size() * Σ.size() */ Set F; // F subset S S.containsAll(F) } // Btw, in Python, we'd have tau be a map,state> new FSM( new Set{"q0","q1","q2","q4"}, "q0", new Set{ 'a', 'b' } new BiFunction { String apply( String currState, Character c ) { return switch (currState) { case "q0" -> switch (c) { case 'a' -> "q4"; case 'b' -> "q1"; }; case "q1" -> switch (c) { case 'a' -> "q4"; case 'b' -> "q2"; }; case "q2" -> switch (c) { case 'a' -> "q2"; case 'b' -> "q1"; }; case "q4" -> "q4"; } } } new Set{"q1"} )