Modern programming frequently requires generalised notions of program equivalence based on a metric or a similar structure. Previous work addressed this challenge by introducing the notion of a V-equation, i.e. an equation labelled by an element of a quantale V, which covers inter alia (ultra-)metric, classical, and fuzzy (in)equations. It also introduced a V-equational system for the linear variant of lambda-calculus where any given resource must be used exactly once. In this paper we drop the (often too strict) linearity constraint by adding graded modal types which allow multiple uses of a resource in a controlled manner. We show that such a control, whilst providing more expressivity to the programmer, also interacts more richly with V-equations than the linear or Cartesian cases. Our main result is the introduction of a sound and complete V-equational system for a lambda-calculus with graded modal types interpreted by what we call a Lipschitz exponential comonad. We also show how to build such comonads canonically via a universal construction, and use our results to derive graded metric equational systems (and corresponding models) for programs with timed and probabilistic behaviour.
翻译:现代编程经常需要基于度量或类似结构的广义程序等价性概念。早期的研究通过引入 V-等式的概念来解决这个挑战,即由一个量子 V 标记的等式,其中涵盖了包括(超)度量、经典和模糊(不)等式在内的各种情况。同时还引入了一个 V-等式系统,用于线性 lambda 演算的变体,其中给定的任何资源必须正好使用一次。本文通过添加分级模态类型来丢弃(往往过于严格的)线性约束,从而允许以受控制的方式多次使用资源。我们证明了这样的控制不仅为程序员提供了更多的表达能力,而且也更加丰富地与 V-等式进行交互,而线性或笛卡尔的情况则不能如此。我们的主要结果是针对一个由 Lipschitz 指数余函子解释的带有分级模态类型的 lambda 演算引入了一个音效和完整的 V-等式系统。我们还展示了如何通过一个通用的构造来规范地构建这样的余函子,并利用我们的结果为具有时态和概率行为的程序推导分级度量等式系统(以及相应的模型)。