[General boards] [Fall 2018 courses] [Summer 2018 courses] [Winter 2018 courses] [Older or newer terms]

Question about Exercise 417


#1

In Exercise 417 below (and I suppose in general for data transformer questions), I do not understand how to come up with the data transformer. How was the solution to a) reached? And why were variables i and j used?
Thanks in advance.


#2

Here is my attempt. In this exercise, we already have the 8 operations implemented using the two binary implementer’s variables a and b. Now instead of using those two binary variables, we want to re-implement the 8 operations using integer variables. We want to achieve this by using the integer value 0 to represent the binary value false, and by using any non-zero integer value to represent the binary value true. Since there are two binary implementer’s variables, we will introduce one new integer implementer’s variable for each binary variable, and call them i and j.

A data transformer is a binary expression that relates the new implementer’s variables, in this case, i and j, to the old implementer’s variables, in this case, a and b. The relationship is already described informally in English in the question. So we formalize that in binary expression. In the solution, the first conjunct says a is true if and only if i is non-zero. Similarly, the second conjunct says b is true if and only if j is not zero.

I guess in general, for data transformation question, the relationship would be given to you in English. To come up with the data transformer, think of what new implementer’s variables to use and formalize the relationship in binary expression.