Papers
Topics
Authors
Recent
2000 character limit reached

Abstracting Gradual Typing (AGT)

Updated 3 January 2026
  • Abstracting Gradual Typing (AGT) is a systematic framework that derives gradually-typed languages by abstracting static type systems using concretization and abstraction functions.
  • It ensures both static and dynamic semantics through evidence-based type consistency, enabling reliable runtime checks and support for advanced features.
  • AGT underpins various applications such as gradual security typing, parametric polymorphism, and space-efficient dynamic semantics in production compilers.

Abstracting Gradual Typing (AGT) is a principled, systematic methodology for deriving gradually-typed languages from static type systems. At its core, AGT views gradual types as abstractions of sets of static types, assigning precise semantics to imprecise types and providing a foundation for lifting static relations—such as subtyping or equality—to the gradual setting. The methodology automatically yields both the static and dynamic semantics for gradually-typed languages, ensures satisfaction of the (static and dynamic) gradual guarantees, and enables modular gradualization of advanced typing features, including polymorphism and security types. Runtime support relies on evidence—algebraic justifications for type consistency—that evolves through reduction, enforcing dynamic typing invariants. AGT has been instantiated for simple types, security-typed calculi, System F-style polymorphism, and has inspired efficient evidence-passing and monotonic semantics in production compilers.

1. Theoretical Foundations of AGT

AGT is grounded in abstract interpretation and Galois connections. Given a static type system with a set Type\mathrm{Type} of static types, AGT introduces the class of gradual types, GType\mathrm{GType}, by incorporating an imprecise type (typically denoted ??), so $G ::= ... \mid \, ?\$. The central definitions are:

  • Concretization function γ:GType→P(Type)\gamma: \mathrm{GType} \rightarrow \mathcal{P}(\mathrm{Type}) assigns to each gradual type the set of static types it may represent, e.g., γ(?)=Type\gamma(?) = \mathrm{Type} and γ(T)={T}\gamma(T) = \{T\}, extending homomorphically over type formers.
  • Abstraction function α:P(Type)→GType\alpha: \mathcal{P}(\mathrm{Type}) \rightarrow \mathrm{GType} is defined so (α,γ)(\alpha, \gamma) forms a Galois connection: for valid S⊆TypeS \subseteq \mathrm{Type}, S⊆γ(α(S))S \subseteq \gamma(\alpha(S)), and for all GG, α(γ(G))⪯G\alpha(\gamma(G)) \preceq G, up to type precision.

These functions enable defining:

  • Precision ordering: G1⪯G2G_1 \preceq G_2 iff γ(G1)⊆γ(G2)\gamma(G_1) \subseteq \gamma(G_2).
  • Type consistency: Given a static binary relation PP, the lifted relation on gradual types is P♯(G1,G2)  ⟺  ∃T1∈γ(G1),T2∈γ(G2):P(T1,T2)P^{\sharp}(G_1,G_2) \iff \exists T_1 \in \gamma(G_1), T_2 \in \gamma(G_2): P(T_1, T_2). The typical case is type consistency, G1∼G2G_1 \sim G_2.

AGT delivers:

  • A static gradual type system by systematically lifting static relations (such as subtyping, equality, effect judgments) to the gradual setting.
  • A dynamic semantics where each use of a lifted relation is justified by evidence, recording why two types are consistent with each other. At runtime, computation over gradual types reduces to proof reduction, in which evidence is composed via a consistent transitivity operator. Failure of this composition indicates a dynamic type error.

This methodology guarantees that gradual languages developed via AGT satisfy the semantic criteria for graduality (including the static and dynamic gradual guarantee) as identified by Siek et al. (Schwerter et al., 2020, Romero et al., 27 Dec 2025, Labrada et al., 2018, Garcia et al., 2015, Siek, 2020).

2. Static and Dynamic Semantics: Lifting and Evidence

