[Paper Review] S4 modal sequent calculus as intermediate logic and intermediate language
The paper argues that continuation-based intermediate languages correspond to intermediate logics, specifically showing that second-class continuations align with a restricted S4 modal logic, and presents a polarised L^□_pol calculus with a heap/stack memory model to study stackability of the modal fragment.
In this short paper, we advocate for the idea that continuation-based intermediate languages correspond to intermediate logics. The goal of intermediate languages is to serve as a basis for compiler intermediate representations, allowing to represent expressive program transformations for optimisation and compilation, while preserving the properties that make programs compilable efficiently in the first place, such as the "stackability" of continuations. Intermediate logics are logics between intuitionistic and classical logic in terms of provability. Second-class continuations used in CPS-based intermediate languages correspond to a classical modal logic S4 with the added restriction that implications may only return modal types. This indeed corresponds to an intermediate logic, owing to the Gödel-McKinsey-Tarski theorem which states the intuitionistic nature of the modal fragment of S4. We introduce a three-kinded polarised sequent calculus for S4, together with an operational machine model that separates a heap from a stack. With this model we study a stackability property for the modal fragment of S4.
Motivation & Objective
- Motivate the use of continuation-based intermediate languages as a basis for compiler intermediate representations.
- Characterise second-class continuations as a restricted S4 modal logic and link it to intermediate logic concepts.
- Introduce a polarised sequent calculus for S4 and an operational machine model to study memory management and stackability.
Proposed method
- Define the polarised classical L-calculus extension L^□_pol for S4 with three polarities (□, +, -).
- Present a machine-like semantics with a two-part memory (heap for modal values and a stack-like region for covariables).
- Show that restricting S4 to functions returning modal types yields a stackable, second-class continuation regime.
- Relate CPS translations to a decomposition into an interpretation in L^□_pol followed by CPS, without detailing the second CPS step here.
- Provide an execution model and reduction rules that align with CBV/CBN evaluation priorities for modal vs non-modal types.
Experimental results
Research questions
- RQ1Can second-class continuations be characterized by a modal logic restriction of S4?
- RQ2How does a polarised S4 sequent calculus model the separation between modal (first-class) and non-modal (second-class) types?
- RQ3Does a two-store memory model (heap plus stack) ensure stackability for the modal fragment of S4?
- RQ4How does CPS translation interact with the polarised L^□_pol calculus in this framework?
Key findings
- A polarised three-kind sequent calculus L^□_pol for classical S4 is introduced.
- A two-store memory model separates a heap for modal values from a stack that is freed when evaluating modal covariables.
- Restricting S4 to functions with modal return types recovers stackability for second-class continuations.
- The modal fragment of S4 is shown to correspond, via Gödel–McKinsey–Tarski, to an intermediate logic between intuitionistic and classical logic.
- The CPS translation framework can be decomposed into an interpretation into L^□_pol followed by a CPS translation, aligning with prior CPS decompositions.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.