Diamonds Are Forever: Stabilization Semantics for Unrestricted Aggregation and Recursion in Logica
EVGENY SKVORTSOV, YILIN XIA, OJASWA GARG, SHAWN BOWERS, BERTRAM LUDÄSCHERAbstract
Logica is an open-source logic programming language that compiles to SQL and runs on platforms including DuckDB, SQLite, PostgreSQL, and BigQuery. Unlike classic Datalog, Logica permits the free combination of recursion and aggregation, enabling concise formulations of algorithms from shortest paths to PageRank. This expressiveness introduces fundamental semantic challenges: aggregate predicates are updated by replacement rather than accumulation, evaluation is sensitive to rule scheduling, and programs may converge to meaningful results without ever reaching a fixpoint, placing them outside the scope of traditional fixpoint semantics. We address these challenges with
Defendant-Opponent (DO) semantics
, a stabilization-based framework for nonmonotonic logic programs. Program evaluation is modeled as a rewrite system over derivation states. A ground atom is true if, from every reachable state, there exists a continuation after which the atom persists in all further derivations. This notion admits two equivalent characterizations: (1) game-theoretically, truth is what a Defendant can defend against any Opponent in a three-turn derivation game; and (2) modally, a formula