AGT's lifting procedure affects both static and runtime semantics:

  • In the static type system, rules from the static discipline are converted to use gradual types, consistent relations (e.g., consistent subtyping or equality), and operations (e.g., gradual join, gradual meet). For example, static subtyping T1<:T2T_1 <: T_2 becomes G1<:~G2G_1 \widetilde{<:} G_2—consistency of subtyping—where G1,G2G_1, G_2 are gradual types.
  • At the dynamic level, AGT moves beyond cast calculi by annotating derivations with evidence. Evidence is algebraic data—often another gradual type, a type pair, or richer structures—that witnesses why two gradual types are consistent in a particular context.

For simply-typed calculi, evidence can typically be defined inductively (e.g., meet of gradual types). The initial evidence I=(G1,G2)=α(γ(G1)∩γ(G2))=G1⊓G2I_=(G_1, G_2) = \alpha(\gamma(G_1) \cap \gamma(G_2)) = G_1 \sqcap G_2 justifies G1∼G2G_1 \sim G_2. Consistent transitivity of evidence e2∘e1=e1⊓e2e_2 \circ e_1 = e_1 \sqcap e_2 captures the composition of justifications, failing when the meet is undefined (i.e., types are proved inconsistent).

Reduction rules integrate evidence: for instance, ascription and application manipulate values e ue\,u where ee is evidence and uu is a value. Each ascription or function application computes the new evidence by combining existing evidence via meet; errors are signaled if the operation is undefined (Romero et al., 27 Dec 2025, Garcia et al., 2015).

3. Applications: Security, Parametricity, and Space Efficiency

AGT enables the systematic creation of gradual versions of diverse advanced type disciplines, as follows:

  • Gradual Security Typing: By gradualizing only security labels, AGT yields calculi like λSEC~\lambda_{\widetilde{\text{SEC}}}, where gradual security types S~\widetilde{S} are built from gradual labels â„“~∈GLabel::=ℓ∣?\tilde{\ell} \in \mathit{GLabel} ::= \ell \mid ?. The concretization and abstraction functions are lifted over both type and label, yielding consistent subtyping and ordering. This approach, combined with step-indexed logical relations, enables a noninterference proof for gradual security languages without requiring explicit security casts in source code (Garcia et al., 2015).
  • Gradual Parametric Polymorphism: In "Gradual System F" (GSF), AGT is used to extend System F with gradual types, including polymorphic unknowns. Concretization and abstraction are recursively defined for universal types, and evidence is extended to handle sealing and unsealing in the presence of type abstraction. The methodology preserves a form of relational parametricity for gradual terms up to runtime errors, achieving the static gradual guarantee and (in a weakened form) the dynamic gradual guarantee. This allows embedding both untyped and statically-typed polymorphic terms, and supports gradual transition between these extremes (Labrada et al., 2018).
  • Space-Efficient Semantics: AGT-based dynamic semantics can incur space inefficiencies; default semantics may violate space guarantees (e.g., proper tail calls). AGT has been refined for space efficiency by interpreting the runtime check abstraction in terms of subtyping; ensuring forward-completeness of the abstract domain yields efficient implementation, preserving expected invariants from static and dynamic languages (Schwerter et al., 2020).

Empirical results from the GrEv compiler demonstrate that evidence-based AGT semantics can yield runtime behavior competitive with and sometimes superior to classic coercion-based approaches (e.g., Grift)—notably, GrEv offers predictable performance across the statically-typed to dynamically-typed spectrum and supports efficient monotonic references and closures (Romero et al., 27 Dec 2025).

4. Implementation Strategies and Empirical Evaluation

AGT has inspired practical and efficient compiler architectures:

  • Evidence Representation: In production implementations such as GrEv, evidence is represented as additional metadata (immediate or boxed as needed) on values. Operation modes (guarded, monotonic) dictate whether values carry proxy objects or in-place evidence.
  • Ascribe Operations: Compilation decorates programs with ascribe(e, t) calls representing runtime checks justified by static evidence ee. At runtime, ascription operations check compatibility of evidence and combine it by meet; incompatible evidence aborts computation.
  • Monotonic Semantics: Monotonic references (and closures) update shared in-place evidence cells when values are ascribed to more precise types; this reduces allocations and improves performance by avoiding proxy objects.
  • Empirical Results: On benchmarks ranging from 0% to 100% statically-typed code, evidence-based AGT compilers demonstrate robust, predictable performance, outperforming coercion-based compilers on fully untyped and partially typed code, and matching performance on fully typed code. Monotonic semantics further optimize mixed-typed scenarios, eliminating proxy allocation bottlenecks (Romero et al., 27 Dec 2025).
