领域特定张量语言
Domain-Specific Tensor Languages
AI总结:
针对函数式编程中张量记法缺失的问题,本文在Haskell中嵌入一种领域特定语言,其语法贴近索引记法,语义基于代数结构,兼具科学计算与理论表达用途。
摘要:
数学多个领域中使用的张量记法是一种有用的记法,但它在函数式编程社区中并未被广泛采用。从实践角度看,当前用于张量代数的(嵌入式)领域特定语言(DSL)要么是1. 面向数组的语言,不强制利用张量性质和代数结构;要么是2. 遵循张量的范畴结构,但要求程序员以笨拙的无点记法操作张量。更深层的问题是,对于张量微积分,主流教学范式假设受众要么能接受程序员无法承受的记法自由,要么专注于张量的应用数学,而将其语言学方面(变量绑定的行为、语法和语义等)留给读者自行理解。这种状况并不令人惊讶,因为我们指出,标准张量记法的若干性质从lambda演算的角度看有些奇特。我们通过定义一个嵌入在Haskell中的DSL来弥合这一差距,其语法紧密捕捉了文献中广泛使用的张量索引记法。该EDSL的语义依据定义张量完整一般性的代数结构来界定。这样,我们相信我们的EDSL既可以用作科学计算的工具,也可以用作表达和呈现张量理论及其应用的载体。
英文摘要:
The tensor notation used in several areas of mathematics is a useful one, but it is not widely available to the functional programming community. In a practical sense, the (embedded) domain-specific languages (DSLs) that are currently in use for tensor algebra are either 1. array-oriented languages that do not enforce or take advantage of tensor properties and algebraic structure or 2. follow the categorical structure of tensors but require the programmer to manipulate tensors in an unwieldy point-free notation. A deeper issue is that for tensor calculus, the dominant pedagogical paradigm assumes an audience which is either comfortable with notational liberties which programmers cannot afford, or focus on the applied mathematics of tensors, largely leaving their linguistic aspects (behaviour of variable binding, syntax and semantics, etc.) for the reader to figure out by themselves. This state of affairs is hardly surprising, because, as we highlight, several properties of standard tensor notation are somewhat exotic from the perspective of lambda calculi. We bridge the gap by defining a DSL, embedded in Haskell, whose syntax closely captures the index notation for tensors in wide use in the literature. The semantics of this EDSL is defined in terms of the algebraic structures which define tensors in their full generality. This way, we believe that our EDSL can be used both as a tool for scientific computing, but also as a vehicle to express and present the theory and applications of tensors.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。