skip to main content
10.1145/3236950.3236953acmotherconferencesArticle/Chapter ViewAbstractPublication PagesppdpConference Proceedingsconference-collections
research-article

Implicit Parameters for Logic Programming

Published: 03 September 2018 Publication History

Abstract

Implicit parameters allow programmers to omit certain arguments from function calls and have them automatically inferred by the compiler based on their types. At every call site, the compiler determines the values of the implicit parameters based on their declared types and the bindings currently in implicit scope. The programmer controls this mechanism in two ways: by adding bindings to the implicit scope, or by explicitly providing the implicit parameters for the function call.
Implicit parameters are known from functional and object-oriented languages such as Haskell and Scala. In recent years, more languages have added support for implicit parameters, including Agda, Coq, and Idris. Implicit parameters have played an impressive role as the foundation for a broad range of language features such as type classes, capability and effect systems, software transactional memory, macros, and more.
In this paper, we propose a design of implicit parameters for typed Horn clause based logic programming languages, such as Datalog and Prolog. We illustrate the usefulness of implicit parameters and show how they support logic programming in the large. We explore some of the differences that arise between implicit parameters in functional languages and in logic languages.

References

[1]
Peter Alvaro, William R Marczak, Neil Conway, Joseph M Hellerstein, David Maier, and Russell Sears. 2011. Dedalus: Datalog in Time and Space. In Datalog Reloaded.
[2]
Martin Bravenboer and Yannis Smaragdakis. 2009. Strictly Declarative Specification of Sophisticated Points-To Analyses. In Proc. Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA).
[3]
Nathan G Bronson, Hassan Chafi, and Kunle Olukotun. 2010. CCSTM: A Library-based STM for Scala. In Proc. Workshop on Scala (SCALA).
[4]
Eugene Burmako. 2013. Scala Macros: Let Our Powers Combine!: On How Rich Syntax and Static Types work with Metaprogramming. In Proc. Workshop on Scala (SCALA).
[5]
Dominique Devriese and Frank Piessens. 2011. On the Bright Side of Type Classes: Instance Arguments in Agda. In Proc. International Conference on Functional Programming (ICFP).
[6]
Philipp Haller and Alex Loiko. 2016. LaCasa: Lightweight Affinity and Object Capabilities in Scala. In Proc. Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA).
[7]
Mark Jones. 1999. Exploring the Design Space for Typebased Implicit Parameterization. Technical Report. Oregon Graduate Institute.
[8]
Jeffrey R Lewis, John Launchbury, Erik Meijer, and Mark B Shields. 2000. Implicit Parameters: Dynamic Scoping with Static Types. In Proc. Principles of Programming Languages (POPL).
[9]
Magnus Madsen, Ming-Ho Yee, and Ondřej Lhoták. 2016. From Datalog to Flix: A Declarative Language for Fixed Points on Lattices. In Proc. Programming Language Design and Implementation (PLDI).
[10]
Adriaan Moors, Tiark Rompf, Philipp Haller, and Martin Odersky. 2012. Scala-Virtualized. In Partial Evaluation and Program Manipulation (PEPM).
[11]
Bruno CdS Oliveira, Adriaan Moors, and Martin Odersky. 2010. Type Classes as Objects and Implicits. In Proc. Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA).
[12]
Bruno CdS Oliveira, Tom Schrijvers, Wontae Choi, Wonchan Lee, and Kwangkeun Yi. 2012. The Implicit Calculus: A New Foundation for Generic Programming. In Proc. Programming Language Design and Implementation (PLDI).
[13]
Leo Osvald, Grégory Essertel, Xilun Wu, Lilliam I González Alayón, and Tiark Rompf. 2016. Gentrification Gone Too Far? Affordable 2nd-class Values for Fun and (co-) Effect. In Proc. Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA).
[14]
Yannis Smaragdakis, Martin Bravenboer, and Ondrej Lhoták. 2011. Pick Your Contexts Well: Understanding Object-Sensitivity. In Proc. Principles of Programming Languages (POPL).
[15]
Zoltan Somogyi, Fergus Henderson, and Thomas Conway. 1996. The Execution Algorithm of Mercury, an Efficient Purely Declarative Logic Programming Language. The Journal of Logic Programming (1996).
[16]
Zoltan Somogyi, Fergus J Henderson, and Thomas Charles Conway. 1995. Mercury, an Efficient Purely Declarative Logic Programming Language. (1995).
[17]
Jean Yang et al. 2015. Preventing Information Leaks with Policy-Agnostic Programming. Ph.D. Dissertation. Massachusetts Institute of Technology.

Cited By

View all

Recommendations

Reviews

Prahladavaradan Sampath

The art of programming is all about building programs that are concise, elegant, efficient, and, most importantly, readable and understandable by others. Software engineers use a number of tools to make code readable, for example, well-designed types, expressive names, and architectural principles such as DRY and SOLID. These tools are in turn supported by language features such as strong type systems, as well as features in the programming language and integrated development environment (IDE) such as code navigation, automatic inference of types, online static analysis of code, and so on. The current paper is an exposition of one such micro feature: simplifying argument lists for functions and procedures. In most modern programming languages, functions (or more generally relations) and procedures are the smallest unit of construction. Any practitioner would be familiar with the conundrum of how to maximize reuse of the algorithmic part of the procedure while still minimizing the interface (or arguments) of the procedure. Language features such as hierarchical name scopes and inheritance provide different design points for this aspect of language design. Implicit parameters is one such language feature that directly tackles the problem of argument lists. In many practical situations there is a strong correlation between the parameters passed to a procedure and the context in which it is called. Implicit parameters are designed to automatically detect these correlations from the program structure and automate the inference of parameters to a procedure call. Often when a procedure is called, for example, there is only one variable of a particular type visible in the context of the procedure call-this is especially true when the program is well structured using principles such as DRY and SOLID. The paper addresses the problem of inferring arguments to predicates in the context of logic programming languages where the notion of control and information flow is implicit. The authors provide a simple formalization of the problem of inferring arguments in the context of logic programs, along with a very attractive solution in terms of a handful of inference rules that should be quite easy to implement as a preprocessing step in a compiler/interpreter. They also formalize a set of attributes for evaluating implicit parameter schemes: type safety, consistency, determinism, and predictability, and show that their formulation has these attributes. It will be interesting to compare the formalization provided by this paper with implicit parameter schemes in other languages-default parameters in C++, implicit parameters in Scala, and named and default parameters in OCaml all fall into this category. An even more ambitious endeavor would be to deeply explore the relation with type classes in Haskell and name resolution in C++; these language features are proven in practice to provide the infrastructure for large-scale programming, and the current paper could provide the basis of an approach for importing these features into logic programming languages.

Access critical reviews of Computing literature here

Become a reviewer for Computing Reviews.

Comments

Information & Contributors

Information

Published In

cover image ACM Other conferences
PPDP '18: Proceedings of the 20th International Symposium on Principles and Practice of Declarative Programming
September 2018
306 pages
ISBN:9781450364416
DOI:10.1145/3236950
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]

In-Cooperation

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 03 September 2018

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. implicit parameters
  2. typed logic programming

Qualifiers

  • Research-article
  • Research
  • Refereed limited

Conference

PPDP '18

Acceptance Rates

PPDP '18 Paper Acceptance Rate 22 of 39 submissions, 56%;
Overall Acceptance Rate 230 of 486 submissions, 47%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • 0
    Total Citations
  • 96
    Total Downloads
  • Downloads (Last 12 months)5
  • Downloads (Last 6 weeks)1
Reflects downloads up to 30 Jan 2025

Other Metrics

Citations

Cited By

View all

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