问题
So this is not about the pumping lemma and how it works, it's about a pre-condition.
Everywhere in the net you can read, that regular languages must pass the pumping lemma, but noweher anybody talks about finite languages, which actually are a part of regular languages.
So we might all aggree, that the following language is a finite language as well as it's a regular one, but it definitely does not pass the pumping lemma:
L = {'abc', 'defghi'}
Please, tell me if simply no one writes about it or why we're wrong - or even not.
回答1:
The reason that finite languages work with the pumping lemma is because you can make the pumping length longer than the longest word in the language. The pumping lemma, as stated on Wikipedia (I don't have my theory of computation book with me) is the following:
Let L be a regular language. Then there exists an integer p ≥ 1 depending only on L such that every string w in L of length at least p (p is called the "pumping length") can be written as w = xyz (i.e., w can be divided into three substrings), satisfying the following conditions:
- |y| ≥ 1
- |xy| ≤ p
- for all i ≥ 0, xyiz ∈ L
Now, consider some finite language L, and let k = maxw ∈ L |w| be the length of the longest word in L. Then I claim that the minimal pumping length for L is p = k+1. Since there are no words in L with length at least k+1, it is (vacuously) true that every such word satisfies the three conditions (or, indeed, any other condition you care to specify).
You can see that any finite language is regular, of course (regular languages are closed under finite union, and all languages of one word are regular), but note that this argument doesn't show this; it's important to remember that while any regular language can be pumped, there exist languages that can be pumped but are not regular.
回答2:
"IN CONTEXT OF PUMPING LEMMA FOR REGULAR LANGUAGES "
Yes we agree, All finite languages are regular language means we can have Finite automata as well as regular expression for any finite language.
Whereas a infinite language may be regular or not
. Venn-Diagram is shown below. So we need to only check for infinite language L where its regular of not!
Think about FA:
Any
automata
fora finite language can not contains loop!
(alsoregular expressions for finite language will be without * and +
operation).Any
automata
fora infinite language(regular) will contain the loop
.We can't construct an automata for infinite language without loop
; where loop may be a self loop of via some other state. {If its self loop then a single symbol repeats any number of time, if via other state a sequence of symbols comes in loop can be repeat any numbers of time}.
Pumping means repeating. In pumping lemma w
can be break in three parts x, y, z. The 'y' is in part of w
occurs in loop (that's y>=1 ). So pumping lemma is nothing finding looping part y
and repeating this looping part any numbers of time.
w'
its still in language.
NOTE: Regular Expressions for infinite language can't be without * and +
operation!
[answer] There is no loop in an automata for finite language so we can't pump(generate by repeating) new strings in language. And Pumping Lemma is not applicable for finite language.
Although some writers also explain pumping lemma for finite language where
i
in xyiz can be repeat boundedly (say k ≤ i ≤ m )
In Venn-Diagram Every finite set is regular.
Infinite set may be regular or not.
Regular-Languages ⊆ Non-Regular Languages
回答3:
There's a simplest way to show that some language is infinite. Assume that L is the language for some regular expression E, L(E).
Suppose L(E) is equivalent to {ab^nc | n ≥ 0}
.
We know that E is in the form ab*c
, and we know this language is probably regular(we can't prove something be regular), since the pumping lemma this conclusion is k = 0
, put in another way, xz = ac
, and every regular expression has an equivalent automaton.
The conclusion is simple, if the DFA has some state with transition to itself, the language is infinite.
a b c
q0 q1
q1 q1 q2
*q2
q1 has transition to itself, thus L(E) is infinite.
回答4:
Finite languages are regular languages by definition because you can build a regular expression that satisfies it by just expressing the union of all the words (e.g. (abc)|(defghi)
is a regular expression that satisfies your language) and consequently you can have a deterministic finite automaton that satisfies it.
Not being able to pass the pumping lemma does not means that the language is not regular. In fact, to use the pumping lemma your language must have some kind of closure in its definition. If your language is just a set of words there is nothing to "pump" in it.
来源:https://stackoverflow.com/questions/11832371/to-make-sure-pumping-lemma-for-infinite-regular-languages-only