Advertisement

Formal Aspects of Computing

, Volume 29, Issue 3, pp 475–494 | Cite as

Transforming Boolean equalities into constraints

Original Article
  • 45 Downloads

Abstract

Although functional as well as logic languages use equality to discriminate between logically different cases, the operational meaning of equality is different in such languages. Functional languages reduce equational expressions to their Boolean values, True or False, logic languages use unification to check the validity only and fail otherwise. Consequently, the language Curry, which amalgamates functional and logic programming features, offers two kinds of equational expressions so that the programmer has to distinguish between these uses. We show that this distinction can be avoided by providing an analysis and transformation method that automatically selects the appropriate operation. Without this distinction in source programs, the language design can be simplified and the execution of programs can be optimized. As a consequence, we show that one kind of equational expressions is sufficient and unification is nothing else than an optimization of Boolean equality.

Keywords

Functional logic programming Program analysis Program transformation Unification 

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. ACE+02.
    Alpuente M, Comini M, Escobar S, Falaschi M, Lucas S (2002) Abstract diagnosis of functional programs. In: Proceedings of the 12th int’l workshop on logic-based program synthesis and transformation (LOPSTR 2002), LNCS 2664. Springer, Berlin, pp 1–16Google Scholar
  2. AEH00.
    Antoy S, Echahed R, Hanus M (2000) A needed narrowing strategy. J ACM 47(4): 776–822MathSciNetCrossRefMATHGoogle Scholar
  3. AH10.
    Antoy S, Hanus M (2010) Functional logic programming. Commun ACM 53(4): 74–85CrossRefGoogle Scholar
  4. AH12.
    Antoy S, Hanus M (2012) Contracts and specifications for functional logic programming. In: Proceedings of the 14th international symposium on practical aspects of declarative languages (PADL 2012), LNCS 7149. Springer, Berlin, pp 33–47Google Scholar
  5. AH14.
    Antoy S, Hanus M (2014) Curry without success. In: Proceedings of the 23rd international workshop on functional and (constraint) logic programming (WFLP 2014). CEUR workshop proceedings, vol 1335. CEUR-WS.org, pp 140–154Google Scholar
  6. AHH+05.
    Albert E, Hanus M, Huch F, Oliver J, Vidal G (2005) Operational semantics for declarative multi-paradigm languages. J Symb Comput 40(1): 795–829MathSciNetCrossRefMATHGoogle Scholar
  7. Ant01.
    Antoy S (2001) Constructor-based conditional narrowing. In: Proceedings of the 3rd international ACM SIGPLAN conference on principles and practice of declarative programming (PPDP 2001). ACM Press, New York, pp 199–206Google Scholar
  8. Ant10.
    Antoy S (2010) Programming with narrowing. J Symbol Comput 45(5): 501–522MathSciNetCrossRefMATHGoogle Scholar
  9. AGL94.
    Arenas-Sánchez P, Gil-Luezas A, López-Fraguas FJ (1994) Combining lazy narrowing with disequality constraints. In: Proceedings of the 6th international symposium on programming language implementation and logic programming, LNCS 844. Springer, Berlin, pp 385–399Google Scholar
  10. BE95.
    Bert D, Echahed R (1995) Abstraction of conditional term rewriting systems. In: Proceedings of the 1995 international logic programming symposium. MIT Press, Massachusetts, pp 147–161Google Scholar
  11. BEØ93.
    Bert D, Echahed R, Østvold M (1993) Abstract rewriting. In: Proceedings of third international workshop on static analysis, LNCS 724. Springer, Berlin, pp 178–192Google Scholar
  12. BHPR11.
    Braßel B, Hanus M, Peemöller B, Reck F (2011) KiCS2: a new compiler from Curry to Haskell. In: Proceedings of the 20th international workshop on functional and (constraint) logic programming (WFLP 2011), LNCS 6816. Springer, Berlin, pp 1–18Google Scholar
  13. BHPR13.
    Braßel B, Hanus M, Peemöller B, Reck F (2013) Implementing equational constraints in a functional language. In: Proceedings of the 15th international symposium on practical aspects of declarative languages (PADL 2013), LNCS 7752. Springer, Berlin, pp 125–140Google Scholar
  14. CC77.
    Cousot P, Cousot R (1977) Abstract interpretation: a unified lattice model for static analysis of programs by construction of approximation of fixpoints. In: Proceedings of the 4th ACM symposium on principles of programming languages, pp 238–252Google Scholar
  15. Cou97.
    Cousot P (1997) Types as abstract interpretations. In: Proceedings of the 24th ACM symposium on principles of programming languages (Paris), pp 316–331Google Scholar
  16. DM82.
    Damas L, Milner R (1982) Principal type-schemes for functional programs. In: Proceedings of the 9th annual symposium on principles of programming languages, pp 207–212Google Scholar
  17. HAB+16.
    Hanus M, Antoy S, Braßel B, Engelke M, Höppner K, Koj J, Niederau P, Sadre R, Steiner F (2016) PAKCS: the Portland Aachen Kiel Curry system. http://www.informatik.uni-kiel.de/~pakcs/
  18. Han97.
    Hanus M (1997) Teaching functional and logic programming with a single computation model. In: Proceedings of the ninth international symposium on programming languages, implementations, logics, and programs (PLILP’97), LNCS 1292. Springer, Berlin, pp 335–350Google Scholar
  19. Han01.
    Hanus M (2001) High-level server side web scripting in Curry. In: Proceedings of the third international symposium on practical aspects of declarative languages (PADL’01), LNCS 1990. Springer, Berlin, pp 76–92Google Scholar
  20. Han07.
    Hanus M (2007) Putting declarative programming into the web: translating Curry to JavaScript. In: Proceedings of the 9th ACM SIGPLAN international conference on principles and practice of declarative programming (PPDP’07). ACM Press, New York, pp 155–166Google Scholar
  21. Han08.
    Hanus M (2008) Call pattern analysis for functional logic programs. In: Proceedings of the 10th ACM SIGPLAN international conference on principles and practice of declarative programming (PPDP’08). ACM Press, New York, pp 67–78Google Scholar
  22. Han12.
    Hanus M (ed) (2012) Curry: an integrated functional logic language (vers. 0.8.3). http://www.curry-language.org
  23. Han13.
    Hanus M (2013) Functional logic programming: from theory to Curry. In: Programming logics—essays in memory of Harald Ganzinger, LNCS 7797. Springer, Berlin, pp 123–168Google Scholar
  24. Han16.
    Hanus M (ed) (2016) Curry: an integrated functional logic language (vers. 0.9.0). http://www.curry-language.org
  25. HS14.
    Hanus M, Skrlac F (2014) A modular and generic analysis server system for functional logic programs. In: Proceedings of the ACM SIGPLAN 2014 workshop on partial evaluation and program manipulation (PEPM’14). ACM Press, New York, pp 181–188Google Scholar
  26. KLMR92.
    Kuchen H, López-Fraguas FJ, Moreno-Navarro JJ, Rodríguez-Artalejo M (1992) Implementing a lazy functional logic language with disequality constraints. In: Proceedings of the 1992 joint international conference and symposium on logic programming. MIT Press, CambridgeGoogle Scholar
  27. MR07.
    Mitchell N, Runciman C (2007) A static checker for safe pattern matching in Haskell. In: Trends in functional programming, vol 6. Intellect, New York, pp 15–30Google Scholar
  28. Myc80.
    Mycroft A (1980) The theory and practice of transforming call-by-need into call-by-value. In: Proceedings of the international symposium on programming, LNCS 83. Springer, Berlin, pp 269–281Google Scholar
  29. OSS02.
    Overton D, Somogyi Z, Stuckey PJ (2002) Constraint-based mode analysis of mercury. In: Proceedings of the 4th ACM SIGPLAN international conference on principles and practice of declarative programming (PPDP’02). ACM Press, Berlin, pp 109–120Google Scholar
  30. PJ03.
    Peyton Jones S (ed) (2003) Haskell 98 language and libraries—the revised report. Cambridge University Press, CambridgeGoogle Scholar
  31. Red85.
    Reddy US (1985) Narrowing as the operational semantics of functional languages. In: Proceedings of the IEEE internat. symposium on logic programming, Boston, pp 138–151Google Scholar
  32. Rey72.
    Reynolds JC (1972) Definitional interpreters for higher-order programming languages. In: Proceedings of the ACM annual conference, pp 717–740. ACM Press, New YorkGoogle Scholar
  33. Rob65.
    Robinson JA (1965) A machine-oriented logic based on the resolution principle. J. ACM 12(1): 23–41MathSciNetCrossRefMATHGoogle Scholar
  34. SHC96.
    Somogyi Z, Henderson F, Conway T (1996) The execution algorithm of mercury, an efficient purely declarative logic programming language. J Logic Program 29(1–3): 17–64CrossRefMATHGoogle Scholar
  35. Sla74.
    Slagle JR (1974) Automated theorem-proving for theories with simplifiers, commutativity, and associativity. J ACM 21(4): 622–642MathSciNetCrossRefMATHGoogle Scholar
  36. Ter03.
    Bezem M, Klop JW, de Vrijer R (eds) (2003) Term rewriting systems. Cambridge University Press, CambridgeGoogle Scholar
  37. War82.
    Warren DHD (1982) Higher-order extensions to prolog: are they needed? In: Machine intelligence, vol 10, pp 441–454Google Scholar

Copyright information

© British Computer Society 2016

Authors and Affiliations

  1. 1.Computer Science Dept.Portland State UniversityOregonUSA
  2. 2.Institut für InformatikCAU KielKielGermany

Personalised recommendations