简体   繁体   English

找到DFA的补充?

[英]Finding the complement of a DFA?

I am asked to show DFA diagram and RegEx for the complement of the RegEx (00 + 1)* . 我被要求显示DFA图和RegEx作为RegEx (00 + 1)*的补充。 In the previous problem I had to prove that the complement of a DFA is closed and is a regular expression also, so I know that to convert a DFA, M to the complement, M`, I just need to swap the initial accepting states and final accepting states. 在之前的问题中,我必须证明DFA的补充是封闭的并且也是正则表达式,所以我知道要将DFA,M转换为补码,M`,我只需要交换初始接受状态和最终接受国家。

However, it appears that the initial accepting states for the RegEx are {00, 1, ^} and the final accepting states are {00, 1, ^} as well. 但是,似乎RegEx的初始接受状态是{00, 1, ^} 00,1 {00, 1, ^} ,最终接受状态也是{00, 1, ^} So swapping them will just result in the exact same RegEx and DFA which seems contradictory. 因此,交换它们只会产生完全相同的RegEx和DFA,这似乎是相互矛盾的。

Am I doing something wrong or is this RegEx supposed to not have a real complement? 我做错了什么,或者这个RegEx应该没有真正的补充?

Thank you 谢谢

As you says in question: 正如你所说的那样:

I know that to convert a DFA, M to the complement, M`, I just need to swap the initial accepting states and final accepting states. 我知道要将DFA,M转换为补码,M`,我只需要交换初始接受状态和最终接受状态。

Its not complement , but you are doing something like reverse of a language and regular languages are closure under reversal . 不是补充 ,但你正在做一些像 语言的逆转常规语言的逆转

Reversal of DFA 撤销DFA

What is the Reversal Language ? 什么是逆转语言?

The reversal of a language L (denoted L R ) is the language consisting of the reversal of all strings in L. 语言L(表示为L R )的逆转是由L中所有字符串的反转组成的语言。

Given that L is L(A) for some FA A, we can construct an automaton for L R : 鉴于某些FA A的L是L(A),我们可以为L R构造一个自动机:

  • reverse all edges (arcs) in the transition diagram 反转转换图中的所有边(弧)

  • the accepting state for the L R automaton is the start state for A L R自动机的接受状态是A的开始状态

  • create a new start state for the new automaton with epsilon transitions to each of the accept states for A 为新自动机创建一个新的开始状态,epsilon转换为A的每个接受状态

Note : By reversing all its arrows and exchanging the roles of initial and accepting states of a DFA you may get an NFA instead. 注意 :通过反转其所有箭头并交换DFA的初始和接受状态的角色,您可能会获得NFA。
that's why I written FA(not DFA) 这就是我写FA(不是DFA)的原因

Complement DFA 补充DFA

Finding the complement of a DFA? 找到DFA的补充?

Defination: The complement of a language is defined in terms of set difference from Σ* (sigma star). Defination:语言的补语是根据与Σ*(sigma star)的集合差异来定义的。 that is L ' = Σ * - L. 那是L '* - L.

And the complement language (L ' ) of L has all strings from Σ* (sigma star) except the strings in L. Σ* is all possible strings over the alphabet Σ. 并且L的补语(L ' )具有来自Σ*(sigma star)的所有字符串,除了L.Σ*中的字符串是字母表Σ上的所有可能的字符串。
Σ = Set of language symbols Σ=语言符号集

To construct the DFA D that accepts the complement of L, simply convert each accepting state in A into a non-accepting state in D and convert each non-accepting state in A into an accept state in D. 要构造接受L的补码的DFA D,只需将A中的每个接受状态转换为D中的非接受状态,并将A中的每个非接受状态转换为D中的接受状态。
( Warning! This is not true for NFA's ) 警告!对于NFA来说不是这样

A is DFA of L, D is for complement A是L的DFA,D是补体

Note : To construct complement DFA, old DFA must be a complete means there should all possible out going edge from each state(or in other words δ should be a complete function ). 注意 :要构建补充DFA,旧的DFA必须是一个完整的手段,应该从每个状态都可能出现边缘(或者换句话说, δ应该是一个完整的函数 )。

Complement: reference with example 补充:参考例子

Complement DFA for Regular Expression (00+1)* 正则表达式的补充DFA (00+1)*

below is DFA named A : 以下是名为A的 DFA:

00 + 1

But not this DFA is not complete DFA. 但是这个DFA不是完整的DFA。 transition function δ is partially defined but not for full domain Q×Σ ( missing out going edge from q1 for lable 1 ). 过渡函数δ是部分定义的,但不适用于全域Q×Σ从标签1 q1中错过了边缘 )。

Its complete DFA can be as follows ( A ): 其完整的DFA可以如下( A ):

completeDFA

In the above DFA, all possible transactions are defined (*for every pair of Q,Σ *) and δ is a complete function in this case. 在上面的DFA中,定义了所有可能的事务(*对于每对Q,Σ *),在这种情况下δ是一个完整的函数。

Reff: to learn what is Partial Function. Reff:了解什么是部分功能。

New complement DFA D can be constructed by changing all final states q0 to not final states and vice-versa. 可以通过将所有最终状态q0改变为非最终状态来构造新补码DFA D,反之亦然。

So in complement q0 become non-final and q1, q2 are the final states. 因此在补充q0变为非最终和q1, q2是最终状态。

补充

Now you can write Regular expression for complement language using ARDEN'S THEOREM and DFA I given. 现在,您可以使用ARDEN'S THEOREM和我给出的DFA为补充语言编写正则表达式。

Here I am writing Regular Expression for complement directly: 在这里,我直接写补充正则表达式:

(00 + 1)* 0 (^ + 1(1 + 0)*) (00 + 1)* 0 (^ + 1(1 + 0)*)

where ^ is null symbol. 其中^是空符号。

some helpful links : 一些有用的链接
From here and through my profile you can find some more helpful answers on FA. 这里开始 ,通过我的个人资料,您可以在FA上找到更多有用的答案。 Also, two good links on properties of regular language: one , second 另外,关于常规语言属性的两个很好的链接:

I didn't take the time to read all of Grijesh's answer, but here's the simple way to get a DFA accepting the complement of a language, given a DFA accepting the language: use the same DFA, but change accepting states to non-accepting, and vice-versa. 我没有花时间阅读Grijesh的所有答案,但这是让DFA接受语言补充的简单方法,因为DFA接受语言:使用相同的DFA,但将接受状态更改为不接受,反之亦然。

Strings previously accepted will be rejected, and strings previously rejected will be accepted. 之前接受的字符串将被拒绝,之前拒绝的字符串将被接受。 Since all transitions must be defined in any valid DFA, and since all input strings lead to exactly one state, this always works. 由于必须在任何有效的DFA中定义所有转换,并且由于所有输入字符串都只导致一个状态,因此这始终有效。

To get a DFA for the reversal, you can first construct an NFA by adding a new initial state that branches non-deterministically to all of the accepting states of the original DFA. 要获得反转的DFA,您可以首先通过添加一个新的初始状态来构造NFA,该状态非确定性地分支到原始DFA的所有接受状态。 Reverse all the transitions of the original DFA, and make the only accepting state be the initial state of the original DFA. 反转原始DFA的所有转换,并使唯一的接受状态为原始DFA的初始状态。

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

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