Eliminating Irrelevant Non-determinism in Functional Logic Programs

  • Sergio Antoy
  • Michael Hanus
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10137)


Functional logic programming languages support non-deterministic search and a flexible use of defined operations by applying them to unknown values. The use of these features has the risk that equal values might be computed several times or I/O computations could fail due to non-deterministic subcomputations. To detect such problems at compile time, we present a method to locate non-deterministic operations. If the non-determinism caused by some operation is semantically not relevant, the programmer can direct the compiler to produce only one result of a computation. If all the results of the computations are equal, this directive preserves the semantics and improves the operational behavior of programs. We define the declarative meaning of such annotations and propose both testing and verification techniques that respectively increase the confidence or formally prove that the non-determinism of an operation is irrelevant.


Operational Behavior Critical Pair Proof Obligation Proof Assistant Default Rule 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.



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


  1. 1.
    Albert, E., Hanus, M., Huch, F., Oliver, J., Vidal, G.: Operational semantics for declarative multi-paradigm languages. J. Symbolic Comput. 40(1), 795–829 (2005)MathSciNetCrossRefzbMATHGoogle Scholar
  2. 2.
    Antoy, S.: Definitional trees. In: Kirchner, H., Levi, G. (eds.) ALP 1992. LNCS, vol. 632, pp. 143–157. Springer, Heidelberg (1992). doi: 10.1007/BFb0013825 CrossRefGoogle Scholar
  3. 3.
    Antoy, S., Echahed, R., Hanus, M.: A needed narrowing strategy. J. ACM 47(4), 776–822 (2000)MathSciNetCrossRefzbMATHGoogle Scholar
  4. 4.
    Antoy, S., Hanus, M.: Declarative programming with function patterns. In: Hill, P.M. (ed.) LOPSTR 2005. LNCS, vol. 3901, pp. 6–22. Springer, Heidelberg (2006). doi: 10.1007/11680093_2 CrossRefGoogle Scholar
  5. 5.
    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). doi: 10.1007/11799573_9 CrossRefGoogle Scholar
  6. 6.
    Antoy, S., Hanus, M.: Set functions for functional logic programming. In: Proceedings of PPDP 2009, pp. 73–82. ACM Press (2009)Google Scholar
  7. 7.
    Antoy, S., Hanus, M.: Functional logic programming. Commun. ACM 53(4), 74–85 (2010)CrossRefGoogle Scholar
  8. 8.
    Antoy, S., Hanus, M.: Default rules for Curry. In: Gavanelli, M., Reppy, J. (eds.) PADL 2016. LNCS, vol. 9585, pp. 65–82. Springer, Cham (2016). doi: 10.1007/978-3-319-28228-2_5 CrossRefGoogle Scholar
  9. 9.
    Antoy, S., Hanus, M., Libby, S.: Proving non-deterministic computations in Agda. In: Proceedings of 24th International Workshop on Functional and Logic Programming (WFLP 2016), EPTCS (2016)Google Scholar
  10. 10.
    Braßel, B., Hanus, B., 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)CrossRefGoogle Scholar
  11. 11.
    Caballero, R., López-Fraguas, F.J.: Improving deterministic computations in lazy functional logic languages. J. Funct. Logic Program. 2003 (2003)Google Scholar
  12. 12.
    Christiansen, J., Fischer, S.: EasyCheck — test data for free. In: Garrigue, J., Hermenegildo, M.V. (eds.) FLOPS 2008. LNCS, vol. 4989, pp. 322–336. Springer, Heidelberg (2008). doi: 10.1007/978-3-540-78969-7_23 CrossRefGoogle Scholar
  13. 13.
    Claessen, K., Hughes, J.: QuickCheck: a lightweight tool for random testing of Haskell programs. In: Proceedings of ICFP 2000, pp. 268–279. ACM Press (2000)Google Scholar
  14. 14.
    Cleva, J.M., Leach, J., López-Fraguas, F.J.: A logic programming approach to the verification of functional-logic programs. In: Proceedings of PPDP 2004, pp. 9–19. ACM Press (2004)Google Scholar
  15. 15.
    Fribourg, L.: Slog: a logic programming language interpreter based on clausal superposition and rewriting. In: Proceedings of IEEE International Symposium on Logic Programming, pp. 172–184 (1985)Google Scholar
  16. 16.
    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. Logic Program. 40, 47–87 (1999)MathSciNetCrossRefzbMATHGoogle Scholar
  17. 17.
    Hanus, M.: Efficient implementation of narrowing and rewriting. In: Boley, H., Richter, M.M. (eds.) PDK 1991. LNCS, vol. 567, pp. 344–365. Springer, Heidelberg (1991). doi: 10.1007/BFb0013543 CrossRefGoogle Scholar
  18. 18.
    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). doi: 10.1007/978-3-642-37651-1_6 CrossRefGoogle Scholar
  19. 19.
    Hanus, M., Skrlac, F.: A modular and generic analysis server system for functional logic programs. In: Proceedings of PEPM 2014, pp. 181–188. ACM Press (2014)Google Scholar
  20. 20.
    Hanus, M. et al.: PAKCS: The Portland Aachen Kiel Curry System (2016).
  21. 21.
    Loogen, R., Winkler, S.: Dynamic detection of determinism in functional logic languages. Theor. Comput. Sci. 142, 59–87 (1995)MathSciNetCrossRefzbMATHGoogle Scholar
  22. 22.
    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 PPDP 2007, pp. 197–208. ACM Press (2007)Google Scholar
  23. 23.
    Stump, A.: Verified Functional Programming in Agda. ACM and Morgan & Claypool, New York (2016)CrossRefGoogle Scholar
  24. 24.
    TeReSe: Term Rewriting Systems, vol. 55 of Cambridge Tracts in Theoretical Computer Science. Cambridge University Press, Cambridge (2003)Google Scholar

Copyright information

© Springer International Publishing AG 2017

Authors and Affiliations

  1. 1.Computer Science DepartmentPortland State UniversityOregonUSA
  2. 2.Institut Für InformatikKielGermany

Personalised recommendations