Skip to main content

Practical Idiomatic Considerations for Checkable Meta-logic in Experimental Functional Programming

  • Conference paper
  • First Online:
Functional and Constraint Logic Programming (WFLP 2020)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 12560))

Included in the following conference series:

  • 163 Accesses

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    A full and self-contained source archive for practical evaluation is publicly available at http://bandm.eu/download/purecheck/.

  2. 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. 3.

    Thus named here for clear contrast with the alternatives, but largely synonymous with property-based testing [7].

  4. 4.

    Implementations can be found in the full source.

  5. 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. 6.

    Note the discourse-level meta-variable \( A \) for a monomorphic Haskell type, instead of an object-level type variable \(\alpha \).

  7. 7.

    The implementation of \( gpair \) is explained in detail in the full source.

References

  1. 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)

    Article  MathSciNet  Google Scholar 

  2. 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

    Chapter  Google Scholar 

  3. 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

    Article  Google Scholar 

  4. 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

    Article  Google Scholar 

  5. 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

  6. 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

    Article  MathSciNet  MATH  Google Scholar 

  7. 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

    Article  Google Scholar 

  8. Hanus, M.: Curry: a truly integrated functional logic language (2014). https://www-ps.informatik.uni-kiel.de/currywiki/

  9. Norell, U.: Towards a practical programming language based on dependent type theory. Ph.D. thesis, Chalmers University of Technology (2007)

    Google Scholar 

  10. Jones, S.P.: Literate comments. The Haskell 98 report (2002). https://www.haskell.org/onlinereport/literate.html

  11. 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

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Baltasar Trancón y Widemann .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2021 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

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)

Publish with us

Policies and ethics