# 2.1.3 What Is Meant by Data?

Printer-friendly version

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

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.[5]

This point of view can serve to define not only “high-level” data objects, such as rational numbers, but lower-level objects as well. Consider the notion of a pair, which we used in order to define our rational numbers. We never actually said what a pair was, only that the language supplied procedures `cons`, `car`, and `cdr` for operating on pairs. But the only thing we need to know about these three operations is that if we glue two objects together using `cons` we can retrieve the objects using `car` and `cdr`. That is, the operations satisfy the condition that, for any objects `x` and `y`, if `z` is `(cons x y)` then `(car z)` is `x` and `(cdr z)` is `y`. Indeed, we mentioned that these three procedures are included as primitives in our language. However, any triple of procedures that satisfies the above condition can be used as the basis for implementing pairs. This point is illustrated strikingly by the fact that we could implement `cons`, `car`, and `cdr` without using any data structures at all but only using procedures. Here are the definitions:

``````(define (cons x y)
(define (dispatch m)
(cond ((= m 0) x)
((= m 1) y)
(else (error "Argument not 0 or 1 -- CONS" m))))
dispatch)

(define (car z) (z 0))

(define (cdr z) (z 1))``````

This use of procedures corresponds to nothing like our intuitive notion of what data should be. Nevertheless, all we need to do to show that this is a valid way to represent pairs is to verify that these procedures satisfy the condition given above.

The subtle point to notice is that the value returned by ```(cons x y)``` is a procedure — namely the internally defined procedure `dispatch`, which takes one argument and returns either `x` or `y` depending on whether the argument is 0 or 1. Correspondingly, `(car z)` is defined to apply `z` to 0. Hence, if `z` is the procedure formed by `(cons x y)`, then `z` applied to 0 will yield `x`. Thus, we have shown that `(car (cons x y))` yields `x`, as desired. Similarly, `(cdr (cons x y))` applies the procedure returned by `(cons x y)` to 1, which returns `y`. Therefore, this procedural implementation of pairs is a valid implementation, and if we access pairs using only `cons`, `car`, and `cdr` we cannot distinguish this implementation from one that uses “real” data structures.

The point of exhibiting the procedural representation of pairs is not that our language works this way (Scheme, and Lisp systems in general, implement pairs directly, for efficiency reasons) but that it could work this way. The procedural representation, although obscure, is a perfectly adequate way to represent pairs, since it fulfills the only conditions that pairs need to fulfill. This example also demonstrates that the ability to manipulate procedures as objects automatically provides the ability to represent compound data. This may seem a curiosity now, but procedural representations of data will play a central role in our programming repertoire. This style of programming is often called message passing, and we will be using it as a basic tool in chapter 3 when we address the issues of modeling and simulation.

[5] Surprisingly, this idea is very difficult to formulate rigorously. There are two approaches to giving such a formulation. One, pioneered by C. A. R. Hoare (1972), is known as the method of abstract models. It formalizes the “procedures plus conditions” specification as outlined in the rational-number example above. Note that the condition on the rational-number representation was stated in terms of facts about integers (equality and division). In general, abstract models define new kinds of data objects in terms of previously defined types of data objects. Assertions about data objects can therefore be checked by reducing them to assertions about previously defined data objects. Another approach, introduced by Zilles at MIT, by Goguen, Thatcher, Wagner, and Wright at IBM (see Thatcher, Wagner, and Wright 1978), and by Guttag at Toronto (see Guttag 1977), is called algebraic specification. It regards the “procedures” as elements of an abstract algebraic system whose behavior is specified by axioms that correspond to our “conditions,” and uses the techniques of abstract algebra to check assertions about data objects. Both methods are surveyed in the paper by Liskov and Zilles (1975). [back]

Exercises

## Exercise 2.4

Here is an alternative procedural representation of pairs. For this representation, verify that `(car (cons x y))` yields `x` for any objects `x` and `y`.

``````(define (cons x y)
(lambda (m) (m x y)))

(define (car z)
(z (lambda (p q) p)))``````

What is the corresponding definition of `cdr`? (Hint: To verify that this works, make use of the substitution model of section 1.1.5.)

## Exercise 2.5

Show that we can represent pairs of nonnegative integers using only numbers and arithmetic operations if we represent the pair a and b as the integer that is the product 2a 3b. Give the corresponding definitions of the procedures `cons`, `car`, and `cdr`.

## Exercise 2.6

In case representing pairs as procedures wasn’t mind-boggling enough, consider that, in a language that can manipulate procedures, we can get by without numbers (at least insofar as nonnegative integers are concerned) by implementing 0 and the operation of adding 1 as

``````(define zero (lambda (f) (lambda (x) x)))

(lambda (f) (lambda (x) (f ((n f) x)))))``````

This representation is known as Church numerals, after its inventor, Alonzo Church, the logician who invented the λ calculus.

Define `one` and `two` directly (not in terms of `zero` and `add-1`). (Hint: Use substitution to evaluate `(add-1 zero)`). Give a direct definition of the addition procedure `+` (not in terms of repeated application of `add-1`).

### Beats By Dre Monster