Mode/Configuration Runtime Approach Performance Impact
Guarded Proxy evidence Slower, less predictable
Monotonic (values/closures) In-place evidence Faster, most stable across spectrum
Coercion-based (Grift) Heap proxies Variable, slower for untyped/mixed
Evidence-based (GrEv) Uniform evidence Predictable, often fastest

5. Meta-theory and Parameterization

AGT supports modular metatheory and reusable proofs:

  • Parameterization Over Cast Calculi: Recent developments abstract over cast representations in lambda calculi, allowing proofs of type safety, blame safety, static/dynamic gradual guarantees, and space consumption to be parameterized and reused across various calculi. This is facilitated by Agda record definitions, which encapsulate properties and proof obligations for casts, evidence, and operational semantics (Siek, 2020).
  • Reusable Proofs: The approach yields one proof for each metatheoretic property, universally quantified over the choice of cast/evidence structure. Instantiating the abstract framework with a new cast calculus (e.g., supercoercions, hypercoercions) immediately delivers all core theorems—mirroring AGT’s advocacy of separation of concerns and meta-theoretic robustness.
  • Advanced Features: The modularity of AGT and its embeddings allows cohesive extension to subtyping, blame tracking, polymorphism, effects, and security without bespoke proofs per feature or calculus.

6. Limitations, Refinements, and Open Directions

Several limitations and ongoing research directions have emerged in AGT and its instantiations:

  • Dynamic Gradual Guarantee Nuances: While AGT formalizes the static and dynamic gradual guarantees, certain advanced type disciplines (notably, parametric polymorphism as in GSF) require a weakened dynamic guarantee, due to non-monotonicity of evidence composition under imprecision inside universal types (Labrada et al., 2018).
  • Space and Control Efficiency: Baseline AGT semantics may fail to preserve space or tail call properties; refined approaches ensure forward completeness of the abstraction domain to guarantee space efficiency and correct tail behavior (Schwerter et al., 2020).
  • Implementation Complexity: Runtime composition and manipulation of evidence, especially under polymorphism or complex type features, introduces performance and engineering challenges, motivating research into bounded monitors, efficient evidence-passing schemes, and unboxing strategies (Romero et al., 27 Dec 2025).
  • Source Language Simplicity: AGT enables source languages to be cast-free, inserting only those runtime checks strictly required by imprecision and consistency, as opposed to explicit or ad-hoc cast constructs (Garcia et al., 2015).
  • Extension to New Type Systems: AGT’s methodology naturally generalizes to gradualizations of effect systems, information flow, refinement types, and others, provided suitable abstraction and concretization operations are defined.

7. Impact and Outlook

AGT has established itself as the universal foundation for systematically deriving and analyzing gradually-typed languages. It unifies diverse gradual type disciplines under a consistent methodology; modularizes metatheory and implementation; and enables empirical evaluation of semantic designs at scale, as seen in contemporary compilers supporting space efficiency and monotonicity. Active research focuses on generalizing the platform to encompass all AGT-derived disciplines, measuring real-world performance, and extending AGT's theoretical guarantees to richer typing phenomena (Schwerter et al., 2020, Romero et al., 27 Dec 2025, Labrada et al., 2018, Garcia et al., 2015, Siek, 2020).

Whiteboard

Topic to Video (Beta)

Follow Topic

Get notified by email when new papers are published related to Abstracting Gradual Typing (AGT).

Don't miss out on important new AI/ML research

See which papers are being discussed right now on X, Reddit, and more:

“Emergent Mind helps me see which AI papers have caught fire online.”

Philip

Philip

Creator, AI Explained on YouTube