[英]Regular Expression to DFA
No, for multiple reasons:不,有多种原因:
bab
bab
ab
ab
Regarding the first point: starting at q1
, we see b
, go to q2
, see a
, go to q3
, see b
, and go to q4
, which is accepting.关于第一点:从
q1
开始,我们看到b
,到q2
,看到a
,到q3
,看到b
,再到q4
,这是接受。 We saw bab
and accepted it.我们看到了
bab
并接受了它。
Regarding the second point: starting at q1
, we see a
but have no defined transition.关于第二点:从
q1
开始,我们看到a
但没有定义的转换。 The automaton "crashes" and fails to accept.自动机“崩溃”并且无法接受。 So no string starting with
a
is accepted, including ab
.因此不接受以
a
开头的字符串,包括ab
。
Regarding the third point: DFAs are often required to show all states and transitions, including dead states and transitions that will never lead back to any accepting state.关于第三点:DFA 通常需要显示所有状态和转换,包括死状态和永远不会返回任何接受状态的转换。 You don't show all transitions and don't show all states in your automaton.
您不会显示所有转换,也不会显示自动机中的所有状态。
You can use the Myhill-Nerode theorem to determine how many states a minimal DFA for your language has.您可以使用 Myhill-Nerode 定理来确定您的语言的最小 DFA 有多少个状态。 We note that the empty state can have appended either the empty string,
b
or ab
to get a string in the language;我们注意到空状态可以附加空字符串
b
或ab
以获得语言中的字符串; a
can have b
appended; a
可以附加b
; and b
can have the empty string appended.并且
b
可以附加空字符串。 Nothing can be appended to aa
, bb
, or ba
to get a string in the language (so these are indistinguishable);不能将任何内容附加到
aa
、 bb
或ba
以获取语言中的字符串(因此这些是无法区分的); but ab
can have the empty string appended (and so is indistinguishable from b
).但
ab
可以附加空字符串(因此与b
无法区分)。
Equivalence classes so determined correspond to states in a minimal DFA.如此确定的等价类对应于最小 DFA 中的状态。 Our equivalence classes are:
我们的等价类是:
b
b
这样的字符串a
a
字符串aa
aa
这样的字符串We note that b
is in the language, so the second class will correspond to an accepting state.我们注意到
b
在语言中,因此第二类将对应于接受状态。 We notice nothing can be appended to aa
to get a string in the language, so this class corresponds to a dead state in the DFA.我们注意到不能将任何内容附加到
aa
以获取语言中的字符串,因此此类对应于 DFA 中的死状态。 We write the transitions between these states by seeing which new equivalence class the appending of a new symbol puts us in:我们通过查看附加新符号将我们置于哪个新等价类来编写这些状态之间的转换:
Appending a
puts us in (3) since appending a
to the empty string gives a
which is in (3).附加
a
将我们置于 (3) 中,因为将a
附加到空字符串给出a
(3) 中的 a。 Appending b
puts us in (2) since appending b
to the empty string gives b
which is in (2)附加
b
将我们置于 (2) 中,因为将b
附加到空字符串会得到位于 (2) 中的b
Appending a
puts us in (4) since appending a
to to b
gives ba
which is like aa
in that it isn't a prefix of any string in the language.附加
a
将我们置于 (4) 中,因为将a
附加到b
给出了ba
,这与aa
类似,因为它不是语言中任何字符串的前缀。 Appending b
, we arrive in (4) by a similar argument.附加
b
,我们通过类似的论点到达(4)。
Appending a
we get aa
and are in (4).附加
a
我们得到aa
并且在 (4) 中。 Appending b
we get ab
which is like b
so we are in (2).附加
b
我们得到ab
就像b
所以我们在(2)中。
All transitions from a dead state return to a dead state;所有从死状态的转换都返回到死状态; both
a
and b
lead back to (4). a
和b
都返回到 (4)。
You end up with something like:你最终会得到类似的东西:
q1 --a--> q3
| /|
b --b--< a
| / |
vv v
q2 -a,b-> q4 \
^ a,b
\_/
Or in tabular form:或以表格形式:
q s q'
== = ==
q1 a q3
q1 b q2
q2 a q4
q2 b q4
q3 a q4
q3 b q2
q4 a q4
q4 b q4
Your attached DFA is wrong.. your DFA is acceptable only for €,b,bab but it cannot accept ab.您附加的 DFA 错误.. 您的 DFA 仅适用于 €,b,bab 但不能接受 ab。 To make your dfa to accept ab also add a new state to q0 which accepts a and whenever newstate gets input as b send it to a final state.
为了让您的 dfa 接受 ab,还向 q0 添加一个新状态,它接受 a 并且每当 newstate 作为 b 获得输入时,将其发送到最终状态。 As it is a dfa the inputs which are not required for u send it to a new state (DEAD STATE) The dfa for your question is here: click here to view the dfa
由于它是一个 dfa,因此您不需要将其发送到新状态(死亡状态)您的问题的 dfa 在这里:单击此处查看 dfa
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.