当前位置: X-MOL 学术J. Funct. Program. › 论文详情
Our official English website, www.x-mol.net, welcomes your feedback! (Note: you will need to create a separate account there.)
Sparcl: A language for partially invertible computation
Journal of Functional Programming ( IF 1.1 ) Pub Date : 2024-01-26 , DOI: 10.1017/s0956796823000126
KAZUTAKA MATSUDA , MENG WANG

Invertibility is a fundamental concept in computer science, with various manifestations in software development (serializer/deserializer, parser/printer, redo/undo, compressor/decompressor, and so on). Full invertibility necessarily requires bijectivity, but the direct approach of composing bijective functions to develop invertible programs is too restrictive to be useful. In this paper, we take a different approach by focusing on partially invertible functions—functions that become invertible if some of their arguments are fixed. The simplest example of such is addition, which becomes invertible when fixing one of the operands. More involved examples include entropy-based compression methods (e.g., Huffman coding), which carry the occurrence frequency of input symbols (in certain formats such as Huffman tree), and fixing this frequency information makes the compression methods invertible. We develop a language Sparcl for programming such functions in a natural way, where partial invertibility is the norm and bijectivity is a special case, hence gaining significant expressiveness without compromising correctness. The challenge in designing such a language is to allow ordinary programming (the “partially” part) to interact with the invertible part freely, and yet guarantee invertibility by construction. The language Sparcl is linear-typed and has a type constructor to distinguish data that are subject to invertible computation and those that are not. We present the syntax, type system, and semantics of the language and prove that Sparcl correctly guarantees invertibility for its programs. We demonstrate the expressiveness of Sparcl with examples including tree rebuilding from preorder and inorder traversals, Huffman coding, arithmetic coding, and LZ77 compression.

中文翻译:

Spacl:一种用于部分可逆计算的语言

可逆性是计算机科学中的一个基本概念,在软件开发中具有多种表现形式(串行器/解串器、解析器/打印机、重做/撤消、压缩器/解压缩器等)。完全可逆性必然需要双射性,但是组合双射函数来开发可逆程序的直接方法限制太大,无法使用。在本文中,我们采取不同的方法,重点关注部分可逆函数——如果某些参数固定,则函数变得可逆。最简单的例子是加法,当固定操作数之一时,加法变得可逆。更多涉及的示例包括基于熵的压缩方法(例如,霍夫曼编码),其携带输入符号的出现频率(以某些格式,例如霍夫曼树),并且固定该频率信息使得压缩方法可逆。我们开发一种语言斯帕克尔以自然的方式对此类函数进行编程,其中部分可逆性是常态,双射性是一种特殊情况,因此在不影响正确性的情况下获得了显着的表达能力。设计这种语言的挑战是允许普通编程(“部分”部分)与可逆部分自由交互,同时通过构造保证可逆性。语言斯帕克尔是线性类型的,并且具有类型构造函数来区分进行可逆计算的数据和不进行可逆计算的数据。我们展示了该语言的语法、类型系统和语义,并证明斯帕克尔正确保证其程序的可逆性。我们展示了表现力斯帕克尔示例包括从前序和中序遍历重建树、霍夫曼编码、算术编码和 LZ77 压缩。
更新日期:2024-01-26
down
wechat
bug