skip to main content
10.1145/2103746.2103763acmconferencesArticle/Chapter ViewAbstractPublication PagespepmConference Proceedingsconference-collections
research-article

Well-typed narrowing with extra variables in functional-logic programming

Published: 23 January 2012 Publication History

Abstract

Narrowing is the usual computation mechanism in functional-logic programming (FLP), where bindings for free variables are found at the same time that expressions are reduced. These free variables may be already present in the goal expression, but they can also be introduced during computations by the use of program rules with extra variables. However, it is known that narrowing in FLP generates problems from the point of view of types, problems that can only be avoided using type information at run-time. Nevertheless, most FLP systems use static typing based on Damas-Milner type system and they do not carry any type information in execution, thus ill-typed reductions may be performed in these systems. In this paper we prove, using the let-narrowing relation as the operational mechanism, that types are preserved in narrowing reductions provided the substitutions used preserve types. Based on this result, we prove that types are also preserved in narrowing reductions without type checks at run-time when higher order (HO) variable bindings are not performed and most general unifiers are used in unifications, for programs with transparent patterns. Then we characterize a restricted class of programs for which no binding of HO variables happens in reductions, identifying some problems encountered in the definition of this class. To conclude, we use the previous results to show that a simulation of needed narrowing via program transformation also preserves types.

References

[1]
S. Antoy. Optimal non-deterministic functional logic computations. In Proc. 6th Int. Conf. on Algebraic and Logic Programming (ALP'97), pages 16--30. Springer LNCS 1298, 1997.
[2]
S. Antoy. Constructor based conditional narrowing. In Proc. 3rd Int. Conf. on Principles and Practice of Declarative Programming (PPDP'01), pages 199--206. ACM, 2001.
[3]
S. Antoy and M. Hanus. Functional logic programming. Commun. ACM, 53 (4): 74--85, 2010.
[4]
S. Antoy and A. Tolmach. Typed higher-order narrowing without higher-order strategies. In Proc. 4th Int. Symp. on Functional and Logic Programming (FLOPS'99), pages 335--352. Springer LNCS 1722, 1999.
[5]
S. Antoy, R. Echahed, and M. Hanus. A needed narrowing strategy. J. ACM, 47: 776--822, July 2000.
[6]
F. Baader and T. Nipkow. Term Rewriting and All That. Cambridge University Press, 1998.
[7]
B. Brassel. Two to three ways to write an unsafe type cast without importing unsafe - Curry mailing list. http://www.informatik.uni-kiel.de/ curry/listarchive/0705.html, May 2008.
[8]
B. Brassel, S. Fischer, M. Hanus and F. Reck Transforming Functional Logic Programs into Monadic Functional Programs In Proc. 19th Int. Work. on Functional and (Constraint) Logic Programming (WFLP'10), Springer LNCS 6559, pages 30--47, 2011.
[9]
L. Damas and R. Milner. Principal type-schemes for functional programs. In Proc. 9th ACM SIGPLAN-SIGACT Symp. on Principles of Programming Languages (POPL'82), pages 207--212. ACM, 1982.
[10]
R. del Vado Vırseda. Estrategias de estrechamiento perezoso. Master's thesis, Universidad Compluetense de Madrid, 2002.
[11]
P. Deransart, A. Ed-Dbali, and L. Cervoni. Prolog: The Standard. Reference Manual. Springer, 1996.
[12]
J. González-Moreno, T. Hortalá-González, and M. Rodríguez-Artalejo. A higher order rewriting logic for functional logic programming. In Proc. 14th Int. Conf. on Logic Programming (ICLP'97), pages 153--167. MIT Press, 1997.
[13]
J. González-Moreno, T. Hortalá-González, F. López-Fraguas, and M. Rodríguez-Artalejo. An approach to declarative programming based on a rewriting logic. Journal of Logic Programming, 40 (1): 47--87, 1999.
[14]
J. González-Moreno, T. Hortalá-González, and M. Rodríguez-Artalejo. Polymorphic types in functional logic programming. Journal of Functional and Logic Programming, 2001 (1), July 2001.
[15]
M. Hanus. Multi-paradigm declarative languages. In Proc. 23rd Int. Conf. on Logic Programming (ICLP'07), pages 45--75. Springer LNCS 4670, 2007.
[16]
M. Hanus (ed.). Curry: An integrated functional logic language (version 0.8.2). http://www.informatik.uni-kiel.de/ curry/report.html, March 2006.
[17]
M. Hanus and F. Steiner. Type-based nondeterminism checking in functional logic programs. In Proc. 2nd. Inf. Conf. Principles and Practice of Declarative Programming. (PDP 2000), pages 202--213, ACM, 2000.
[18]
P. Hudak, J. Hughes, S. Peyton Jones, and P. Wadler. A history of Haskell: being lazy with class. In Proc. 3rd ACM SIGPLAN Conf. on History of Programming Languages (HOPL III), pages 12--1--12--55. ACM, 2007.
[19]
J.-M. Hullot. Canonical forms and unification. In Proc. 5th Conf. on Automated Deduction (CADE-5), pages 318--334. Springer LNCS 87, 1980.
[20]
K. Laufer and M. Odersky. Polymorphic type inference and abstract data types. ACM Trans. Program. Lang. Syst., 16: 1411--1430, 1994.
[21]
F. López-Fraguas, E. Martin-Martin, and J. Rodríguez-Hortalá. Liberal typing for functional logic programs. In Proc. 8th Asian Symp. on Programming Languages and Systems (APLAS'10), pages 80--96. Springer LNCS 6461, 2010.
[22]
F. López-Fraguas, E. Martin-Martin, and J. Rodríguez-Hortalá. New results on type systems for functional logic programming. In Proc. 18th Int. Workshop on Functional and (Constraint) Logic Programming (WFLP'09), Revised Selected Papers, pages 128--144. Springer LNCS 5979, 2010.
[23]
F. López-Fraguas, E. Martin-Martin, and J. Rodríguez-Hortalá. Well-typed narrowing with extra variables in functional-logic programming (extended version). Technical Report SIC-11--11, Universidad Complutense de Madrid, November 2011. Available at http://gpd.sip.ucm.es/enrique/publications/pepm12/SIC-11--11.pdf.
[24]
F. López-Fraguas and J. Sánchez-Hernández. TOY: A multiparadigm declarative system. In Proc. 10th Int. Conf. on Rewriting Techniques and Applications (RTA'99), pages 244--247. Springer LNCS 1631, 1999.
[25]
F. López-Fraguas, J. Rodríguez-Hortalá, and J. Sánchez-Hernández. Rewriting and call-time choice: the HO case. In Proc. 9th Int. Symp. on Functional and Logic Programming (FLOPS'08), pages 147--162. Springer LNCS 4989, 2008.
[26]
W. Lux. Adding Haskell-style overloading to Curry. In Workshop of Working Group 2.1.4 of the German Computing Science Association GI, pages 67--76, 2008.
[27]
A. Martelli and U. Montanari. An efficient unification algorithm. ACM Trans. Program. Lang. Syst., 4 (2): 258--282, 1982.
[28]
E. Martin-Martin. Advances in type systems for functional logic programming. Master's thesis, Universidad Complutense de Madrid, July 2009. http://gpd.sip.ucm.es/enrique/publications/master/masterThesis.pdf.
[29]
E. Martin-Martin. Type classes in functional logic programming. In Proc. 20th ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation (PEPM'11), pages 121--130. ACM, 2011.
[30]
M. Rodríguez-Artalejo. Functional and constraint logic programming. In Constraints in Computational Logics, pages 202--270. Springer LNCS 2002, 2001.
[31]
P. Wadler. Theorems for free! In phProc. 4th Int. Conf. on Functional Programming Languages and Computer Architecture (FPCA'89), pages 347--359. ACM, 1989.
[32]
F. Zartmann. Denotational abstract interpretation of functional logic programs. In Proc. 4th Int. Symp. on Static Analysis (SAS'97), pages 141--159. Springer LNCS 1302, 1997.

Cited By

View all
  • (2013)Typing as functional-logic evaluationProceedings of the ACM SIGPLAN 2013 workshop on Partial evaluation and program manipulation10.1145/2426890.2426896(23-32)Online publication date: 21-Jan-2013
  • (2012)Transparent function typesProceedings of the 14th symposium on Principles and practice of declarative programming10.1145/2370776.2370793(127-138)Online publication date: 19-Sep-2012

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
PEPM '12: Proceedings of the ACM SIGPLAN 2012 workshop on Partial evaluation and program manipulation
January 2012
172 pages
ISBN:9781450311182
DOI:10.1145/2103746
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

In-Cooperation

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 23 January 2012

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. extra variables
  2. functional-logic programming
  3. narrowing
  4. type systems

Qualifiers

  • Research-article

Conference

POPL '12
Sponsor:

Acceptance Rates

Overall Acceptance Rate 66 of 120 submissions, 55%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)0
  • Downloads (Last 6 weeks)0
Reflects downloads up to 25 Feb 2025

Other Metrics

Citations

Cited By

View all
  • (2013)Typing as functional-logic evaluationProceedings of the ACM SIGPLAN 2013 workshop on Partial evaluation and program manipulation10.1145/2426890.2426896(23-32)Online publication date: 21-Jan-2013
  • (2012)Transparent function typesProceedings of the 14th symposium on Principles and practice of declarative programming10.1145/2370776.2370793(127-138)Online publication date: 19-Sep-2012

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media