论文标题
学习使用语言模型格式化COQ代码
Learning to Format Coq Code Using Language Models
论文作者
论文摘要
记录声明中的最终右括号是否应该在单独的行上?是否应该通过一个空间将重写策略的争论分开? COQ代码往往由不同的人和团队以不同的方式写成。 COQ的语言和符号的表现力,灵活性和可扩展性意味着COQ项目具有多种可识别的编码样式,有时会明确记录为有关命名和格式的约定。特别是,即使没有经验的用户也可以使用标准库和普通LTAC与惯用性的白话区分白话,并使用数学组件(MathComp)库和SSSREFLECT区分白话。 虽然编码约定对于理解和维护很重要,但记录和执行的代价很高。基于规则的格式器(例如Coq的美化机)具有有限的灵活性,并且仅捕获大型验证项目中所需的约定的一小部分。我们认为,语言模型的应用 - 一类自然语言处理(NLP)技术来捕获语料库的规律性 - 可以为此难题提供解决方案。更具体地说,我们认为,基于现有COQ代码自动学习惯例,然后在适当上下文中向用户提出惯用代码的方法,可以优于手动方法和静态分析工具 - 无论是在努力和结果方面。 作为第一步,我们在这里概述了在COQ文件中学习和建议空间格式的初始模型,并针对COQ 8.10进行了初步实现,并根据MathComp 1.9.0进行了评估,该模型包括来自四个核心项目的COQ代码的164K行。
Should the final right bracket in a record declaration be on a separate line? Should arguments to the rewrite tactic be separated by a single space? Coq code tends to be written in distinct manners by different people and teams. The expressiveness, flexibility, and extensibility of Coq's languages and notations means that Coq projects have a wide variety of recognizable coding styles, sometimes explicitly documented as conventions on naming and formatting. In particular, even inexperienced users can distinguish vernacular using the standard library and plain Ltac from idiomatic vernacular using the Mathematical Components (MathComp) library and SSReflect. While coding conventions are important for comprehension and maintenance, they are costly to document and enforce. Rule-based formatters, such as Coq's beautifier, have limited flexibility and only capture small fractions of desired conventions in large verification projects. We believe that application of language models - a class of Natural Language Processing (NLP) techniques for capturing regularities in corpora - can provide a solution to this conundrum. More specifically, we believe that an approach based on automatically learning conventions from existing Coq code, and then suggesting idiomatic code to users in the proper context, can be superior to manual approaches and static analysis tools - both in terms of effort and results. As a first step, we here outline initial models to learn and suggest space formatting in Coq files, with a preliminary implementation for Coq 8.10, and evaluated on a corpus based on MathComp 1.9.0 which comprises 164k lines of Coq code from four core projects.