home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / function / 936 < prev    next >
Encoding:
Text File  |  1992-07-21  |  6.4 KB  |  148 lines

  1. Newsgroups: comp.lang.functional
  2. Path: sparky!uunet!mcsun!sun4nl!wn1.sci.kun.nl!cs.kun.nl!daniel
  3. From: daniel@cs.kun.nl (Daniel Tuijnman)
  4. Subject: Re: Bird-Meerten Formalism
  5. Message-ID: <1992Jul21.130843.16294@sci.kun.nl>
  6. Keywords: Program Derivation, Calculational Approach
  7. Sender: news@sci.kun.nl (NUnet News Owner)
  8. Organization: University of Nijmegen, The Netherlands
  9. References: <1992Jul17.050148.23871@cse.iitb.ernet.in> <1992Jul17.142218.7319@sci.kun.nl> <1992Jul20.160706.10025@cs.ruu.nl>
  10. Date: Tue, 21 Jul 1992 13:08:43 GMT
  11. Lines: 135
  12.  
  13. In article <1992Jul20.160706.10025@cs.ruu.nl> nico@cs.ruu.nl (Nico Verwer) writes:
  14. >In <1992Jul17.142218.7319@sci.kun.nl> daniel@cs.kun.nl (Daniel Tuijnman) writes:
  15. >>The current situation is that the proponents of BMF make heavily use of
  16. >>category theory; Fokkinga shows in his PhD thesis [Fok92] nicely how
  17. >>categorical "arrow chasing" can be translated into calculations.
  18. >
  19. >Don't say that! Maarten Fokkinga is absolutely against diagram chasing
  20. >(which is what you mean by `arrow chasing'). Instead, all his proofs are
  21. >equational, which is much more concise. It takes some time to get used
  22. >to, however.
  23.  
  24. Actually, that is what I meant to say. And I agree with you
  25. wholeheartedly, that Maarten's proofs are much more elegant.
  26.  
  27. >>>5. What is the criteria that a given formalism should possess?
  28. >
  29. >It should be correct, and it should be usable. If this is important for
  30. >you, use BMF. If, on the contrary, your criterium is that there is an
  31. >implementation on your favorite machine, use CIP.
  32.  
  33. We don't think you're being serious here. Are you referring to the CIP-S
  34. system? That does indeed give machine support for carrying out the
  35. transformations, but certainly doesn't produce executable code.
  36.  
  37. The distinction you draw here between BMF and CIP sounds very strange to
  38. me. Both methods have their merits in their own right, but they are
  39. aimed quite differently, as we pointed out in our previous post.
  40.  
  41. Both BMF and CIP are defined formally, and their transformation rules
  42. are correct. Usability applies to both methods, as numerous examples
  43. demonstrate. Yes, as far as manipulating functional programs, e.g.
  44. transforming one recursion pattern to another, is concerned, BMF has
  45. done a great deal more than CIP, and has developed a much conciser (and
  46. elegant, and at last uniform) notation. But this is due to the
  47. deliberate restriction of BMF to functional programming -- which we do
  48. not condemn, but merely state as a fact that is relevant for the
  49. comparison above. 
  50.  
  51. Within functional programming, both methods do have the same power. We
  52. challenge you to present us a BMF law which cannot be expressed as a CIP
  53. transformation rule.
  54.  
  55. >>CIP on the other hand, is meant as an overall method for program
  56. >>development [Boi92e]. One first specifies an algebraic data type -- 
  57. >>without the BMF constraint of polynomial types -- and then has several 
  58. >>layers of expression constructs for making programs over these data types. 
  59. >
  60. >If you can give an example of a datatype which uses non-polynomial
  61. >constructors, I would be very interested! All datatypes occurring in
  62. >current programming languages, however, are polynomial.
  63.  
  64. You're right about the latter. But for instance bags (multisets) or (finite)
  65. sets are not expressible as a polynomial datatype, since additionally
  66. laws are needed to express commutativity and idempotency. Certainly, under some
  67. conditions, they can be represented by one (e.g., finite sets over an ordered
  68. carrier set as ordered sequences without multiple occurrences), but this
  69. has not been a topic of research within BMF. With respect to datatypes
  70. with laws, only Chapter 5 of Maarten Fokkinga's PhD-thesis comes to mind,
  71. which certainly is promising for the future. But then, to actually
  72. implement these datatypes with laws in an everyday programming language,
  73. you still need some kind of representation theorem in order to obtain an
  74. isomorphism between the datatype with laws and a (subset of a) purely
  75. polynomial datatype.
  76.  
  77. >>Thus one can start program development with a very abstract
  78. >>specification and step-by-step transform this into a concrete,
  79. >>executable program. An overview over the method is given in [Par90a].
  80. >>Since all language layers (algebraic, descriptive, functional,
  81. >>imperative) are combined in one, formally defined, language [CIP85], 
  82. >>the transformations from one layer to another are correct.
  83. >
  84. >I don't see how this can guarantee correctness. I think that you always
  85. >have to prove correctness of the transformation steps yourself. 
  86.  
  87. No! Just like in BMF, CIP transformational rules are of the form
  88.       condition(s)   =>   E1 = E2
  89. Furthermore, some rules establish a refinement between E1 and E2, which
  90. is not possible in BMF as it has no nondeterministic constructs.
  91. Here, E1 and E2 are *expression schemes* rather than expressions. After
  92. matching E1 (or E2 for that matter) with your actual expression, giving
  93. a substitution s, and checking the condition(s), the actual
  94. transformation step s(E1) --> s(E2) can be established. So, not the
  95. transformation *steps* have to be proven correct, only the general
  96. transformation *rules*.
  97.  
  98. > ... It
  99. >doesn't really matter if you use one language or more, in this respect.
  100.  
  101. In theory you're right. But it can be quite a pain in the ass to try to
  102. make an "interface" of transformation rules between two completely 
  103. different languages. In view of that, a wide spectrum language
  104. comprising various layers which have been tuned to one another, like
  105. CIP-L, gives better support to program development than using a
  106. different language for every layer. For example, in CIP-L,
  107. transformation from (tail)recursive functional programs to imperative,
  108. iterative programs is straightforward:
  109.  
  110.     f:: m -> r
  111.     f x = H(x),    if B(x)
  112.         = f (K(x)), otherwise
  113.  
  114.         ^
  115.         |
  116.         ----+----
  117.         |
  118.         v
  119.  
  120.     function f (x : m) r;
  121.       begin
  122.         var vx : m := x;
  123.         while not(B(x))
  124.         do vx := K(vx);
  125.         f := H(vx)
  126.       end;
  127.  
  128. where for the sake of clarity, for the functional program a Miranda-like
  129. syntax is used, and for the imperative part Pascal-like syntax.
  130. Furthermore, B, H and K are arbitrary expressions only containing x as
  131. free variable. The double arrow means that both programs are
  132. equivalent.
  133.  
  134. >It helps if your language is formally defined (it helps even more if it
  135. >is simple, like BMF), but that doesn't take away the proof obligations.
  136.  
  137. It helps? I should say, it is an absolutely necessary prerequisite to
  138. have it formally defined.
  139.  
  140. Greetings,
  141.  
  142. Daniel Tuijnman            Max Geerling
  143. daniel@cs.kun.nl        max@cs.kun.nl
  144. -- 
  145. Daniel Tuijnman
  146. daniel@cs.kun.nl
  147.  
  148.