Resource-aware type systems statically approximate not only the expected result type of a program, but also the way external resources are used, e.g., how many times the value of a variable is needed. We extend the type system of Featherweight Java to be resource-aware, parametrically on an arbitrary grade algebra modeling a specific usage of resources. We prove that this type system is sound with respect to a resource-aware version of reduction, that is, a well-typed program has a reduction sequence which does not get stuck due to resource consumption. Moreover, we show that the available grades can be heterogeneous, that is, obtained by combining grades of different kinds, via a minimal collection of homomorphisms from one kind to another. Finally, we show how grade algebras and homomorphisms can be specified as Java classes, so that grade annotations in types can be written in the language itself.
翻译:资源智能型系统不仅静态地近似一个程序的预期结果类型,而且静态地近似外部资源的使用方式,例如需要变量价值的多少倍。我们扩展了Featherweight Java 类型系统,使之具有资源认知度,对任意的等级代数进行模拟,以特定资源使用量进行特定的使用量。我们证明这种类型系统对于资源认知值的递减版本来说是健全的,也就是说,一个类型良好的程序有一个递减序列,不会因资源消耗而卡住。此外,我们表明,现有的等级可以是多样化的,通过将不同等级合并,通过从一种类型到另一种类型的同质性最小的集合获得的。最后,我们展示了如何将等级变数和同质性指定为 Java 类,这样就可以用语言本身写出等级说明。