秩多态的语义
The Semantics of Rank Polymorphism
摘要:
艾弗森的APL及其后代(如J、K和FISh)是“等级多态”程序设计语言家族的例子。这种语言的主要控制机制是对秩(或维度)$r$的数组进行操作的函数的一般提升,以操作任何更高秩$r' > r$的数组。我们提出了一个核心,功能语言,Remora,捕捉这种机制,并开发一个正式的,动态的语义语言,和一个配套的静态,排名多态类型系统的语言。重要的是,静态语义捕获了语言的基于形状的提升机制。我们为类型系统建立了通常的进度和保存属性,表明它是合理的,这意味着在良好类型的程序中,“数组形状”错误不会在运行时间发生。我们的类型系统使用依赖类型,包括一个存在类型抽象,允许程序对数组的形状或秩进行动态计算;然而,它的限制足以允许静态类型检查。秩多态计算范例是不寻常的,因为参数的类型影响程序的动态执行-它们是驱动函数在更高秩的数组中的秩多态分布的原因。为了突出这一属性,我们还提出了一个动态语义的完全类型化的语言的部分删除的变体,并显示,与一个完全类型化的长期执行的计算保持在锁定步骤与其部分删除的长期执行的计算。因此,剩余类型精确地描述了动态语义所需的类型信息,这对于(最终)构建秩多态语言的高效编译器是有用的。
英文摘要:
Iverson's APL and its descendants (such as J, K and FISh) are examples of the family of "rank-polymorphic" programming languages. The principal control mechanism of such languages is the general lifting of functions that operate on arrays of rank (or dimension) $r$ to operate on arrays of any higher rank $r' > r$. We present a core, functional language, Remora, that captures this mechanism, and develop both a formal, dynamic semantics for the language, and an accompanying static, rank-polymorphic type system for the language. Critically, the static semantics captures the shape-based lifting mechanism of the language. We establish the usual progress and preservation properties for the type system, showing that it is sound, which means that "array shape" errors cannot occur at run time in a well-typed program. Our type system uses dependent types, including an existential type abstraction which permits programs to operate on arrays whose shape or rank is computed dynamically; however, it is restricted enough to permit static type checking. The rank-polymorphic computational paradigm is unusual in that the types of arguments affect the dynamic execution of the program -- they are what drive the rank-polymorphic distribution of a function across arrays of higher rank. To highlight this property, we additionally present a dynamic semantics for a partially erased variant of the fully-typed language and show that a computation performed with a fully-typed term stays in lock step with the computation performed with its partially erased term. The residual types thus precisely characterise the type information that is needed by the dynamic semantics, a property useful for the (eventual) construction of efficient compilers for rank-polymorphic languages.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。