Name_
CS5003
Homework #7
I worked with:
I consulted:
#1. M is the Turing machine:
q0
q1
q2
B
q1,B,R
q2,B,L
a
b
c
q1,a,R
q2,c,L
q1,c,R
q1,c,R
q2,b,L
a) Trace the computation of a a b c a
b) Trace the computation of b c b c
c) Draw the graph for M
d) What d
Foundations of C.S.
CS5003
Final Exam
Spring, 2014
PRINT NAME:
SIGN :
1. (15 pts) Let L be the language with denition
L = cfw_ai bj ck | 1 j 3, i = k.
a) Give a recursive denition of L.
a) A recursive denition is:
BASIS: b, b2 , b3 L
RECURSIVE STEP: If u
Ma2201/CS2022
Quiz 0111
Foundations of C.S.
Spring, 2016
PRINT NAME:
SIGN :
1. (4 pts) Let = cfw_a, b and G be the grammar
G : S aSa | bSb | aa | bb | a | b
and let L = w | w = wR
a) Prove L L(G).
Let w L, so w = wR . We will show w L(G) by induction o
Ma2201/CS2022
Quiz 0100
Foundations of C.S.
Spring, 2016
PRINT NAME:
SIGN :
1. (3 pts) Let = cfw_a, b, c. Find two languages A, B so that |A| = 5, |B| = 3, and
|AB| =
6 15.
We want to choose our languages so that there the same string can occur with more
Ma2201/CS2022
Quiz 0001
Foundations of C.S.
Spring, 2016
PRINT NAME:
SIGN :
1. (10 pts) Use the double inclusion method to show that (A B) C = (A C) (B C).
First we show (A B) C (A C) (B C).
Let x (A B) C, so either x A B or x C.
If x (A B) then both x A
Ma2201/CS2022
Quiz 1010
Foundations of C.S.
Spring, 2014
PRINT NAME:
SIGN :
1. Given the grammar G
G : S BB
A AA | b
B AB | BA | b,
give an equivalent grammar in Greibach Normal Form
It is possible to first prove that the language of this grammar is just
Foundations of C.S.
Ma2201/CS2022
Double Down Quiz 1011
Spring, 2016
PRINT NAME:
SIGN :
- Ordinary
- Replace
6 - Double Down
1. (4 pts) Given a grammar G:
G:S
A
B
C
D
AB | C
AC | AAC | AB | BC | BD
BC | BCC | BD | a | bb
CC | CCC | aa | bbb
aa | bb
Expr
Ma2201/CS2022
Quiz 0010
Foundations of C.S.
Spring, 2014
PRINT NAME:
SIGN :
1. Show that A (B C) = (A B) (A C).
Solution
First show A (B C) (A B) (A C)
Let x A (B C). So x A and x B C.
If x B, then x A B, and so x (A B) (A C).
If x 6 B then x C, since x B
Ma2201/CS2022
Quiz 0011
Foundations of C.S.
Spring, 2014
PRINT NAME:
SIGN :
1. Define a relation R on N by setting (n, m) R if the number |n m| ends in 00 or 50.
(Note: for the purposes of this question, 3 = 03)
Show that the relation R is an equivalence
Ma2201/CS2022
Quiz 0101
Foundations of C.S.
Spring, 2016
PRINT NAME:
SIGN :
1. (4 pts) Give a regular expression for the language L cfw_a, b in which the substring
bbb occurs exactly once.
bbb occurs once.
After the bbb the string is either empty, or sta
Ma2201/CS2022
Quiz 0110
Foundations of C.S.
Spring, 2016
PRINT NAME:
SIGN :
1. (4 pts) Give a regular grammar for the language L cfw_a, b in which the substring bbb
occurs exactly once.
We interpret the variables as follows:
S The prefix has no bbb and d
Foundations of C.S.
Ma2201/CS2022
Quiz 1000
Spring, 2016
PRINT NAME:
SIGN :
1. Given a grammar G:
G:S
A
B
C
D
Sa | AB | A | B |
Aa | abcA | C
Ba | abcB | D
c | ,
d
a) (3 pts) Convert G to an equivalent grammar G0 without a recursive start.
Every easy, n
Ma2201/CS2022
Quiz 1001
Foundations of C.S.
Spring, 2016
PRINT NAME:
SIGN :
1. Given a grammar G:
G:S
A
B
C
D
E
F
G
AB | EF
AD | DA | a
AA | CD
CC | CE,
BB | DD | F F
CF | CE,
aC | bF | cE|F G
aC | bF | cE | abc
Compute REACH and TERM recursively in the
Ma2201/CS2022
Quiz 0100
Foundations of C.S.
Spring, 2014
PRINT NAME:
SIGN :
1. Prove by induction that for all n N that the number n3 n + 3 is divisible by n.
Base Case: n = 1. Then n3 n + 3 = 3, which is divisible by 3, so the bases case is
proved.
Induc
Ma2201/CS2022
Quiz 0011
Foundations of C.S.
1. (6 pts) Prove by induction that
Spring, 2016
PRINT NAME:
SIGN :
n
X
3
k =
k=1
n(n + 1)
2
2
Proof by Induction:
Base Case: n = 1. The statement is that
1
X
3
k =
k=1
1(1 + 1)
2
2
which says 13 = 12 ,
which is
Foundations of C.S.
Ma2201/CS2022
Quiz 0111
Spring, 2014
PRINT NAME:
SIGN :
1. Give a regular expression for the strings on = cfw_a, b, c such that every b is immediately
followed by at least one c or at least two as.
There are many ways to analysis this.
CS5003
Practice Final
Foundations of C.S.
Spring, 2014
PRINT NAME:
SIGN :
1. Let L be the language with definition
L = cfw_ai bj | 0 i j 2i.
a) Give a recursive definition of L.
b) Use your recursive definition to construct a context free grammar whose la
Ma2201/CS2022
Quiz 1011
Foundations of C.S.
Spring, 2014
PRINT NAME:
SIGN :
Let M be the Nondeterministic Finite Automaton
a
a
q0
b
q1
b
q2
b
b
1. Construct the transition table for M .
There are no moves so the -closure of a set is itself.
q0
q1
q2
a
b
c
Ma2201/CS2022
Quiz 0110
Foundations of C.S.
Spring, 2014
PRINT NAME:
SIGN :
1. Find a regular expression for the language of the grammar:
S aA | bA |
A aA | bS
There are many ways to analysis this. Here are two.
A has one recursive and one non-recursive
Ma2201/CS2022
Quiz 0001 (not graded)
Foundations of C.S.
Spring, 2014
PRINT NAME:
SIGN :
1. Show that A B = A B.
Solution
First show A B A B
Let x A B. So x 6 A B. So x 6 A B. So either x 6 A or x 6 B, in other
words, x A or x B, thus x A B. Thus A B A B.
Ma2201/CS2022
Quiz 0010
Foundations of C.S.
Spring, 2016
PRINT NAME:
SIGN :
1. (8 pts) Let R N N be a relation on the natural numbers.
Suppose that (7, 17) R and (5, n) R for all n N.
Suppose also that R is symmetric and transitive.
a) Show R is also refl
Foundations of C.S.
Ma2201/CS2022
Quiz 1000
Spring, 2014
PRINT NAME:
SIGN :
1. Given the grammar
G : S SBA | A
A aA |
B Bba | ,
convert to an equivalent non-contracting grammar with no recursive start.
We compute Null(G) = cfw_A, B, S.
So the conversion
CS5003
Final Exam
Foundations of C.S.
Spring, 2016
PRINT NAME:
SIGN :
Do any six problems. Write your answers clearly and neatly.
Use the back if necessary.
1. Let L cfw_a, b, c be the language with definition
L = cfw_a2n bm c3k cfw_a, b, c | 0 n, 0 m 2,
Ma2201/CS2022
Quiz 1001
Foundations of C.S.
Spring, 2014
PRINT NAME:
SIGN :
1. Give an equivalent grammar in Chomsky Normal Form
G:S
A
B
C
aAbBC | AB | a
aA | a
bBcC | aC | b,
c,
convert to an equivalent non-contracting grammar with no recursive start.
We
Foundations of C.S.
Ma2201/CS2022
Quiz 1010
Spring, 2016
PRINT NAME:
SIGN :
1. Given a grammar G:
G:S
A
B
C
AB
AB | AC | BC
BB | b
BC | c
Trace the CYK algorithm to determine if the words cbcbcb and bcbbb are in L(G).
The first is not in the language sin
CS5003
Final Exam
Foundations of C.S.
Spring, 2015
PRINT NAME:
SIGN :
Do any six problems. Write your answers clearly and neatly.
Use the back if necessary.
1. Let L be the language with definition
L = cfw_ai bk | 0 i k 2i.
Give a recursive definition of
Ma2201/CS2022
Quiz 1100
Foundations of C.S.
Spring, 2014
PRINT NAME:
SIGN :
1. Show that the language L consisting of strings of the form an bm with n < m is not
regular by the Pumping Lemma.
If L is regular then it is recognized by an Automaton with K st
Ma2201/CS2022
Quiz 0101
Foundations of C.S.
Spring, 2014
PRINT NAME:
SIGN :
1. Give a recursive definition of the set of strings over cfw_a, b which contain at least one b
and have an even number of as before the first b.
Let the language be L.
Basis: b L