Compactness via Pattern Stepping Bisimulation
Matias Scharager
TL;DR
This work addresses proving the compactness lemma in languages with control flow by introducing pattern stepping bisimulation, which indexes the relation over execution steps and uses a pattern language to track where a recursive function occurs. The core idea is to relate a term to its finite unrollings through an indexed relation $\mathbf{of}^n$, enabling a generalized compactness result $[F_\omega/x]e\downarrow \iff \exists n.\ [F_n/x]e\downarrow$ and a Coq-verified formalization with continuations. The main contributions are the pattern language construction, the indexed bisimulation strategy, and the demonstrated Coq formalization that extends compactness to explicit control flow and polymorphism, reducing reliance on contextual approximation. This approach broadens the applicability of compactness in logical relations and type theories, providing a robust, machine-checked foundation for reasoning about recursive functions in complex languages.
Abstract
The compactness lemma in programming language theory states that any recursive function can be simulated by a finite unrolling of the function. One important use case it has is in the logical relations proof technique for proving properties of typed programs, such as strong normalization. The relation between recursive functions and their finite counterparts is a special variant of the class of bisimulation relations. However, standard bisimulation proof approaches do not apply to the compactness lemma as properties of the relation vary over execution. As a result, the proof of compactness is often messy because the multiple copies made of the recursive function during execution can be unrolled an inconsistent number of times. We present a new proof technique by indexing the bisimulation relation over the step transitions and utilizing an intermediate "pattern" language to mechanize bookkeeping. This generalization of "pattern stepping bisimulation" obviates the need for contextual approximation within the compactness lemma, and thus extends the compactness lemma to a wider range of programming languages, including those that incorporate control flow effects. We demonstrate this approach by formally verifying the compactness lemma within the Coq theorem prover in the setting of explicit control flow and polymorphism.
