Typed Datalog

David Zook, Emir Pasalic, Beata Sarna-Starosta. Typed Datalog. In Andy Gill, Terrance Swift, editors, Practical Aspects of Declarative Languages, 11th International Symposium, PADL 2009, Savannah, GA, USA, January 19-20, 2009. Proceedings. Volume 5418 of Lecture Notes in Computer Science, pages 168-182, Springer, 2009. [doi]

Abstract

Static type safety is an important feature of many commercial programming languages, as has become apparent in our experience developing LogicBlox—a Datalog-based platform for building enterprise-scale systems for corporate planning. Existing approaches to enhancing Datalog (and Prolog) with type safety are problematic for LogicBlox applications because (1) they do not support inclusion constraints, which are crucial for database reasoning, and (2) their worst-case running times are exponential in the size of the programs. In the LogicBlox environment—where clients interactively add and execute programs and queries—efficient compilation and execution are critical, and so a PTIME type-checking algorithm is preferred. Furthermore, one of the central design goals of LogicBlox is to express the compiler itself in Datalog, which in general excludes exponential-time algorithms.

This paper presents a definition of type safety for Datalog which can express inclusion constraints along with an efficient (PTIME) and sound (but not complete) type-checking algorithm, proposes work-arounds for some common limitations of the algorithm, and indicates how the type-checking algorithm itself may be represented in Datalog.