15453: FLAC
K. Sutner
Solutions Assignment 1
Solution: CourseofValue Recursion
Part A: Denition
We cannot dene f directly using the polyadic function h since primitive recursive functions must
have xed arity. But we can use sequence numbers to dene a f
15453: FLAC
K. Sutner
Solutions Assignment 1
Solution: WriteFirst Turing Machines
Part A: Computation
As for ordinary Turing machines we dene an instantaneous description of a writerst TM to the
be a word in Q (assume Q and to be disjoint). Then x p y
Formal Languages, Automata, and Computation (FLAC)
CS 15453

Spring 2009
What is Sudoku?
6
3
1
2
9
Played on a nn board.
5
1
4
4
9
2
3
4
8
1
1
7
3
6
8
9
1
5
4
7
9
5
3
2
PuzzleSolving Process
1
A single number from 1 to n
must be put in each cell;
some cells are prefilled.
Puzzle
Encoder
Board is subdivided into
n n blocks
Formal Languages, Automata, and Computation (FLAC)
CS 15453

Spring 2009
MyhillNerode Handout
Denition. An equivalence relation E on strings is right invariant i concatenating a
string w onto two equivalent strings u and v produces two strings (uw and v w) that are also
equivalent; i.e., for all strings u, v , and w, we have
Formal Languages, Automata, and Computation (FLAC)
CS 15453

Spring 2009
15453
FORMAL LANGUAGES,
AUTOMATA AND
COMPUTABILITY
NP =
NTIME(n )
k
k N
Theorem: L NP if there exists a polytime
Turing machine V(erifier) with
L = cfw_ x  y(witness) y = poly(x) and V(x,y) accepts
Proof:
(1) If L = cfw_ x  y y = poly(x) and
Formal Languages, Automata, and Computation (FLAC)
CS 15453

Spring 2009
15453
FORMAL LANGUAGES,
AUTOMATA AND
COMPUTABILITY
Read sections 7.1 7.3 of the book for next time
TIME COMPLEXITY
OF ALGORITHMS
(Chapter 7 in the textbook)
COMPLEXITY THEORY
Studies what can and cant be computed under
limited resources such as time, spa
Formal Languages, Automata, and Computation (FLAC)
CS 15453

Spring 2009
15453
FORMAL LANGUAGES,
AUTOMATA AND
COMPUTABILITY
ATM = cfw_ (M,w)  M is a TM that accepts string w
HALTTM = cfw_ (M,w)  M is a TM that halts on string w
ETM = cfw_ M  M is a TM and L(M) =
REGTM = cfw_ M  M is a TM and L(M) is regular
EQTM = cfw_
Formal Languages, Automata, and Computation (FLAC)
CS 15453

Spring 2009
15453
FORMAL LANGUAGES,
AUTOMATA AND
COMPUTABILITY
ATM = cfw_ (M,w)  M is a TM that accepts string w
HALTTM = cfw_ (M,w)  M is a TM that halts on string w
ETM = cfw_ M  M is a TM and L(M) =
REGTM = cfw_ M  M is a TM and L(M) is regular
EQTM = cfw_
Formal Languages, Automata, and Computation (FLAC)
CS 15453

Spring 2009
15453
FORMAL LANGUAGES,
AUTOMATA AND
COMPUTABILITY
UNDECIDABILITY II:
REDUCTIONS
ATM = cfw_ (M,w)  M is a TM that accepts string w
ATM is undecidable: (constructive proof & subtle)
Assume machine H semidecides ATM
Accept if M accepts w
H( (M,w) ) =
Re
Formal Languages, Automata, and Computation (FLAC)
CS 15453

Spring 2009
15453
FORMAL LANGUAGES,
AUTOMATA, AND
COMPUTABILITY
* Read chapter 4 of the book for next time *
Lecture9x.ppt
REVIEW
A Turing Machine is represented by a 7tuple T
= (Q, , , , q0, qaccept, qreject):
Q is a finite set of states
is the input alphabet, wh
Formal Languages, Automata, and Computation (FLAC)
CS 15453

