[英]Pumping lemma for regular language
I have a little confusion in checking whether the given language is regular or not using pumping lemma.我在使用抽水引理检查给定语言是否规则时有点困惑。
Suppose we have to check whether:假设我们必须检查是否:
L. The language accepting even number of
0
's in regular or not?L.常规中是否接受偶数个
0
的语言?
We know that it is regular because we can construct a DFA for L. But I want to prove this with pumping lemma.我们知道它是正则的,因为我们可以为 L 构造一个 DFA。但我想用泵引理证明这一点。
Now suppose, I take a String w= "0000"
:现在假设,我使用一个 String
w= "0000"
:
Now will divide the string as x = 0
, y = 0
, and z = 00
.现在将字符串划分为
x = 0
、 y = 0
和z = 00
。 Now on applying pumping lemma for i = 2
, I will get the string "00000"
, which is not present in my language so by pumping lemma its prove that the language is not regular.现在对
i = 2
应用抽引引理,我将得到字符串"00000"
,它在我的语言中不存在,因此通过抽引引理证明该语言不规则。 But it is accepted by DFA ?但它被 DFA 接受了?
Any help will be greatly appreciated任何帮助将不胜感激
Thank you谢谢
You are not completely clear about pumping lemma.您对抽引引理并不完全清楚。
What pumping lemma say:什么泵引理说:
Formal definition: Pumping lemma for regular languages正式定义: 常规语言的抽引引理
Let
L
be a regular language.让
L
成为常规语言。 Then there exists an integerp
≥ 1
depending only onL
such that every stringw
inL
of length at leastp
(p
is called the"pumping length"
) can be written asw
=xyz
(ie,w
can be divided into three substrings), satisfying the following conditions:那么存在一个整数
p
≥ 1
仅取决于L
使得L
中长度至少为p
(p
称为"pumping length"
)的每个字符串w
可以写成w
=xyz
(即w
可以分为三个substrings),满足以下条件:
|
y
| ≥ 1
y
| ≥ 1
| ≥ 1
|
xy
| ≤
xy
| ≤
| ≤
p
| ≤
p
- for all
i
≥ 0
,xy
i
z
∈
L
对于所有
i
≥ 0
,xy
i
z
∈
L
But what this statement says is that:但是这个声明说的是:
If a language is really a regular language then there must be some way to generate( pump ) new strings from all sufficiently large strings .如果一种语言确实是一种常规语言,那么必须有某种方法可以从所有足够大的字符串中生成(抽取)新字符串。
Sufficiently large string means, a string in language that is of the length ≥ P .足够大的字符串意味着长度≥ P 的语言字符串。
So it may not be possible to generate new string from small strings even if language is Regular Language因此,即使语言是正则语言,也可能无法从小字符串生成新字符串
Some way means, if language is really a regular and our choice of w
is correct.某种方式意味着,如果语言真的是一个正则并且我们对
w
的选择是正确的。 Then there should be at lest one way to break w
in three parts xyz
such that by repeating(pumping) y
for any number of times we can generate new strings in the language.那么至少应该有一种方法可以将
w
分成三部分xyz
以便通过重复(泵送) y
任意次数我们可以在语言中生成新的字符串。
correct choice of w
means: w
in language and sufficiently large ≥ P w
正确选择意味着: w
在语言中并且足够大 ≥ P
note : in second point, there may be a chance that even if you breaks w
correctly into xyz
according to formal definition still some new generated strings are not in language.注意:在第二点中,即使您根据正式定义将
w
正确分解为xyz
,仍有一些新生成的字符串不在语言中。 As you did .正如你所做的。
And in this situation you are to retry with some other possible choice of y
.在这种情况下,您将重试其他一些可能的
y
选择。
In you chosen string w
= " 0000 " you can break w
such that y = 00
.在您选择的字符串
w
= " 0000 " 中,您可以打破w
使得y = 00
。 And with this choice of y
you would always find a new generated string in in Language that is "even number of zeros"通过选择
y
您总是会在 Language 中找到一个新生成的字符串,它是“偶数个零”
One mistake you are doing in your proof that you are doing for a specific string 0000. You should proof for all w
≥ P .你在证明你正在为特定字符串 0000 做的一个错误。你应该证明所有
w
≥ P 。 So still your proof is incomplete所以你的证明仍然不完整
Read my this answer IN CONTEXT OF PUMPING LEMMA FOR REGULAR LANGUAGES 在常规语言的抽水引理的上下文中阅读我的这个答案
In that answer, I have explained that breaking w
into xyz
and pumping y
means finding looping part and repeating looping part to generate new strings in language.在那个答案中,我已经解释了将
w
分解为xyz
并抽取y
意味着找到循环部分并重复循环部分以生成语言中的新字符串。
When we proof that some language is regular;当我们证明某种语言是正则时; then actually we don't know where is the looping part so we try with all possible choices that satisfies pumping lemma's rule 1,2 & 3.
那么实际上我们不知道循环部分在哪里,所以我们尝试满足抽引引理规则 1,2 和 3 的所有可能选择。
And Pumping lemma says that if language is regular and infinite them there must be a loop in the DFA and every sufficiently large string in language passes through looping part (according to pigeonhole principle ) of DFA (and hence y
can't be null. That's rule-1 in above formal definition). Pumping lemma 说,如果语言是规则的和无限的,那么 DFA 中必须有一个循环,并且语言中每个足够大的字符串都通过 DFA 的循环部分(根据鸽巢原理)(因此
y
不能为空。那是上述正式定义中的规则 1)。
Think, loop can be at initial position or at end and so x
and z
can be null strings.想想,循环可以在初始位置或结束位置,因此
x
和z
可以是空字符串。
But actually we don't know where loop falls in DFA so we try with all possible ways.但实际上我们不知道循环在 DFA 中的哪个位置,所以我们尝试了所有可能的方法。
To proof a language is regular : You are to proof that for all sufficiently long strings ( w ) in language there is at-least one way ( y ) to generate new strings in the language by repeating looping part any number ( i ) of times.证明语言是规则的:您要证明对于语言中所有足够长的字符串( w )至少有一种方法( y ) 通过重复循环部分任意次数( i ) 次来生成语言中的新字符串.
To proof a language is not regular :You are to find at least one sufficiently long strings ( w ) in language such that there no choice for any way 'y' so that its possible to generate new strings with all possible repetition ( i ).为了证明一个语言不是正规:你要找到语言至少一个足够长的字符串(W),使得任何方式“Y”,以便其能够生成所有可能的重复(我)新的字符串别无选择。
To proof using Pumping Lemma:
+-------------------------+--------------------------+----------------+--------------+
| | Sufficient large W in L | y | i >=0 |
+-------------------------+--------------------------+----------------+--------------+
| language is regular | For all W (all W can use | At-least one | For all i>=0 |
| | to generate new W' in L) | | |
+-------------------------+--------------------------+----------------+--------------+
| language is NOT regular | Find Any W (at-least 1 | With all (Show | At-least one |
| | W that can't generates | no possible Y | i |
| | new W' in L | exists) | |
+-------------------------+--------------------------+----------------+--------------+
CAUTION: : The Rule always not works to proof 'Weather a Language is Regular?'警告::该规则始终无法证明“语言是否正常?”
Pumping Lemma necessary but not sufficient condition for a language to be regular.
Pumping Lemma 是语言规则的必要但非充分条件。 A language possible that satisfies these conditions may still be non-regular.
满足这些条件的语言可能仍然是非常规的。
Reference参考
To proof a language is regular you have some necessary and sufficient conditions for a language to be regular.要证明一种语言是正则的,您有一些必要和充分条件使语言成为正则。
Although the accepted answer is complete in its own way, I had to add a few things.尽管接受的答案以自己的方式完成,但我不得不添加一些内容。 I have a very playful way to exploit the pumping lemma to be able to prove that a given language is not a Regular language.
我有一个非常有趣的方法来利用泵引理来证明给定的语言不是正则语言。 Just to have a context to talk about, let me state the lemma:
只是为了有一个讨论的背景,让我陈述引理:
Pumping Lemma for Regular Languages:常规语言的抽引引理:
For any regular language L, there exists an integer k.
对于任何正则语言 L,都存在一个整数 k。
Such that for all x ∈ L with |x|
这样对于所有 x ∈ L 且 |x| ≥ k, there exists u, v, w ∈ Σ∗, such that x = uvw, and
≥ k,存在 u, v, w ∈ Σ∗,使得 x = uvw,并且
(1) |uv|
(1) |紫外线| ≤ k
≤ k
(2) |v|
(2) |v| ≥ 1
≥ 1
(3) for all i ≥ 0: u(v^i)w ∈ L
(3) 对于所有 i ≥ 0: u(v^i)w ∈ L
The k is called the Pumping lemma constant
. k 称为
Pumping lemma constant
。 Let me come straight to the point and show you how to go about proving a language L is not regular.让我开门见山,向您展示如何证明语言 L 不是正则的。
Now to start the game you need two players here.现在要开始游戏,您需要两个玩家。 One is the Reader(
R
) and the other is the Adversary( A
).一个是读者(
R
),另一个是对手( A
)。
Input: A language L输入:A语言L
The Goal of R
: Somehow prove the language L is not regular by some contradiction. R
的目标:通过某种矛盾以某种方式证明语言 L 不是正则的。
The Goal of A
: Somehow be prepared enough to face the arguments of R
and do not let him/her create a contradiction. A
的目标:以某种方式准备好面对R
的论点,不要让他/她制造矛盾。
Now let us start the argument.现在让我们开始论证。
A
: The language L is not Irregular because none could show the contradiction using pumping lemma with a certain pumping constant k. A
: 语言 L 不是 Irregular,因为没有人可以使用带有某个泵送常数 k 的泵送引理来显示矛盾。 (Each language is mapped to only one integer k) (每种语言只映射到一个整数k)
R
: Let me assume what you say. R
: 让我假设你所说的。 If language L is regular then it must satisfy the conditions of the pumping lemma.如果语言 L 是正则的,那么它必须满足泵引理的条件。 So, let me choose a suitable string x ∈ L (|x| >= k), such that it helps me create a contradiction later.
所以,让我选择一个合适的字符串 x ∈ L (|x| >= k),这样它可以帮助我稍后创建一个矛盾。
A
: Challenged by the R
, A
tries its best to find at least one suitable partitioning u, v and w of the string x, such that A
:受到R
挑战, A
尽力找到至少一个合适的字符串 x 的分区 u、v 和 w,使得
x = uvw and |uv| <= k and |v| > 0
R
: With any possible partition given by A
, wins the the argument if able to show an integer i >= 0 such that R
:对于A
给出的任何可能的分区,如果能够显示整数 i >= 0 使得该参数获胜
u(v^i)w ∉ L
Because now the R
has shown that the Language L has at least one string x which doesn't have any partition(u, v, w) such that it satisfies the pumping lemma.因为现在
R
已经表明语言 L 至少有一个字符串 x 没有任何分区(u,v,w),因此它满足泵引理。 The contradiction happened because our assumption that L is regular is FALSE
.矛盾的发生是因为我们对 L 是正则的假设是
FALSE
。 Therefore the language L is proven to be not regular.因此语言 L 被证明不是正则的。
If the R
is not able to show the above, this is not a Proof of the language being Regular.如果
R
无法显示上述内容,则这不是该语言是正则的证明。 It just means that L can be a Regular or Irregular language which just happens to satisfy the pumping lemma conditions.这只是意味着 L 可以是正则或不规则语言,恰好满足泵引理条件。
Always remember, the pumping lemma is if
( L
is regular), then
Statements.永远记住,抽水引理是
if
( L
是正则的), then
Statements。 The vice-versa is not necessarily TRUE
.反之亦然不一定是
TRUE
。 Although it might be TRUE
in some cases.尽管在某些情况下它可能是
TRUE
。
Therefore the pumping lemma is useful only if you want to prove that a language is not regular.因此,抽水引理只有在您想证明一种语言不规则时才有用。
(Source: Theory of Computation(NPTEL): Prof. Somenath Biswas(IIT Kanpur) (来源: Theory of Computation(NPTEL): Prof. Somenath Biswas(IIT Kanpur)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.