CMPSCI 250: Introduction to Computation

David Mix Barrington

Fall, 2004

Question and Answers on HW#2

Due on paper in class, Friday 24 September 2004

Questions are in black, answers in blue

Question #6, 22 Sept 2004

In Problem 2.3.3, what's a "proper subset"? And how should I parenthesize "∀a:∀b:P(a)→Q(b)"?

Set A is a proper subset of set B if A is a subset of B but A is not equal to B. Equivalently, all elements of A are in B but at least one element of B is not in A. This definition got left out of Section 1.1, sorry.

Usually, unless there are other parentheses involved, the scope of a quantifier extends to the end of the statement. So this statement would be correctly parenthesized as "∀a:∀b:[P(a)→Q(b)]".

Question #5, 22 Sept 2004

In Problem 2.6.2, I don't agree with the symbolic translation of "None of my ideas about Bath-Buns are worth writing down" as "∀x:B(x)→WWD(x)". I think it should be "∀x:B(x)→¬WWD(x)". Am I right, and if so which version is meant in the problem?

You are right, because "None of my ideas about Bath-Buns are worth writing down" means "For any of my ideas, if they are about Bath-Buns, they are not worth writing down." This is what your symbolic statement says, not what mine says. Heinlein's English text is what is meant. My symbolic translation of the second premise is wrong and should be corrected as you say, by inserting a ¬ before "WWD(x)".

Question #4, 22 Sept 2004

In answer to question #2 below you said that n in Problem 1.10.4 was a natural. But aren't we writing real Java here, rather than your pseudo-Java?

Quite right, in real Java n should be an int or a long. Either real or Pseudo-Java code is acceptable for this problem.

Question #3, 21 Sept 2004

Can you help me with the types in Problem 2.1.3? What are A and B in terms of Java?

Good question, this could have been clearer. Let's say that there are Java classes AElement and BElement representing elements of the sets A and B respectively. Since these are objects rather than primitives, you should test them for equality with .equals rather than ==. So the return type of getFirst() is AElement and the return type of getSecond is BElement.

Also, I didn't say how your method gets the array L. Since it's already a static method, let's say that it gets a third argument whose type is Pair [] or "array of Pairs".

Question #2, 21 Sept 2004

In Problem 1.10.4 (a), is the variable "n" an integer or a string?

It is a natural. I tend to use the same letters for the same types, so i, j, k, and n are usually naturals, u, v, and w usually strings, and so on. But see the answer to Question #4 above.

Question #1, 20 Sept 2004

I don't know where to start with 1.10.4, can you give me any hints?

Remember that a Java array A has elements indexed starting with A[0] and going through A[A.length - 1]. The number of elements is A.length, which does not have parentheses. Here you're given an array of ints and asked whether the array has the property that the elements increase by one each time. So on "[3,4,5,6,7]" you would return "true", and on [3,4,4,5,6] you would return "false". Your method takes the array as input and returns a boolean.

Last modified 22 September 2004