### SICP of the Day 12/14

Today’s post comes after the heading “What Is Meant By Data?” The context is a rational number arithmetic package introduced at the beginning of the chapter.

We began the rational-number implementation in section 2.1.1 by implementing the rational-number operations

`add-rat`

,`sub-rat`

, and so on in terms of three unspecified procedures:`make-rat`

,`numer`

, and`denom`

. At that point, we could think of the operations as being defined in terms of data objects — numerators, denominators, and rational numbers — whose behavior was specified by the latter three procedures.But exactly what is meant by data? It is not enough to say “whatever is implemented by the given selectors and constructors.” Clearly, not every arbitrary set of three procedures can serve as an appropriate basis for the rational-number implementation. We need to guarantee that, if we construct a rational number

`x`

from a pair of integers`n`

and`d`

, then extracting the`numer`

and the`denom`

of x and dividing them should yield the same result as dividing`n`

by`d`

. In other words,`make-rat`

,`numer`

, and`denom`

must satisfy the condition that, for any integer`n`

and any non-zero integer`d`

, if`x`

is`(make-rat n d)`

, then`(numer x) n --------- = - (denom x) d`

In fact, this is the only condition

`make-rat`

,`numer`

, and`denom`

must fulfill in order to form a suitable basis for a rational-number representation. In general, we can think of data as defined by some collection of selectors and constructors, together with specified conditions that these procedures must fulfill in order to be a valid representation.