依赖类型代数层级中的多继承隐患
Multiple-inheritance hazards in dependently-typed algebraic hierarchies
AI总结:
本文针对依赖类型定理证明器中代数层级多继承引发的类型路径不一致问题,分析其成因与不同实现方案的判定相等性保留情况,提出内核支持结构η-归约等解决方案。
摘要:
抽象代数提供了对象集合可满足的庞大性质层级,例如构成阿贝尔群或半环。这些分类可被组织成一个宽泛且通常为非循环的有向图。这种图视角可自然编码在Lean等定理证明器的类型类系统中,其中节点可表示为包含必要公理的结构(或记录)。这种设计不可避免地需要某种形式的多继承:环既是半环也是阿贝尔群。 当存在本身将类型类作为类型参数的依赖类型类型类时——例如假设已有加法结构的向量空间类型类——结构多继承的实现细节就至关重要。外层类型类的类型会受到解析其所用类型类的路径的影响。除非所有可能的路径都被判定为相等,否则这将引发严重问题。 本文具体解释了这些情况是如何产生的(源自mathlib中的真实案例简化),根据是否保留判定相等性比较了多继承的实现方法,并概述了针对所发现问题的解决方案(值得注意的是:内核对结构η-归约的支持)。
英文摘要:
Abstract algebra provides a large hierarchy of properties that a collection of objects can satisfy, such as forming an abelian group or a semiring. These classifications can arranged into a broad and typically acyclic directed graph. This graph perspective encodes naturally in the typeclass system of theorem provers such as Lean, where nodes can be represented as structures (or records) containing the requisite axioms. This design inevitably needs some form of multiple inheritance; a ring is both a semiring and an abelian group. In the presence of dependently-typed typeclasses that themselves consume typeclasses as type-parameters, such as a vector space typeclass which assumes the presence of an existing additive structure, the implementation details of structure multiple inheritance matter. The type of the outer typeclass is influenced by the path taken to resolve the typeclasses it consumes. Unless all possible paths are considered judgmentally equal, this is a recipe for disaster. This paper provides a concrete explanation of how these situations arise (reduced from real examples in mathlib), compares implementation approaches for multiple inheritance by whether judgmental equality is preserved, and outlines solutions (notably: kernel support for $η$-reduction of structures) to the problems discovered.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。