# Specification=program+types

## Abstract

It has been claimed that logic programs are equivalent to or consequences of specifications. We argue this is generally not correct. Programs often make implicit assumptions about types, leading to the possibility of incorrect answers. If the assumptions are made explicit, so that the program is equivalent to the specification, the program is less efficient. We define when programs with type declarations are *type correct* and show all well typed answers returned by such programs are correct.

As well as making to relationship between programs and specifications clear, this type scheme can be used to detect certain programming errors. The semantics we define for type declarations can also be applied to other type schemes. This leads to a simple characterization of what errors are detected by these schemes, and a way to generalize these schemes to allow arbitrary type definitions. One such implementation is discussed.

## Keywords

Logic Program Logic Programming Incorrect Answer Type Scheme Prolog Program## Preview

Unable to display preview. Download preview PDF.

## References

- [Apt 86]K. R. Apt, H. A. Blair, and A. Walker, Towards a theory of declarative knowledge,
*Preprints of the Workshop on Foundations of Deductive Databases and Logic Programming*, Washington, D.C., August 1986, pp. 546–628.Google Scholar - [Bruynooghe 82]M. Bruynooghe, Adding redundancy to obtain more reliable and more readable Prolog programs,
*Proceedings of the First International Logic Programming Conference*, Faculte des Sciences de Luminy, Marseille, France, September 1982, pp. 129–133.Google Scholar - [Cardelli 85]L. Cardelli, and P. Wegner, On understanding types, data abstraction, and polymorphism,
*ACM Computing Surveys*, 17:471–522 (December 1985).CrossRefGoogle Scholar - [Clark 77]K. Clark, and S. Sickel, Predicate logic: a calculus for the formal derivation of programs,
*Proceedings of the Fifth International Joint Conference on Artificial Intelligence*, Cambridge, Massachusetts, August 1977, pp. 419–420.Google Scholar - [Clark 84]K. Clark, The synthesis and verification of logic programs,
*Proceedings of the Conference on Logic and Computation, Vol. II*, Melbourne, January 1984.Google Scholar - [Hankley 87]W. Hankley, Feature analysis of Turbo Prolog,
*SIGPLAN Notices*, 22:111–118 (March 1987).Google Scholar - [Hill 74]R. Hill, Lush-Resolution and its completeness, DCL Memo 78, Department of Artificial Intelligence, University of Edinburgh, Edinburgh, Scotland, August 1974.Google Scholar
- [Hogger 81]C. J. Hogger, Derivation of logic programs,
*Journal of the ACM*, 28:372–392 (April 1981).CrossRefGoogle Scholar - [Kowalski 85]R. Kowalski, The relationship between logic programming and logic specification, in: A. Hoare, and J. Shepherdson (eds.),
*Mathematical logic and programming languages*, Prentice Hall, 1985.Google Scholar - [Lloyd 84a]J. W. Lloyd, and R. W. Topor, Making Prolog more expressive,
*Journal of Logic Programming*, 1:225–240 (1984).CrossRefGoogle Scholar - [Lloyd 84b]J. W. Lloyd,
*Foundations of logic programming*, Springer-Verlag, New York, 1984.Google Scholar - [Maher 86]M. J. Maher, Equivalences of logic programs,
*Proceedings of the Third International Conference on Logic Programming*, Imperial College of Science and Technology, London, England, July 1986, pp. 410–424.Google Scholar - [Milner 78]R. Milner, A theory of type polymorphism in programming,
*Journal of Computer and System Sciences*, 17:348–375 (December 1978).CrossRefGoogle Scholar - [Mishra 84]P. Mishra, Towards a theory of types in Prolog,
*Proceedings of the IEEE International Symposium on Logic Programming*, Atlantic City, New Jersey, February 1984, pp. 289–298.Google Scholar - [Mycroft 83]A. Mycroft, and R. O'Keefe, A polymorphic type system for Prolog,
*Proceedings of the Logic Programming Workshop*, Algarve, Portugal, 1983, pp. 107–122.Google Scholar - [Naish 86]L. Naish, Negation and quantifiers in NU-Prolog,
*Proceedings of the Third International Conference on Logic Programming*, Imperial College of Science and Technology, London, England, July 1986, pp. 624–634.Google Scholar - [Tamaki 84]H. Tamaki, and T. Sato, Unfold/fold transformation of logic programs,
*Proceedings of the Second International Logic Programming Conference*, Uppsala University, Uppsala, Sweden, July 1984, pp. 127–138.Google Scholar - [Thom 86]J. Thom, and J. Zobel (eds.), NU-Prolog reference manual, version 1.0, Technical Report 86/10, Department of Computer Science, University of Melbourne, Melbourne, Australia, 1986.Google Scholar
- [Zobel 87]J. Zobel, Derivation of polymorphic types for Prolog programs,
*Proceedings of the Fourth International Conference on Logic Programming*, Melbourne, Australia, May 1987.Google Scholar