20 research outputs found

    From Boolean Equalities to Constraints

    Get PDF
    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

    Singular and Plural Functions for Functional Logic Programming

    Full text link
    Functional logic programming (FLP) languages use non-terminating and non-confluent constructor systems (CS's) as programs in order to define non-strict non-determi-nistic functions. Two semantic alternatives have been usually considered for parameter passing with this kind of functions: call-time choice and run-time choice. While the former is the standard choice of modern FLP languages, the latter lacks some properties---mainly compositionality---that have prevented its use in practical FLP systems. Traditionally it has been considered that call-time choice induces a singular denotational semantics, while run-time choice induces a plural semantics. We have discovered that this latter identification is wrong when pattern matching is involved, and thus we propose two novel compositional plural semantics for CS's that are different from run-time choice. We study the basic properties of our plural semantics---compositionality, polarity, monotonicity for substitutions, and a restricted form of the bubbling property for constructor systems---and the relation between them and to previous proposals, concluding that these semantics form a hierarchy in the sense of set inclusion of the set of computed values. We have also identified a class of programs characterized by a syntactic criterion for which the proposed plural semantics behave the same, and a program transformation that can be used to simulate one of them by term rewriting. At the practical level, we study how to use the expressive capabilities of these semantics for improving the declarative flavour of programs. We also propose a language which combines call-time choice and our plural semantics, that we have implemented in Maude. The resulting interpreter is employed to test several significant examples showing the capabilities of the combined semantics. To appear in Theory and Practice of Logic Programming (TPLP)Comment: 53 pages, 5 figure

    Constraint Functional Logic Programming over Finite Domains.

    Get PDF
    Abstract In this paper, we present our proposal to Constraint Functional Logic Programming over Finite Domains (CFLP (FD) ) with a lazy functional logic programming language which seamlessly embodies finite domain (FD) constraints. This proposal increases the expressiveness and power of constraint logic programming over finite domains (CLP (FD) ) by combining functional and relational notation, curried expressions, higher-order functions, patterns, partial applications, non-determinism, lazy evaluation, logical variables, types, domain variables, constraint composition, and finite domain constraints. We describe the syntax of the language, its type discipline, and its declarative and operational semantics. We also describe TOY(FD), an implementation for CFLP (FD) , and a comparison of our approach with respect to CLP (FD) from a programming point of view, showing the new features we introduce. And, finally, we show a performance analysis which demonstrates that our implementation is competitive with respect to existing CLP (FD) systems and that clearly outperforms the closer approach to CFLP (FD)

    Programmiersprachen und Rechenkonzepte

    Get PDF
    Seit 1984 veranstaltet die GI-Fachgruppe "Programmiersprachen und Rechenkonzepte", die aus den ehemaligen Fachgruppen 2.1.3 "Implementierung von Programmiersprachen" und 2.1.4 "Alternative Konzepte f眉r Sprachen und Rechner" hervorgegangen ist, regelm盲脽ig im Fr眉hjahr einen Workshop im Physikzentrum Bad Honnef. Das Treffen dient in erster Linie dem gegenseitigen Kennenlernen, dem Erfahrungsaustausch, der Diskussion und der Vertiefung gegenseitiger Kontakte

    Programming with Specifications

    Get PDF
    This thesis explores the use of specifications for the construction of correct programs. We go beyond their standard use as run-time assertions, and present algorithms, techniques and implementations for the tasks of 1) program verification, 2) declarative programming and 3) software synthesis. These results are made possible by our advances in the domains of decision procedure design and implementation. In the first part of this thesis, we present a decidability result for a class of logics that support user-defined recursive function definitions. Constraints in this class can encode expressive properties of recursive data structures, such as sortedness of a list, or balancing of a search tree. As a result, complex verification conditions can be stated concisely and solved entirely automatically. We also present a new decision procedure for a logic to reason about sets and constraints over their cardinalities. The key insight lies in a technique to decompose con- straints according to mutual dependencies. Compared to previous techniques, our algorithm brings significant improvements in running times, and for the first time integrates reasoning about cardinalities within the popular DPLL(T ) setting. We integrated our algorithmic ad- vances into Leon, a static analyzer for functional programs. Leon can reason about constraints involving arbitrary recursive function definitions, and has the desirable theoretical property that it will always find counter-examples to assertions that do not hold. We illustrate the flexibility and efficiency of Leon through experimental evaluation, where we used it to prove detailed correctness properties of data structure implementations. We then illustrate how program specifications can be used as a high-level programming construct ; we present Kaplan, an extension of Scala with first-class logical constraints. Kaplan allows programmers to create, manipulate and combine constraints as they would any other data structure. Our implementation of Kaplan illustrates how declarative programming can be incorporated into an existing mainstream programming language. Moreover, we examine techniques to transform, at compile-time, program specifications into efficient executable code. This approach of software synthesis combines the correctness benefits of declarative programming with the efficiency of imperative or functional programming

    A generic, collaborative framework for internal constraint solving

    Get PDF
    Esta tesis propone un esquema gen茅rico y cooperativo para CLP(Interval(X)) donde X es cualquier dominio de computaci贸n con estructura de ret铆culo. El esquema, que est谩 basado en la teor铆a de ret铆culos, es un enfoque general para la satisfacci贸n y op-timizaci贸n de restricciones de intervalo as铆 como para la cooperaci贸n de resolutores de intervalo definidos sobre dominios de computaci贸n con estructura de ret铆culos, independientemente de la cardinalidad de estos. Nuestra propuesta asegura un enfoque transparente sobre el cual las restricciones, los dominios de computaci贸n y los mecanismos de propagaci贸n y cooperaci贸n, definidos entre las variables restringidas, pueden ser f谩cilmente especificados a nivel del usuario. La parte principal de la tesis presenta una especificaci贸n formal de este esquema.Los principales resultados conseguidos en esta tesis son los siguientes:Una comparativa global de la eficiencia y algunos aspectos de la expresividad de ocho sistemas de restricciones. Esta comparativa, realizada sobre el dominio finito y el dominio Booleano, muestra diferencias principales entre los sistemas de restricciones existentes.Para formalizar el marco de satisfacci贸n de restricciones para CLP(Interval(X))hemos descrito el proceso global de resoluci贸n de restricciones de intervalo sobre cualquier ret铆culo, separando claramente los procesos de propagaci贸n y divisi贸n (ramificaci贸n) de intervalos. Una de las ventajas de nuestra propuesta es que la mon贸tona de las restricciones esta impl铆citamente definida en la teor铆a. Adem谩s, declaramos un conjunto de propiedades interesantes que, bajo ciertas condiciones, son satisfechas por cualquier instancia del esquema gen茅rico. Mas a煤n, mostramos que muchos sistemas de restricciones actualmente existentes satisfacen estas condiciones y, adem谩s, proporcionamos indicaciones sobre como extender el sistema mediante la especificaci贸n de otras instancias interesantes y novedosas. Nuestro esquema para CLP(Interval(X)) permite la cooperaci贸n de resolutores de manera que la informaci贸n puede 鈦皍ir entre diferentes dominios de computaci贸n.Adem谩s, es posible combinar distintas instancias del esquema: por ejemplo, instancias bien conocidas tales como CLP(Interval(<)), CLP(Interval(Integer)),CLP(Interval(Set)), CLP(Interval(Bool)), y otras novedosas que son el resultado de la generaci贸n de nuevos dominios de computaci贸n definidos por el usuario, o incluso que surgen de la combinaci贸n de dominios ya existentes como puede ser CLP(Interval(X1 拢 : : : 拢 Xn)). Por lo tanto, X puede ser instanciado a cualquier conjunto de dominios de computaci贸n con estructura de ret铆culo de forma que su correspondiente instancia CLP(Interval(X)) permite una amplia flexibilidad en la definici贸n de dominios en X (probablemente definidos por el usuario) y en la interaccion entre estos dominios.Mediante la implementacion de un prototipo, demostramos que un unico sistema,que este basado en nuestro esquema para CLP(Interval(X)), puede proporcionarsoporte para la satisfaccion y la optimizacion de restricciones as como para la cooperacion de resolutores sobre un conjunto conteniendo multiples dominios decomputacion. Ademas, el sistema sigue un novedoso enfoque transparente sujeto a una doble perspectiva ya que el usuario puede definir no solo nuevas restricciones y su mecanismo de propagacion, sino tambien nuevos dominios sobre los cuales nuevas restricciones pueden ser resueltas as como el mecanismo de cooperacion entre todos los dominios de computaci贸n (ya sean definidos por el usuario o predefinidos por el sistema).En nuestra opini贸n, esta tesis apunta nuevas y potenciales direcciones de investigaci贸n dentro de la comunidad de las restricciones de intervalo.Para alcanzar los resultados expuestos, hemos seguido los siguientes pasos (1) la elecci贸n de un enfoque adecuado sobre el cual construir los fundamentos te贸ricos de nuestro esquema gen茅rico; (2) la construcci贸n de un marco te贸rico gen茅rico (que llamaremos el marco b谩sico) para la propagaci贸n de restricciones de intervalo sobre cualquier ret铆culo; (3) la integraci贸n, en el marco b谩sico, de una t茅cnica novedosa que facilita la cooperaci贸n de resolutores y que surge de la definici贸n, sobre m煤ltiples dominios, de operadores de restricciones y (4) la extensi贸n del marco resultante para la resoluci贸n y optimizaci贸n completa de las restricciones de intervalo.Finalmente presentamos clp(L), un lenguaje de programaci贸n l贸gica de restricciones de intervalo que posibilita la resoluci贸n de restricciones sobre cualquier conjunto de ret铆culos y que esta implementado a partir de las ideas formalizadas en el marco te贸rico. Describimos una primera implementaci贸n de este lenguaje y desarrollamos algunos ejemplos de como usarla. Este prototipo demuestra que nuestro esquema para CLP(Interval(X)) puede ser implementado en un sistema 煤nico que, como consecuencia, proporciona, bajo un enfoque transparente sobre dominios y restricciones, cooperaci贸n de resolutores as铆 como satisfacci贸n y optimizaci贸n completa de restricciones sobre diferentes dominios de computaci贸n
    corecore