Table of Contents
Fetching ...

Grokking the Sequent Calculus (Functional Pearl)

David Binder, Marco Tzschentke, Marius Müller, Klaus Ostermann

TL;DR

The paper addresses the barrier to understanding the sequent calculus by presenting the $λμ̃μ$-calculus as a practical intermediate language and demonstrating it with a compiler from a small surface language to the calculus to expose evaluation contexts and control flow. It develops a concrete, stepwise translation from the surface language Fun to the sequent-calculus-based Core, covering arithmetic, binding forms, top-level definitions, algebraic data and codata, first-class functions, and control operators. It exposes deep dualities such as data versus codata and $μ$-abstraction versus $μ̃$-abstraction, and provides an interactive online evaluator to illustrate reductions and translations. The result is a usable bridge between sequent-calculus theory and practical compiler design, clarifying evaluation contexts and enabling targeted optimizations.

Abstract

The sequent calculus is a proof system which was designed as a more symmetric alternative to natural deduction. The λμμ-calculus is a term assignment system for the sequent calculus and a great foundation for compiler intermediate languages due to its first-class representation of evaluation contexts. Unfortunately, only experts of the sequent calculus can appreciate its beauty. To remedy this, we present the first introduction to the λμμ-calculus which is not directed at type theorists or logicians but at compiler hackers and programming-language enthusiasts. We do this by writing a compiler from a small but interesting surface language to the λμμ-calculus as a compiler intermediate language.

Grokking the Sequent Calculus (Functional Pearl)

TL;DR

The paper addresses the barrier to understanding the sequent calculus by presenting the -calculus as a practical intermediate language and demonstrating it with a compiler from a small surface language to the calculus to expose evaluation contexts and control flow. It develops a concrete, stepwise translation from the surface language Fun to the sequent-calculus-based Core, covering arithmetic, binding forms, top-level definitions, algebraic data and codata, first-class functions, and control operators. It exposes deep dualities such as data versus codata and -abstraction versus -abstraction, and provides an interactive online evaluator to illustrate reductions and translations. The result is a usable bridge between sequent-calculus theory and practical compiler design, clarifying evaluation contexts and enabling targeted optimizations.

Abstract

The sequent calculus is a proof system which was designed as a more symmetric alternative to natural deduction. The λμμ-calculus is a term assignment system for the sequent calculus and a great foundation for compiler intermediate languages due to its first-class representation of evaluation contexts. Unfortunately, only experts of the sequent calculus can appreciate its beauty. To remedy this, we present the first introduction to the λμμ-calculus which is not directed at type theorists or logicians but at compiler hackers and programming-language enthusiasts. We do this by writing a compiler from a small but interesting surface language to the λμμ-calculus as a compiler intermediate language.
Paper Structure (10 sections, 47 equations, 1 figure)

This paper contains 10 sections, 47 equations, 1 figure.

Figures (1)

  • Figure 1: Screenshot of the online evaluator.

Theorems & Definitions (7)

  • Definition 2.1: Arithmetic Expressions
  • Definition 2.2: Evaluation for Arithmetic Expressions
  • Definition 2.3: Let-Bindings and $\tilde{\mu}$-abstractions
  • Definition 2.4: Top-level Definitions
  • Definition 2.5: Algebraic Data and Codata Types
  • Definition 2.6: First-Class Functions
  • Definition 2.7: Control Operators