Ramsey Quantifiers in Linear Arithmetics

Pascal Bergsträßer, Moses Ganardi, Anthony W. Lin, Georg Zetzsche · DOI

TL;DR

This paper introduces a breakthrough algorithm for eliminating Ramsey quantifiers from common linear arithmetics (LIA, LRA, and LIRA). By reducing the complexity from triply exponential to polynomial for existential formulas, the authors make it practical to use modern SMT solvers for complex verification tasks like proving program termination and checking if formulas can be simplified into "monadic" components.

What Problem Does This Paper Address?

In software verification, we often use Satisfiability Modulo Theories (SMT) to check if certain program properties hold. While standard First-Order Logic (FO) is powerful, it struggles with properties like well-foundedness—the idea that a program won't run forever. To reason about this, researchers use Ramsey quantifiers ($\exists^{\text{ram}}$), which assert the existence of an infinite "clique" (a set of states where every pair satisfies a specific relation) in a graph defined by a formula.

Until now, the algorithms to eliminate these quantifiers—essentially "translating" them back into standard SMT-solvable formulas—were theoretically possible but computationally disastrous (often triply exponential). This made them useless for practical tools. Furthermore, while solutions existed for integers (LIA), the cases for real numbers (LRA) and mixed integer-reals (LIRA) remained largely unsolved or lacked efficient algorithms.

Methods

The authors achieve their results through two "key novel ingredients":

  1. Quantifier Shifting Lemma: They prove a surprising equivalence that allows them to "pull" standard existential quantifiers out from under a Ramsey quantifier. Specifically, they show that choosing a witness for every edge in an infinite clique is equivalent to choosing a witness for every node. This drastically simplifies the formula structure.
  2. Profile-Based Characterization: To handle the infinite nature of cliques, they use "profiles" to describe how sequences of numbers behave (e.g., do they converge to a limit, or diverge to infinity?).
  3. For Integers (LIA), they show that if an infinite clique exists, one must exist in the form of an arithmetic progression ($\mathbf{a}_0 + k\mathbf{a}$).
  4. For Reals (LRA), they develop a more sophisticated sequence form: $\mathbf{a}_k = \mathbf{a} - \frac{1}{k}\mathbf{d}_c + k\mathbf{d}_\infty$. This formula simultaneously captures convergence (via the $1/k$ term) and divergence (via the $k$ term), allowing them to express the existence of a clique as a standard existential formula.

Datasets

The authors evaluated their approach using a prototype implementation in Python, interfacing with the Z3 SMT solver. They used two sets of micro-benchmarks:

  • Termination Benchmarks: Formulas derived from program termination and non-termination examples (e.g., a simplified McCarthy 91 program).
  • Monadic Decomposability Benchmarks: Tests to see if a formula can be broken down into parts that each only involve a single variable. They compared their results against existing tools like mondec1 and a recent tool by Markgraf et al.

Key Insights and Ideas

  • The "Aha" Moment on Complexity: The realization that for existential fragments, the elimination process is polynomial-time and results in a linear-sized formula. This means adding Ramsey quantifiers to SMT solvers adds almost no overhead compared to the original problem's complexity.
  • Bridging the Gap to Reals: Handling LRA was previously difficult because real numbers can converge without ever reaching a limit. The authors' specific sequence construction for LRA is a clever way to "trap" this behavior in a first-order formula.
  • Optimal Complexity for Monadic Decomposability: The paper settles an open problem by proving that checking monadic decomposability for LRA and LIRA is coNP-complete, which is the best possible theoretical complexity.

Key Results

  • Efficiency: The prototype successfully eliminated Ramsey quantifiers from formulas with up to 100 variables in seconds.
  • Scalability: Unlike previous methods where formula size exploded, the authors' output formulas grew linearly with the input size.
  • Superiority over Existing Tools: In monadic decomposability checks, their decision algorithm was significantly faster than mondec1, particularly because their method doesn't require computing the actual decomposition if the goal is just to check if one exists.

Limitations and Future Work

  • Existential Fragment Focus: While the results are powerful for existential formulas, the paper primarily focuses on this fragment. Full First-Order Logic with arbitrary quantifier alternation remains a tougher challenge.
  • Theory Extensions: The authors suggest that extending these techniques to non-linear real arithmetic or theories involving Uninterpreted Functions (EUF) are promising next steps.
  • Integration: A natural future direction is integrating these algorithms directly into high-performance SMT solvers or automated termination provers that use Constraint Horn Clauses (CHC).

Summary updated

BibTeX
@article{bergstraer2024ramsey,
  author = {Pascal Bergsträßer and Moses Ganardi and Anthony W. Lin and Georg Zetzsche},
  title = {{Ramsey Quantifiers in Linear Arithmetics}},
  journal = {Proc. ACM Program. Lang.},
  year = {2024},
  doi = {10.1145/3632843},
}
Figure