home *** CD-ROM | disk | FTP | other *** search
/ ftp.umcs.maine.edu / 2015-02-07.ftp.umcs.maine.edu.tar / ftp.umcs.maine.edu / pub / WISR / wisr6 / proceedings / ascii / yakhnis.ascii < prev    next >
Text File  |  1993-10-19  |  16KB  |  307 lines

  1.     Yakhnis - 1
  2.  
  3.  
  4. Reusing Program Derivation Techniques and 
  5. Correctness Proofs via Generic Algorithms
  6.  
  7.  
  8. Vladimir R. Yakhnis
  9.  
  10. Tel: (607) 752-5051
  11. Email: vlad@gdlvm7.vnet.ibm.com
  12.  
  13. Joel A. Farrell
  14.  
  15. Tel: (607) 752-5046
  16. Email: farrellj@gdlvm7.vnet.ibm.com
  17.  
  18. Steven S. Shultz
  19.  
  20. Tel: (607) 752-5048
  21. Email: shultzss@gdlvm7.vnet.ibm.com
  22.  
  23. IBM Corporation
  24. Dept. G37/16-3
  25. 1701 North Street
  26. Endicott, NY 13760
  27. Fax: (607) 752-5803
  28.  
  29.  
  30. Abstract
  31.  
  32. We suggest that the notion of reuse be extended to Dijkstra-Gries 
  33. techniques of deriving programs from their specifications.  The formal 
  34. derivation and proof of programs as is practiced today is a very powerful 
  35. tool for the development of high quality software.  However, its application 
  36. by the software development community has been slowed by the amount of 
  37. mathematical expertise needed to apply these formal methods to complex 
  38. projects and by the lack of reuse within the framework of program 
  39. derivation.  To address these problems, we have developed an approach to 
  40. formal derivation that employs the new concept of generic algorithms.  A 
  41. generic algorithm is an algorithm which has 1) a formal specification; 2) a 
  42. proof that it satisfies this specification; and 3) generic identifiers 
  43. representing types and operations.  Using them, most software developers 
  44. need to know only how to pick and adapt generic algorithms, rather than 
  45. perform more technically challenging tasks such as finding loop 
  46. invariants and deriving loop programs.  The adaptation corresponds to 
  47. replacing the generic identifiers by concrete types and operations.  In 
  48. addition, this new methodology provides the developer with a form of reuse 
  49. of program derivation techniques, correctness proofs and formal 
  50. specifications.
  51.  
  52. Keywords: program derivation, proof of correctness, generic algorithm, 
  53. formal specification
  54.  
  55. Workshop Goals: discussing reuse of derivation techniques, correctness 
  56. proofs and formal specifications, discussing application of generic 
  57. algorithms within the framework of object orientation
  58.  
  59. Workshop Groups: reuse and formal methods, reuse and OO methods, tools 
  60. and environments
  61.  
  62. 1    Introduction
  63. The program development approach taught by the Dijkstra-Gries school is also 
  64. known as ╥calculational╙.  Indeed, as illustrated in [6], the best beginner's book 
  65. on the subject, programs could be calculated from the specifications in a 
  66. rigorous and elegant way.  In [15], a book intended for intermediate and 
  67. advanced students, many difficult programs are calculated from the 
  68. specifications.  Of course, anyone interested in the subject should also look 
  69. into classical [10].
  70. Since the DO-loop is the most difficult programming element, this school 
  71. mostly concentrates on extracting ╥candidates╙ for the loop invariants from 
  72. the specifications.  Once a good candidate is found, the loop guard and the 
  73. loop body are ╥calculated╙ around it.  If the calculation is unsuccessful, 
  74. another candidate will be sought.  This methodology is very powerful.  
  75. However, it is not free of disadvantages:
  76. 1)    To efficiently utilize the methodology, one has to have certain 
  77. mathematical skill.  An ability to prove simple logical assertions may not 
  78. be enough;
  79.  
  80. 2)    When reasoning about the program on the level of invariants a great deal 
  81. of programming intuition is lost.  For instance, while looking into the 
  82. elegant Kaldewaij's solution of maxsegsum problem, one could have a 
  83. ╥gut╙ feeling that we are dealing with a recursively defined function.  But 
  84. it is never explicitly seen behind the manipulations with formulas;
  85.  
  86. 3)    As presently taught, the methodology requires application of the same 
  87. detailed technique again and again, though for different programs.  In 
  88. deriving programs, one could often see that exact same thing was already 
  89. done before, but there is no way given to ╥reuse╙ it.  It is especially 
  90. obvious with ╥tail recursion╙ and ╥search by elimination╙ techniques 
  91. discussed in [15].
  92. Recently an interesting work by J. Bohorquez and R. Cardoso (see [4]) 
  93. addressed the second disadvantage by providing intuitive motivation for some 
  94. of the techniques for extracting the loop invariants and by making them more 
  95. general.  However this work did not address the first and third disadvantages.  
  96. Our new methodology ╥deriving programs using generic algorithms╙ extends 
  97. the Dijkstra-Gries methodology and is designed to overcome all three 
  98. disadvantages as follows.
  99.  
  100. 1)  A number of pre-proved program templates supplied with invariants and 
  101. bound functions frees the practitioner from looking for the invariants.  We 
  102. call these templates ╥generic algorithms╙.  With the generic algorithms an 
  103. ability to prove simple logical assertions may be sufficient;
  104.  
  105. 2)  Generic algorithms enhance the intuition.  For instance, the maxsegsum 
  106. problem is easily solved by an intuitively clear generic algorithm for 
  107. computing recursive functions.
  108.  
  109. 3)  Generic algorithms allow reuse of program derivation techniques, 
  110. correctness proofs and formal specifications.  For instance, ╥tail recursion╙ 
  111. and ╥search by elimination╙ techniques were converted into generic 
  112. algorithms.
  113.  
  114. 2   Background
  115. The notion of a generic algorithm as a tool intended to augment the 
  116. traditional program derivation techniques (see [6,10], etc.) was born in the 
  117. beginning of 1992 when the Endicott Programming Laboratory (EPL), IBM 
  118. Corporation, began investigating the use of formal methods to help improve 
  119. the quality of our commercial software products.  Since then we have taught 
  120. classes on formal methods and generic algorithms within the framework of IBM 
  121. Education System and successfully applied the approach for proving 
  122. correctness of one of the crucial parts of the CMS multitasking system.
  123. The basis of the CMS multitasking system is the notion of a ╥thread╙.  
  124. Informally, a thread is a part of a program that a) has a logically independent 
  125. goal and b) runs concurrently with other parts of the same program or with 
  126. other programs.  One of the key components of the CMS thread management is 
  127. a module called ╥HighestPriorityRunnable╙.  Informally, 
  128. HighestPriorityRunnable finds the highest priority runnable thread from a 
  129. given set of threads.
  130. We created a formal specification for HighestPriorityRunnable by isolating the 
  131. part of system state which interacts with HighestPriorityRunnable.  Having 
  132. done so, we looked at our library of generic algorithms for an algorithm with a 
  133. similar specification and chose one called 
  134. ╥Choice_Based_Filtered_Bounded_Search╙.  This generic algorithm not only 
  135. applied easily to HighestPriorityRunnable, but produced a particularly elegant 
  136. and efficient solution to the problem.  For complete information on the formal 
  137. specification of HighestPriorityRunnable, and the refinement based on 
  138. ╥Choice_Based_Filtered_Bounded_Search╙ see [21].
  139. We summarized our results in three papers, [20,21,22].  Presently we are 
  140. working on the application of our approach within a new development project, 
  141. as well as on helping other developers throughout the EPL set up pilot projects 
  142. to utilize the generic algorithms.
  143.  
  144. 3    Position
  145. Our purpose is to ╥hide╙ most of the mathematical techniques involved in 
  146. program derivation in a number of pre-derived program templates that we call 
  147. generic algorithms.  A generic algorithm has the following features
  148. Ñ    a formal specification;
  149.  
  150. Ñ    it is formally proven to satisfy this specification;
  151.  
  152. Ñ    it may have one or more generic identifiers representing data types or 
  153. operations;
  154.  
  155. Ñ    it may have embedded program specifications or pseudocode 
  156. instructions describing the next steps in the stepwise refinement process.  
  157. We have created a library of generic algorithms that implicitly contains many 
  158. techniques of program derivation converted into generic algorithms, as well as 
  159. generic algorithms not corresponding to a single such technique.  Some of our 
  160. generic algorithms were developed using the Dijkstra-Gries methodology and 
  161. the rest were derived using our extension of the Dijkstra-Gries methodology.  So 
  162. far we have about 30 algorithms in our library.  On the basis of our 
  163. development experience and by working through numerous examples in such 
  164. classical textbooks as [6,10,15], we became convinced that our library covers 
  165. most of the DO-loops a programmer could conceivably encounter in everyday 
  166. work.
  167. In [22] we list the library of generic algorithms in Dijkstra-Gries notation.  The 
  168. work of converting them into other languages is underway.  We present below a 
  169. part of the table of contents from [22]:
  170. 1.0  Computation of Recursive Functions Using DO-loops
  171.     1.1  Simple Recursive Function
  172.     1.2  Finite Memory Recursive Function
  173.     1.3  Tail Recursion
  174.  
  175. 2.0  Searches
  176.     2.1  Search by Elimination
  177.     2.2  Searches with Quantifiers
  178.         2.2.1  General Quantifiers
  179.             2.2.1.1  Unbounded
  180.             2.2.1.2  Bounded
  181.         2.2.1  Boolean Quantifiers
  182.             2.2.1.1  Unbounded
  183.             2.2.1.2  Bounded
  184.  
  185. 3.0  Logarithmically Efficient Algorithms
  186.     3.1.  Binary Search
  187.     3.2.  Binary Iteration
  188. With the advent of the library of generic algorithms the program derivation 
  189. process could be ideally represented as follows.  We start from a formal 
  190. specification and view it as an algorithm consisting of a unique pseudocode 
  191. instruction.  The process of derivation consists of several stages, each resulting 
  192. in an algorithm having more detail than the previous ones.  We may stop 
  193. either when the algorithm becomes a compilable program or before that.  In 
  194. either case the resulting algorithm will satisfy the initial specification.  Each of 
  195. those stages consists of one or more iterations of the following steps:
  196. 1.    Choose a pseudocode instruction from the algorithm created in the 
  197. previous stage.  (Recall that every such instruction corresponds to a 
  198. formal specification that encodes a certain behavior during execution);
  199.  
  200. 2.    Find a generic algorithm in the library that might be doing similar work;
  201.  
  202. 3.    Adapt the generic algorithm by replacing its abstract types, operations 
  203. and variables by the related types, operations and variables from the 
  204. pseudocode instruction.  Adapt the specification of the generic algorithm 
  205. by the same replacement of types, operations and variables;
  206.  
  207. 4.    Justify that the adapted specification from step 3 correctly implements 
  208. the specification of the pseudocode instruction.  [20] provides an 
  209. explanation of how to do it in a simple 3-step procedure.  If the 
  210. justification fails, go back to step 2;
  211.  
  212. 5.    Replace the pseudocode instruction in the algorithm created in the 
  213. previous stage by the algorithm from the step 3.
  214.  
  215. 4    Conclusion
  216. Generic algorithms serve as reusable, transformable ╥building blocks╙ in the 
  217. formal derivation of programs.  They extend the paradigm of program reuse to 
  218. the reuse of program derivation techniques, program correctness proofs, formal 
  219. specifications and design steps.  Generic algorithms alleviate the problem of 
  220. mathematical skill levels by freeing the programmer from the search for loop 
  221. invariants and from providing respective interim proofs.  Thus they enable 
  222. programmers to derive mathematically correct programs from a formal 
  223. specifications with only occasional need to consult experts in program 
  224. derivation and program correctness proofs.  This methodology is applicable to 
  225. a vast segment of the program development process, from high level design to 
  226. coding.
  227.  
  228.  
  229.  
  230. References
  231. [1]    K. R. Apt, ╥Ten Years of Hoare's Logic, a Survey╙, ACM Trans. on Prog. 
  232. Lang. and Sys., 3, 431-483 (1981).
  233. [2]    R. Apt, E. R. Olderog,  Verification of Sequential and Concurrent Programs, 
  234. Springer-Verlag, 1991.
  235. [3]    R. C. Backhouse, ╥Program Construction and Verification╙, Prentice-Hall, 
  236. 1986.
  237. [4]    J. Bohorquez, R. Cardoso, ╥Problem Solving Strategies for the Derivation of 
  238. Programs╙, to appear in Logical Methods, a collection of papers honoring 
  239. A. Nerode's 60th birthday.
  240. [5]    T. Clement, ╥The Role of Data Reification in Program Refinement: Origin, 
  241. Synthesis and Appraisal╙, The Computer Journal, vol. 35, num. 5, October 
  242. 1992.
  243. [6]    E. Cohen, Programming in the 90s: An Introduction to the Calculation of 
  244. Programs, Springer-Verlag, 1990.
  245. [7]    E. W. Dijkstra, A Discipline of Programming, Prentice Hall, 1976.
  246. [8]    E. W. Dijkstra, W. H. J. Feijen, A Method of Programming, Addison Wesley, 
  247. 1988.
  248. [9]    E. W. Dijkstra, C. S. Scholten, Predicate Calculus and Program Semantics, 
  249. Springer-Verlag, 1990.
  250. [10]    D. Gries, The Science of Programming, Springer-Verlag, 1981.
  251. [11]    C. A. R. Hoare, ╥An Axiomatic Basis for Computer Programming╙, CACM 
  252. 12, 1969.
  253. [12]    C. A. R. Hoare, ╥An Axiomatic Approach to Computer Programming╙, in 
  254. Essays in Computer Science, C. A. .R. Hoare and C. B. Jones (eds), Prentice-
  255. Hall, 1989.
  256. [13]    D. C. Ince, An Introduction to Discrete Mathematics and Formal System 
  257. Specification, Oxford University Press, 1988.
  258. [14]    C. B. Jones, Systematic Software Development using VDM, Prentice-Hall 
  259. International 1990.
  260. [15]    A. Kaldewaij, Programming: The Derivation of Algorithms, Prentice Hall, 
  261. 1990.
  262. [16]    J. Loeckx, K. Sieber, The Foundations of Program Verification, John Wiley 
  263. & Sons, 1987.
  264. [17]    C. Morgan, Programming from specifications, Oxford University Press, 
  265. 1991.
  266. [18]    J. C. P. Woodcock,  ╥The Rudiments of Algorithm Refinement╙, The 
  267. Computer Journal, vol. 35, num. 5, October 1992.
  268. [19]    J Woodcock, M Loomes, Software Engineering Mathematics, Pitman, 1988.
  269. [20]    V. Yakhnis, J Farrell, S Shultz, ╥Deriving Programs with Generic 
  270. Algorithms: An Overview╙, to appear in IBM Systems Journal.
  271. [21]    V. Yakhnis, J Farrell, S Shultz, ╥Deriving Programs with Generic 
  272. Algorithms: The Approach and a Case Study╙, to appear.
  273. [22]    V. Yakhnis, J Farrell, ╥The Library of Generic Algorithms in Dijkstra-Gries 
  274. Notation╙, to appear.
  275. 5    Biography
  276. Vladimir R. Yakhnis is an advisory programmer in the IBM Endicott 
  277. Programming Laboratory.  He received a Diploma in mathematics from Moscow 
  278. State University, Moscow, Russia in 1975.  He worked as a computer 
  279. programmer in Moscow, Russia and Houston, Texas.  Dr. Yakhnis received a 
  280. Ph.D. in mathematics and an M.S. in computer science from Cornell 
  281. University, Ithaca, New York in 1990.  He worked as a Postdoctoral Fellow at 
  282. Mathematical Sciences Institute, Cornell University until 1991.  His research 
  283. was in program correctness for concurrent and sequential programs, winning 
  284. strategies for two person games, finite automata and recursion theory.  Dr. 
  285. Yakhnis joined IBM in 1991 in Endicott.
  286. Joel A. Farrell is a senior programmer at the IBM Endicott Programming 
  287. Laboratory in Endicott, New York.  He joined IBM in Endicott in 1981 in VM 
  288. Development where he has worked on such areas as I/O and program 
  289. management.  Most recently he has been involved in parallel and distributed 
  290. computing and in formal methods for software development.  Mr. Farrell 
  291. received his BS degree in computer science from Kansas State University in 
  292. 1980 and his MS degree in 1985 from Syracuse University, also in computer 
  293. science.  In 1992 he received an IBM Outstanding Innovation Award for his 
  294. work on parallel processing in CMS, and an IBM First Level Invention 
  295. Achievement Award.  He is a member of the Association for Computing 
  296. Machinery.
  297. Steven S. Shultz is an advisory programmer at the IBM Endicott Programming 
  298. Laboratory in Endicott, New York.  He joined IBM in Endicott in 1981 in VM 
  299. Development where he has worked on such areas as I/O and virtual storage 
  300. management. Most recently he has been involved in parallel and distributed 
  301. computing and in formal methods for software development.  Mr. Shultz 
  302. received his BS degree in Computer and Information Science from Ohio State 
  303. University in 1981.  In 1992 he received an Outstanding Innovation Award for 
  304. his work on parallel processing in CMS, and an IBM First Level Invention 
  305. Achievement Award.
  306.  
  307.