一句话:提出面向完全依赖类型理论的一等隐式函数精化算法,借助核心类型论中的函数类型追踪并细化隐式插入信息。
隐式函数是依赖类型函数,其参数默认由推理机制而非程序员提供;Agda 的隐式函数和 GHC 的多态类型都是典型例子。当隐式函数类型成为一等类型时,精化与推理变得困难,该问题被称为 impredicative instantiation。本文提出一种面向完全依赖类型理论的新精化方案,建立在 Norell 的 Agda 双向精化算法之上,并指出关键困难在于隐式抽象与应用插入信息不完整。为此,作者在核心 Martin-Löf 类型论中加入一种支持严格定义性柯里化的函数类型,用于表示隐式函数类型中未确定的定义域元数,从而可在精化过程中任意时刻追踪并细化此类插入信息,决定是否插入隐式抽象。该方案在能力、通用性和简洁性上优于先前方法。
Implicit functions are dependently typed functions, such that arguments are provided (by default) by inference machinery instead of programmers of the surface language. Implicit functions in Agda are an archetypal example. In the Haskell language as implemented by the Glasgow Haskell Compiler (GHC), polymorphic types are another example. Implicit function types are first-class if they are treated as any other type in the surface language. This holds in Agda and partially holds in GHC. Inference and elaboration in the presence of first-class implicit functions poses a challenge; in the context of Haskell and ML-like languages, this has been dubbed “impredicative instantiation” or “impredicative inference”. We propose a new solution for elaborating first-class implicit functions, which is applicable to full dependent type theories and compares favorably to prior solutions in terms of power, generality and simplicity. We build atop Norell’s bidirectional elaboration algorithm for Agda, and we note that the key issue is incomplete information about insertions of implicit abstractions and applications. We make it possible to track and refine information related to such insertions, by adding a function type to a core Martin-L'of type theory, which supports strict (definitional) currying. This allows us to represent undetermined domain arities of implicit function types, and we can decide at any point during elaboration whether implicit abstractions should be inserted.