Logica

Logica is an open-source, declarative logic programming language based on Datalog which is designed for data manipulation and analysis. Logica is held out to be "modern logic programming".

Logica was developed at Google as a successor to Yedalog.  Yedalog, also based on Datalog, aims to address perceived usability limitations of SQL. So, Logica and Yedalog both belong to the Datalog "family".

Logic programming is a declarative programming paradigm based on formal logic where the program is written as a set of logical statements. Logic programming was developed in the 1960s. Prolog and Datalog are the most prominent examples of logic programming languages. LISP is another approach to logic programming. Answer Set Programming (ASP) is another approach to logic programming. 

Datalog is the logic used by relational databases.  Datalog is a subset of first order logic that can safely be processed by computer based processes because it avoids logical paradoxes which can cause catastrophic system failures.  That is one of the reasons why relational databases are so reliable.

Datalog and relational databases are based on the same ideas, which is to think of data as relations and data manipulation (i.e. processing that data) as a set of steps which perform operations over these relations. 

Datalog and SQL differ in how these operations are described but their processing gives you the same result. But Datalog was inspired by the mathematical syntax of the first order propositional logic whereas SQL follows more of a natural language looking syntax.

While the intent of SQL, which is an ISO standard, was to give people without formal training in computer programming or mathematics the capability to access database information; the reality is that expressing complex logic in SQL is nontrivial.  

Older Yedalog and now Logica are an attempt to make access to data easer using an elegant syntax of Logic Programming to solve practical problems and leverage the tremendous advances of SQL infrastructure for the execution of that logic.

All this ties into another ISO standard called Common Logic (CL).   Common Logic is not just a single logic language, rather it is a framework for a family of logic-based languages designed to support knowledge representation and information interchange across diverse computer systems which use a multitude of technology stacks. All of these logic languages use first order logic but the syntax and expressive power of the languages can be different.

But Datalog is a common denominator between all the logic languages in this "family" of logic languages.  Basically, Logica makes SQL and Datalog easier to use.  Logica bridges the gap between SQL and Datalog.

SQL is powerful but can be verbose when trying to write complex queries in what often becomes procedural in style.

Datalog is elegant but lacks widespread tooling and integration.

Logica merges the two: it lets you write logical rules that feel like Datalog, but compiles them into optimized SQL queries that run on real-world databases. This hybrid approach means you get the:
  • semantic clarity of logic programming
  • performance and scalability of mature SQL engines
  • modularity and reusability of declarative rules
But what if you took Logica to the next level.  What if you had a specific dialect of Logica that understands business reports.  That is what I think XBRL International's XBRL Rules and Query Language 3.0 is all about.  I originally thought that YAML might be the way to go; but maybe Logica could be better.

Additional Information:

Comments

Popular posts from this blog

Big Idea for 2025: Semantic Accounting and Audit Working Papers

Microsoft CEO: "AI Agents will Replace All Software"

Professional Study Group for Digital Financial Reporting