Re: Create DFA from regular expression?
- From: "Matt Timmermans" <mt0000@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 17 Nov 2005 23:55:16 -0500
"Paminu" <jadajada@xxxxxxx> wrote in message
news:dli8r2$osu$1@xxxxxxxxxxxxxxxxxxxx
> Is it possible to create a DFA directly from a regular expression or is it
> necessary first to create the NFA?
You can create it directly from the regular expression using "derivatives",
where the derivative of a regular expression R w.r.t. some symbol 'a',
written D_aR, is the expression that matches all strings x such that R
matches ax. A DFA that accepts R will have a transition on 'a' from the
start state to a state that accepts D_aR.
Let \ be the expression matching nothing, and let E be the expression
matching only the empty string.
For all symbols a and b, and expressions R and S:
D_a\ = \
D_aE = \
D_aa = E
D_ab = \
D_a(R|S) = D_aR | D_aS
D_aR* = (D_aR)(R*)
D_a(RS) = (D_aR)S | (D_aS) if R matches the empty string, and just (D_aR)S
otherwise.
Using these with some simplification rules is often the easiest way to find
DFAs by hand. If you're programming it, though, all that symbolic stuff is
a pain, and it's much easier just to make the NFA first and convert it.
--
Matt
.
- Follow-Ups:
- Re: Create DFA from regular expression?
- From: Torben Ægidius Mogensen
- Re: Create DFA from regular expression?
- From: Paminu
- Re: Create DFA from regular expression?
- References:
- Create DFA from regular expression?
- From: Paminu
- Create DFA from regular expression?
- Prev by Date: Re: Can someone give me an example of this type of problem?
- Next by Date: Re: Can someone give me an example of this type of problem?
- Previous by thread: Create DFA from regular expression?
- Next by thread: Re: Create DFA from regular expression?
- Index(es):
Relevant Pages
|