Advertisement

plspec – A Specification Language for Prolog Data

  • Philipp Körner
  • Sebastian Krings
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10997)

Abstract

In general, even though Prolog is a dynamically typed language, predicates may not be called with arbitrarily typed arguments. Assumptions regarding type or mode are often made implicitly, without being directly represented in the source code. This complicates identifying the types or data structures anticipated by predicates. In consequence, Covington et al. proposed that Prolog developers should implement their own runtime type checking system.

In this paper, we present a re-usable Prolog library named plspec. It offers a simple and easily extensible DSL used to specify type and structure of input and output arguments. Additionally, an elegant insertion of multiple kinds of runtime checks was made possible by using Prolog language features such as co-routining and term expansion. Furthermore, we will discuss performance impacts and possible future usages.

Keywords

Prolog Runtime checks Type system Data specification 

References

  1. 1.
    Amaral, C., Florido, M., Santos Costa, V.: PrologCheck – property-based testing in prolog. In: Codish, M., Sumii, E. (eds.) FLOPS 2014. LNCS, vol. 8475, pp. 1–17. Springer, Cham (2014).  https://doi.org/10.1007/978-3-319-07151-0_1CrossRefGoogle Scholar
  2. 2.
    Bracha, G.: Pluggable type systems. In: OOPSLA Workshop on Revival of Dynamic Languages (2004)Google Scholar
  3. 3.
    Covington, M.A., Bagnara, R., O’Keefe, R.A., Wielemaker, J., Price, S.: Coding guidelines for prolog. Theory Practice Logic Program. 12(6), 889–927 (2012)MathSciNetCrossRefGoogle Scholar
  4. 4.
    Dowd, T., Somogyi, Z., Henderson, F., Conway, T., Jeffery, D.: Run time type information in mercury. In: Nadathur, G. (ed.) PPDP 1999. LNCS, vol. 1702, pp. 224–243. Springer, Heidelberg (1999).  https://doi.org/10.1007/10704567_14CrossRefGoogle Scholar
  5. 5.
    Hickey, R.: clojure.spec - Rationale and Overview (2016). https://clojure.org/about/spec
  6. 6.
    Hughes, J.: QuickCheck testing for fun and profit. In: Hanus, M. (ed.) PADL 2007. LNCS, vol. 4354, pp. 1–32. Springer, Heidelberg (2006).  https://doi.org/10.1007/978-3-540-69611-7_1CrossRefGoogle Scholar
  7. 7.
    Jeffery, D.: Expressive type systems for logic programming languages. Dissertation, Department of Computer Science and Software Engineering, The University of Melbourne (2002)Google Scholar
  8. 8.
    Jimenez, M., Lindahl, T., Sagonas, K.: A language for specifying type contracts in erlang and its interaction with success typings. In: Proceedings of the 2007 SIGPLAN Workshop on ERLANG, ERLANG 2007, pp. 11–17. ACM (2007)Google Scholar
  9. 9.
    Kulaš, M.: Annotations for prolog – a concept and runtime handling. In: Bossi, A. (ed.) LOPSTR 1999. LNCS, vol. 1817, pp. 234–254. Springer, Heidelberg (2000).  https://doi.org/10.1007/10720327_14CrossRefzbMATHGoogle Scholar
  10. 10.
    Leuschel, M., Craig, S.J., Bruynooghe, M., Vanhoof, W.: Specialising interpreters using offline partial deduction. In: Bruynooghe, M., Lau, K.-K. (eds.) Program Development in Computational Logic. LNCS, vol. 3049, pp. 340–375. Springer, Heidelberg (2004).  https://doi.org/10.1007/978-3-540-25951-0_11CrossRefGoogle Scholar
  11. 11.
    Lindahl, T., Sagonas, K.: Detecting software defects in telecom applications through lightweight static analysis: a war story. In: Chin, W.-N. (ed.) APLAS 2004. LNCS, vol. 3302, pp. 91–106. Springer, Heidelberg (2004).  https://doi.org/10.1007/978-3-540-30477-7_7CrossRefGoogle Scholar
  12. 12.
    Mandrioli, D., Meyer, B.: Design by contract. In: Advances in Object-Oriented Software Engineering, p. 1 (1991)Google Scholar
  13. 13.
    Mera, E., Lopez-García, P., Hermenegildo, M.: Integrating software testing and run-time checking in an assertion verification framework. In: Hill, P.M., Warren, D.S. (eds.) ICLP 2009. LNCS, vol. 5649, pp. 281–295. Springer, Heidelberg (2009).  https://doi.org/10.1007/978-3-642-02846-5_25CrossRefGoogle Scholar
  14. 14.
    Mycroft, A., O’Keefe, R.A.: A polymorphic type system for prolog. Artif. Intell. 23(3), 295–307 (1984)MathSciNetCrossRefGoogle Scholar
  15. 15.
    Neugebauer, G.: pl-Literate Programming for Prolog with Open image in new window (1996). https://www.ctan.org/pkg/pl, version 3.0
  16. 16.
    Overton, D.: Precise and expressive mode systems for typed logic programming languages. Dissertation, Department of Computer Science and Software Engineering, The University of Melbourne (2003)Google Scholar
  17. 17.
    Puebla, G., Bueno, F., Hermenegildo, M.: Combined static and dynamic assertion-based debugging of constraint logic programs. In: Bossi, A. (ed.) LOPSTR 1999. LNCS, vol. 1817, pp. 273–292. Springer, Heidelberg (2000).  https://doi.org/10.1007/10720327_16CrossRefzbMATHGoogle Scholar
  18. 18.
    Schrijvers, T., Santos Costa, V., Wielemaker, J., Demoen, B.: Towards typed prolog. In: Garcia de la Banda, M., Pontelli, E. (eds.) ICLP 2008. LNCS, vol. 5366, pp. 693–697. Springer, Heidelberg (2008).  https://doi.org/10.1007/978-3-540-89982-2_59CrossRefGoogle Scholar
  19. 19.
    Somogyi, Z., Henderson, F.J., Conway, T.C.: Mercury, an efficient purely declarative logic programming language. In: Proceedings ASCS, pp. 499–512 (1995)Google Scholar
  20. 20.
    Wielemaker, J., Anjewierden, A.: PlDoc: Wiki style Literate Programming for Prolog. CoRR, abs/0711.0618 (2007)Google Scholar
  21. 21.
    Wielemaker, J., Schrijvers, T., Triska, M., Lager, T.: SWI-prolog. Theory Practice Logic Program. 12(1–2), 67–96 (2012)MathSciNetCrossRefGoogle Scholar

Copyright information

© Springer Nature Switzerland AG 2018

Authors and Affiliations

  1. 1.Institut für InformatikUniversität DüsseldorfDüsseldorfGermany

Personalised recommendations