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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
References
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_1
Bracha, G.: Pluggable type systems. In: OOPSLA Workshop on Revival of Dynamic Languages (2004)
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)
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_14
Hickey, R.: clojure.spec - Rationale and Overview (2016). https://clojure.org/about/spec
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_1
Jeffery, D.: Expressive type systems for logic programming languages. Dissertation, Department of Computer Science and Software Engineering, The University of Melbourne (2002)
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)
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_14
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_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_7
Mandrioli, D., Meyer, B.: Design by contract. In: Advances in Object-Oriented Software Engineering, p. 1 (1991)
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_25
Mycroft, A., O’Keefe, R.A.: A polymorphic type system for prolog. Artif. Intell. 23(3), 295–307 (1984)
Neugebauer, G.: pl-Literate Programming for Prolog with (1996). https://www.ctan.org/pkg/pl, version 3.0
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)
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_16
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_59
Somogyi, Z., Henderson, F.J., Conway, T.C.: Mercury, an efficient purely declarative logic programming language. In: Proceedings ASCS, pp. 499–512 (1995)
Wielemaker, J., Anjewierden, A.: PlDoc: Wiki style Literate Programming for Prolog. CoRR, abs/0711.0618 (2007)
Wielemaker, J., Schrijvers, T., Triska, M., Lager, T.: SWI-prolog. Theory Practice Logic Program. 12(1–2), 67–96 (2012)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2018 Springer Nature Switzerland AG
About this paper
Cite this paper
Körner, P., Krings, S. (2018). plspec – A Specification Language for Prolog Data. In: Seipel, D., Hanus, M., Abreu, S. (eds) Declarative Programming and Knowledge Management. WFLP WLP INAP 2017 2017 2017. Lecture Notes in Computer Science(), vol 10997. Springer, Cham. https://doi.org/10.1007/978-3-030-00801-7_13
Download citation
DOI: https://doi.org/10.1007/978-3-030-00801-7_13
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-00800-0
Online ISBN: 978-3-030-00801-7
eBook Packages: Computer ScienceComputer Science (R0)