home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pipex!bnr.co.uk!uknet!mucs!m1!bevan
- From: bevan@cs.man.ac.uk (Stephen J Bevan)
- Newsgroups: comp.programming
- Subject: Re: Programming by Description of Output...
- Message-ID: <BEVAN.92Dec31001940@panda.cs.man.ac.uk>
- Date: 31 Dec 92 00:19:40 GMT
- References: <C01yxr.BGF@phage.cshl.org> <1992Dec30.174004.4168@cs.cornell.edu>
- <C036t1.KCH@phage.cshl.org>
- Sender: news@cs.man.ac.uk
- Organization: Department of Computer Science, University of Manchester
- Lines: 38
- In-reply-to: boutell@isis.cshl.org's message of 30 Dec 92 19:15:01 GMT
-
- In article <C036t1.KCH@phage.cshl.org> boutell@isis.cshl.org (Tom Boutell) writes:
- In article <1992Dec30.174004.4168@cs.cornell.edu> karr@cs.cornell.edu (David Karr) writes:
- >In article <C01yxr.BGF@phage.cshl.org> boutell@isis.cshl.org (Tom Boutell) writes:
- >>Initial state:
- >>Array A[] contains n whole numbers...
- [deleted]
- >How much easier is it to specify a program by predicates on its input
- >and output rather than by an algorithm?
-
- I find that the spec. is usually shorter, but there are times when a
- particular implementation (algorithm) is shorter than the spec.
-
-
- An excellent question. I gather Prolog programmers have discovered
- it is often as much or more work than writing the algorithm, as
- you point out.
-
- Getting back to the sorting example: if the arrays are changed to
- lists, then a spec is :-
-
- sort(List, Sorted_List) :-
- permutation(List, Sorted_List),
- ordered(Sorted_List).
-
- Suitable definitions of `permutation' and `ordered' are left as an
- excercise for the reader.
-
- By using various transformations you can move from the spec. to a
- particular algorithm, say a quicksort (sic) or mergesort or you alter
- the spec. to ensure that the sort is stable. Someone here did some
- work on automatically transforming Prolog programs (the thesis
- specifically covers generation of various sort routines from the above
- spec). If you are interested in program transformation in general, it
- is worth looking at papers/books on Bird-Merteens Formalism, CIP, VDM
- and Z or for a more gentle introduction try _Science of Programming_
- by Gries.
-
- bevan
-