|
This is one of the trickier ones. You're unconditionally right that the second type cannot represent the first. Given a member of A, an object of the first type produces both a member of B and a member of C. The second type produces one or the other. Clearly, there's no sensible way in general for a member of B to represent both an element of B and a member of C. (For some particular values of B and C there are tricky ways to do this, but no general way.) If you like to nail these nonrepresentation results with a numerical calculation, let A have 2 members, and let each of B and C have 3 members. Then the first type has (3^2)*(3^2)=9^2=3^4=81 members. The second type has (3+3)^2=6^2=36 members. No way can 36 things represent 81 things. The question about the first type representing the second is the tricky one. It depends on precisely what criteria we use. Technically, if one of B or C is empty or has only one member, then there can be no representation for numerical reasons. E.g., let A have 2 members, but let B and C have one member each. Then the first type has (1^2)*(1^2)=1 member, but the second type has (1+1)^2=2^2=4 members. As long as both B and C have 2 or more members, then the first type has at least as many members as the second type, and there is theoretically some sort of representation. But it's questionable whether there is a computationally sensible one. Given a member of A, an object of the first type can produce a member of B and a member of C, but how can it tell us which one is the relevant one? That is, how do you encode the mark part of B+C? You can do it, but it's tricky. If members of B and C are to represent themselves (which is mighty natural and convenient), then the mark must be encoded into some sort of relationship between a member of B and a member of C. For example, if B=C, then two equal values could represent one mark, and unequal values could represent the other. But you must know something about the internal structure of B and C to define the representation. From another angle, a nice structurally uniform representation of the second type by the first would work even for the degenerate cases where B and C have 1 or 0 members. This is an application to types of the same principle that says that a program on lists is cleaner if it works uniformly on the empty list as well as lists with something in them. Since there is no representation at all for the extreme cases, there can't be a really clean and uniform representation. On this question, I would accept any answer that's based correctly on a self-consistent point of view. I didn't ask anything this subtle about datatype representation on this year's exam (in some previous years, we spent more of our effort on the representation question). To complete the picture, notice that the two types (A->B)->(A->C)and A->(BxC)are equivalent in the sense that each can represent the information in the other. Mike O'D. |
what was the numerical conversion again? by Gary Yeung, 2000, Dec 04
to: