[英]Combining deterministic finite automata
I'm really new to this stuff so I apologize for the noobishness here. 我对这些东西真的很新,所以我为这里的noobishness道歉。
construct a Deterministic Finite Automaton
DFA recognizing the following language: 构造
Deterministic Finite Automaton
DFA识别以下语言:
L= { w : w has at least two a's and an odd number of b's}.
The automate for each part of this (at least 2 a's, odd # of b's)
are easy to make separately... Can anyone please explain a systematic way to combine them into one? 每个部分的自动化
(at least 2 a's, odd # of b's)
很容易分开制作......任何人都可以解释一种系统的方法将它们合二为一吗? Thanks. 谢谢。
You can use following simple steps to construct combined DFA. 您可以使用以下简单步骤构建组合DFA。
Let Σ = {a 1 , a 2 , ...,a k } . 设Σ= {a 1 ,a 2 ,...,a k } 。
1st step: Design DFA for both languages and name their state Q 0 , Q 1 , ... 第一步:为两种语言设计DFA并将其状态命名为Q 0 ,Q 1 ,......
2nd step : Rename every state in both DFA uniquely ie rename all states in DFA as Q 0 , Q 1 , Q 2 , Q 3 , ... assuming you have started with subscript 0; 第二步:重新命名两个DFA中的每个状态,即将DFA中的所有状态重命名为Q 0 ,Q 1 ,Q 2 ,Q 3 ,...假设您已经开始使用下标0; that means none of the state would have same name.
这意味着没有一个州会有相同的名字。
3rd Step: Construct transition table(δ) by using following steps 第3步:使用以下步骤构建转换表(δ)
3a. 3A。 Start state of the combined DFA:
组合DFA的开始状态:
Take start state of both DFAs(DFA1 and DFA2) and name them as Q [ i , j ] where i and j are the subscript of start state of DFA1 and DFA2 respectively; 取两个DFA(DFA1和DFA2)的起始状态,并将它们命名为Q [i,j] ,其中i和j分别是DFA1和DFA2的起始状态的下标; ie Q i is start state of 1st DFA and Q j is start state of 2nd DFA and mark Q [i , j] as start state of combined DFA.
即,Q i是第1个DFA的开始状态,Q j是第2个DFA的开始状态,将Q [i,j]标记为组合DFA的开始状态。
3b. 3B。 Map state of both DFAs as
将两个DFA的状态映射为
if δ(Q i ,a k ) = Q p1 and δ(Q j ,a k ) = Q p2 , where Q p1 belongs to DFA1 and Q p2 belongs to DFA2 then δ(Q [ i , j ] , a k ) = Q [p1,p2] 如果δ(Q i ,a k )= Q p1且δ(Q j ,a k )= Q p2 ,其中Q p1属于DFA1而Q p2属于DFA2则δ(Q [i,j] ,a k ) = Q [p1,p2]
3c . 3c 。 fill entire table while there is any Q [i,j] remaining in transition table.
在转换表中剩余任何Q [i,j]时填充整个表。
3d . 3d 。 Final state of the combined DFA:
合并DFA的最终状态:
For AND
case final state would be all Q [i , j] where Q i and Q j are final state of DFA1 and DFA2 respectively. 对于
AND
情况,最终状态将是Q [i,j] ,其中Q i和Q j分别是DFA1和DFA2的最终状态。
For OR
case final state would be all Q [i , j] where either Q i or Q j is the final state of DFA1 and DFA2. 对于
OR
情况,最终状态将是Q [i,j] ,其中Q i或Q j是DFA1和DFA2的最终状态。
4th step: Rename all Q [i, j] (uniquely) and draw DFA this will be your result. 第4步:重命名所有Q [i,j] (唯一)并绘制DFA,这将是您的结果。
Example: 例:
L= {w: w has at least two a's and an odd number of b's}.
Step1: 第1步:
DFA for odd number of b's . DFA为奇数个b。
DFA for at least 2 a's. DFA至少为2个。
Step2: 第2步:
Rename the stae of DFA1 重命名DFA1的stae
Step3(a,b,c): 步骤3(A,B,C):
Constructed transition table will be as. 构造过渡表将为。
Step3d: Step3d:
Since we have to take AND of both DFA so final state would be Q [2,4] , since it contains final state of both DFA . 因为我们必须使用两个DFA的AND,所以最终状态将是Q [2,4] ,因为它包含两个DFA的最终状态。
If we have to take OR of both DFA the final state would be Q [0,4] ,Q [2,3] ,Q [1,4] ,Q [2,4] . 如果我们必须对两个DFA进行OR,则最终状态为Q [0,4] ,Q [2,3] ,Q [1,4] ,Q [2,4] 。
Transition table would like this after adding final state . 在添加最终状态后,转换表会这样。
Step4: 第四步:
Rename all states Q [i,j] 重命名所有州Q [i,j]
Q [0,3] to Q 0 Q [0,3]到Q 0
Q [1,3] to Q 2 Q [1,3]到Q 2
Q [0,4] to Q 1 Q [0,4]至Q 1
Q [2,3] to Q 4 Q [2,3]至Q 4
Q [1,4] to Q 3 问[1,4]至Q 3
Q [2,4] to Q 5 Q [2,4]至Q 5
So final DFA would will look like as below . 所以最终的DFA将如下所示。
它是使用两个自动机的产品完成的。
The Language L
where a
are at-least two and b
are odd is an regular language. 其中
a
至少为2且b
为奇数的语言L
是常规语言。 Its DFA is as below: 其DFA如下:
In this DFA I have combined two DFS
s conceptually! 在这个DFA中,我在概念上结合了两个
DFS
!
DFA-1 = for odd number of `b`'s (placed vertically three times in diagram)
DFA-2 = for >= two a (placed Horizontally two times in diagram)
The DFA is too symptomatic and simple so I believe no need in word that how to combine both DFAs DFA过于对症和简单,所以我认为不需要如何结合两种DFA
To draw this DFA you are always keep track how many b
s has been come either even or odd. 为了绘制这个DFA,你总是跟踪有多少
b
s是偶数还是奇数。 States 0, 2 and 4
means even number of b
has been come. States 0, 2 and 4
表示偶数b
已经到来。 So you can divide this DFA in two parts vertically where bottom states at even b
s and upper states at odd. 因此,您可以将此DFA垂直分为两部分,其中底部状态为偶数
b
s,上部状态为奇数。
Also String is accepted if odd b
hence final state should be in one of state in upper part. 如果奇数
b
也接受字符串,因此最终状态应该处于上部的状态之一。
not only number of b
s is condition but a
should be atleast 2
. 不仅
b
的数量是条件,而且a
应至少为2
。 So you can divide this DFA horizontally in three parts where number of a
s are 0 at state-0 and 1
, a
s are one at state-2 and 3
and a
s are 2 at state-4 and 5
. 因此可以在三个部分水平地划分这个DFA,其中的数
a
s的0 state-0 and 1
, a
s为一个在state-2 and 3
和a
s为2时state-4 and 5
。 After first two a
s any number of a
s are allow in string so there is self loop on state q4
and q5
. 前两后
a
Ş任意数量的a
s的允许在字符串,所以有状态的自我循环q4
和q5
。
number of state required is six because, 2 state for odd even b
and as hould be atleast 2
so 3 states a=0, a=1, a=2, hence 2*3 = 6 所需的状态的数量是六个,因为2状态奇偶
b
和作为HOULD是ATLEAST 2
SO 3状态的= 0,A = 1,A = 2,因此2 * 3 = 6
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.