CSE 103 Midterm 2
Given: E = {0,1}, write clear regular expressions for the following languages: Strings that begin with a 10 and end with a 01. Strings that contain at least three 1s. Strings whose length is equal to the binary number represented by the string. Strings that begin with a 0 and have a length of at most three.
10 (0+1)* 01 + 101 0*1 0*1 0*1 (0+1)* 1 + 10 0 (e+0+1) (e+0+1) (0+1)* (00+01+11)
What is the minimum number of states required in a DFA that accepts the language L2 = {x e {0,1}* | the second symbol from the right in x is a 0.}
4
What is the minimum number of states required in a DFA that accepts the language: L2 = {x e {0,1}* | the second symbol from the right in x is a 0.}
4
What is the minimum number of states required in a DFA that accepts language? L3 = {x E {a, b}* | the third symbol from the right in x is an a}
8
Write the formal definition of regular expression as given in class.
A Regular Expression, re, over an alphabet sigma, is a string over the symbols in the set sigma U {e, nulll, (,) , +, dot, *} that can be formed according to the following rules. 1) E is a r.e. 2) null is a r.e. 3) Va E sigma, a is a r.e. 4) If r1, r2 are r.e. then (r1 + r2) & (r1r2) are r.e. 5) If r is reg then r* is also 6) Nothing else is r.e.
Prove or disprove that all subsets of regular languages are regular.
All subsets of regular languages are not necessarily regular. Counterexample: Sigma = {0,1} Sigma* is regular {0^m 1^m | m >= 0 } C sigma* and is not regular
Prove that the reverse of a non-regular language must be non-regular.
Assume toward a contradiction that L is not regular and L^r is regular. L^r regular => (L^r)^r is regular Closure of reversal for reg. lang. (L^r)^r = L so we have L^r regular => L is regular A contradiction.
List the operations covered in class under which regular languages are closed?
COMPLEMENT INTERSECTION UNION DIFFERENCE REVERSAL CONCATENATION KLEENE STAR
List the ways covered in class that can be used to prove a language is regular.
DFA NFA e-NFA REGULAR EXPRESSION CLOSURE PROPERTIES
Show the state diagram for a NFA (with out epsilon moves and not more than 5 states) that recognizes the languages (11+101)* 0.
Diagram
Show the state diagram for an NFA with no more than three states that recognizes the language: L2 = {x e {0,1}* | the second symbol from the right in x is a 0.}
Diagram
Show the state diagram for an NFA with no more than four states that recognize the language: L3 = {x E {a, b}* | the third symbol from the right in x is an a}
Diagram.
Use the subset construction to build a DFA that recognizes the language recognized by the NFA for L2. Be sure to label the states in such a way that it is clear that you used the subset construction. Identify the inaccessible states. You do not have to put in the transition arrows for inaccessible states.
Diagram.
We have previously proved by induction, that the finite union of regular languages is regular. In other words that for all n >= 2 L1 U L2 U ... U Ln where all the Li are regular languages must be regular. Prove that the infinite union of regular languages is not necessarily regular. (Hint: a language with a finite number of strings, e.g., just one string is regular)
Proof by counter example: infinity U m=1 {0^m 1^m} = {0^m 1^m | m >= 1} is known to be not regular.
The subset construction can produce an exponential blow-up in the number of states. Is it possible that some other construction could be foudn that could avoid the exponential blow-up in all cases. Justify your answer.
Proven in class. No. # of states for DFA for Ln can not be < 2^n Definition: Ln = {w e {0, 1}* | who's 1 in nth position from end} Theorem: A DFA that recognizes Ln can not have less than 2^n states. Proof: String of length n There are 2^n different ones Pigeonhole at least 2 must end in some state. s ===x=y==> q Consider the first position where they differ, say k+1. x = u1v y = u0w |u| = k-1 |v| = |w| = n-k x' = u1v1 ^|u| y' = u0w1 ^|u| finishing in the same state, but one is rejected, the other is accepted. Contradiction.
Fill in the blanks. The basis of the pumping lemma is that for any __________ language, all strings in the language which are __________ long must contain some non-void substring that can be pumped, where pumped means that if the string is modified by removing the substring or arbitrarily repeating it the modified string will still be ________
REGULAR SUFFICIENTLY IN THE LANGUAGE
Prove the first part of Kleene's Theorem. For all regular expressions there exists a DFA that accepts the language denoted by the regular expression. Use proof by induction on the length of the regular expression. You may assume that if an e-NFA or NFA exists then an equivalent DFA exists.
THM: For every regular expression there is equivalent e-DFA. Proof: Use fact that R.E.s are recursively defined. And use constructive induction to get an equivalent e-NFA. For convenience all our FAs will have a unique accepting state. Any e.NFA can be so transformed, simply add the new unique accepting state and then make the old accepting states rejecting states. Diagram INDUCTIVE STEP If R is not a base case then R must be R1 + R2 or R1R2 or R1* where R1,R2 are reg. exp. whose lengths is less than the length of R. R1 aand R2 have equivalent e-NFAs by the I.H. say they are M1 and M2 Diagrams. So we have built e-NFAs for all three cases and the inductive step proof is completed.
What does Kleene's Theorem state about the family of languages that can be defined with DFAs and the family of languages that can be denoted with regular expressions?
They are the same family of languages.
What does the subset construction prove about the relative expressive power of NFAs vs DFAs?
They have the same expressive power.
How is an NFA different from a DFA?
Transitions: DFA For each state and letter there must be one and only one arrow. NFA For each state and letter there may be 0, 1, or more arrows. Acceptance: DFA Accept if stops in an accept state. NFA Accept if possible to end in an accept state.
Given sigma = {a, b}, write clear regular expressions for the following languages: Begins with a and has a length of at most three. Does not end with bb.
a + a(a+b) + a(a+b)(a+b) e + a + b + (a+b)*aa + (a+b)*ab + (a+b)*ba
Prove hte language, L = {a^n b^n | n >= 0}, is non-regular by showing you can win the daemon adversary game regardless of what legal choices the daemon makes.
p s = a^p b^p s e l AND |s| = 2p >= p xyz = a^p b^p |xy| =< p } |y| >= 1 } => y is one or more a's i = 2 x y^i z not e L Because more a's than b's