D
Daniel Pitts
I think Daniel's notation is non-standard, but it does make seem to make sense.
What he's doing is removing the states themselves from the picture, leaving
only the trails of input words that have been recognised.
It is indeed non-standard. I was trying to represent transitions more
than states, and was trying to do so concisely.
I wasn't trying to create an all-purpose notation, I doubt it worksSo in:
Whereas "a[bc]d" produces the NDA
(s)->a
/ \
b c
\ /
d->(e)
the first 'a' is not a state label, but marks the fact that we have accepted an
'a'. The actual state we are in has no name (in this notation) but is sort of
hidden "just after" the label 'a'. From that state we can transition by
accepting 'b' to an anonymous state hidden behind the label 'b', or can
transition by accepting 'c' to the anonymous state hidden behind the 'c' label.
And from either of those states we can accept 'd' to go to the corresponding
state, and since that is a final state, we have matched the input. And the NFA
does indeed recognise a(b|c)d.
I don't think the notation covers all possible cases, for all it is nice and
clear for the cases it /does/ cover. The problems comes when one state has two
or more incoming edges with different labels (including epsilon transitions):
(S0)---x---> (S1)
| |
a y
| |
v |
(S2)---b--->[S3]
(I hope my ASCII art is legible). S0 is the start state, from which we can
transition via 'x' to S1, or via 'a' to S2. From S1 and S2 we can transition
via 'b' or 'y' (respectively) to S3, the accepting state. Thus it recognises
(ab|xy). I don't think that can be represented in Daniel's notation without
changing the definition of the NFA itself.
I don't know whether every regexp can be represented as /some/ NFA in Daniel's
notation. I haven't been able to think of a counter example yet, although the
NFA is sometimes more awkward than one which can be written in the classic
diagram format.
for all regexp, but it might.
In Java, that may be true, but in implementing a NFA-to-DFA converter,It depends on how you see it. Every DFA corresponds trivially to an NFA with
the same structure, so in that sense the DFAs are a subset of the NFAs. But
the formal definition of a DFA is different from that of a NFA, since it has a
/single/' state at any one time rather than a set of states. And of course
type Set<State> is not assignable to, or from, type State.
you may choose to create a class StateSet implements State, since
every State in the DFA results from a set of states in the NDA.
Daniel.