Abstract
Implementing a complex concept as an executable model in a strongly typed, purely functional language hits a sweet spot between mere simulation and formal specification. For research and education it is often desirable to enrich the algorithmic code with meta-logical annotations, variously embodied as assertions, theorems or test cases. Checking frameworks use the inherent logical power of the functional paradigm to approximate theorem proving by heuristic testing. Here we propose several novel idioms to enhance the practical expressivity of checking, namely meta-language marking, nominal axiomatics, and constructive existentials. All of these are formulated in literate Haskell’98 with some common language extensions. Their use and impact are illustrated by application to a realistic modeling problem.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
A full and self-contained source archive for practical evaluation is publicly available at http://bandm.eu/download/purecheck/.
- 2.
Consider the “constructive” logical reading of the type of a generic recursion operator, \((\alpha \rightarrow \alpha )\rightarrow \alpha \); it says literally that begging the question, \(\alpha \rightarrow \alpha \), is a valid proof method for any proposition \(\alpha \).
- 3.
Thus named here for clear contrast with the alternatives, but largely synonymous with property-based testing [7].
- 4.
Implementations can be found in the full source.
- 5.
The reader is invited to contemplate for example the variety of possible higher-order logical meanings of the following specialization of a well-known Haskell Prelude function: \( foldl \mathbin {::}( Foldable \;\tau )\Rightarrow ( Bool \rightarrow \alpha \rightarrow Bool )\rightarrow Bool \rightarrow \tau \;\alpha \rightarrow Bool \).
- 6.
Note the discourse-level meta-variable \( A \) for a monomorphic Haskell type, instead of an object-level type variable \(\alpha \).
- 7.
The implementation of \( gpair \) is explained in detail in the full source.
References
Backus, J.: Can programming be liberated from the von Neumann style? A functional style and its Algebra of programs. Commun. ACM 21(8), 613–641 (1978)
Chitil, O., Huch, F.: A pattern logic for prompt lazy assertions in Haskell. In: Horváth, Z., Zsók, V., Butterfield, A. (eds.) IFL 2006. LNCS, vol. 4449, pp. 126–144. Springer, Heidelberg (2007). https://doi.org/10.1007/978-3-540-74130-5_8
Claessen, K., Hughes, J.: QuickCheck: a lightweight tool for random testing of Haskell programs. SIGPLAN Notes 35(9), 268–279 (2000). https://doi.org/10.1145/351240.351266
Clarke, L.A., Rosenblum, D.S.: A historical perspective on runtime assertion checking in software development. ACM SIGSOFT Softw. Eng. Notes 31(3), 25–37 (2006). https://doi.org/10.1145/1127878.1127900
Cooper, J., Vik, J.O., Waltemath, D.: A call for virtual experiments: accelerating the scientific process. In: PeerJ PrePrints (2014). https://doi.org/10.7287/peerj.preprints.273v1
Coquand, T., Huet, G.: The calculus of constructions. Inf. Comput. 76(2–3), 95–120 (1988). https://doi.org/10.1016/0890-5401(88)90005-3
George, F., Matt, B.: Property-based testing; a new approach to testing for assurance. Softw. Eng. Notes 22(4), 74–80 (1997). https://doi.org/10.1145/263244.263267
Hanus, M.: Curry: a truly integrated functional logic language (2014). https://www-ps.informatik.uni-kiel.de/currywiki/
Norell, U.: Towards a practical programming language based on dependent type theory. Ph.D. thesis, Chalmers University of Technology (2007)
Jones, S.P.: Literate comments. The Haskell 98 report (2002). https://www.haskell.org/onlinereport/literate.html
Runciman, C., Naylor, M., Lindblad, F.: Smallcheck and lazy smallcheck: automatic exhaustive testing for small values. In: Haskell 2008: Proceedings of the First ACM SIGPLAN Symposium on Haskell, pp. 37–48 (2008). https://doi.org/10.1145/1411286.1411292
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2021 Springer Nature Switzerland AG
About this paper
Cite this paper
Trancón y Widemann, B., Lepper, M. (2021). Practical Idiomatic Considerations for Checkable Meta-logic in Experimental Functional Programming. In: Hanus, M., Sacerdoti Coen, C. (eds) Functional and Constraint Logic Programming. WFLP 2020. Lecture Notes in Computer Science(), vol 12560. Springer, Cham. https://doi.org/10.1007/978-3-030-75333-7_2
Download citation
DOI: https://doi.org/10.1007/978-3-030-75333-7_2
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-75332-0
Online ISBN: 978-3-030-75333-7
eBook Packages: Computer ScienceComputer Science (R0)