Dependent Multiplicities in Dependent Linear Type Theory
We present a dependent linear type theory in which the multiplicity of a variable—i.e., the number of times it can be used in a program—may depend on other variables. This allows precise resource annotations for programs whose usage of one input is governed by the value of another, which is not possible in type theories based on static multiplicities. For example, mapping a function $f$ over a list $xs$ uses that function $\mathsf{length}~xs$ times, which is hence the multiplicity of $f$. Our system is obtained by embedding linear logic into a dependent type theory and letting the host theory’s natural numbers act on the embedded resources, quantitative structure is then derived rather than postulated. The theory supports W-types, giving a uniform resource-aware account of a large class of inductive types, and fractional multiplicities, which specify that a program consumes only part of an inductive value. This allows us to type, e.g., substitution for lambda terms. We characterise the models of our theory as Categories with Families indexed in symmetric monoidal closed categories, elaborate the surface syntax into any such model, and prove that our theory extends Quantitative Type Theory over the resource algebras $\mathbb{N}$ and ${0,1,\omega}$. The construction can be carried out inside existing dependently typed languages, which we demonstrate with a formalisation in Agda.