From Non-determinism to Goroutines: A Fair Implementation of Curry in Go

The declarative programming language Curry amalgamates demand-driven evaluation from functional programming with non-determinism from logic programming. In contrast to Prolog, the search strategy for non-deterministic computations is not fixed so that complete or parallel strategies are reasonable for Curry. In particular, a desirable option is a fair strategy which frees the programmer from considering the influence of the search strategy to the success of a computation. In this paper we describe an implementation with this property. Based on recent developments on operational models for functional logic programming, we present a new implementation which transforms Curry programs in several transformation steps into Go programs. By exploiting lightweight threads in the form of goroutines, we obtain a complete and fair implementation which automatically uses multi-processing to speed up non-deterministic computations. This has the effect that, in some cases, non-deterministic algorithms are more efficiently evaluated than deterministic ones.

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

[2]  Heinrich Hußmann Nondeterministic Algebraic Specifications and Nonconfluent Term Rewriting , 1988, ALP.

[3]  A needed narrowing strategy , 2000, JACM.

[4]  Francesca Rossi,et al.  Strict and Nonstrict Independent And-Parallelism in Logic Programs: Correctness, Efficiency, and Compile-Time Conditions , 1995, J. Log. Program..

[5]  Seif Haridi,et al.  ANDORRA Prolog - An Integration of Prolog and Committed Choice Languages , 1988, FGCS.

[6]  John C. Reynolds,et al.  Definitional Interpreters for Higher-Order Programming Languages , 1972, ACM '72.

[7]  Wolfgang Lux Implementing Encapsulated Search for a Lazy Functional Logic Language , 1999, Fuji International Symposium on Functional and Logic Programming.

[8]  Simon L. Peyton Jones,et al.  Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine , 1992, Journal of Functional Programming.

[9]  Michael Hanus,et al.  Transforming Boolean equalities into constraints , 2017, Formal Aspects of Computing.

[10]  Sergio Antoy,et al.  On the correctness of pull-tabbing , 2011, Theory and Practice of Logic Programming.

[11]  Sergio Antoy,et al.  The Pull-Tab Transformation , 2010 .

[12]  Ramin Sadre,et al.  An Abstract Machine for Curry and Its Concurrent Implementation in Java , 1999, J. Funct. Log. Program..

[13]  Germán Vidal,et al.  Operational semantics for declarative multi-paradigm languages , 2005, J. Symb. Comput..

[14]  Jacques Chassin de Kergommeaux,et al.  Parallel logic programming systems , 1994, CSUR.

[15]  Michael Hanus,et al.  Set functions for functional logic programming , 2009, PPDP '09.

[16]  Hassan Aâ¢t-Kaci Warren's Abstract Machine: A Tutorial Reconstruction , 1991 .

[17]  Detlef Plump,et al.  Term graph rewriting , 1999 .

[18]  John Launchbury,et al.  A natural semantics for lazy evaluation , 1993, POPL '93.

[19]  R Echahed,et al.  On Constructor-based Graph Rewriting Systems on Constructor-based Graph Rewriting Systems , 1997 .

[20]  Will Partain,et al.  The nofib Benchmark Suite of Haskell Programs , 1992, Functional Programming.

[21]  D. H. D. Warren 22 Higher-order extensions to PROLOG : are they needed ? , 2013 .

[22]  Bernd Brassel,et al.  On a Tighter Integration of Functional and Logic Programming , 2007, APLAS.

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

[24]  Michael Hanus,et al.  Contracts and Specifications for Functional Logic Programming , 2012, PADL.

[25]  Philip Wadler,et al.  How to declare an imperative , 1997, CSUR.

[26]  Ramin Sadre,et al.  Pakcs: The portland aachen kiel curry system , 2000 .

[27]  Sergio Antoy,et al.  Compiling a Functional Logic Language: The Fair Scheme , 2013, LOPSTR.

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

[29]  Michael Hanus,et al.  Declarative Programming with Function Patterns , 2005, LOPSTR.

[30]  Michael Hanus,et al.  A Virtual Machine for Functional Logic Computations , 2004, IFL.

[31]  Michael Hanus Improving Lazy Non-Deterministic Computations by Demand Analysis , 2012, ICLP.

[32]  Michael Hanus,et al.  CurryCheck: Checking Properties of Curry Programs , 2016, LOPSTR.

[33]  Alan Robinson,et al.  Computational Logic - Essays in Honor of Alan Robinson , 1991, Computational Logic - Essays in Honor of Alan Robinson.

[34]  Michael Hanus,et al.  Compiling Multi-Paradigm Declarative Programs into Prolog , 2000, FroCoS.

[35]  Joyce L. Vedral,et al.  Functional Programming Languages and Computer Architecture , 1989, Lecture Notes in Computer Science.

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

[37]  Michael Hanus,et al.  Default rules for Curry* , 2016, Theory and Practice of Logic Programming.

[38]  Michael Hanus,et al.  Functional Logic Programming: From Theory to Curry , 2013, Programming Logics.

[39]  Michael Hanus,et al.  Overlapping Rules and Logic Variables in Functional Logic Programs , 2006, ICLP.

[40]  Michael Hanus,et al.  Compiling Logic Programs with Equality , 1990, PLILP.

[41]  C. A. R. Hoare,et al.  Communicating sequential processes , 1978, CACM.

[42]  Sergio Antoy,et al.  A New Functional-Logic Compiler for Curry: Sprite , 2016, LOPSTR.

[43]  Michael Hanus,et al.  Memoized Pull-Tabbing for Functional Logic Programming , 2020, WFLP.

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

[45]  Hassan Aït-Kaci Warren's Abstract Machine , 1991, ICLP.

[46]  Michael Hanus,et al.  KiCS2: A New Compiler from Curry to Haskell , 2011, WFLP.

[47]  Uday S. Reddy,et al.  Narrowing as the Operational Semantics of Functional Languages , 1985, SLP.

[48]  David H. D. Warren,et al.  The SRI Model for Or-Parallel Execution of Prolog: Abstract Design and Implementation Issues , 1987, SLP.

[49]  Peyton Jones,et al.  Haskell 98 language and libraries : the revised report , 2003 .

[50]  Michael Hanus,et al.  Combining Static and Dynamic Contract Checking for Curry , 2017, LOPSTR.