public class NFA
extends java.lang.Object
implements java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
java.util.Set<State> |
accept
Accept states (A).
|
Alphabet |
alphabet
The automaton alphabet (
![]() |
State |
initial
Initial state (q0).
|
static char |
LAMBDA
Our representation of
![]() |
java.util.Set<State> |
states
Set of
State objects (Q). |
java.util.Map<StateSymbolPair,java.util.Set<State>> |
transitions
Transition function (
![]() |
Constructor and Description |
---|
NFA()
Constructs an uninitialized NFA.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accepts(java.lang.String s)
Runs the given string on this automaton.
|
void |
addLambda(State p,
State q)
Adds a
![]() |
NFA |
checkWellDefined()
Checks that this automaton is well-defined.
|
java.lang.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.
|
java.util.Set<State> |
delta(State q,
char c)
Looks up transitions in transition function.
|
java.util.Set<State> |
deltaStar(State q,
java.lang.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.
|
java.util.Set<State> |
lambdaClosure(java.util.Set<State> set)
Computes the
![]() |
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
![]() |
java.lang.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.
|
public Alphabet alphabet
public static final char LAMBDA
public java.util.Map<StateSymbolPair,java.util.Set<State>> transitions
LAMBDA
.public NFA()
public boolean accepts(java.lang.String s) throws java.lang.IllegalArgumentException
s
- a stringjava.lang.IllegalArgumentException
- if a symbol in s is not in the alphabetpublic void addLambda(State p, State q)
p
- from stateq
- to statepublic NFA checkWellDefined() throws AutomatonNotWellDefinedException
AutomatonNotWellDefinedException
- if this automaton is not well-definedpublic java.lang.Object clone()
clone
in class java.lang.Object
public NFA concat(NFA f) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if the alphabets of f and this automaton are not the samepublic java.util.Set<State> delta(State q, char c) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if c is not in the alphabetpublic java.util.Set<State> deltaStar(State q, java.lang.String s) throws java.lang.IllegalArgumentException
java.lang.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
public int getNumberOfStates()
public NFA kleene()
public java.util.Set<State> lambdaClosure(java.util.Set<State> set)
public static NFA makeEmptyLanguage(Alphabet a)
a
- automaton alphabetpublic static NFA makeEmptyString(Alphabet a)
a
- automaton alphabetpublic static NFA makeSingleton(Alphabet a, char c)
a
- automaton alphabetc
- the symbol in the singleton stringpublic NFA removeLambdas()
NFA
by reducing all
public java.lang.String toDot()
public NFA union(NFA f) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if the alphabets of f and this automaton are not the sameCopyright © 2003-2015 Anders Møller.