Skip to main content

Counting Successes: Effects and Transformations for Non-deterministic Programs

  • Chapter
  • First Online:
A List of Successes That Can Change the World

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

Abstract

We give a simple effect system for non-deterministic programs, tracking static approximations to the number of results that may be produced by each computation. A relational semantics for the effect system establishes the soundness of both the analysis and its use in effect-based program transformations.

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.

    It is tempting to replace \(S \sim _{X} S'\) by \(S/[\![X]\!]= S'/[\![X]\!]\), but \(S/[\![X]\!]\) contains the empty set when there is an \(x\in S\) with \((x,x)\notin [\![X]\!]\).

  2. 2.

    Phil was involved in this debate at least as far back as 1997 [11].

References

  1. Ahman, D., Plotkin, G.D.: Refinement types for algebraic effects. In: Abstracts of the 21st Meeting ‘Types for Proofs and Programs’ (TYPES), Institute of Cybernetics, Tallinn University of Technology, pp. 10–11 (2015)

    Google Scholar 

  2. Benton, N.: Simple relational correctness proofs for static analyses and program transformations. In: 31st ACM SIGPLAN Symposium on Principles of Programming Languages (POPL), pp. 14–25. ACM (2004)

    Google Scholar 

  3. Benton, N., Buchlovsky, P.: Semantics of an effect analysis for exceptions. In: 3rd ACM SIGPLAN Workshop on Types in Language Design and Implementation (TLDI), pp. 15–26. ACM (2007)

    Google Scholar 

  4. Benton, N., Hofmann, M., Nigam, V.: Abstract effects and proof-relevant logical relations. In: 41st ACM SIGPLAN Symposium on Principles of Programming Languages (POPL), pp. 619–632. ACM (2014)

    Google Scholar 

  5. Benton, N., Hofmann, M., Nigam, V.: Effect-dependent transformations for concurrent programs arXiv:1510.02419 (2015)

  6. Benton, N., Hughes, J., Moggi, E.: Monads and effects. In: Barthe, G., Dybjer, P., Pinto, L., Saraiva, J. (eds.) APPSEM 2000. LNCS, vol. 2395, p. 42. Springer, Heidelberg (2002)

    Chapter  Google Scholar 

  7. Benton, A., Kennedy, L. Beringer, N., Hofmann, M.: Relational semantics for effect-based program transformations with dynamic allocation. In: 9th International ACM SIGPLAN Conference on Principles and Practice of Declarative Programming (PPDP), pp. 87–96. ACM (2007)

    Google Scholar 

  8. Benton, N., Kennedy, A., Hofmann, M.O., Beringer, L.: Reading, writing and relations: towards extensional semantics for effects analyses. In: Kobayashi, N. (ed.) APLAS 2006. LNCS, vol. 4279, pp. 114–130. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  9. Benton, N., Kennedy, A., Russell, G.: Compiling Standard ML to Java bytecodes. In: Third ACM SIGPLAN International Conference on Functional Programming (ICFP), pp. 129–140. ACM (1998)

    Google Scholar 

  10. Braem, C., Le Charlier, B., Modart, S., Van Hentenryck, P.: Cardinality analysis of Prolog. In: International Symposium on Logic Programming, pp. 457–471. MIT Press (1994)

    Google Scholar 

  11. Claessen, K., Wadler, P. et al.: Laws for monads with zero and plus. In: Haskell mailing list, May 1997. http://www.mail-archive.com/haskell%40haskell.org/msg01583.html. Accessed January 2016

  12. Cousot, P., Cousot, R.: Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. In: Fourth ACM SIGPLAN Symposium on Principles of Programming Languages (POPL), pp. 238–252. ACM (1977)

    Google Scholar 

  13. Debray, S.K., Warren, D.S.: Functional computations in logic programs. ACM Trans. Program. Lang. Syst. (TOPLAS) 11(3), 451–481 (1989)

    Article  Google Scholar 

  14. Fischer, S., Kiselyov, O., Shan, C.-C.: Purely functional lazy nondeterministic programming. J. Funct. Program. 21(4/5), 413–465 (2011)

    Article  MathSciNet  MATH  Google Scholar 

  15. Gifford, D.K., Lucassen, J.M.: Integrating functional and imperative programming. In: ACM Conference on LISP and Functional Programming, pp. 28–38. ACM (1986)

    Google Scholar 

  16. Henderson, F., Somogyi, Z., Conway, T.: Determinism analysis in the Mercury compiler. In: Proceedings of the Australian Computer Science Conference, pp. 337–34 (1996)

    Google Scholar 

  17. Hinze, R.: Deriving backtracking monad transformers. In: Fifth ACM SIGPLAN International Conference on Functional Programming (ICFP), pp. 186–197. ACM (2000)

    Google Scholar 

  18. Kammar, O., Plotkin, G.D.: Algebraic foundations for effect-dependent optimizations. In: 39th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL), pp. 349–360. ACM (2012)

    Google Scholar 

  19. Katsumata, S.: Parametric effect monads and semantics of effect systems. In: 41st ACM SIGPLAN Symposium on Principles of Programming Languages (POPL), pp. 633–646. ACM (2014)

    Google Scholar 

  20. López-García, P., Bueno, F., Hermenegildo, M.V.: Determinacy analysis for logic programs using mode and type information. In: Etalle, S. (ed.) LOPSTR 2004. LNCS, vol. 3573, pp. 19–35. Springer, Heidelberg (2005)

    Chapter  Google Scholar 

  21. Lucassen, J.M., Gifford, D.K.: Polymorphic effect systems. In: 15th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL), pp. 47–57. ACM (1988)

    Google Scholar 

  22. Moggi, E.: Computational lambda-calculus and monads. In: 4th Annual Symposium on Logic in Computer Science (LICS), pp. 14–23. IEEE Computer Society (1989)

    Google Scholar 

  23. Peyton Jones, S., Wadler, P.: Comprehensive comprehensions. In: ACM SIGPLAN Workshop on Haskell, pp. 61–72. ACM (2007)

    Google Scholar 

  24. Reynolds, J.C.: The meaning of types - from intrinsic to extrinsic semantics. Technical report BRICS RS-00-32, BRICS, University of Aarhus, December 2000

    Google Scholar 

  25. Rivas, E., Jaskelioff, M., Schrijvers, T.: From monoids to near-semirings: the essence of monadplus and alternative. In: 17th International Symposium on Principles and Practice of Declarative Programming (PPDP), pp. 196–207. ACM (2015)

    Google Scholar 

  26. Tolmach, A.: Optimizing ML using a hierarchy of monadic types. In: Leroy, X., Ohori, A. (eds.) TIC 1998. LNCS, vol. 1473, pp. 97–115. Springer, Heidelberg (1998)

    Chapter  Google Scholar 

  27. Uustalu, T.: A divertimento on MonadPlus and nondeterminism. J. Logical Algebraic Methods Program. (2016, to appear)

    Google Scholar 

  28. Wadler, P.: How to replace failure by a list of successes: a method for exception handling, backtracking, and pattern matching in lazy functional languages. In: Jouannaud, J.-P. (ed.) FPCA 1985. LNCS, vol. 201, pp. 113–128. Springer, Heidelberg (1985)

    Chapter  Google Scholar 

  29. Wadler, P.: Theorems for free!. In: Fourth International Symposium on Functional Programming Languages and Computer Architecture (FPCA), pp. 347–359. ACM (1989)

    Google Scholar 

  30. Wadler, P.: The marriage of effects and monads. In: Third ACM SIGPLAN International Conference on Functional Programming (ICFP), pp. 63–74. ACM (1998)

    Google Scholar 

  31. Wadler, P., Thiemann, P.: The marriage of effects and monads. ACM Trans. Comput. Logic 4(1), 1–32 (2003)

    Article  MathSciNet  Google Scholar 

  32. Yakeley, A. et al.: MonadPlus reform proposal (2006). https://wiki.haskell.org/MonadPlus_reform_proposal. Accessed January 2016

Download references

Acknowledgements

We thank the referees for their thorough and helpful comments.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Nick Benton .

Editor information

Editors and Affiliations

Additional information

Dedicated to Philip Wadler on the occasion of his $$60^{th}$$ 60 th birthday.

Rights and permissions

Reprints and permissions

Copyright information

© 2016 Springer International Publishing Switzerland

About this chapter

Cite this chapter

Benton, N., Kennedy, A., Hofmann, M., Nigam, V. (2016). Counting Successes: Effects and Transformations for Non-deterministic Programs. In: Lindley, S., McBride, C., Trinder, P., Sannella, D. (eds) A List of Successes That Can Change the World. Lecture Notes in Computer Science(), vol 9600. Springer, Cham. https://doi.org/10.1007/978-3-319-30936-1_3

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-30936-1_3

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-30935-4

  • Online ISBN: 978-3-319-30936-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics