Abstract
Datalog is a declarative logic programming language that has been used in a variety of applications, including big-data analytics, language processing, networking and distributed systems, and program analysis.
In this paper, we propose first-class Datalog constraints as a mechanism to construct, compose, and solve Datalog programs at run time. The benefits are twofold: We gain the full power of a functional programming language to operate on Datalog constraints-as-values, while simultaneously we can use Datalog where it really shines: to declaratively express and solve fixpoint problems.
We present an extension of the lambda calculus with first-class Datalog constraints, including its semantics and a type system with row polymorphism based on Hindley-Milner. We prove soundness of the type system and implement it as an extension of the Flix programming language.
Supplemental Material
- Peter Alvaro, Neil Conway, Joseph M Hellerstein, and William R Marczak. 2011. Consistency Analysis in Bloom: a CALM and Collected Approach. In Proc. Conference on Innovative Data Systems (CIDR).Google Scholar
- Peter Alvaro, William R Marczak, Neil Conway, Joseph M Hellerstein, David Maier, and Russell Sears. 2010. Dedalus: Datalog in time and space. In International Datalog 2.0 Workshop.Google Scholar
- Michael Arntzenius and Neel Krishnaswami. 2019. Seminaïve evaluation for a higher-order functional language. Proc. of ACM on Programming Languages Principles of Programming Languages (POPL) ( 2019 ).Google Scholar
- Michael Arntzenius and Neelakantan R Krishnaswami. 2016. Datafun: a functional Datalog. In Proc. International Conference on Functional Programming.Google Scholar
Digital Library
- Pavel Avgustinov, Oege De Moor, Michael Peyton Jones, and Max Schäfer. 2016. QL: Object-oriented queries on relational data. In Proc. European Conference on Object-Oriented Programming (ECOOP 2016 ).Google Scholar
- Francois Bancilhon, David Maier, Yehoshua Sagiv, and Jefrey D Ullman. 1985. Magic Sets and Other Strange Ways to Implement Logic Programs. In Proc. Principles of Database Systems (PODS). https://doi.org/10.1145/6012.15399 Google Scholar
Digital Library
- Aaron Bembenek and Stephen Chong. 2018. FormuLog: Datalog for static analysis involving logical formulae. arXiv preprint arXiv: 1809. 06274 ( 2018 ).Google Scholar
- Martin Bravenboer and Yannis Smaragdakis. 2009. Strictly Declarative Specification of Sophisticated Points-To Analyses. In Proc. Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA). https://doi.org/10.1145/1640089. 1640108 Google Scholar
Digital Library
- Stefano Ceri, Georg Gottlob, and Letizia Tanca. 1989. What You Always Wanted to Know About Datalog (and Never Dared to Ask). IEEE Transactions on Knowledge and Data Engineering (TKDE) ( 1989 ). https://doi.org/10.1109/69.43410 Google Scholar
Digital Library
- Stefano Ceri, Georg Gottlob, and Letizia Tanca. 2012. Logic programming and databases. Springer Science & Business Media.Google Scholar
Digital Library
- Jacques Cohen. 1990. Constraint Logic Programming Languages. Commun. ACM ( 1990 ). https://doi.org/10.1145/79204.79209 Google Scholar
Digital Library
- Neil Conway, William R Marczak, Peter Alvaro, Joseph M Hellerstein, and David Maier. 2012. Logic and Lattices for Distributed Programming. In Proc. Symposium on Cloud Computing (SoCC). https://doi.org/10.1145/2391229.2391230 Google Scholar
Digital Library
- Luis Damas and Robin Milner. 1982. Principal Type-Schemes for Functional Programs. In Proc. Symposium on Principles of Programming Languages (POPL).Google Scholar
Digital Library
- O de Moor, G Gottlob, T Furche, and AJ Sellers (Eds.). 2011. Datalog Reloaded-First International Workshop, Datalog 2010. https://doi.org/10.1007/978-3-642-24206-9 Google Scholar
Cross Ref
- Matthias Felleisen, Robert Bruce Findler, and Matthew Flatt. 2009. Semantics Engineering with PLT Redex.Google Scholar
Digital Library
- Melvin Fitting. 2002. Fixpoint Semantics for Logic Programming a Survey. Theoretical Computer Science (TCS) ( 2002 ). https://doi.org/10.1016/S0304-3975 ( 00 ) 00330-3 Google Scholar
Digital Library
- Michael Gelfond and Vladimir Lifschitz. 1988. The Stable Model Semantics for Logic Programming. In Proc. International Conference on Logic Programming (ICLP/SLP).Google Scholar
- Michael Gelfond and Vladimir Lifschitz. 1991. Classical Negation in Logic Programs and Disjunctive Databases. New Generation Computing ( 1991 ). https://doi.org/10.1007/BF03037169 Google Scholar
Cross Ref
- Goetz Graefe. 1993. Query Evaluation Techniques for Large Databases. ACM Computing Surveys (CSUR) ( 1993 ). https: //doi.org/10.1145/152610.152611 Google Scholar
Digital Library
- Steve Gregory. 1987. Parallel Logic Programming in PARLOG: The Language and its Implementation. Addison-Wesley.Google Scholar
- Elnar Hajiyev, Mathieu Verbaere, and Oege De Moor. 2006. codeQuest: Scalable Source Code Queries with Datalog. In Proc. European Conference on Object-Oriented Programming (ECOOP). https://doi.org/10.1007/11785477_2 Google Scholar
Digital Library
- Daniel Halperin, Victor Teixeira de Almeida, Lee Lee Choo, Shumo Chu, Paraschos Koutris, Dominik Moritz, Jennifer Ortiz, Vaspol Ruamviboonsuk, Jingjing Wang, Andrew Whitaker, et al. 2014. Demonstration of the Myria big data management service. In Proc. International Conference on Management of Data.Google Scholar
Digital Library
- Fergus Henderson, Thomas Conway, Zoltan Somogyi, David Jefery, Peter Schachte, Simon Taylor, Chris Speirs, Tyson Dowd, Ralph Becket, and Mark Brown. 1996. The Mercury language reference manual. ( 1996 ).Google Scholar
- Shan Shan Huang, Todd Jefrey Green, and Boon Thau Loo. 2011. Datalog and Emerging Applications: An Interactive Tutorial. In Proc. Management of Data (SIGMOD). https://doi.org/10.1145/1989323.1989456 Google Scholar
Digital Library
- Joxan Jafar and Jean-Louis Lassez. 1987. Constraint Logic Programming. In Proc. Principles of Programming Languages (POPL). https://doi.org/10.1145/41625.41635 Google Scholar
Digital Library
- Joxan Jafar and Michael J Maher. 1994. Constraint Logic Programming: A Survey. Journal of Logic Programming ( 1994 ). https://doi.org/10.1016/ 0743-1066 ( 94 ) 90033-7 Google Scholar
Cross Ref
- Herbert Jordan, Bernhard Scholz, and Pavle Subotić. 2016. Souflé: On Synthesis of Program Analyzers. In International Conference on Computer Aided Verification.Google Scholar
- Herbert Jordan, Bernhard Scholz, and Pavle Subotic. 2018. Two concurrent data structures for eficient datalog query processing. In Proc. Symposium on Principles and Practice of Parallel Programming.Google Scholar
- George Kastrinis and Yannis Smaragdakis. 2013. Hybrid context-sensitivity for points-to analysis. Proc. International Conference on Programming Language Design and Implementation (PLDI) ( 2013 ).Google Scholar
Digital Library
- Ross D King. 2004. Applying Inductive Logic Programming to Predicting Gene Function. AI Magazine ( 2004 ).Google Scholar
- Kenneth Kunen. 1987. Negation in Logic Programming. Journal of Logic Programming ( 1987 ). https://doi.org/10.1016/ 0743-1066 ( 87 ) 90007-0 Google Scholar
Digital Library
- Monica S Lam, John Whaley, V Benjamin Livshits, Michael C Martin, Dzintars Avots, Michael Carbin, and Christopher Unkel. 2005. Context-sensitive Program Analysis as Database Queries. In Proc. Principles of Database Systems (PODS). https://doi.org/10.1145/1065167.1065169 Google Scholar
Digital Library
- Daan Leijen. 2005. Extensible records with scoped labels. Trends in Functional Programming ( 2005 ).Google Scholar
- Ninghui Li and John C Mitchell. 2003. Datalog with Constraints: A Foundation for Trust Management Languages. In Proc. Practical Aspects of Declarative Languages (PADL). https://doi.org/10.1007/3-540-36388-2_6 Google Scholar
Cross Ref
- Boon Thau Loo, Tyson Condie, Minos Garofalakis, David E Gay, Joseph M Hellerstein, Petros Maniatis, Raghu Ramakrishnan, Timothy Roscoe, and Ion Stoica. 2009. Declarative networking. Commun. ACM ( 2009 ).Google Scholar
- Magnus Madsen and Ondřej Lhoták. 2020. Fixpoints for the Masses: Programming with First-class Datalog Constraints. Technical Report CS-2020-05. University of Waterloo. https://cs.uwaterloo.ca/sites/ca.computer-science/files/uploads/ ifles/cs-2020-05.pdfGoogle Scholar
- Magnus Madsen, Ming-Ho Yee, and Ondřej Lhoták. 2016. From Datalog to Flix: A Declarative Language for Fixed Points on Lattices. In Programming Language Design and Implementation (PLDI).Google Scholar
- Jack Minker. 1988. Foundations of Deductive Databases and Logic Programming. Morgan Kaufmann.Google Scholar
- Raymond J Mooney. 1996. Inductive Logic Programming for Natural Language Processing. In International Conference on Inductive Logic Programming.Google Scholar
- Christos H. Papadimitriou. 1985. A note the expressive power of Prolog. Bulletin of the European Association for Theoretical Computer Science (EATCS) ( 1985 ).Google Scholar
- Thomas Reps, Susan Horwitz, and Mooly Sagiv. 1995. Precise Interprocedural Dataflow Analysis via Graph Reachability. In Proc. Principles of Programming Languages (POPL). https://doi.org/10.1145/199448.199462 Google Scholar
Digital Library
- Mooly Sagiv, Thomas Reps, and Susan Horwitz. 1996. Precise Interprocedural Dataflow Analysis with Applications to Constant Propagation. Theoretical Computer Science (TCS) ( 1996 ). https://doi.org/10.1016/ 0304-3975 ( 96 ) 00072-2 Google Scholar
Digital Library
- Max Schäfer and Oege de Moor. 2010. Type inference for datalog with complex type hierarchies. In Proc. Symposium on Principles of Programming Languages (POPL).Google Scholar
Digital Library
- Bernhard Scholz, Herbert Jordan, Pavle Subotić, and Till Westmann. 2016. On fast large-scale program analysis in datalog. In Proc. International Conference on Compiler Construction (CC).Google Scholar
Digital Library
- Jiwon Seo, Stephen Guo, and Monica S Lam. 2013. SociaLite: Datalog extensions for eficient social network analysis. In International Conference Data Engineering (ICDE).Google Scholar
- Alexander Shkapsky, Mohan Yang, Matteo Interlandi, Hsuan Chiu, Tyson Condie, and Carlo Zaniolo. 2016. Big Data Analytics with Datalog Queries on Spark. In Proc. International Conference on Management of Data.Google Scholar
Digital Library
- Yannis Smaragdakis, George Balatsouras, and George Kastrinis. 2013. Set-based pre-processing for points-to analysis. In Proc. International Conference on Object Oriented Programming Systems Languages & Applications (OOPSLA).Google Scholar
Digital Library
- Yannis Smaragdakis and Martin Bravenboer. 2011. Using Datalog for Fast and Easy Program Analysis. In Datalog Reloaded. https://doi.org/10.1145/1926385.1926390 Google Scholar
Digital Library
- Yannis Smaragdakis, Martin Bravenboer, and Ondrej Lhoták. 2011. Pick Your Contexts Well: Understanding Object-Sensitivity. In Proc. Principles of Programming Languages (POPL). https://doi.org/10.1145/1925844.1926390 Google Scholar
Digital Library
- Yannis Smaragdakis, George Kastrinis, and George Balatsouras. 2014. Introspective analysis: context-sensitivity, across the board. Proc. International Conference on Programming Language Design and Implementation (PLDI).Google Scholar
Digital Library
- Zoltan Somogyi, Fergus Henderson, and Thomas Conway. 1996. The Execution Algorithm of Mercury, an Eficient Purely Declarative Logic Programming Language. The Journal of Logic Programming ( 1996 ).Google Scholar
- Zoltan Somogyi, Fergus J Henderson, and Thomas Charles Conway. 1995. Mercury, an eficient purely declarative logic programming language. Australian Computer Science Communications ( 1995 ).Google Scholar
- Soufle Authors. 2018. Soufle. https://soufle-lang.github.io/ [Online; accessed 18-October-2018].Google Scholar
- Pavle Subotic, Herbert Jordan, Lijun Chang, Alan Fekete, and Bernhard Scholz. 2018. Automatic Index Selection for Large-Scale Datalog Computation. ( 2018 ).Google Scholar
- Jefrey D Ullman. 1984. Principles of Database Systems. Galgotia publications.Google Scholar
- Jefrey D. Ullman. 1988. Principles of Database and Knowledge-Base Systems.Google Scholar
- Todd L Veldhuizen. 2012. Leapfrog Triejoin: a worst-case optimal join algorithm. arXiv preprint arXiv:1210.0481 ( 2012 ).Google Scholar
- Andrew K Wright and Matthias Felleisen. 1994. A Syntactic Approach to Type Soundness. Information and computation ( 1994 ).Google Scholar
- David Zook, Emir Pasalic, and Beata Sarna-Starosta. 2009. Typed datalog. In International Symposium on Practical Aspects of Declarative Languages (PADL).Google Scholar
Index Terms
Fixpoints for the masses: programming with first-class Datalog constraints
Recommendations
Datafun: a functional Datalog
ICFP '16Datalog may be considered either an unusually powerful query language or a carefully limited logic programming language. Datalog is declarative, expressive, and optimizable, and has been applied successfully in a wide variety of problem domains. ...
Datafun: a functional Datalog
ICFP 2016: Proceedings of the 21st ACM SIGPLAN International Conference on Functional ProgrammingDatalog may be considered either an unusually powerful query language or a carefully limited logic programming language. Datalog is declarative, expressive, and optimizable, and has been applied successfully in a wide variety of problem domains. ...
First-Order Logic Characterization of Program Properties
A program is first-order reducible (FO-reducible) w.r.t. a set IC of integrity constraints if there exists a first-order theory T such that the set of models for T is exactly the set of intended models for the program w.r.t. all possible EDBs. In this ...






Comments