Spring 2009
15453
FORMAL LANGUAGES,
AUTOMATA AND
COMPUTABILITY
Lecture7x.ppt
Chomsky Normal Form
and
TURING MACHINES
CHOMSKY NORMAL FORM
A contextfree grammar is in Chomsky normal
form if every rule is of the form:
A BC
B and C arent start variables
Aa
a is a termi
15453: FLAC
K. Sutner
Solutions Assignment 5
Solution: Deterministic Simulation
Part A: 2Nondeterminism
Introduce two new dummy states d1 and d2 with transitions
(di , a) = cfw_(d1 , a, 0), (d2, a, 0)
If  (p, a) 1 add transitions to the dummy states
15453: FLAC
K. Sutner
Solutions Assignment 4
Solution: Uniformization
Part A: Uniformization
The idea is to pick the rst witness y such that R(x, y ) holds. More precisely, consider a primitive
recursive relation P (s, x, y ) such that R(x, y ) s P (s, x
15453: FLAC
K. Sutner
Solutions Assignment 3
Solution: Graphs of Computable Functions
Part A: Semidecidability
If a partial function f : N p N is computable we can enumerate a set G in stages s:
Stage s: compute fs (x) for x < s. If a computation converg
15453: FLAC
K. Sutner
Solutions Assignment 6
Solution: Word Shue
Part A: Disjoint
Let Mx , My be the trim DFAs for x and y (no sinks), respectively. We can identify the state sets
Qx and Qy of these machines with the prexes of x and y . The state set of
15453: FLAC
K. Sutner
Solutions Assignment 8
Solution: Decidability and CFG
Part A: Emptiness
Call a syntactic variable A useful if A x for some x . Clearly, the grammar generates a
nonempty language i S is useful.
To determine usefulness proceed by ind
15453
Midterm
1 of 3
15453: Midterm
March 1, 2011
Problem 1: Growth Functions and Decidability (25 pts.)
For any set A N we can dene its growth function fA : N N by
f (n) = cardinality of A cfw_0, 1, . . . , n 1
Clearly fA is nondecreasing and f (n) n.
15453
Midterm
1 of 12
15453: Midterm
Name:
March 1, 2011
Andrew ID:
Instructions
Fill in the box above with your name and your Andrew ID. Do it, now!
Answer in the allocated space. If need be, use the back of a page for scratch space. If you have made
15453: FLAC
K. Sutner
Solutions Assignment 10
Solution: Adding Numbers
Part A: NP
We can guess the subset I [n] and then verify correctness by performing the necessary summations.
Adding n k bit numbers produces a result with at most k + log n digits, s
15453: FLAC
K. Sutner
Solutions Assignment 9
Solution: Tag Systems
Part A: P1
We have the rewrites
asx xb
bsx xbaa
where s cfw_a, b, x cfw_a, b .
Now consider some string x of sucient length (short strings can be eliminated by brute force
computation). S
Formal Languages, Automata, and Computation (FLAC)
CS 15453

Spring 2009
15453
FORMAL LANGUAGES,
AUTOMATA AND
COMPUTABILITY
CONTEXTFREE GRAMMARS
AND PUSHDOWN AUTOMATA
NONE OF THESE ARE REGULAR
= cfw_0, 1, L = cfw_ 0n1n  n 0
= cfw_a, b, c, , z, L = cfw_ w  w = wR
= cfw_ (, ) , L = cfw_ balanced strings of parens
(),
Formal Languages, Automata, and Computation (FLAC)
CS 15453

Spring 2009
15453
FORMAL LANGUAGES,
AUTOMATA AND
COMPUTABILITY
MINIMIZING DFAs
THURSDAY Jan 24
IS THIS MINIMAL?
NO
0
1
1
1
1
0
0
0
IS THIS MINIMAL?
0
1
1
0
THEOREM
For every regular language L, there exists
a UNIQUE (up to relabeling of the states)
minimal DFA M su
Formal Languages, Automata, and Computation (FLAC)
CS 15453

Spring 2009
FLAC Assignment 2
Exercise 1. Use the construction given in
class or in Theorem 1.39 to convert each of
the two NFAs at the right into an equivalent
DFA.
Exercise 2. Are the following languages
regular? For each language, either give
an automaton1 that re
Formal Languages, Automata, and Computation (FLAC)
CS 15453

Spring 2009
Name:
FLAC Assignment 1
Please read all questions ASAP. If a question is unclear, please email the TAs.
Clarications may also be posted on the Assignments page of the course website.
Remember to staple together all pages of your completed assignment.
Exer
Formal Languages, Automata, and Computation (FLAC)
CS 15453

Spring 2009
FLAC Assignment 7
Exercise 1 Give a Turing machine with at most 12 states that doubles a number in unary
representation. You will lose points if you use extra states. It should be clear your solution
is correct; give explanation if necessary.
Exercise 2 (
Formal Languages, Automata, and Computation (FLAC)
CS 15453

Spring 2009
FLAC Assignment 6
Exercise 1. Give contextfree grammars that generate the following languages. In all parts
the alphabet is is cfw_0, 1.
a. cfw_w  w contains at least three 1s
b. cfw_w  w starts and ends with the same symbol
c. cfw_w  the length of w