Download presentation
1
Introduction to CS Theory
Lecture 8 – Pumping Lemma, Myhill-Nerode Theorem Piotr Faliszewski
2
The Pumping Lemma Theorem (The Pumping Lemma)
Let L be a regular language. There is an integer n such that for any x L with |x| n there are strings u, v, w such that x = uvw |uv| ≤ n |v| > 0 For each m 0, uvmw L Applications of the pumping lemma Showing that some language is not regular Prove that for this language the pumping lemma does not hold Just because the pumping lemma holds does not mean that the language is regular!
3
Proving a Language Nonregular
Set L = {aibi | i N }. Goal: Show that L is not regular. Proof. (by contradiction) Suppose that L is regular. Thus, pumping lemma holds for L and there exists an n such that for each string x in L, |x| > n, there are strings u, v, w such that x = uvm, |uv| ≤ n |v| > 0 For each m 0, uvmw L Pick x = anbn. The pumping lemma implies however that for some j 1 it holds that an+jbn is in L! But this is false. A contradiction..
4
Steps of a “Pumping Lemma” Proof
Nonmechanical elements of a “pumping lemma”-based nonregularity proof Choose x of length at least n. Choose m (often 0 or 2, never 1) Derive the contradiction Some examples: L1 = {ai | i is a square} L2 = {ai | i is prime} L3 = {ww | w Σ*} L4 = {w | w has an equal number of a’s and b’s} What about: {aibjcj | i,j N} {bjck | j,k N} {x | no prefix of x has more 0s than 1s}
5
Regular and Nonregular Languages
How do we know a language is regular? Give a regular expression Find an NFA … ? How do we know a language is not regular? Pumping lemma What if we cannot come up with an NFA or a regular expressin, but we also have trouble showing the language is not regular via the pumping lemma?
6
Distinguishing Strings
Def. Let L be a language over Σ, and x be a string in Σ*. The set L/x is defined as follows: L/x = {z Σ* | xz L} Distinguishing two strings Two strings x, y are distinguishable if L/x ≠ L/y If L is regular and x and y are two distinguishable strings, can there be an FA that ends in the same state after processing x and after processing y? Theorem. Let L be a language over Σ. Suppose there are n > 0 strings that are pairwise distinguishable with respect to L. Then there can be no FA recognizing L with fewer than n states
7
Myhill-Nerode Theorem
Def. Let L be a language over Σ. The indistinguishability relation IL on Σ* is defined as follows: For all x, y Σ*, x IL y iff L/x = L/y. Applications of Myhill-Nerode Theorem Show that a language is regular Show that a language is not regular Derive an FA for a regular language with a minimum number of states. Properties of IL IL is an equivalence relation We will later see that L is regular if and only if the set of equivalence classes of IL is finite (Myhill-Nerode Theorem)
8
Myhill-Nerode Theorem: Examples
Σ = {0,1} Show that the language of palindromes is not regular: L = {wΣ* | w = wR } Show that the following language is regular: L’ = {wΣ* | w ends with 10 }
9
Constructing an FA from IL
Theorem. Let L be a language over Σ and let QL be the set of equivalence classes of IL. If QL is finite, then ML = (QL, Σ, q0, AL δ) is a finite automaton accepting L, where: q0 = [ε] AL = { qQL|QL L≠} δ([x], a) = [xa] ML has the fewest states of any FA accepting L.
10
Minimizing an FA Why is that correct?
We can use Myhill-Nerode to construct a minimal automaton for a regular language specified via an automaton. Minimizing an automaton Remove all states unreachable from the start state. For p, q Q, p ≡ q if and only if for all strings z, (δ*(p,z) A δ*(q,z) A) Determine all pairs of equivalent states. Then identify all equivalent states. Why is that correct? Claim. For any two strings, x, y, x IL y iff δ*(q0, x) ≡ δ*(q0, y). 0, 1 2 3 1 0, 1 1 6 1 1 4 5 0, 1
11
Algorithm for Determining Equivalent States
Algorithm List all unordered pairs of states (p,q) where p ≠ q Mark each pair on the list that has exactly one element in A Make a pass through the list of states and mark those pairs (p,q) such that (δ(p,a), δ(q,a)) is marked Repeat 3. until you make a pass where no new pairs are marked. Marked pairs are exactly those that contain states that are not equivalent. 4 1 2 1 5 1 1 1 1 6 3 1 7 1
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.