Note: Text Cross-References in Parenthesis Are for 2Nd Ed
Total Page:16
File Type:pdf, Size:1020Kb
Chapter 4 Properties of Regular Languages 2/14/03 ==> 10/1/03
Note: text cross-references in parenthesis are for 2nd ed.
NOTE: The “prime” symbol (as in L’) means complement
Closure
If L1 and L2 are regular languages,
Then so are L1L2, L1L2, L1L2, L1’, and L*
Regular languages are closed under reversal.
Homomorphism:
Let and be two alphabets.
h: * is a homomorphism: h(ai) = u *, ai extending to strings we have:
w = a1a2...an
h(w) = h(a1)h(a2)...h(an)
Homomorphic image:
If L is a language on , then homomorphic image of L is
h(L) = { h(w) : w L }, h = homomorphism
Example 4.2, 4.3
Theorem 4.3
Let h be a homomorphism.
If L is a regular language, then its homomorphic image h(L) is also regular.
==> Regular languages are closed under homomorphisms.
CS373 Fall 2003 Chapter 4 N. Guydosh Page 1 Definition 4.2 Right Quotient
Let L1 and L2 be languages on same .
Then right quotient is defined as
L1/L2 = {x: xy L1, for some y L2}
==> “Set of all strings in L1 that have a suffix in L2 with this suffix removed”
n m Example: L1 = {a b : n 1, m 0} {ba} m L2 = {b : m 1} n m L1/L2 = {a b : n 1, m 0}
aaabbbbb L1 aaabb L1/L2 bbb is suffix
==> aaab L1/L2
==> aaa L1/L2 Theorem 4.4
If L1 and L2 are regular languages over , then L1/L2 is also regular
==> Family of regular languages is closed under right quotient with a regular language.
See examples 4.4 and 4.5
Elementary questions about regular languages (4.2) - or - Regular questions about elementary languages!
Standard representation
A regular language is given in standard representation (SR) if, and only if, it is described by:
(1) Finite automaton, (2) Regular expression, or (3) Regular grammar
Informal descriptions and set notation are excluded.
CS373 Fall 2003 Chapter 4 N. Guydosh Page 2 Theorem 4.5
Given a standard representation of a regular language L on and any w *, then an algorithm determining whether or not w L.
==> Construct DFA for L and test w.
Theorem 4.6
an algorithm for determining whether a regular language in standard representation form is empty, finite, or infinite.
==> Construct DFA. If simple path (no edge or vertex repeated) from q0 ==> qf then non-empty.
Question: Does any walk from q0 ==> qf implies a simple path also? If q0 ==> qf path passes through vertex which is base of cycle then infinite
Theorem 4.7
Given two regular languages L1 and L2 in standard representation form, an algorithm to determine if/(if not) L1 = L2.
==> Define regular language: L3 = (L1 L2’) (L1’ L2) = L1 L2 ... “Exclusive OR”
Since L3 is a regular language, DFA M accepting L3.
Use Theorem 4.6 to see if L3 is empty.
L3 = if, and only if, L1 = L2. (Why?)
CS373 Fall 2003 Chapter 4 N. Guydosh Page 3 Identifying Non-Regular Languages (Sect 4.3)
Pigeon hole principle (a target of denial)
Put n objects into m boxes.
If n > m, then at least one box must have more than one item in it.
Can prove L is non-regular language by assuming contrary ==> denying pigeon hole property.
Example 4.6 Prove L = {anbn : n 0} is non-regular
Assume contrary: (Assume L is regular language)
==> DFA, M = (Q, {a,b}, , q0, F)
i Consider *(q0, a ) i > 0
==> infinite number of is and finite number of states.
n m ==> q Q and some n, m (n m) such that *(q0, a ) = q = *(q0, a ) due to pigeon hole principle. ... q would be the first state to repeat for a sufficiently long string of a’s. But since, by assumption (contrary),
n n n M accepts a b , we have *(q, b ) = qf F
[Uses: *(q,w1w2) = *(*(q,w1),w2)]
But also,
m n m n n *(q0,a b ) = *(*(q0,a ),b ) = *(q, b ) = qf F
Contradiction since m n and ambn should be rejected. QED
CS373 Fall 2003 Chapter 4 N. Guydosh Page 4 “Pumping Lemma” (another object of denial)
Application of pigeon hole principle
Theorem 4.8
Let L be an infinite regular language.
Then, some integer m > 0 such that w L and |w| m,
we can decompose w as
w = xyz
with |xy| m
|y| 1
i such that wi = xy z, i 0 (pumped up w) is also in L.
Proof: L is regular language ==> DFA M with states q0, q1, q2, ..., qn , (n+1 states)
Let w L such that |w| m = n + 1
M goes through the following sequence of states as it processes w:
q0, qi, qj, ..., qf
Since |w| n + 1,
Number of states in walk = |w| + 1 > n + 1 See example below ... Number of states in walk > number of states
==> at least 1 repeated state (pigeon hole principle)
CS373 Fall 2003 Chapter 4 N. Guydosh Page 5 Example: w = abc
number of states = |w|+1 = 3+1. = 4. Sequence looks like:
q0 , qi , qj , ..., qr , ..., qr , ..., qf ------x y
substrings x, y, z such that
*(q0 , x) = qr
*(qr , y) = qr
*(qr ,z) = qf
with |xy| n + 1 and |y| 1 Note: Reason for |xy| n + 1 =m: If qr is the first occurrence of a vertex which will be also the next repeated one, st Then it (1 qr) will occur no later than nth move since there are only n+1 states in going from q0 to qf . Since there can be no repetitions of states in the “y loop or segment”, and we need at least 1 move to complete the loop, it follows that number of moves in xy = |xy| number of states = n+1 = m. Remember the example above relating number of moves (string length) with number of states.
nd Thus *(q0 , xz) = qf skip the loops, and |xy| n + 1 = m … see p. 116 (120, 2 ed)
i and *(q0 , xy z) = qf i 0 any number of loops will work
xyiz = pumped string is accepted QED
CS373 Fall 2003 Chapter 4 N. Guydosh Page 6 Observation: - If assuming a language L is a regular language (accepted by DFA)
And pumping lemma is denied in the process, then L is not a regular language (contradiction)
- We are guaranteed existence of m as well as the decomposition xyz
But
We do not know what they are. - Cannot claim contradiction just because the pumping lemma is violated for some specific value of m or specific xyz … see middle p. 117 (bottom p. 120).
- But: Pumping Lemma holds w L, |w| m and all i.
Thus If Pumping Lemma is violated for even one w or i, then L is not a regular language.
Game Theory Approach to Applying Pumping Lemma
1. Opponent picks m
2. Given m, we pick w L such that |w| m (totally free to choose)
3. Opponent chooses decomposition xyz with |xy| m and |y| 1. Opponent makes optimal choice.)
i 4. We try to pick some particular i such that the pumped string wi = xy z is not in L. … make no assumptions on what partition is – must guarantee violation for all possible partitions …
If we can do this, we win.
Else inconclusive (opponent wins).
CS373 Fall 2003 Chapter 4 N. Guydosh Page 7