JOURNAL ARTICLE

Functional Programming with Datalog

Pacak, AndréErdweg, Sebastian

Year: 2022 Journal:   Leibniz-Zentrum für Informatik (Schloss Dagstuhl)   Publisher: Schloss Dagstuhl – Leibniz Center for Informatics

Abstract

Datalog is a carefully restricted logic programming language. What makes Datalog attractive is its declarative fixpoint semantics: Datalog queries consist of simple Horn clauses, yet Datalog solvers efficiently compute all derivable tuples even for recursive queries. However, as we argue in this paper, Datalog is ill-suited as a programming language and Datalog programs are hard to write and maintain. We propose a "new" frontend for Datalog: functional programming with sets called functional IncA. While programmers write recursive functions over algebraic data types and sets, we transparently translate all code to Datalog relations. However, we retain Datalog’s strengths: Functions that generate sets can encode arbitrary relations and mutually recursive functions have fixpoint semantics. We also ensure that the generated Datalog program terminates whenever the original functional program terminates, so that we can apply off-the-shelve bottom-up Datalog solvers. We demonstrate the versatility and ease of use of functional IncA by implementing a type checker, a program transformation, an interpreter of the untyped lambda calculus, two data-flow analyses, and clone detection of Java bytecode.

Keywords:
Datalog Tuple Functional programming Logic programming Deductive database Program analysis Code (set theory) Data type ENCODE Prolog

Metrics

7
Cited By
1.37
FWCI (Field Weighted Citation Impact)
0
Refs
0.80
Citation Normalized Percentile
Is in top 1%
Is in top 10%

Citation History

Topics

Logic, programming, and type systems
Physical Sciences →  Computer Science →  Artificial Intelligence
Formal Methods in Verification
Physical Sciences →  Computer Science →  Computational Theory and Mathematics
Logic, Reasoning, and Knowledge
Physical Sciences →  Computer Science →  Artificial Intelligence

Related Documents

JOURNAL ARTICLE

Declarative Probabilistic Programming with Datalog

Vince BárányBalder ten CateBenny KimelfeldDan OlteanuZografoula Vagena

Journal:   ACM Transactions on Database Systems Year: 2017 Vol: 42 (4)Pages: 1-35
JOURNAL ARTICLE

Declarative Probabilistic Programming with Datalog

Vince BárányBalder ten CateBenny KimelfeldDan OlteanuZografoula Vagena

Journal:   Leibniz-Zentrum für Informatik (Schloss Dagstuhl) Year: 2016
JOURNAL ARTICLE

Dynamic programming in Datalog with aggregates

Sergio Greco

Journal:   IEEE Transactions on Knowledge and Data Engineering Year: 1999 Vol: 11 (2)Pages: 265-283
JOURNAL ARTICLE

Object-Oriented Fixpoint Programming with Datalog

D. A. KloppSebastian ErdwegAndré Pacak

Journal:   Proceedings of the ACM on Programming Languages Year: 2024 Vol: 8 (OOPSLA2)Pages: 60-86
© 2026 ScienceGate Book Chapters — All rights reserved.