-3

Is the term "procedure" synonymous with the term "operation" in SICP or not? (For example in the chapter below.) If they are not the same, what is the difference and why?

More specifically, what is the difference between "compound operation" and "compound procedure" ? Is there any ?

SICP Chapter 1.1.4 Compound Procedures

Here is an other related chapter from the book :

SICP Chapter 1.2 Procedures and the Processes They Generate

It seems to me that in these contexts the term "operation" in SICP refers to an arithmetic operation (as no other kind of operations - whatever they may be in general - were used in the examples so far).

Rainer Joswig
  • 136,269
  • 10
  • 221
  • 346
jhegedus
  • 20,244
  • 16
  • 99
  • 167
  • I saw your earlier question, as well as this one. While it's commendable to try to make sure you understand the details of the text that you're reading, it may be very useful, when you come across terms like these, to keep reading for a while, and then reviewing the place where the term originally occurred. Later on in the SICP book, you'll find an implementation of the language, and that will make some of these concepts much clearer (since you're reading the implementation of them). Not all of these terms are precise mathematical definitions, though. – Joshua Taylor Aug 19 '14 at 20:57
  • 1
    I see your point and I thank you for the advice, I try to follow it. I was just assuming that such a highly regarded book as SICP is precise with respect to its use of the terminology and the terms they use have a clear definition. I, personally, would not write a technical text in which the terms I use are not clearly explained the first time I use them, unless the meaning of those terms is clear to the reader aquainted with the field. However, since SICP is an introductory text I would have expected clear definitions of the terms given at the first occurance of the term. – jhegedus Aug 20 '14 at 07:13
  • 2
    @jhegedus I think SICP is not a technical text per se. :) They start using Scheme without even explaining what it is. – Will Ness Aug 20 '14 at 08:33
  • 1
    @jhegedus That's an entirely reasonable expectation for some types of technical texts. However, different texts do take different approaches; some take a more Socratic approach in which concepts are developed and refined a bit more organically until a good, precise definition is teased out. (*The Little Schemer* is another good example of this.) In my opinion, SICP has to take an approach something like this because in the later parts of the book where you'll be *implementing* a Scheme, you get to see how different implementation of the language lead to different behaviors (literally, ... – Joshua Taylor Aug 20 '14 at 11:51
  • 1
    different *structures* and *interpretations* of computer programs). E.g., it can be tricky to pin down "what is a cons cell" because there are lots of ways of implementing it. Or "what is a variable binding", because different approaches to implementation lead to dynamic scoping, or to lexical scope and lexical closures. Terms that are specific to the implementation of a language are left a bit vague because things could be done differently. – Joshua Taylor Aug 20 '14 at 11:53
  • Thank you for the advice, I think I see your point, hopefully the meaning of vaguely defined terms will become clearer as I dive into the text deeper and deeper. – jhegedus Aug 20 '14 at 13:55
  • 2
    This question is being discussed on Meta: http://meta.stackoverflow.com/q/284577/3001761 – jonrsharpe Jan 27 '15 at 10:43
  • 1
    Looks like your question got bit by the [Meta Effect](http://meta.stackoverflow.com/questions/251487/getting-to-know-stack-overflows-voting-culture). – JDB Jan 28 '15 at 18:18
  • yeah, the absurdity is quite entertaining actually... :) – jhegedus Jan 28 '15 at 23:17
  • 1
    The images make this question whole. – jhegedus Jan 29 '15 at 15:52
  • Can I protect this question from trolls editing the images out of it ? – jhegedus Jan 29 '15 at 15:53
  • No he is not, but there was someone before who just took out the images without putting anything in place of them. Well, lets hope this question can find some peace finally. – jhegedus Jan 29 '15 at 18:40
  • @JoshuaTaylor ["\[different\] *structure**s*** and *interpretation**s*** of computer programs"](https://stackoverflow.com/questions/25389640/sicp-terminology-difference-between-procedure-and-operation/25392668#comment39624128_25389640)... suddenly this has cast a new light onto the book's meaning for me. this could have been a much better title for the book, too. thanks for that! :) – Will Ness Jan 24 '20 at 08:17

2 Answers2

6

An "operation" whether primitive or compound, is some actual computation like addition, say in an assembly code of a compiled program, just like a number is an actual computational object, an entity in computer memory.

A "procedure" is part of a programming language, which expresses/describes operations. A programming language lets us define procedures which express some primitive operations, and by means of combining them, some more complex operations:

(define (sum x y) (+ x y))   ; a procedure expressing  primitive operation

(define (sum-squares x y)    ; a procedure describing a more complex operation
    (+ (* x x) (* y y)))     ;  defined by means of combining the operations
Will Ness
  • 70,110
  • 9
  • 98
  • 181
  • Let us denote the set of operations by O and the set of procedures by P. Is there an injective function from P to O? http://en.wikipedia.org/wiki/Injective_function – jhegedus Aug 20 '14 at 05:23
  • What about non terminating procedures? Do they have a corresponding operation ? Or is the correspondig operation bottom? – jhegedus Aug 20 '14 at 05:25
  • 2
    "Is there an injective function from P to O?" obviously not: `(define (double1 x) (* x 2))` and `(define (double2 x) (* x 2))` both describe the same operation. – Will Ness Aug 20 '14 at 08:05
  • "does a non-terminating procedure correspond to some operation?" I think yes, to a non-terminating one, e.g. `(define (f) (f))` would correspond to `LOOP: goto LOOP;` or something. When talking about such a procedure we could say that it is "bottom" as it describes a non-terminating computing process. I think there is no "bottom" in real life as we (people) could always (theoretically) inspect the state of the computer at any given moment, whether it's finished yet or not. Or press the reset button. :) – Will Ness Aug 20 '14 at 08:30
  • Thank you Will! Your comment on the non-existence of an injective function from P to O really helped my understanding of how procedures and operations relate to each other! – jhegedus Aug 20 '14 at 14:00
  • on the other hand, if we write it this way: `(define double1 (lambda (x) (* x 2)))` and `(define double2 (lambda (x) (* x 2)))`, which is how it actually is processed by Scheme, then it looks like I was wrong - the procedure is the same, it's just that several bindings are made to refer to the same procedure. – Will Ness Aug 20 '14 at 15:27
  • also, are `(lambda(x) (* x 2))` and `(lambda(x) (+ x x))` different procedures? obviously they describe different operations, but as a function they are indistinguishable. Although there might be a very slight difference in execution times. – Will Ness Aug 20 '14 at 15:31
  • I guess I just have to accept that the meaning of some terms in SICP is a little bit unclear at times, somewhat disappointing because the book was recommended by Martin Odersky. I was hoping it is only me who does not know the difference between operation and procedure because my background is physics and not computer science, this is why I asked this question here, hoping that the precise meaning of these terms is well known to some computer science veterans. – jhegedus Aug 20 '14 at 19:00
  • I still think what I wrote in the answer is correct. I meant that my *comment* was wrong, about the isomorphism between procedures and operations. Looks like there is one. (yes isomorphism because Scheme is Turing complete, so any operation can be expressed in it). – Will Ness Aug 20 '14 at 20:28
1

Numbers and arithmetic operations are primitive data and procedures.

How I read that is that Numbers map to primitive data and arithmetic operations map to procedure. Thus operations are procedures.

In a combination like (* 2 3), * is called the operator while 2 and 3 are called the operands (arguments). The operator is a procedure.

Later on they introduce conditionals (cond, if) but never call them operations.

Sylwester
  • 47,942
  • 4
  • 47
  • 79
  • So operations are built in (predefined) arithmetic procedures? – jhegedus Aug 19 '14 at 19:20
  • Not quite. Operations are procedures. arithmetic is just an adjective so it narrows something down. Thus not all operations are arithmetic and those who are not cannot be arithmetic procedures but they still are procedures. Also they use the term compound operation and compound procedure that indicate that both can be either predefined of user defined. I think they user operations as synonym for procedures just to increase the understanding and it might have backfired for you. – Sylwester Aug 19 '14 at 19:32