Shallow embedding of type theory is morally correct

Ambrus Kaposi, András Kovács, Nicolai Kraus

Research output: Chapter in Book/Report/Conference proceedingConference contribution

181 Downloads (Pure)

Abstract

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.
Original languageEnglish
Title of host publicationMathematics of Program Construction
Subtitle of host publication13th International Conference, MPC 2019, Porto, Portugal, October 7–9, 2019, Proceedings
EditorsGraham Hutton
PublisherSpringer
Pages329-365
ISBN (Electronic)9783030336363
ISBN (Print)9783030336356
DOIs
Publication statusPublished - 20 Oct 2019
Event13th International Conference on Mathematics of Program Construction (MPC 2019) - Porto, Portugal
Duration: 7 Oct 20199 Oct 2019

Publication series

NameLecture Notes in Computer Science
PublisherSpringer
Volume11825
ISSN (Print)0302-9743
ISSN (Electronic)1611-3349

Conference

Conference13th International Conference on Mathematics of Program Construction (MPC 2019)
Country/TerritoryPortugal
CityPorto
Period7/10/199/10/19

Keywords

  • Agda
  • canonicity
  • parametricity
  • set model
  • shallow embedding
  • standard model
  • type theory

Fingerprint

Dive into the research topics of 'Shallow embedding of type theory is morally correct'. Together they form a unique fingerprint.

Cite this