Skip to main content

Synthesizing Set Functions

  • Conference paper
  • First Online:
  • 328 Accesses

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

Abstract

Set functions are a feature of functional logic programming to encapsulate all results of a non-deterministic computation in a single data structure. Given a function f of a functional logic program written in Curry, we describe a technique to synthesize the definition of the set function of f. The definition produced by our technique is based on standard Curry constructs. Our approach is interesting for three reasons. It allows reasoning about set functions, it offers an implementation of set functions which can be added to any Curry system, and it has the potential of changing our thinking about the implementation of non-determinism, a notoriously difficult problem.

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

Buying options

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

Learn about institutional subscriptions

Notes

  1. 1.

    The notion of “plural function” is also used in [22] to define a “plural” semantics for functional logic programs. Although the type of their plural functions is identical to ours, their semantics is quite different.

  2. 2.

    Actually, this operation is the monadic “bind” operation with flipped arguments if is an instance of , as proposed in [13]. Here, we prefer to provide a more direct implementation.

  3. 3.

    This is a consequence of the fact that is a functor. A more general treatment of these structures can be found in [6].

  4. 4.

    Although the current definition of Curry [17] does not include type classes, many implementations of Curry, like PAKCS, KiCS2, or MCC, support them.

  5. 5.

    The use of ensures that the argument is evaluated. Thus, non-determinism and failures in arguments of set functions are not encapsulated, as intended.

  6. 6.

    Multi-parameter type classes are not yet supported in the Curry systems PAKCS and KiCS2. The code presented here is more elegant, but equivalent, to the actual implementation.

  7. 7.

    Of course, one can replace such lists by more efficient access structures.

  8. 8.

    This requires a specific primitive to catch failures, which is usually supported in Curry implementations to handle exceptions.

  9. 9.

    https://github.com/finnteegen/synthesizing-set-functions.

References

  1. Alqaddoumi, A., Antoy, S., Fischer, S., Reck, F.: The pull-tab transformation. In: Proceedings of the Third International Workshop on Graph Computation Models, Enschede, The Netherlands, pp. 127–132 (2010). http://gcm-events.org/gcm2010/pages/gcm2010-preproceedings.pdf

  2. Antoy, S., Echahed, R., Hanus, M.: A needed narrowing strategy. J. ACM 47(4), 776–822 (2000)

    Article  MathSciNet  Google Scholar 

  3. Antoy, S., Hanus, M.: Overlapping rules and logic variables in functional logic programs. In: Etalle, S., Truszczyński, M. (eds.) ICLP 2006. LNCS, vol. 4079, pp. 87–101. Springer, Heidelberg (2006). https://doi.org/10.1007/11799573_9

    Chapter  MATH  Google Scholar 

  4. Antoy, S., Hanus, M.: Set functions for functional logic programming. In: Proceedings of the 11th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming (PPDP 2009), pp. 73–82. ACM Press (2009)

    Google Scholar 

  5. Antoy, S., Hanus, M.: Functional logic programming. Commun. ACM 53(4), 74–85 (2010)

    Article  Google Scholar 

  6. Atkey, R., Johann, P.: Interleaving data and effects. J. Funct. Programm. 25, e20 (2015). https://doi.org/10.1017/S0956796815000209

    Article  MathSciNet  MATH  Google Scholar 

  7. Braßel, B., Fischer, S., Hanus, M., Reck, F.: Transforming functional logic programs into monadic functional programs. In: Mariño, J. (ed.) WFLP 2010. LNCS, vol. 6559, pp. 30–47. Springer, Heidelberg (2011). https://doi.org/10.1007/978-3-642-20775-4_2

    Chapter  MATH  Google Scholar 

  8. Braßel, B., Hanus, M., Huch, F.: Encapsulating non-determinism in functional logic computations. J. Funct. Log. Program. 6, 2004 (2004)

    MathSciNet  MATH  Google Scholar 

  9. Braßel, B., Hanus, M., Peemöller, B., Reck, F.: KiCS2: a new compiler from curry to Haskell. In: Kuchen, H. (ed.) WFLP 2011. LNCS, vol. 6816, pp. 1–18. Springer, Heidelberg (2011). https://doi.org/10.1007/978-3-642-22531-4_1

    Chapter  Google Scholar 

  10. Christiansen, J., Hanus, M., Reck, F., Seidel, D.: A semantics for weakly encapsulated search in functional logic programs. In: Proceedings of the 15th International Symposium on Principle and Practice of Declarative Programming (PPDP 2013), pp. 49–60. ACM Press (2013)

    Google Scholar 

  11. de Dios Castro, J., López-Fraguas, F.J.: Extra variables can be eliminated from functional logic programs. Electron. Notes Theor. Comput. Sci. 188, 3–19 (2007)

    Article  Google Scholar 

  12. Dijkstra, E.W.: A note on two problems in connexion with graphs. Numer. Math. 1(1), 269–271 (1959)

    Article  MathSciNet  Google Scholar 

  13. Fischer, S., Kiselyov, O., Shan, C.: Purely functional lazy nondeterministic programming. J. Funct. program. 21(4&5), 413–465 (2011)

    Article  MathSciNet  Google Scholar 

  14. González-Moreno, J.C., Hortalá-González, M.T., López-Fraguas, F.J., Rodríguez-Artalejo, M.: An approach to declarative programming based on a rewriting logic. J. Log. Program. 40, 47–87 (1999)

    Article  MathSciNet  Google Scholar 

  15. Hanus, M.: Functional logic programming: from theory to curry. In: Voronkov, A., Weidenbach, C. (eds.) Programming Logics. LNCS, vol. 7797, pp. 123–168. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-37651-1_6

    Chapter  MATH  Google Scholar 

  16. Hanus, M., et al.: PAKCS: the Portland Aachen Kiel curry system (2018). http://www.informatik.uni-kiel.de/~pakcs/

  17. Hanus, M. (ed.): Curry: an integrated functional logic language (vers. 0.9.0) (2016). http://www.curry-language.org

  18. Hinze, R.: Prolog’s control constructs in a functional setting - axioms and implementation. Int. J. Found. Comput. Sci. 12(2), 125–170 (2001)

    Article  Google Scholar 

  19. Hussmann, H.: Nondeterministic algebraic specifications and nonconfluent term rewriting. J. Log. Program. 12, 237–255 (1992)

    Article  MathSciNet  Google Scholar 

  20. López-Fraguas, F.J., Rodríguez-Hortalá, J., Sánchez-Hernández, J.: A simple rewrite notion for call-time choice semantics. In: Proceedings of the 9th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming (PPDP 2007), pp. 197–208. ACM Press (2007)

    Google Scholar 

  21. José Moreno-Navarro, J., Kuchen, H., Loogen, R.: Lazy narrowing in a graph machine. In: Kirchner, H., Wechler, W. (eds.) ALP 1990. LNCS, vol. 463, pp. 298–317. Springer, Heidelberg (1990). https://doi.org/10.1007/3-540-53162-9_47

    Chapter  Google Scholar 

  22. Riesco, A., Rodríguez-Hortalá, J.: Singular and plural functions for functional logic programming. Theory Pract. Log. Program. 14(1), 65–116 (2014)

    Article  MathSciNet  Google Scholar 

  23. Seres, S., Spivey, M., Hoare, T.: Algebra of logic programming. In: Proceedings of the ICLP 1999, pp. 184–199. MIT Press (1999)

    Google Scholar 

  24. 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). https://doi.org/10.1007/3-540-15975-4_33

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Michael Hanus .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Antoy, S., Hanus, M., Teegen, F. (2019). Synthesizing Set Functions. In: Silva, J. (eds) Functional and Constraint Logic Programming. WFLP 2018. Lecture Notes in Computer Science(), vol 11285. Springer, Cham. https://doi.org/10.1007/978-3-030-16202-3_6

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-16202-3_6

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-16201-6

  • Online ISBN: 978-3-030-16202-3

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics