|
1 | 1 | Presentation |
2 | 2 | ======= |
3 | 3 |
|
4 | | -This repo contains formalisation work on implementing a logical relation over MLTT with one universe. |
5 | | -This formalisation follows the [work done by Abel et al.]((https://github.com/mr-ohman/logrel-mltt/)) (described in [Decidability of conversion for Type Theory in Type Theory, 2018](https://dl.acm.org/doi/10.1145/3158111)), and [Loïc Pujet's work](https://github.com/loic-p/logrel-mltt) on removing induction-recursion from the previous formalization, making it feasible to translate it from Agda to Coq. |
| 4 | +This repo contains the formalisation work accompanying the paper "In Cantor Space No One Can Hear You Stream". |
6 | 5 |
|
7 | | -The definition of the logical relation (**LR**) ressembles Loïc's in many ways, but also had to be modified for a few reasons : |
8 | | -- Because of universe constraints and the fact that functors cannot be indexed by terms in Coq whereas it is possible in Agda, the relevant structures had to be parametrized by a type level and a recursor, and the module system had to be dropped out entirely. |
9 | | -- Since Coq and Agda's positivity checking for inductive types is different, it turns out that **LR**'s definition, even though it does not use any induction-induction or induction-recursion in Agda, is not accepted in Coq. As such, the predicate over Π-types for **LR** has been modified compared to Agda. You can find a MWE of the difference in positivity checking in the two systems in [Positivity.v] and [Positivity.agda]. |
| 6 | +The formalization is based on a [previous work](https://github.com/coqhott/logrel-coq/) by Adjej et al ([*Martin-Löf à la Coq*, CPP'24](https://arxiv.org/abs/2310.06376)), which itself follows a similar [Agda formalization](https://github.com/mr-ohman/logrel-mltt/) (described in [*Decidability of conversion for Type Theory in Type Theory*, 2018](https://dl.acm.org/doi/10.1145/3158111)). In order to avoid some work on the syntax, this project uses the [AutoSubst](https://github.com/uds-psl/autosubst-ocaml) project to generate syntax-related boilerplate. |
10 | 7 |
|
11 | | -In order to avoid some work on the syntax, this project uses the [AutoSubst](https://github.com/uds-psl/autosubst-ocaml) project to generate syntax-related boilerplate. |
| 8 | +TL;DR HOWTO INSTALL |
| 9 | +=================== |
| 10 | + |
| 11 | +- Install opam through your favourite means. |
| 12 | +- Double-check that no Coq-related environment variables like COQBIN or COQPATH are set. |
| 13 | +- Launch the following commands in the folder of this development. |
| 14 | +``` |
| 15 | +opam switch create . --empty |
| 16 | +eval $(opam env) |
| 17 | +opam install ocaml-base-compiler=4.14.3 |
| 18 | +opam repo --this-switch add coq-released https://coq.inria.fr/opam/released |
| 19 | +opam install . --deps-only |
| 20 | +make |
| 21 | +``` |
| 22 | + |
| 23 | +IMPORTANT NOTE |
| 24 | +============== |
| 25 | + |
| 26 | +The coqdocjs subfolder is **not** part of this development, but an independent project vendored here for simplicity of the build process. The upstream repository can be found at https://github.com/coq-community/coqdocjs/. |
12 | 27 |
|
13 | 28 | Building |
14 | 29 | =========== |
15 | 30 |
|
16 | | -The project builds with Coq version `8.16.1`. It needs the opam package `coq-smpl`. Once these have been installed, you can simply issue `make` in the root folder. |
| 31 | +The project builds on Coq version `8.19.2`, see the [opam](./opam) file for complete dependencies. Since they are not available as opam packages, [coqdocjs](https://github.com/coq-community/coqdocjs/) is simply included. |
| 32 | + |
| 33 | +Once the dependencies have been installed, you can simply issue `make` in the root folder. The development should build within 10 minutes (around 3 minutes on a modern laptop). |
17 | 34 |
|
18 | | -The syntax has been generated using AutoSubst OCaml with the options `-s ucoq -v ge813 -allfv` (see the [AutoSubst OCaml documentation](https://github.com/uds-psl/autosubst-ocaml) for installation instructions for it). Currently, this package works only with older version of Coq (8.13), so we cannot add a recipe to the MakeFile for automatically |
19 | | -re-generating the syntax. |
| 35 | +Apart from a few harmless warnings, and the output of some examples, the build reports on the assumptions of our main theorems, using `Print Assumptions`. |
20 | 36 |
|
21 | | -**In order to regenerate the syntax**, install autosubst paying attention to [this issue](https://github.com/uds-psl/autosubst-ocaml/issues/1) -- in an opam installation do a `cp -R $OPAM_SWITCH_PREFIX/share/coq-autosubst-ocaml $OPAM_SWITCH_PREFIX/share/autosubst`--, modify the syntax file `AutoSubst/PiUniv.sig`, run autosubst on it (`autosubst -s ucoq -v ge813 -allfv PiUniv.sig -o Ast.v`) and patch the resulting files using the checked in patch (`git apply -R autosubst-patch.diff`). |
| 37 | +For simplicity, the html documentation built using `coqdoc` is included in the artefact. It can be built again by invoking `make coqdoc`. |
22 | 38 |
|
23 | | -Browsing the Development |
| 39 | +Browsing the development |
24 | 40 | ================== |
25 | 41 |
|
26 | | -The development, rendered using `coqdoc`, can be [browsed online](https://coqhott.github.io/logrel-coq/coqdoc/toc.html). |
| 42 | +The development, rendered using the [coqdoc](https://coq.inria.fr/refman/using/tools/coqdoc.html) utility, can be then browsed (as html files). To start navigating the sources, the best entry point is probably the [the table of content](https://ppedrot.github.io/quote-mltt-lics24/coqdoc/toc.html). A [short description of the file contents](https://ppedrot.github.io/quote-mltt-lics24/index.md) is also provided to make the navigation easier. |
27 | 43 |
|
28 | | -Getting Started |
| 44 | +Files of interest |
29 | 45 | ================= |
30 | 46 |
|
31 | | -A few things to get accustomed to if you want to use the development. |
| 47 | +Definitions |
| 48 | +-------- |
32 | 49 |
|
33 | | -Notations and refolding |
34 | | ------------ |
| 50 | +The abstract syntax tree of terms is in [Ast](https://ppedrot.github.io/quote-mltt-lics24/coqdoc/LogRel.AutoSubst.Ast.html), the declarative typing and conversion predicates are in [DeclarativeTyping](https://ppedrot.github.io/quote-mltt-lics24/coqdoc/LogRel.DeclarativeTyping.html), reduction is in [UntypedReduction](https://ppedrot.github.io/quote-mltt-lics24/coqdoc/LogRel.UntypedReduction.html). |
35 | 51 |
|
36 | | -In a style somewhat similar to the [Math Classes](https://math-classes.github.io/) project, |
37 | | -generic notations for typing, conversion, renaming, etc. are implemented using type-classes. |
38 | | -While some care has been taken to try and respect the abstractions on which the notations are |
39 | | -based, they might still be broken by carefree reduction performed by tactics. In this case, |
40 | | -the `refold` tactic can be used, as the name suggests, to refold all lost notations. |
| 52 | +The logical relation is defined with respect to a generic notion of typing, given in [GenericTyping](https://ppedrot.github.io/quote-mltt-lics24/LogRel.GenericTyping.html). |
41 | 53 |
|
42 | | -Induction principles |
| 54 | +Proofs |
43 | 55 | ---------- |
44 | 56 |
|
45 | | -The development relies on large, mutually-defined inductive relations. To make proofs by induction |
46 | | -more tractable, functions `XXXInductionConcl` are provided. These take the predicates |
47 | | -to be mutually proven, and construct the type of the conclusion of a proof by mutual induction. |
48 | | -Thus, a typical induction proof looks like the following: |
| 57 | +The toplevel results are exposed in a standalone file [Main](https://ppedrot.github.io/quote-mltt-lics24/coqdoc/LogRel.Main.html). |
49 | 58 |
|
50 | | -``` coq-lang |
51 | | -Section Foo. |
| 59 | +The logical relation is defined in [LogicalRelation](https://ppedrot.github.io/quote-mltt-lics24/coqdoc/LogRel.LogicalRelation.html). It is first defined component by component, before the components are all brought together by inductive `LR` at the end of the file. The fundamental lemma of the logical relation, saying that every well-typed term is reducible, is in [Fundamental](https://ppedrot.github.io/quote-mltt-lics24/coqdoc/LogRel.Fundamental.html). |
52 | 60 |
|
53 | | -Let P := … . |
54 | | -… |
| 61 | +Injectivity and no-confusion of type constructor, and subject reduction, are proven in [TypeConstructorsInj](https://ppedrot.github.io/quote-mltt-lics24/coqdoc/LogRel.TypeConstructorsInj.html). |
55 | 62 |
|
56 | | -Theorem Foo : XXXInductionConcl P … . |
57 | | -Proof. |
58 | | - apply XXXInduction. |
59 | | -
|
60 | | -End Section. |
61 | | -``` |
62 | | -The names of the arguments printed when querying `About XXXInductionConcl` should make it clear |
63 | | -to which mutually-defined relation each predicate corresponds. |
64 | | - |
65 | | -[Utils]: ./theories/Utils.v |
66 | | -[BasicAst]: ./theories/BasicAst.v |
67 | | -[Context]: ./theories/Context.v |
68 | | -[AutoSubst/]: ./theories/AutoSubst/ |
69 | | -[AutoSubst/Extra]: ./theories/AutoSubst/Extra.v |
70 | | -[Notations]: ./theories/Notations.v |
71 | | -[Automation]: ./theories/Automation.v |
72 | | -[NormalForms]: ./theories/NormalForms.v |
73 | | -[UntypedReduction]: ./theories/UntypedReduction.v |
74 | | -[GenericTyping]: ./theories/GenericTyping.v |
75 | | -[DeclarativeTyping]: ./theories/DeclarativeTyping.v |
76 | | -[Properties]: ./theories/Properties.v |
77 | | -[DeclarativeInstance]: ./theories/DeclarativeInstance.v |
78 | | -[LogicalRelation]: ./theories/LogicalRelation.v |
79 | | -[Induction]: ./theories/LogicalRelation/Induction.v |
80 | | -[Escape]: ./theories/Escape.v |
81 | | -[Reflexivity]: ./theories/Reflexivity.v |
82 | | -[Irrelevance]: ./theories/Irrelevance.v |
83 | | -[ShapeView]: ./theories/ShapeView.v |
84 | | -[Positivity.v]: ./theories/Positivity.v |
85 | | -[Weakening]: ./theories/Weakening.v |
86 | | -[Substitution]: ./theories/Substitution.v |
87 | | -[AlgorithmicTyping]: ./theories/AlgorithmicTyping.v |
88 | | -[AlgorithmicConvProperties]: ./theories/AlgorithmicConvProperties.v |
89 | | -[AlgorithmicTypingProperties]: ./theories/AlgorithmicTypingProperties.v |
90 | | -[LogRelConsequences]: ./theories/LogRelConsequences.v |
91 | | -[BundledAlgorithmicTyping]: ./theories/BundledAlgorithmicTyping.v |
92 | | - |
93 | | -[autosubst-ocaml]: https://github.com/uds-psl/autosubst-ocaml |
94 | | -[Positivity.agda]: ./theories/Positivity.agda |
| 63 | +Consistency and canonicity are derived in [Consequences](https://ppedrot.github.io/quote-mltt-lics24/coqdoc/LogRel.Consequences.html). |
0 commit comments