CMPSCI 250: Introduction to Computation

David Mix Barrington

Spring, 2006

Homework #5 Questions and Answers

Question 5.2, 11 April 2006

We have a recursive solution to problem 4.11.2, but we can't figure out how to get it into the form given except by guessing.

Guessing is the way to go -- there are formal techniques to "integrate" the pizza function to get the cheese function, but you don't know about them. (If you're interested, look at Excursion 7.3, which we're not doing this term.) You need a function in cubic form that fits the values you have, and you can find that by using the values you've computed for n = 1, 2, 3, and 4 and solving for a, b, c, and d so that an3 + bn2 + cn + d works for those values of n. Then all you have to do is prove by induction that this cubic polynomial satisfies the recursive solution you found.

Question 5.1, 11 April 2006

Could you explain problems 5.2.5 and 5.5.3 more clearly? We don't understand what an almost periodic language is.

Think of a language L over {a} in terms of the sequence of answers to the questions "is a0 in L", "is a 1 in L", "is a 2 in L", and so forth. Here's an almost periodic language:

{a, aaaa, aaaaaa, aaaaaaaa, aaaaaaaaaa,...}

where the answers to the questions above are:

N, Y, N, N, Y, N ,Y, N, Y, N, Y,...

and the "..." means that it will continue "Y, N" forever.

A periodic language would be one that was repetitions of the same finite sequence from the beginning. This language doesn't have that property, but after n=4 it is just repetitions of "Y, N".

Now look at the definition of "almost periodic". This language has the property that if i>3, we can tell whether ai is in L just by looking at i%2 -- if i is even then ai is in L, and if i is odd then it isn't. For i≤3 we have to consider each case separately. This fits the definition of an almost periodic language with t = 3 and q = 2.

Here's another example:

Y, Y, N, N, N, N, Y, N, N, N, Y, Y, N, Y, Y, N, Y, Y, N, Y, Y, N,...

where the "..." means that the "Y, Y, N" goes on forever. (Remember that this means that the i's for which ai is in L are 0, 1, 6, 10, 11, 13, 14, 16, 17, 19, 20,...)

Can you give the t and q for this language? Then, can you give a regular expression for this language? (Section 5.2.4 of the book might help.) Then you need to explain how for an arbitrary almost periodic language, you can take t, q, the set of moduli for i>t, and the special cases for i≤t, and use these to get a regular expression for the language.

Last modified 12 February 2006