|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.metasyntactic.math.automata.AbstractFiniteAutomata | +--org.metasyntactic.math.automata.NondeterministicFiniteAutomata
FORMAL DEFINITION OF A NONDETERMINISTIC FINITE AUTOMATAON
The formal definition of a nondeterministic finite automaton is silmilar to
that of a deterministic finite automaton. Both have states, an input
alphabet, a transition function, a start state, and a collection of accept
states. However, they differ in one essential way:
in the type of transition function. In a DFA the transition function takes
a state and an input symbol and produces the next state. In an NFA the
transition function takes a state and an input symbol or the empty
string and produces the set of possible next states. In order to
write the formal definition, we need to set up some additional notation. For
any set Q we write P(Q) to be the collection of all subsets of Q. Here P(Q)
is called the power set of Q. For any alphabet Σ we
write Σε to be Σ∪{ε}.
Now we can easily write the formal description of the type of the transition function in an NFA. It is δ:Q x Σε→P(Q), and we are ready to give the formal definition.
A nondeterministic finite automaton is a 5-tuple (Q, Σ, δ, q0, F), where
Nested Class Summary | |
protected static class |
NondeterministicFiniteAutomata.DFAState
Used to compress DFA states in toDeterministicFiniteAutomata |
Field Summary |
Fields inherited from class org.metasyntactic.math.automata.AbstractFiniteAutomata |
acceptStates, alphabet, cachedTable, decision, immedateDecisionPossible, startState, states, transitionFunction |
Constructor Summary | |
protected |
NondeterministicFiniteAutomata()
For subclasses only |
|
NondeterministicFiniteAutomata(java.util.Set states,
java.util.Set alphabet,
TransitionFunction transitionFunction,
java.lang.Object startState,
java.util.Set acceptStates)
Construct a new NondeterministicFiniteAutomata |
|
NondeterministicFiniteAutomata(java.util.Set states,
java.util.Set alphabet,
TransitionFunction transitionFunction,
java.lang.Object startState,
java.util.Set acceptStates,
java.util.Map symbolToClasses)
NFA's can be modified to accept symbol classes so as to compress tables and also to handle abstract concepts such as "any character". |
Method Summary | |
boolean |
accept(java.util.Iterator iterator)
The formal definition of computation for a NondeterministicFiniteAutomata also is similar to that for a DeterministicFiniteAutomata. |
boolean |
accept(java.util.Iterator iterator,
java.util.Map symbolToClasses)
|
java.util.Set |
eClosure(java.lang.Object start)
Set of NFA states reachable from NFA state 'start' on ε-transitions alone. |
java.util.Set |
eClosure(java.util.Set T)
Set of NFA states reachable from some NFA state s in T on ε-transitions alone |
protected void |
init()
|
java.util.Set |
move(java.util.Set states,
java.lang.Object symbol,
java.util.Map symbolToClasses)
Set of NFA states to which there is a transition on input symbol 'symbol' from some NFA state s in 'states' |
DeterministicFiniteAutomata |
toDeterministicFiniteAutomata()
Converts this NFA to a DFA using the 'subset construction method' |
DeterministicFiniteAutomata |
toDeterministicFiniteAutomata(boolean compress)
Converts this NFA to a DFA using the 'subset construction method' |
Methods inherited from class org.metasyntactic.math.automata.AbstractFiniteAutomata |
getAcceptStates, getAlphabet, getStartState, getStates, getTransitionFunction, toStateTable, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
protected NondeterministicFiniteAutomata()
public NondeterministicFiniteAutomata(java.util.Set states, java.util.Set alphabet, TransitionFunction transitionFunction, java.lang.Object startState, java.util.Set acceptStates)
states
- Q is a finite set of statesalphabet
- Σ is a finite alphabettransitionFunction
- δ:Q x Σε→P(Q)
is the transition functionstartState
- q0∈Q is the start stateacceptStates
- F⊆Q is the set of accept statespublic NondeterministicFiniteAutomata(java.util.Set states, java.util.Set alphabet, TransitionFunction transitionFunction, java.lang.Object startState, java.util.Set acceptStates, java.util.Map symbolToClasses)
states
- Q is a finite set of statesalphabet
- Σ is a finite alphabettransitionFunction
- δ:Q x Σε→P(Q)
is the transition functionstartState
- q0∈Q is the start stateacceptStates
- F⊆Q is the set of accept statesMethod Detail |
protected void init()
public DeterministicFiniteAutomata toDeterministicFiniteAutomata()
public DeterministicFiniteAutomata toDeterministicFiniteAutomata(boolean compress)
compress
- Increases computation time required to construc the DFA
but returns a DFA using less memory
public boolean accept(java.util.Iterator iterator)
iterator
- A string over some alphabet Σ
true
if this machine accepts wpublic boolean accept(java.util.Iterator iterator, java.util.Map symbolToClasses)
public java.util.Set eClosure(java.lang.Object start)
start
- The state to find the eClosure of
public java.util.Set eClosure(java.util.Set T)
T
- the set of states to find the eClosure of
public java.util.Set move(java.util.Set states, java.lang.Object symbol, java.util.Map symbolToClasses)
states
- The states to move from
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |