Skip to main content

Compiling a Functional Logic Language: The Fair Scheme

  • Conference paper
  • First Online:
Logic-Based Program Synthesis and Transformation (LOPSTR 2013)

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

  • 313 Accesses

Abstract

We present a compilation scheme for a functional logic programming language. The input program to our compiler is a constructor-based graph rewriting system in a non-confluent, but well-behaved class. This input is an intermediate representation of a functional logic program in a language such as Curry or \(\mathcal{TOY}\). The output program from our compiler consists of three procedures that make recursive calls and execute both rewrite and pull-tab steps. This output is an intermediate representation that is easy to encode in any number of programming languages. We formally and tersely define the compilation scheme from input to output programs. This compilation scheme is the only one to date that implements a deterministic strategy for non-deterministic computations with a proof of optimality and correctness.

This material is based in part upon work supported by the National Science Foundation under Grant No. 1317249.

A longer version of this paper, which include proofs of the statements, is available at http://web.cecs.pdx.edu/~antoy/homepage/publications.html

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

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Albert, E., Hanus, M., Huch, F., Oliver, J., Vidal, G.: Operational semantics for declarative multi-paradigm languages. Journal of Symbolic Computation 40(1), 795–829 (2005)

    Article  MathSciNet  MATH  Google Scholar 

  2. Antoy, S.: Definitional trees. In: Kirchner, H., Levi, G. (eds.) Algebraic and Logic Programming. LNCS, vol. 632, pp. 143–157. Springer, Heidelberg (1992)

    Chapter  Google Scholar 

  3. Antoy, S.: Optimal non-deterministic functional logic computations. In: Hanus, M., Heering, J., Meinke, K. (eds.) ALP 1997 and HOA 1997. LNCS, vol. 1298, pp. 16–30. Springer, Heidelberg (1997). Extended version at http://cs.pdx.edu/ antoy/homepage/publications/alp97/full.pdf

    Chapter  Google Scholar 

  4. Antoy, S.: Constructor-based conditional narrowing. In: Proc. of the 3rd International Conference on Principles and Practice of Declarative Programming (PPDP 2001), pp. 199–206. ACM, Florence, Italy (September 2001)

    Google Scholar 

  5. Antoy, S.: Evaluation strategies for functional logic programming. Journal of Symbolic Computation 40(1), 875–903 (2005)

    Article  MathSciNet  MATH  Google Scholar 

  6. Antoy, S.: Programming with narrowing. Journal of Symbolic Computation 45(5), 501–522 (2010)

    Article  MathSciNet  MATH  Google Scholar 

  7. Antoy, S.: On the correctness of pull-tabbing. TPLP 11(4–5), 713–730 (2011)

    MathSciNet  MATH  Google Scholar 

  8. Antoy, S., Brown, D., Chiang, S.: Lazy context cloning for non-deterministic graph rewriting. In: Proc. of the 3rd International Workshop on Term Graph Rewriting, Termgraph 2006, Vienna, Austria, pp. 61–70 (April 2006)

    Google Scholar 

  9. Antoy, S., Brown, D.W., Chiang, S.-H.: On the correctness of bubbling. In: Pfenning, F. (ed.) RTA 2006. LNCS, vol. 4098, pp. 35–49. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  10. Antoy, S., Hanus, M.: Functional logic design patterns. In: Hu, Z., Rodríguez-Artalejo, M. (eds.) FLOPS 2002. LNCS, vol. 2441, pp. 67–87. Springer, Heidelberg (2002)

    Chapter  Google Scholar 

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

    Chapter  Google Scholar 

  12. 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), Lisbon, Portugal, pp. 73–82 (September 2009)

    Google Scholar 

  13. Antoy, S., Hanus, M.: Functional logic programming. Comm. of the ACM 53(4), 74–85 (2010)

    Article  Google Scholar 

  14. Antoy, S., Hanus, M., Liu, J., Tolmach, A.: A virtual machine for functional logic computations. In: Grelck, C., Huch, F., Michaelson, G.J., Trinder, P. (eds.) IFL 2004. LNCS, vol. 3474, pp. 108–125. Springer, Heidelberg (2005)

    Chapter  Google Scholar 

  15. Antoy, S., Jost, A.: Compiling a functional logic language: The fair scheme. In: 23rd Int’nl Symp. on Logic-based Program Synthesis and Transformation (LOPSTR 2013), pp. 129–143. Dpto. de Systems Informaticos y Computation, Universidad Complutense de Madrid, TR-11-13, Madrid, Spain (Sept. 2013). Extended version available at http://web.cecs.pdx.edu/~antoy/homepage/publications/lopstr13/long.pdf

  16. Antoy, S., Peters, A.: Compiling a functional logic language: The basic scheme. In: Schrijvers, T., Thiemann, P. (eds.) FLOPS 2012. LNCS, vol. 7294, pp. 17–31. Springer, Heidelberg (2012)

    Chapter  Google Scholar 

  17. Brassel, B.: Implementing Functional Logic Programs by Translation into Purely Functional Programs. PhD thesis, Christian-Albrechts-Universität zu Kiel (2011)

    Google Scholar 

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

    Chapter  Google Scholar 

  19. Brassel, B., Huch, F.: On a tighter integration of functional and logic programming. In: Shao, Z. (ed.) APLAS 2007. LNCS, vol. 4807, pp. 122–138. Springer, Heidelberg (2007)

    Chapter  Google Scholar 

  20. Brassel, B., Huch, F.: The Kiel Curry System KiCS. In: Seipel, D., Hanus, M. (eds.) Preproceedings of the 21st Workshop on (Constraint) Logic Programming (WLP 2007), Wüurzburg, Germany, pp. 215–223 (October 2007). Technical report 434

    Google Scholar 

  21. Caballero, R., Sánchez, J. (eds.) TOY: A Multiparadigm Declarative Language (version 2.3.1) (2007). http://toy.sourceforge.net

  22. Echahed, R., Janodet, J.C.: On constructor-based graph rewriting systems. Technical report 985-I, IMAG (1997). ftp://ftp.imag.fr/pub/labo-LEIBNIZ/OLD-archives/PMP/c-graph-rewriting.ps.gz

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

    Article  MATH  Google Scholar 

  24. Fokkink, W., van de Pol, J.: Simulation as a correct transformation of rewrite systems. In: Privara, I., Ružička, P. (eds.) MFCS 1997. LNCS, vol. 1295, pp. 249–258. Springer, Heidelberg (1997)

    Chapter  Google Scholar 

  25. González Moreno, J.C., López Fraguas, F.J., Hortalá González, M.T., Rodríguez Artalejo, M.: An approach to declarative programming based on a rewriting logic. The Journal of Logic Programming 40, 47–87 (1999)

    Article  MATH  Google Scholar 

  26. Hanus, M.: Efficient translation of lazy functional logic programs into Prolog. In: Proietti, M. (ed.) LOPSTR 1995. LNCS, vol. 1048, pp. 252–266. Springer, Heidelberg (1996)

    Chapter  Google Scholar 

  27. Hanus, M. (ed.) Curry: An Integrated Functional Logic Language (Vers. 0.8.2) (2006). http://www-ps.informatik.uni-kiel.de/currywiki/

  28. Hanus, M.: Multi-paradigm declarative languages. In: Dahl, V., Niemelä, I. (eds.) ICLP 2007. LNCS, vol. 4670, pp. 45–75. Springer, Heidelberg (2007)

    Chapter  Google Scholar 

  29. Hanus, M. (ed.) PAKCS 1.9.1: The Portland Aachen Kiel Curry System (2008). http://www.informatik.uni-kiel.de/~pakcs

  30. Hanus, M., Kuchen, H., Moreno-Navarro, J.J.: Curry: A truly functional logic language. In: Proceedings of the ILPS 1995 Workshop on Visions for the Future of Logic Programming, Portland, Oregon, pp. 95–107 (1995)

    Google Scholar 

  31. Hanus, M., Sadre, R.: An abstract machine for Curry and its concurrent implementation in Java. Journal of Functional and Logic Programming 1999(Special Issue 1), 1–45 (1999)

    Google Scholar 

  32. Huet, G., Lévy, J.-J.: Computations in orthogonal term rewriting systems. In: Lassez, J.-L., Plotkin, G. (eds.) Computational Logic: Essays in Honour of Alan Robinson. MIT Press, Cambridge, MA (1991)

    Google Scholar 

  33. Hussmann, H.: Nondeterministic algebraic specifications and nonconfluent rewriting. Journal of Logic Programming 12, 237–255 (1992)

    Article  MathSciNet  MATH  Google Scholar 

  34. Johnsson, T.: Lambda lifting: Transforming programs to recursive equations. In: Jouannaud, J.-P. (ed.) FPCA 1985. LNCS, vol. 201, pp. 190–203. Springer, Heidelberg (1985)

    Chapter  Google Scholar 

  35. Kamperman, J.F.T., Walters, H.R.: Simulating TRSs by minimal TRSs a simple, efficient, and correct compilation technique. Technical report CS-R9605, CWI (1996)

    Google Scholar 

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

    Article  Google Scholar 

  37. López-Fraguas, F.J., Martin-Martin, E., Rodríguez-Hortalá, J., Sánchez-Hernández, J.: Rewriting and narrowing for constructor systems with call-time choice semantics. In: Theory and Practice of Logic Programming, pp. 1–49 (2012)

    Google Scholar 

  38. López-Fraguas, F.J., Rodríguez-Hortalá, J., Sánchez-Hernández, J.: A simple rewrite notion for call-time choice semantics. In: PPDP 2007: Proceedings of the 9th ACM SIGPLAN international conference on Principles and practice of declarative programming, pp. 197–208. ACM, New York, NY, USA (2007)

    Google Scholar 

  39. Fraguas, F.J.L., Hernández, J.S.: TOY: A multiparadigm declarative system. In: Narendran, P., Rusinowitch, M. (eds.) RTA 1999. LNCS, vol. 1631, pp. 244–247. Springer, Heidelberg (1999)

    Chapter  Google Scholar 

  40. Lux, W. (ed.) The Münster Curry Compiler (2012). http://danae.uni-muenster.de/~lux/curry/

  41. Warren, D.H.D.: Higher-order extensions to PROLOG: are they needed? Machine Intelligence 10, 441–454 (1982)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Sergio Antoy .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2014 Springer International Publishing Switzerland

About this paper

Cite this paper

Antoy, S., Jost, A. (2014). Compiling a Functional Logic Language: The Fair Scheme . In: Gupta, G., Peña, R. (eds) Logic-Based Program Synthesis and Transformation. LOPSTR 2013. Lecture Notes in Computer Science(), vol 8901. Springer, Cham. https://doi.org/10.1007/978-3-319-14125-1_12

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-14125-1_12

  • Published:

  • Publisher Name: Springer, Cham

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

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

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics