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.
翻译:渐渐依赖型类型可以帮助逐步采用依附型代码,办法是为不精确的类型和证据提供原则性语义,而有些部分已被省略。目前逐渐依赖型的理论缺乏类型理论的核心特征: 平权。 Lennon- Bertrand 等人 显示,当反射证明$\mathit{refl}美元是平等类型的唯一封闭价值时,逐渐扩大CIC,即存在平权,这违反了静态的观察等同。扩展性功能在运行时应该是不可分的,但平等性和不精确型的组合使得能够区分扩展性、平等但相互配合的功能。尽管目前这种逐渐依赖型的理论缺乏类型理论的核心特征: 平权性证明$\mathit{refl}美元是平等类型中唯一的封闭性价值, 平等性证据包含一个至少与等同的术语一样准确的术语,作为我们看来平等的见证。 这些证人跟踪部分类型信息,作为区分性C- 平权性、 渐渐渐渐变的变的逻辑, 最终, 使信息结构成为一种不变性定义, 渐渐渐渐变的体系中, 渐渐渐变的变的体系中, 渐渐渐渐渐渐渐渐渐渐变的变的变的变的顺序, 成为了。