arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2205.01241cs.PL
收藏

渐进相依类型规划的命题等式

Propositional Equality for Gradual Dependently Typed Programming

Joseph Eremondi, Ronald Garcia, Éric Tanter

摘要:

渐进依赖类型可以通过为不精确的类型和证明(其中某些部分已被省略)提供原则性语义来帮助逐步采用依赖类型化代码。然而,目前的渐进依赖类型理论缺乏类型论的一个核心特征:命题平等。Lennon-Bertrand等人证明,当自反证明$\mathit{refl}$是等式类型的唯一闭值时,CIC的命题等式的逐渐扩展违反了静态观测等价。扩展相等的函数在运行时间应该是不可区分的,但是相等和类型不精确的组合允许区分扩展相等但语法不同的函数的上下文。这项工作提出了一个逐渐类型化的语言,支持命题平等。我们通过设计一个等式类型来避免上述问题,其中$\mathit{refl}$不是唯一的封闭居民。相反,每一个相等性证明都携带一个至少与相等项一样精确的项,作为它们似乎相等的证明。这些见证者在程序运行时跟踪部分类型信息,当该信息显示两个等同的术语不一致时,就会引发错误。类型信息的组合被内化为语言的一个构造,并且对于其求值被变量阻塞的函数体被延迟。通过延迟,我们可以确保外延相等的函数组合没有错误,从而防止上下文区分它们。我们描述了设计这个系统的一致性和精度关系的挑战,以及这些挑战的解决方案。最后,我们证明了重要的元理论:类型安全,保守嵌入的CIC,正规性,并逐步保证Siek等人。

英文摘要:

Gradual dependent types can help with the incremental adoption of dependently typed code by providing a principled semantics for imprecise types and proofs, where some parts have been omitted. Current theories of gradual dependent types, though, lack a central feature of type theory: propositional equality. Lennon-Bertrand et al. show that, when the reflexive proof $\mathit{refl}$ is the only closed value of an equality type, a gradual extension of CIC with propositional equality violates static observational equivalences. Extensionally-equal functions should be indistinguishable at run time, but the combination of equality and type imprecision allows for contexts that distinguish extensionally-equal but syntactically-different functions. This work presents a gradually typed language that supports propositional equality. We avoid the above issues by devising an equality type where $\mathit{refl}$ is not the only closed inhabitant. Instead, each equality proof carries a term that is at least as precise as the equated terms, acting as a witness of their plausible equality. These witnesses track partial type information as a program runs, raising errors when that information shows that two equated terms are undeniably inconsistent. Composition of type information is internalized as a construct of the language, and is deferred for function bodies whose evaluation is blocked by variables. By deferring, we ensure that extensionally equal functions compose without error, thereby preventing contexts from distinguishing them. We describe the challenges of designing consistency and precision relations for this system, along with solutions to these challenges. Finally, we prove important metatheory: type-safety, conservative embedding of CIC, canonicity, and the gradual guarantees of Siek et al.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