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

Francisco López-Fraguas, Enrique Martin-Martin, Juan Rodríguez-Hortalá
2012 Proceedings of the ACM SIGPLAN 2012 workshop on Partial evaluation and program manipulation - PEPM '12  
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
more » ... 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. an extension of a lazy purely-functional language similar to Haskell [18], that has been enhanced with logical features, in particular logical variables and non-deterministic functions. Disregarding some syntactic conventions, the following program defining standard list concatenation is valid in all the three mentioned languages:
doi:10.1145/2103746.2103763 dblp:conf/pepm/Lopez-FraguasMR12 fatcat:vd2wxho5jvg6laf23afjlilhlq