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

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.

[1]  Dr. Pierre Deransart,et al.  Prolog: The Standard , 1996, Springer Berlin Heidelberg.

[2]  Mario Rodríguez-Artalejo,et al.  Functional and Constraint Logic Programming , 2001, CCL.

[3]  J. C. Gonz Alez-Moreno,et al.  An Approach to Declarative Programming Based on a Rewriting Logic , 2022 .

[4]  Rachid Echahed,et al.  A needed narrowing strategy , 2000, JACM.

[5]  Michael Hanus,et al.  Multi-paradigm Declarative Languages , 2007, ICLP.

[6]  Simon L. Peyton Jones,et al.  A history of Haskell: being lazy with class , 2007, HOPL.

[7]  Frank Zartmann,et al.  Denotational Abstract Interpretation of Functional Logic Programs , 1997, SAS.

[8]  Tobias Nipkow,et al.  Term rewriting and all that , 1998 .

[9]  Michael Hanus,et al.  Type-based nondeterminism checking in functional logic programs , 2000, PPDP '00.

[10]  Philip Wadler,et al.  Theorems for free! , 1989, FPCA.

[11]  Enrique Martin-Martin Type classes in functional logic programming , 2011, PEPM '11.

[12]  Michael Hanus,et al.  Curry: an integrated functional logic language (version 0 , 2003 .

[13]  Martin Odersky,et al.  Polymorphic type inference and abstract data types , 1994, TOPL.

[14]  Pierre Deransart,et al.  Prolog - the standard: reference manual , 1996 .

[15]  Francisco Javier López-Fraguas,et al.  An Approach to Declarative Programming Based on a Rewriting Logic , 1999, J. Log. Program..

[16]  Juan Rodríguez-Hortalá,et al.  Rewriting and Call-Time Choice: The HO Case , 2008, FLOPS.

[17]  Lee Naish A Higher Order Rewriting Logic for Functional Logic Programming , 1997 .

[18]  Sergio Antoy Optimal Non-deterministic Functional Logic Computations , 1997, ALP/HOA.

[19]  Sergio Antoy Constructor-based conditional narrowing , 2001, PPDP '01.

[20]  Robin Milner,et al.  Principal type-schemes for functional programs , 1982, POPL '82.

[21]  Mario Rodr,et al.  5 Functional and Constraint Logic Programming , 2002 .

[22]  Sergio Antoy,et al.  Typed Higher-Order Narrowing without Higher-Order Strategies , 1999, Fuji International Symposium on Functional and Logic Programming.

[23]  Enrique Martin-Martin,et al.  Liberal Typing for Functional Logic Programs , 2010, APLAS.

[24]  Enrique Martin-Martin,et al.  New Results on Type Systems for Functional Logic Programming , 2009, WFLP.

[25]  Mario Rodríguez-Artalejo,et al.  A Higher Order Rewriting Logic for Functional Logic Programming , 1997, ICLP.

[26]  Jean-Marie Hullot,et al.  Canonical Forms and Unification , 1980, CADE.

[27]  Enrique Martin-Martin,et al.  Advances in Type Systems for Functional Logic Programming , 2008 .

[28]  Francisco Javier López-Fraguas,et al.  TOY: A Multiparadigm Declarative System , 1999, RTA.

[29]  Michael Hanus,et al.  Functional logic programming , 2010, CACM.

[30]  Alberto Martelli,et al.  An Efficient Unification Algorithm , 1982, TOPL.

[31]  Mario Rodríguez-Artalejo,et al.  Polymorphic Types in Functional Logic Programming , 2001, J. Funct. Log. Program..

[32]  Sebastian Fischer,et al.  Transforming Functional Logic Programs into Monadic Functional Programs , 2010, WFLP.