The Semantics of Rank Polymorphism
Pith reviewed 2026-05-25 11:54 UTC · model grok-4.3
The pith
A dependent type system for rank-polymorphic languages is sound and rules out array shape errors at runtime.
A machine-rendered reading of the paper's core claim, the machinery that carries it, and where it could break.
Core claim
Remora's dependent type system, which incorporates existential abstraction for dynamically computed shapes and ranks, captures the shape-based lifting mechanism of rank polymorphism and is sound: progress and preservation hold, ensuring that array shape errors cannot occur at runtime in well-typed programs. Computations performed with fully typed terms stay in lockstep with those performed after partial type erasure, so the residual types precisely characterize the information required by the dynamic semantics.
What carries the argument
Dependent type system with existential abstraction over array shapes and ranks that encodes the lifting distribution rules.
If this is right
- Well-typed programs execute without encountering array shape errors.
- The dynamic semantics depends only on the residual types that remain after partial erasure.
- Existential types allow programs to operate on arrays whose shapes or ranks are determined at runtime.
- The argument types determine exactly how a function is lifted across higher-rank arrays.
Where Pith is reading between the lines
- The lockstep property between typed and erased terms supplies a route to proving correctness of optimizations that remove shape information after type checking.
- The same combination of dependent types and existentials could be reused to give static guarantees for implicit broadcasting in array libraries of other languages.
- Compilers could use the erased semantics as an intermediate representation that still respects the original lifting rules.
Load-bearing premise
The type rules correctly capture the shape-based distribution and lifting behavior of the dynamic semantics.
What would settle it
A concrete well-typed Remora program whose execution produces an array shape error, or a typed term and its erased counterpart whose reduction sequences diverge.
read the original abstract
Iverson's APL and its descendants (such as J, K and FISh) are examples of the family of "rank-polymorphic" programming languages. The principal control mechanism of such languages is the general lifting of functions that operate on arrays of rank (or dimension) $r$ to operate on arrays of any higher rank $r' > r$. We present a core, functional language, Remora, that captures this mechanism, and develop both a formal, dynamic semantics for the language, and an accompanying static, rank-polymorphic type system for the language. Critically, the static semantics captures the shape-based lifting mechanism of the language. We establish the usual progress and preservation properties for the type system, showing that it is sound, which means that "array shape" errors cannot occur at run time in a well-typed program. Our type system uses dependent types, including an existential type abstraction which permits programs to operate on arrays whose shape or rank is computed dynamically; however, it is restricted enough to permit static type checking. The rank-polymorphic computational paradigm is unusual in that the types of arguments affect the dynamic execution of the program -- they are what drive the rank-polymorphic distribution of a function across arrays of higher rank. To highlight this property, we additionally present a dynamic semantics for a partially erased variant of the fully-typed language and show that a computation performed with a fully-typed term stays in lock step with the computation performed with its partially erased term. The residual types thus precisely characterise the type information that is needed by the dynamic semantics, a property useful for the (eventual) construction of efficient compilers for rank-polymorphic languages.
Editorial analysis
A structured set of objections, weighed in public.
Referee Report
Summary. The paper introduces Remora, a core functional language capturing the rank-polymorphic lifting mechanism of APL-like languages. It defines a dynamic operational semantics, a dependent type system (with existential abstraction over shapes and ranks) that statically captures the lifting rules while remaining decidable, proves progress and preservation (soundness: well-typed programs produce no shape errors at runtime), and establishes a lock-step correspondence between the fully typed semantics and a partially erased dynamic semantics whose residual types characterize exactly the information needed at runtime.
Significance. If the claimed metatheorems hold, the work supplies the first formal account of type safety for rank polymorphism, directly addressing the unusual dependence of dynamic behavior on argument shapes. The existential mechanism for dynamic shapes and the erasure result are both technically useful for language design and compiler construction. The paper ships explicit definitions of the core language, type rules, and reduction relation, which supports reproducibility of the formal claims.
minor comments (1)
- The abstract states that progress and preservation have been established but does not name the specific lemmas or the form of the type environment; a one-sentence pointer in the abstract to the relevant theorem numbers would help readers locate the central results.
Simulated Author's Rebuttal
We thank the referee for their careful reading and positive recommendation to accept the paper. The report accurately captures the contributions of Remora's dynamic semantics, dependent type system with existentials, soundness proofs, and erasure correspondence.
Circularity Check
No significant circularity; derivation self-contained
full rationale
The paper defines a new core language Remora, its operational semantics, and a dependent type system with existentials from the ground up. It then proves standard progress and preservation (soundness) plus a lock-step erasure property. No load-bearing step reduces a claimed result to a fitted parameter, a self-citation chain, or a definitional renaming; the type rules and reduction rules are presented as independent artifacts whose correspondence is verified directly. This matches the most common honest outcome for a formal semantics paper.
Axiom & Free-Parameter Ledger
axioms (1)
- standard math Standard progress and preservation theorems can be established for the presented dependent type system
invented entities (1)
-
Remora core language
no independent evidence
Lean theorems connected to this paper
-
IndisputableMonolith/Foundation/RealityFromDistinction.leanreality_from_one_distinction unclear?
unclearRelation between the paper passage and the cited Recognition theorem.
We establish the usual progress and preservation properties for the type system, showing that it is sound, which means that 'array shape' errors cannot occur at run time in a well-typed program.
What do these tags mean?
- matches
- The paper's claim is directly supported by a theorem in the formal canon.
- supports
- The theorem supports part of the paper's argument, but the paper may add assumptions or extra steps.
- extends
- The paper goes beyond the formal theorem; the theorem is a base layer rather than the whole result.
- uses
- The paper appears to rely on the theorem as machinery.
- contradicts
- The paper's claim conflicts with a theorem or certificate in the canon.
- unclear
- Pith found a possible connection, but the passage is too broad, indirect, or ambiguous to say the theorem truly supports the claim.
discussion (0)
Sign in with ORCID, Apple, or X to comment. Anyone can read and Pith papers without signing in.