简体   繁体   English

两个确定性有限自动机的并集?

[英]The union of two determinstic finite automata?

I'm trying to solve a problem where I have to create a DFA for the union of two languages. 我正在尝试解决一个必须为两种语言的结合创建DFA的问题。

These are: {s is {a, b, c}*| 这些是:{s是{a,b,c} * | every "a" in s is immediately followed by a "b"} and s中的每个“ a”后面紧跟一个“ b”},然后

{ s is {a, b, c}*| {s是{a,b,c} * | every "c" in s is immediately preceeded by a "b"} s中的每个“ c”都以“ b”开头

I think I am on the right track, but not sure if it is totally correct. 我认为我走在正确的道路上,但不确定是否完全正确。 Could someone have a look please? 有人可以看看吗?

Here's a similar post that explains how to find the union of two DFAs. 这是一篇类似的文章 ,介绍了如何查找两个DFA的联合。

The key to understand is that you have to run the two DFAs simultanously, or in general you have to maintain the states of both DFAs in the union DFA. 要理解的关键是,您必须同时运行两个DFA,或者通常必须在联合DFA中维护两个DFA的状态。


Edit: 编辑:

The reason you are getting the incorrect result is because your DFAs are not deterministic and because they do not actually decide the languages you described. 您得到错误结果的原因是因为您的DFA不确定,并且它们实际上并不能决定您描述的语言。 I think your calculation of the Union is correct, but you should fix your DFAs before proceeding further. 我认为您对联盟的计算是正确的,但是您应该先修复DFA,然后再继续进行。

The intersection of the two languages are given by L1 ∩ L2 = not(not(L1) ∪ not(L2)) (by de Morgans law). 两种语言的交集由L1 ∩ L2 = not(not(L1) ∪ not(L2)) (根据de Morgans法则)。

The complement ( "not" ) of a DFA is given by changing all accepting states to non-accepting and vice versa. DFA的补码( "not" )是通过将所有接受状态都更改为不接受而来的,反之亦然。 This will give you a non-deterministic finite automata (NFA). 这将为您提供不确定的有限自动机(NFA)。

The union is created by combining your two DFA or NFA into a new NFA which simultaneously accepts both languages. 通过将您的两个DFA或NFA合并到一个同时接受两种语言的新NFA中来创建联合。 This is done by introducing a start state from which you can go to the start state of both your NFAs without consuming anything (only consuming ε). 这是通过引入一个起始状态完成的,您可以从中进入两个NFA的起始状态,而无需消耗任何东西(仅消耗ε)。

When you've done all this you've got an NFA. 完成所有这些操作后,您便拥有了NFA。 You can use common methods to reduce this into a DFA. 您可以使用常用方法将其简化为DFA。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM