A Logical Framework with Higher-Order Rational (Circular) Terms

Zhibo Chen, Frank Pfenning · DOI

TL;DR

CoLF (Circular Logical Framework) is a new extension of the classic LF framework designed to handle infinite structures and circular proofs natively. By introducing "higher-order rational terms," it allows researchers to represent complex recursive types and coinductive logic derivations elegantly while ensuring that both type checking and term equality remain fully decidable.

What Problem Does This Paper Address?

In the world of formal logic and programming language theory, we often use Logical Frameworks (LF) to define and check the rules of a system. However, standard LF is "finitary"—it assumes that every proof and every term has a finite end.

This creates a massive headache when dealing with modern computer science concepts that are inherently infinite or circular, such as:

  • Recursive types: Types that refer to themselves (like a linked list or a tree).
  • Infinite streams: Data structures that never end (like a clock tick or a network socket).
  • Circular proofs: Logical arguments that use a form of "guarded" self-reference to prove properties about infinite processes.

Currently, formalizing these in LF is "cumbersome and awkward," often requiring researchers to jump through hoops, manually defining equality relations and bisimulations that the framework should ideally handle for them.

Methods

The authors introduce CoLF, a conservative extension of LF. Its "secret sauce" consists of three main components:

  1. Higher-Order Rational Terms: These are terms that can be infinite but are "regular"—meaning they only have a finite number of distinct sub-structures. Think of them like a repeating decimal; it goes on forever, but it follows a finite, predictable pattern.
  2. The Prepattern Restriction: To keep the math tractable, the authors enforce a rule (inspired by Miller’s pattern unification) where recursion constants can only be applied to bound variables. This prevents the "infinite unfolding" from exploding into something undecidable.
  3. Trace Conditions and Priorities: When mixing inductive (finite) and coinductive (infinite) definitions, things get messy. CoLF uses a "trace condition" to ensure that any circularity is "guarded" by a coinductive constructor. It uses the order of declarations to assign priorities, resolving ambiguities in how terms should be interpreted.

The framework is implemented in OCaml, and the authors provide a sound and complete algorithm to decide if two circular terms are equal by unfolding them into "Regular Böhm Trees."

Datasets

As a theoretical paper in logic and type theory, this work does not use traditional training datasets. Instead, it evaluates the framework through several rigorous case studies that represent common "stress tests" for logical frameworks:

  • Natural and Conatural Numbers: Comparing finite counting vs. potentially infinite counting.
  • Finitely Padded Streams: Modeling streams that must contain data eventually (mixed induction/coinduction).
  • Subtyping for Recursive Types: Re-implementing a classic subtyping system (Danielsson and Altenkirch) to show that CoLF is more concise than Agda.
  • Polarized Circular Subtyping: Encoding complex equirecursive types.

Key Insights and Ideas

  • Equality is Automatic: In most frameworks, proving two infinite streams are equal requires a manual bisimulation proof. In CoLF, if two terms unfold to the same infinite tree, the framework simply "sees" them as equal.
  • The Power of "Cotype": By introducing a new syntactic kind called cotype, the authors allow the user to explicitly flag which parts of the system are allowed to be circular, keeping the rest of the system safely inductive.
  • Decidability is Preserved: The most impressive "aha moment" is that even with higher-order functions and infinite terms, the authors proved that type checking and equality checking are still decidable. You get the power of infinity without the "halting problem" nightmares.

Key Results

  • Decidability Proofs: The paper provides formal proofs that both term equality (Theorem 1) and type checking (Theorem 5) are algorithmically decidable in CoLF.
  • Elegance and Conciseness: The case studies demonstrate that CoLF encodings are significantly more direct than those in standard LF or Agda. For example, CoLF handles $\alpha\beta\eta$-equivalence and coinductive equality internally, whereas other systems require explicit manual definitions for these.
  • Adequacy: The authors prove "Adequacy Theorems" for their encodings, showing a perfect one-to-one correspondence between the mathematical objects they are modeling and the terms in CoLF.

Limitations and Future Work

  • Meta-Theoretic Reasoning: While CoLF is great at representing circular derivations, it cannot yet automatically check properties about those derivations (e.g., proving that a subtyping relation is transitive). The authors point to "Twelf-style" meta-reasoning as a future goal.
  • Complex Validity Conditions: Some highly complex circular proof systems (like those by Brotherston and Simpson) have validity conditions that CoLF cannot yet represent in full generality.
  • Implementation Maturity: The current OCaml implementation is a research prototype; further work is needed to make it a production-ready tool for the broader formal methods community.

Summary updated

BibTeX
@misc{chen2022logical,
  author = {Zhibo Chen and Frank Pfenning},
  title = {{A Logical Framework with Higher-Order Rational (Circular) Terms}},
  year = {2022},
  eprint = {2210.06663},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2210.06663},
}

Loading related content...

Figure