面向实际使用的 Lean 用户的 Small Scale Reflection
Small Scale Reflection for the Working Lean User
AI总结:
本文介绍了 Lean 4 证明助手中的 Small Scale Reflection(LeanSSR)方法与策略语言,利用原生元编程在内部实现,无需显式切换表示即可无缝结合演绎与计算证明,案例显示其能显著减小证明规模。
摘要:
我们介绍了 Small Scale Reflection 证明方法学和策略语言(又名 SSR)在 Lean 4 证明助手上的设计与实现。如同其 Coq 前身 SSReflect,我们的 Lean 4 实现(称为 LeanSSR)提供了强大的重写原则和有效管理证明上下文中假设的手段。与 Coq 的 SSReflect 不同,LeanSSR 不需要在目标的逻辑表示和符号表示之间显式切换,从而允许编写更简洁的证明脚本,将演绎步骤与计算证明无缝结合。在本文中,我们首先简要介绍了使用 LeanSSR 构建机械化证明的原则。接着,我们展示了 Lean 4 对元编程的原生支持如何使 LeanSSR 能够完全在证明助手内部开发,极大改善了策略实现者和证明工程师的整体体验。最后,我们通过两个案例研究展示了 LeanSSR 的实用性:(a) 从广泛使用的 Mathematical Components 库移植一批关于序列的 Coq 引理,以及 (b) 在 Lean 的 mathlib4 有限集库中重新实现证明。两项案例研究均显示证明规模显著减小。
英文摘要:
We present the design and implementation of the Small Scale Reflection proof methodology and tactic language (a.k.a. SSR) for the Lean 4 proof assistant. Like its Coq predecessor SSReflect, our Lean 4 implementation, dubbed LeanSSR, provides powerful rewriting principles and means for effective management of hypotheses in the proof context. Unlike SSReflect for Coq, LeanSSR does not require explicit switching between the logical and symbolic representation of a goal, allowing for even more concise proof scripts that seamlessly combine deduction steps with proofs by computation. In this paper, we first provide a gentle introduction to the principles of structuring mechanised proofs using LeanSSR. Next, we show how the native support for metaprogramming in Lean 4 makes it possible to develop LeanSSR entirely within the proof assistant, greatly improving the overall experience of both tactic implementers and proof engineers. Finally, we demonstrate the utility of LeanSSR by conducting two case studies: (a) porting a collection of Coq lemmas about sequences from the widely used Mathematical Components library and (b) reimplementing proofs in the finite set library of Lean's mathlib4. Both case studies show significant reduction in proof sizes.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。