浅论类型论的道德正确性
Shallow Embedding of Type Theory is Morally Correct
摘要:
形式化类型论的元理论有多种方法。对于某些目的,考虑类型论的特定模型就足够了,但有时需要参考语法,例如在规范性和规范化的证明中。一种选择是通过在证明助手中使用归纳定义来深入嵌入语法。然而,在这种情况下,定义等式的处理在技术上变得具有挑战性。或者,我们可以通过浅嵌入对象理论来重用元理论中的转换检查。在本文中,我们考虑了Agda中的类型论对象理论的标准模型。这个模型具有所有等式定义成立的属性,我们可以通过从这个模型的组件构建表达式来将其用作浅嵌入。然而,如果我们要对这种设置的句法进行合理的推理,我们必须确保可区分的句法结构在浅嵌入时不会变得可证明相等。首先,我们证明了浅嵌入是单射的定义平等,通过建模的嵌入作为一个句法翻译目标的元理论。其次,我们使用一个实现隐藏技巧,不允许非法的命题平等证明和建设,不来自语法。我们展示了我们的技术与马丁-洛夫类型论的规范性和参数化的非常短的形式化。我们的技术只需要的功能,可在所有主要的证明助手依赖类型论的基础上。
英文摘要:
There are multiple ways to formalise the metatheory of type theory. For some purposes, it is enough to consider specific models of a type theory, but sometimes it is necessary to refer to the syntax, for example in proofs of canonicity and normalisation. One option is to embed the syntax deeply, by using inductive definitions in a proof assistant. However, in this case the handling of definitional equalities becomes technically challenging. Alternatively, we can reuse conversion checking in the metatheory by shallowly embedding the object theory. In this paper, we consider the standard model of a type theoretic object theory in Agda. This model has the property that all of its equalities hold definitionally, and we can use it as a shallow embedding by building expressions from the components of this model. However, if we are to reason soundly about the syntax with this setup, we must ensure that distinguishable syntactic constructs do not become provably equal when shallowly embedded. First, we prove that shallow embedding is injective up to definitional equality, by modelling the embedding as a syntactic translation targeting the metatheory. Second, we use an implementation hiding trick to disallow illegal propositional equality proofs and constructions which do not come from the syntax. We showcase our technique with very short formalisations of canonicity and parametricity for Martin-Löf type theory. Our technique only requires features which are available in all major proof assistants based on dependent type theory.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。