Vladimir Misic: [email protected] vm Characters and Strings1Tuesday, 9:39 AM Characters and Strings.
Introduction to CS Theory Lecture 8 – Pumping Lemma, Myhill-Nerode Theorem Piotr Faliszewski...
-
Upload
reynard-dorsey -
Category
Documents
-
view
215 -
download
2
Transcript of Introduction to CS Theory Lecture 8 – Pumping Lemma, Myhill-Nerode Theorem Piotr Faliszewski...
Introduction to CS Theory
Lecture 8 – Pumping Lemma, Myhill-Nerode TheoremPiotr [email protected]
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 that1. x = uvw2. |uv| ≤ n
3. |v| > 0
4. 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!
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
1. x = uvm,
2. |uv| ≤ n3. |v| > 04. 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..
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}
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?
Distinguishing Strings
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?
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}
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
Myhill-Nerode Theorem
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)
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.
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.
Myhill-Nerode Theorem: Examples
ExampleΣ = {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 }
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.
Minimizing an FA
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).
2 3
4
6
5
1
0
1
0
0
0
0 1
1
0, 1
0, 1
0, 1
Algorithm for Determining Equivalent States
Algorithm
1. List all unordered pairs of states (p,q) where p ≠ q
2. Mark each pair on the list that has exactly one element in A
3. Make a pass through the list of states and mark those pairs (p,q) such that (δ(p,a), δ(q,a)) is marked
4. Repeat 3. until you make a pass where no new pairs are marked.
5. Marked pairs are exactly those that contain states that are not equivalent.
1
2
3
4
5
7
0
0
0
0
0
1
1
1
1
1
0
0
16
1