|
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.ObjectdRegAut.NFA
public class NFA
Nondeterministic finite state automaton with
transitions.
[Martin, Th. 3.12]
| Field Summary | |
|---|---|
Set<State> |
accept
Accept states (A). |
Alphabet |
alphabet
The automaton alphabet ( ). |
State |
initial
Initial state (q0). |
static char |
LAMBDA
Our representation of . |
Set<State> |
states
Set of State objects (Q). |
Map<StateSymbolPair,Set<State>> |
transitions
Transition function ( ). |
| Constructor Summary | |
|---|---|
NFA()
Constructs an uninitialized NFA. |
|
| Method Summary | |
|---|---|
boolean |
accepts(String s)
Runs the given string on this automaton. |
void |
addLambda(State p,
State q)
Adds a transition. |
NFA |
checkWellDefined()
Checks that this automaton is well-defined. |
Object |
clone()
Clones this automaton. |
NFA |
concat(NFA f)
Constructs a new automaton whose language is the concatenation of the language of this automaton and the language of the given automaton. |
Set<State> |
delta(State q,
char c)
Looks up transitions in transition function. |
Set<State> |
deltaStar(State q,
String s)
Performs transitions in extended transition function. |
FA |
determinize()
Determinizes this automaton by constructing an equivalent FA. |
int |
getNumberOfStates()
Returns number of states in this automaton. |
NFA |
kleene()
Constructs a new automaton whose language is the Kleene star of the language of this automaton. |
Set<State> |
lambdaClosure(Set<State> set)
Computes the -closure
of the given state set. |
static NFA |
makeEmptyLanguage(Alphabet a)
Constructs a new NFA that accepts the empty language. |
static NFA |
makeEmptyString(Alphabet a)
Constructs a new NFA that accepts the language containing only the empty string. |
static NFA |
makeSingleton(Alphabet a,
char c)
Constructs a new NFA that accepts the language containing only the given singleton string. |
NFA |
removeLambdas()
Constructs an equivalent NFA by reducing all
transitions
to other transitions (and if necessary, making the initial state an accept state). |
String |
toDot()
Returns Graphviz Dot representation of this automaton. |
NFA |
union(NFA f)
Constructs a new automaton whose language is the union of the language of this automaton and the language of the given automaton. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public Set<State> accept
states.
public Alphabet alphabet
).
public State initial
states.
public static final char LAMBDA
.
public Set<State> states
State objects (Q).
public Map<StateSymbolPair,Set<State>> transitions
).
This is a map from pairs of states and alphabet symbols to sets of states
(
:
Q
(
{
})
2Q).
We represent
by LAMBDA.
| Constructor Detail |
|---|
public NFA()
| Method Detail |
|---|
public boolean accepts(String s)
throws IllegalArgumentException
s - a string
IllegalArgumentException - if a symbol in s is not in the alphabet
public void addLambda(State p,
State q)
transition.
p - from stateq - to state
public NFA checkWellDefined()
throws AutomatonNotWellDefinedException
AutomatonNotWellDefinedException - if this automaton is not well-definedpublic Object clone()
clone in class Object
public NFA concat(NFA f)
throws IllegalArgumentException
IllegalArgumentException - if the alphabets of f and this automaton are not the same
public Set<State> delta(State q,
char c)
throws IllegalArgumentException
(q,c)
IllegalArgumentException - if c is not in the alphabet
public Set<State> deltaStar(State q,
String s)
throws IllegalArgumentException
*(q,s)
IllegalArgumentException - if a symbol in s is not in the alphabetpublic FA determinize()
FA. [Martin, Th. 3.18]
The input automaton is unmodified.
This implementation only constructs the reachable part of the subset state space.
It first calls removeLambdas() to eliminate
transitions.
public int getNumberOfStates()
public NFA kleene()
public Set<State> lambdaClosure(Set<State> set)
-closure
of the given state set. [Martin, Def. 3.13]
set - set of State objects
State objects (the input set is unmodified)public static NFA makeEmptyLanguage(Alphabet a)
a - automaton alphabetpublic static NFA makeEmptyString(Alphabet a)
a - automaton alphabet
public static NFA makeSingleton(Alphabet a,
char c)
a - automaton alphabetc - the symbol in the singleton stringpublic NFA removeLambdas()
NFA by reducing all
transitions
to other transitions (and if necessary, making the initial state an accept state). [Martin, Th. 3.17]
The input automaton is unmodified.
public String toDot()
public NFA union(NFA f)
throws IllegalArgumentException
IllegalArgumentException - if the alphabets of f and this automaton are not the same
|
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||