Part 1: Regular Expressions


a)  Construct a regular expression on the set A = {a, b, c} who associated regular set is the following:


{ L, ab, ac, abab, abac, acab, acac, ababab, ababac, abacab, abacac, acabab, acabac, acacab, acacac, abababab, ...}













b) Describe the set of binary values constructed from the following regular expression over the set {0, 1}


(10)* 0


Part 2: Matrices


     Let A = 1   2  3       B = -2  0  5      C = 1  0           D  =  1  1         E  =  1  0  1

                   0  2  4                7  1  0            1  1                    0  0                  1  0  1

                                                                   1  1                   1  1        


a) A + B






b)  AT






c)  A * B






d)  A * C







e)  C v D






f)  C ^ D





g)  C o E (o means boolean multiplication)

Part 3: Logic


a)  Give truth tables for the two expressions:


(P ^ Q) v R                                                                  (~P v ~Q) ->  R


















b)  Give an example of a predicate, P(x), on the natural numbers {0, 1, 2, 3, ...} that is always true.






c)  Give an example of a predicate, Q(x), on the natural numbers {0, 1, 2, 3, ...} that is always false.






d)  Give an example of a predicate, R(x),  on the natural numbers {0, 1, 2, 3, ...} that is sometimes true, sometimes false.


Part 4:  Computer exercise.


Use the given Direction and Location classes in Java and write a method, enumerate, that enumerates all elements of type Location. These classes specify directions and locations in an integer numbered grid, as might be used in various simulations.


That is, enumerate takes a single non-negative integer, numToList, as a parameter and returns a list of that number of locations. The list returned by a call with numToList = n+1 should return the same list as a call with numToList = n with one additional location appended.


public static ArrayList<Location> enumerate (int numToList)


enumerate should be defined so that for any element of the type Location, if k is large enough, that element will appear in the list.


Complete your enumerate method in the given driver class TestLocDir.


Write a proof that your method will enumerate all instances of Location.


Classes defining Direction, Location and a driver class are given in the following files: