Papers
Topics
Authors
Recent
Search
2000 character limit reached

The Chase in Lean -- Crafting a Formal Library for Existential Rule Research

Published 24 Apr 2026 in cs.LO and cs.DB | (2604.22531v1)

Abstract: The chase is a sound, complete, but possibly non-terminating algorithm for reasoning with existential rules (aka. tuple-generating dependencies), a highly expressive knowledge representation language. Although the procedure appears simple, research on theoretical properties and optimization for practical implementations has grown to a point where verifying correctness and reproducing proofs becomes challenging and intuition can sometimes be misleading. Lean is a purely functional programming language and interactive theorem prover whose community actively develops formal libraries for mathematics (Mathlib) and computer science (CSLib). In this work, we present our own endeavor of crafting a Lean framework around existential rules and the chase. We discuss design decisions concerning the nuances of chase definitions commonly found in the literature and show how these translate into Lean. To illustrate the framework's capabilities using known results, we show that the result of a chase is a universal model and outline the formalization for proving that without so-called "alternative matches" it is even a core. Beyond existing literature, we unify sufficient chase termination conditions in the likeness of Model-Faithful Acyclicity (MFA) into a common framework while also adding support for constants in rules.

Authors (1)

Summary

  • The paper formalizes the chase procedure for existential rules in Lean, establishing a precise and extensible mechanized framework.
  • It introduces a novel representation of existential witnesses using skolemized local information to ensure uniqueness and simplify proof construction.
  • The framework unifies termination checks and acyclicity notions, enabling verified universality, core properties, and robust model construction.

Formalization of the Chase Procedure for Existential Rules in Lean

Introduction and Motivation

This work addresses the formalization of the chase—a foundational reasoning algorithm in knowledge representation—within the Lean proof assistant. The chase operates over existential rules (tuple-generating dependencies), which underpin much of the theoretical and applied work in ontology-based query answering, database theory, and rule-based knowledge representation. While the chase's conceptual simplicity is well appreciated, advances in the theory and optimizations for practical systems have introduced considerable complexity, making hand-verification of correctness and completeness proofs increasingly error-prone. This creates a clear impetus for mechanized, machine-verifiable formal libraries capable of both encoding foundational definitions and supporting extensible, rigorous formalization of chase variants and their properties.

The author presents a Lean-based library capturing the chase over existential and disjunctive rules, emphasizing mathematical precision, extensibility, and support for proven properties central to existential rule research. The framework generalizes across multiple chase variants (such as Skolem, restricted/standard, and others), unifies the formal treatment of termination conditions (MFA-like acyclicity notions), and incorporates support for constants in rules. Beyond rederiving known results, several generalizations and new formal connections are established.

Core Design Decisions and Lean Formalization

A pivotal conceptual decision in this formalization is the representation of "fresh" existential witnesses via Skolem terms parameterized by local information (rule, head-disjunct, variable, and binding), rather than relying on mutable global state or ad hoc nulls. This leverages the local determinacy and guarantees uniqueness "by design," simplifying mechanization and proof construction.

Rules are encoded structurally, with disjunctive heads represented as lists, and existential variables inferred implicitly (those not present in the body). Various term and atom types are distinguished to minimize case splits in proofs; atoms are parameterized over general term types, accommodating the nuanced requirements of proof development and efficient code navigation.

For rule application, the definition of "trigger" is formalized: a trigger pairs a rule with a ground substitution covering the body variables. The critical element is the generalization of obsolescence conditions, abstracting beyond specific chase instances (Skolem, restricted, etc.). This abstraction is captured as a class of obsolescence predicates satisfying essential properties: subset-monotonicity, entailment of satisfaction, triviality when the head is already present, and closure under equivalence of triggers. This generalization permits uniform treatment and simplifies later extension to new chase variants.

Crucially, the chase sequence is encoded as a coinductive structure, accommodating both finite and infinite derivations as found in practice. The sequence consists of nodes annotated with both the current fact set and the originating trigger, facilitating traceability and inductive reasoning principles amenable to formal proof construction. The branch- and tree-based views are developed in parallel, supporting both the deterministic (linear) and disjunctive (tree-shaped) settings.

Main Formal Results

Universality and Model Construction

One of the canonical results formalized is the universality of the chase tree result: for any model of the knowledge base, some member of the chase result homomorphically maps to it. The formal proof, mechanized in Lean, leverages an inductive construction of appropriate branches and homomorphisms, making precise the inductive choices and their extension to infinite unions of fact sets. The coinductive approach allows the construction of infinite branches, coupling them tightly to the limit objects required for universal model sets.

Cores and Alternative Matches

The library extends formalization to the combinatorial notion of cores. In the absence of "alternative matches" (witnesses of redundancy), the chase result on deterministic rules is not just universal but in fact a (strong) core—that is, every endomorphism is an automorphism. The precise definition of alternative matches captures when an existential witness is redundant, and the formal proof follows by contradiction, refining inductively any endomorphism failing to be strong or injective. A key auxiliary result establishes that any homomorphism from a fact set in the branch to the result can be extended to the entire result; this is handled via a corecursive (possibly infinite) sequence of homomorphisms and is demonstrably crucial for the main contradiction argument.

Unified Framework for MFA-like Termination Conditions

Chase termination is undecidable in general, but various semantic acyclicity notions—Model-Faithful Acyclicity (MFA), Disjunctive MFA (DMFA), and Restricted MFA (RMFA)—supply sufficient conditions. The author generalizes these into an overarching framework parameterized by monotone obsolescence conditions, supporting arbitrary chase variants and rules with constants. The approach constructs a symbolic over-approximation of possible chase sequences over a canonical database, and proves that finiteness of this symbolic computation guarantees termination for all grounded instances.

Differences between acyclicity notions are unified via the choice of obsolescence predicates and which triggers are considered active. The technical handling of fresh constants (for non-frontier variables during backtracking and trigger renaming) and cyclic term detection is made precise using Lean's set-theoretic and inductive machinery, ensuring both correctness and termination of the acyclicity check. The framework introduces clear interfaces for plugging in new acyclicity checks or chase variants, evidenced by its uniform handling of (D)MFA, RMFA, and possible future extensions (e.g., non-termination conditions and advanced cyclicity notions).

Implications and Future Directions

The formal library provides an extensible and machine-verifiable foundation for the mathematics of existential rule reasoning. Immediately, it gives tools for verifying correctness and independence of theoretical claims, especially where intuition is known to be misleading, as exemplified in subtle results about complexity and fairness. Practically, this groundwork can seed the development of formally verified implementations of reasoning systems and acyclicity checkers, either for theoretical certification or for robust backbone implementations in practical systems.

The explicit executable content (proofs and, in principle, code) enables the eventual synthesis of reference chase engines and acyclicity testers within Lean, offering an environment combining high assurance with the potential for efficient realization. Notably, this is likely to influence the development of certified query engines, verified analysis tools, and proof assistants supporting knowledge representation languages with existential rules and constraints.

On the theoretical front, formalization surfaces areas ripe for clarification or generalization, such as non-termination criteria (cf. DMFC and RPC), deeper properties of core chase, or connectives to computability and decidability analysis in more expressive fragments of existential rules.

Conclusion

This paper presents a comprehensive Lean-based formalization of the chase for existential rules, generalizing across multiple chase semantics, supporting constants, and unifying acyclicity notions. Strong formal results are established: the chase yields universal models, is guaranteed to be a core if alternative matches are avoided, and chase termination is ensured by the (parametrized) finite computation simulating acyclicity checks even in the presence of constants. The approach provides a robust platform for both researchers and practitioners aiming for mechanized assurance in complex logical reasoning workflows, and opens clear prospects for verified implementations of knowledge-based systems and further theoretical investments in existential rule research.

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Collections

Sign up for free to add this paper to one or more collections.