- The paper presents a unified approach to amortized analysis by embedding cost abstraction into types using modal type theory.
- It introduces a modal fracture-and-gluing theorem that bridges concrete and abstract cost representations for sound, compositional analysis.
- The work implements an automated inference algorithm in Giralf, generalizing AARA to support dependently-typed programming and resource verification.
Synthetic Amortized Cost Verification: Potential Functions as Types
Introduction and Synthetic Modal Perspective
The paper "Potential Functions as Types" (2607.08547) develops a synthetic, modular framework for amortized analysis that unifies the physicist's and banker's views within dependent type theory. The physicist's view, grounded in potential functions and energy conservation principles, facilitates manual verification of amortized cost bounds in systems like Calf, a dependent type theory for cost analysis. The banker's view, emphasizing credits as substructural resources, enables automated cost inference, as in Automatic Amortized Resource Analysis (AARA).
A central technical contribution is the synthesis of these approaches within a modal, phase-distinct type-theoretic framework. The fracture and gluing theorem is generalized at the computation-type level, rendering every type as encoding both an abstraction function and a potential function. Programs between such types necessarily preserve abstraction (modular behavior) and conserve potential (modular cost).
To internalize the banker's view, the authors introduce synthetic type operators for credits and debits. This enables the construction of resource-aware dependent types supporting cost annotations in a systematic, compositional manner. The modal distinction allows client code to interact with abstract cost interfaces while implementation-specific details remain encapsulated.
Modal Fracture and Gluing for Abstraction and Potential
Building upon previous work on abstraction functions as types, the paper proposes a fracture and gluing theorem for computation types (cost algebras). This theorem establishes an equivalence: every computation type decomposes into a concrete type, an abstract type, and a cost-aware abstraction homomorphism.
This structure generalizes previous results for value types and critically enables cost effects—potential functions can be "built into" types synthetically. Modal operators (abstract/concrete) isolate the client-facing specification from implementation, facilitating modular verification under explicit phase assumptions (such as abstraction or behavior).
Cost algebra homomorphisms are defined to cohere with the cost effect, guaranteeing that homomorphisms preserve and propagate cost as potential. Every type now contains an abstraction function and a potential function, rendering the physicist's conservation of energy as a built-in syntactic invariant.
Credits, Debits, and Substructural Types
The banker's view is synthesized by internalizing credits and debits as type constructors. The credit operator augments a type by emitting additional cost, corresponding to potential stored as credits. Conversely, the debit operator allows cost to be offset by assumed credits, enabling more flexible resource management.
These operators are compositional and admit functorial weakening and monoidal laws. The abstraction homomorphism is leveraged to ensure credits are ghost data; they are invisible in both the concrete implementation and abstract specification phases, serving only to mediate cost invariants.
Inductive types such as credit-carrying lists and trees are constructed, supporting both linear and polynomial credit annotations. This generalization enables representation of classical amortized data structures (e.g., batched queues, splay trees) as synthetically verified types, with both behavioral abstraction and potential encoded.
Giralf: Graded Inferential Resource-Aware Logical Framework
To streamline programming with credits/debits and enable automated resource analysis, the authors introduce Giralf, a graded substructural dependent type theory overlaying Calf. Giralf supports dependency (substructural resources depending on structural values), bounded recursion (structural induction only), and internalizes graded typing judgments.
Types in Giralf embed credit/debit annotations, supporting resource-aware algorithms on data structures such as lists with linear/quadratic credits. The typing judgment Γ;Δ;q⊢e:A encodes a program e given a linear context Δ and a credit context q, resulting in type A.
A resource-aware semantics interprets Giralf as a sublanguage of Calf, providing a soundness theorem: cost bounds inferred in Giralf are always upper bounds for the actual costs accrued in Calf, up to a conservation condition involving the potential function.
Automated Cost Inference and Constraint Solving
The resource analysis techniques of AARA are adapted for Giralf, enabling automated inference of cost bounds via LP-based constraint solving. Skeletal translation augments Calf programs with credit/debit annotations, with unknowns for credit amounts solved by LP techniques. Cost-free and cost-aware annotations are combined to support symbolic invariants, critical for implementing resource-polymorphic types such as quadratic-credit lists.
The integration is certifying: the inference algorithm produces Giralf terms in Agda, each accompanied by a certificate of amortized cost correctness. The mechanized approach guarantees that all cost bounds are sound with respect to the program semantics, and are compositional over inductive types and modular abstractions.
Implications and Future Directions
This work substantially advances the integration of amortized analysis within dependent type theory by encoding potential functions and credits as syntactic elements of types. The modular abstraction allows compositional verification of cost bounds, facilitating implementation of complex resource-aware algorithms without loss of client-facing guarantees.
The practical outcome is a unified framework for both manual and automated amortized cost verification, supporting structurally rich inductive types and advanced resource abstractions. The machinery enables the development of certified resource-aware libraries and interfaces, with cost invariants enforced synthetically at the type level.
Theoretically, the modal, phase-distinct approach opens new avenues for semantic cost analysis, supporting future generalizations to persistent data structures (as in Okasaki's work) and non-commutative cost models. Extensions to multivariate or exponential resource bounds, more general inductive types, or persistent amortization are highlighted as promising directions.
Conclusion
The paper proposes a synthetic, modular, and highly general framework for amortized cost verification in dependent type theory. By rendering potential functions as types and synthesizing the physicist's and banker's perspectives, the approach provides strong compositional and abstraction guarantees for resource-aware programming and verification. The Giralf overlay supports automated cost inference, and the entire framework is mechanized in Cubical Agda, facilitating principled integration into proof assistants and certifying resource analysis tools.