NAME ____________________________________________
CS 420/520 Theory of Computation, Spring 2019 at Indiana State University, taught by Jeff Kinne
Exam 1 practice - regular languages
Points - each part is graded as 1 point, half credit is possible. Note, the practice
exam is a total of 13 points. The actual exam may be slightly shorter.
1)
For each of these,
if the following language is regular, give an RE, DFA, or NFA for the language.
If it is not regular, prove it is not regular using the pumping lemma.
1a.
L = {strings of 0's and 1's that contain 10010 as a substring}
In the language: 10010, 01010010101
Not in the language: 1001, 0010, 101010101, 10011
1b.
L = {strings of 0's and 1's with at least 2 0's and at least 2 1's}
In the language: 0011, 1010, 100111100
Not in the language: 011, 110, 0, 101, 111111, 000010000
1c.
L = {strings of 0's and 1's that start with 1010, end with 0101, and are at least
8 characters long}
1d.
L = {strings of 0's and 1's of length a multiple of 3 and where
each third bit is the parity of the previous 2 bits}
Note: parity of 00 is 0, 01 is 1, 10 is 1, 11 is 0
In the language: 000, 110, 110011
Not in the langage: 0, 1, 01, 010, 111, 000100, 00010
2) For each of the following, give a Python3 regular expression for the given
language.
2a. Floating point numbers
In the language: 3.2344234, .234233423, 2.23423423
Not in the language: abc, pi, e, -,
2b. Sentence of the form - "REFRAIN. VERSE. REFRAIN."
Note - REFRAIN and VERSE can be any combination of the following -
letters, space, -, '
3) Prove by induction or contradiction.
3a. There are infinitely many primes.
3b. 1 + 2 + 3 + ... + n = n(n+1)/2
3c. n! > 2^n (2 to the power n) for all n >= 4
3d. For real numbers a and b, if a is rational and ab is irrational then b is irrational
4) Write a table for the transition function of the following NFA or DFA.
https://upload.wikimedia.org/wikipedia/commons/thumb/0/0e/NFAexample.svg/250px-NFAexample.svg.png
5) Describe the language accepted by the following NFA or DFA.
https://i.stack.imgur.com/TwVxh.png
6) Prove the following. The class of non-regular languages is closed
under complement. In other words, if a language L is not regular then
the complement of L is not regular either.