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.
Preview
Unable to display preview. Download preview PDF.
References
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.
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.
L. Cardelli, and P. Wegner, On understanding types, data abstraction, and polymorphism, ACM Computing Surveys, 17:471–522 (December 1985).
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.
K. Clark, The synthesis and verification of logic programs, Proceedings of the Conference on Logic and Computation, Vol. II, Melbourne, January 1984.
W. Hankley, Feature analysis of Turbo Prolog, SIGPLAN Notices, 22:111–118 (March 1987).
R. Hill, Lush-Resolution and its completeness, DCL Memo 78, Department of Artificial Intelligence, University of Edinburgh, Edinburgh, Scotland, August 1974.
C. J. Hogger, Derivation of logic programs, Journal of the ACM, 28:372–392 (April 1981).
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.
J. W. Lloyd, and R. W. Topor, Making Prolog more expressive, Journal of Logic Programming, 1:225–240 (1984).
J. W. Lloyd, Foundations of logic programming, Springer-Verlag, New York, 1984.
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.
R. Milner, A theory of type polymorphism in programming, Journal of Computer and System Sciences, 17:348–375 (December 1978).
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.
A. Mycroft, and R. O'Keefe, A polymorphic type system for Prolog, Proceedings of the Logic Programming Workshop, Algarve, Portugal, 1983, pp. 107–122.
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.
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.
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.
J. Zobel, Derivation of polymorphic types for Prolog programs, Proceedings of the Fourth International Conference on Logic Programming, Melbourne, Australia, May 1987.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1987 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Naish, L. (1987). Specification=program+types. In: Nori, K.V. (eds) Foundations of Software Technology and Theoretical Computer Science. FSTTCS 1987. Lecture Notes in Computer Science, vol 287. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-18625-5_58
Download citation
DOI: https://doi.org/10.1007/3-540-18625-5_58
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-18625-0
Online ISBN: 978-3-540-48033-4
eBook Packages: Springer Book Archive