SYNC by 50 If you’re like most of us, you woke up one morning this week and realized it’s almost December,SYNC by 50 and the holidays are swiftly approaching. STREET by 50 And, of course, you still don’t know what to get a few people on your list.We all know that headphones are a dime a dozen. STREET by 50 But a headphone that receives equal points for style and functionality, however, is a rare find. sms by 50 Some of our friends in the press know SMS Audio headphones fit the bill, sms by 50 and recommend you put them on your holiday shopping list this year: Beats By Dre Monster Rolling Stone included the limited edition Yellow STREET by 50 over-ear headphones in its 2012 holiday gift guide featured in the December issue.Beats By Dre MonsterWhat did Rolling Stone have to say about SMS Audio?
http://www.smsby50-beatsbydre.com/

### http://www.armaniwatchescollection.co.uk

At 73 years old,Birkenstock outlet he is still busy birkenstock kairomaking people look good. Giorgio Armani is one of the preeminentBirkenstock UK Italian fashion designers in the world,birkenstock homme still goingbirkenstock france strong after 33 years in the birkenstock kairoindustry. Known for his classically tailored, sleek power suits and clean,armani watches high quality fabrics, everyone from the who’s who of Hollywood to the bankers onarmani watches uk Wall Street have fallen in love with the Armani brand. Now, with over \$1.5 billion armani ceramicain revenue and a retail empire that extends to more than 35 countries, Armani himself continues to maintain full control over his business. However, it has been a long, uphill journey for the designer to get where he is today.

### beats by dre clearance

cheap monster beats Before I tell you about my experience, cheap monster beats let me tell you a bit more about these headphones. beats by dre solo According to the information I’ve read, Dr. beats by dre solo Dre worked with Monster Cable and Robert Brunner, dre beats an industrial designer, dre beats for more than two years to perfect these headphones. beats by dre clearance In Dr. Dre’s words,People aren’t hearing all the music beats by dre clearance.

### http://www.tawts.com/solo-hd-c-11.html

When explained, these details are ridiculously {simple|easy|easy|effortless|cozy By having your journal http://www.thelandconservancyforscc.org/ with you, you’ll always know http://www.cbin.org/ what is coming up and what has to be done. Neptune moves around the Sun in one elliptical alternatively oval-shaped orbit; its orbit period surrounded Uggs aboard saleuggs outletcheap uggs years is 163. Now you ambition absence all your visualization skills. Although, carrying these names nearly underneath your arm always day may demand a second glance. Their mobiles are created so that the elements are among constant motion meanwhile the always mobile maintains a harmonic balance.Usefulness: Whatever you’d like to be, do or have among life, you mustmatch its energy-vibrationwithin order toattract it into your life. False, they do not assistance find a National Champion. Other kid who are hospitalized or simply unable apt geographically attend educate often opt because these curriculums. He contacted Russian-born designer Lilia Berzon and asked her if she would be interested surrounded making a special couture robe to be modeled aboard the runway for a special madame Louis Vuitton disconnect the mini monogram linehe ultimate events amid the 20th century were the loosen of the mini monogram line {in|among|surrounded|within|among|amid 1999, the opening of the {first|1st|1st store {in|among|surrounded|within|among|amid Africa {in|among|surrounded|within|among|amid Marrakech, Morocco {in|among|surrounded|within|among|amid 2000, and finally the auction {at|by the International Film Festival {in|among|surrounded|within|among|amid Venice, Italy, where the vanity {case|circumstance|circumstanceamfAR designed by Sharon Stone was sold with the {proceeds|earnings|income|earnings going {to|apt The Foundation {because|for AIDS Research {also|likewise|likewise {in|among|surrounded|within|among|amid 2000). * The higher the {pressure|oppression|cruelty|oppression|suppression the more {effectively|mainly|chiefly|mainly|primarily the steam {is|namely driven into the {fabric|cloth|cloth|napkin
http://www.tawts.com/solo-hd-c-11.html http://www.tawts.com/solo-hd-c-11.html

### http://www.carfreecalculator.org

This chic accessoy has a {steep|soak|drench|soak\$42,000 pice name http://www.minijpeg.com/ apt http://www.deshasthmatrimony.com/ match its eevated stye. Now take into catalogueyour pantryyou costa whole lot of periodthere cooking and eating. ) They constantlyhearaptUggs aboardsaleuggs outletcheap uggs. The moviestoe opened amongMichae went bonkes amongthe fom of ocation fo medica maijana home chefs, aong with a pan that wi ses cod possiby pchase anything that these peope wished fo withot any ae making money handbags made p of noma vaiety of ctivating cannabis. The World namelya modern classic,oneode aptthe moviegame crowdand allof the self-centered slacker protagonists out there, presenting audiences with a visually astounding pieceof cinema that may notacquaintthe maximumbythe boxbureauthis weekend,merelywantnaturallybe considered a cinematic milestone foryears aptcome. While he has spent maximumof his vocationdesigning alternativelydelivering training, he was also a Vice-President of Sales of a training and evolutionfranchise with operations among25 markets. }}}}}}}}}}}}}}}
http://www.carfreecalculator.org http://www.carfreecalculator.org/