|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcore.FiniteStateMachine
public class FiniteStateMachine
This class represents a finite state machine (E,S,I,T,F) where
Field Summary | |
---|---|
static int |
OUTPUT_NORMAL
|
static int |
OUTPUT_OFF
|
static int |
OUTPUT_VERBOSE
|
Constructor Summary | |
---|---|
FiniteStateMachine()
Creates an empty finite state machine |
|
FiniteStateMachine(FiniteStateMachine fsm)
Copy constructor. |
Method Summary | |
---|---|
boolean |
accepts(java.lang.String... s)
Checks whether the FSM accepts the given input. |
void |
addTransition(java.lang.String stateName,
java.lang.String symbol,
java.lang.String... successors)
|
java.lang.Object |
clone()
Makes a deep copy of the FSM |
FiniteStateMachine |
complementLanguage()
Inverts all final states (all non-final states become final, all final states become non-final) If the given fsm is not deterministic or not complete, the complement of the power fsm will be returned. |
State |
createAnonymousState()
Creates a normal state that is automatically named. |
State |
createState(java.lang.String name,
StateType type)
Creates a new state of the specified type in the fsm. |
java.util.Set<java.lang.String> |
determineAlphabet()
Returns a set of all transition symbols of the FSM. |
java.util.Collection<State> |
getFinalStates()
|
java.util.Collection<State> |
getInitialStates()
|
static int |
getOutputMode()
Returns the output mode |
State |
getState(java.lang.String stateName)
|
java.util.Collection<State> |
getStates()
|
StateType |
getType(State s)
|
boolean |
hasReachableFinalState()
|
boolean |
isComplete()
|
boolean |
isDeterministic()
|
FiniteStateMachine |
link(java.lang.String... symbols)
Creates an fsm where some symbols are replaced by other symbols. |
FiniteStateMachine |
makeAllStatesFinal()
Returns a clone of the fsm whose states are all final. |
FiniteStateMachine |
makeComplete()
Adds a non-final error state to the fsm. |
FiniteStateMachine |
makeInvariantTo(FiniteStateMachine... fsm)
Tries to make the "checker"-FSM invariant to the alphabet of all other fsms given as arguments in the array "fsm". |
FiniteStateMachine |
minimize()
Minimizes the FSM. |
FiniteStateMachine |
parallel(FiniteStateMachine fsm)
Constructs a FiniteStateMachine that is the asynchronous composition of the two FSMs. |
static FiniteStateMachine |
partialOrderReduction(FiniteStateMachine checker,
FiniteStateMachine... fsm)
The partial order reduction constructs a reduced state graph of the parallel composition of all FSMs given in the array "fsm". |
FiniteStateMachine |
power()
Returns the power-fsm of the finite state machine. |
FiniteStateMachine |
product(FiniteStateMachine fsm)
Creates a product machine which accepts as a language the intersection of the two languages of the given finite state machines. |
boolean |
removeState(State toRemove)
Removes a state (also initial state and final state) from the FSM. |
static void |
setOutputMode(int outputMode)
Sets the output mode |
void |
setType(State s,
StateType type)
Sets the state to the specified type. |
java.lang.String |
toString()
|
void |
visualize()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int OUTPUT_NORMAL
public static final int OUTPUT_OFF
public static final int OUTPUT_VERBOSE
Constructor Detail |
---|
public FiniteStateMachine()
public FiniteStateMachine(FiniteStateMachine fsm)
fsm
- Method Detail |
---|
public static int getOutputMode()
public static FiniteStateMachine partialOrderReduction(FiniteStateMachine checker, FiniteStateMachine... fsm)
checker
- The fsm that's acting as the checker. May be null if no
checker is needed.fsm
- The parallel components
public static void setOutputMode(int outputMode)
outputMode
- OUTPUT_OFF, OUTPUT_NORMAL or OUTPUT_VERBOSEpublic boolean accepts(java.lang.String... s)
s
- the input in varargs or array form
public void addTransition(java.lang.String stateName, java.lang.String symbol, java.lang.String... successors)
public java.lang.Object clone()
clone
in class java.lang.Object
public FiniteStateMachine complementLanguage()
public State createAnonymousState()
public State createState(java.lang.String name, StateType type)
name
- The name of the state to add (may not start with lower-case
lettertype
- An enumeration giving the type of the State, either
NORMAL_STATE,INITIAL_STATE,FINAL_STATE or INITIAL_FINAL_STATE
public java.util.Set<java.lang.String> determineAlphabet()
public java.util.Collection<State> getFinalStates()
public java.util.Collection<State> getInitialStates()
public State getState(java.lang.String stateName)
public java.util.Collection<State> getStates()
public StateType getType(State s)
public boolean isComplete()
public boolean isDeterministic()
public boolean hasReachableFinalState()
public FiniteStateMachine link(java.lang.String... symbols)
symbols
- An array of symbols. Each even symbol symbols[i] (i=0,2,4,...) is replaced
by its successor-symbol symbols[i+1]. The array must be even sized.
public FiniteStateMachine makeAllStatesFinal()
public FiniteStateMachine makeComplete()
public FiniteStateMachine makeInvariantTo(FiniteStateMachine... fsm)
fsm
- The fsms containing the alphabets, the resulting machine should be invariant to.
public FiniteStateMachine minimize()
public FiniteStateMachine parallel(FiniteStateMachine fsm)
fsm
-
public FiniteStateMachine power()
public FiniteStateMachine product(FiniteStateMachine fsm)
fsm
-
public boolean removeState(State toRemove)
toRemove
- The state to be removed. May not be null.
public void setType(State s, StateType type)
s
- type
- public java.lang.String toString()
toString
in class java.lang.Object
public void visualize()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |