Our proofs are verified in Coq version Coq 8.13.2. We rely on the Coq library:
metalib for the locally nameless representation in our proofs.
-
Install Coq 8.13.2. The recommended way to install Coq is via
OPAM. Refer to here for detailed steps. Or one could download the pre-built packages for Windows and MacOS via here. Choose a suitable installer according to your platform. -
Make sure
Coqis installed, then installMetalib:- Open terminal
git clone -b coq8.10 https://github.com/plclub/metalibcd metalib/Metalibmake install
For checking proofs of the paper, you can already stop here and use the provided
syntax_ott.vandrules_inf.vfiles. We have already built these files, which are generated by theLNgenandOtttools. If you want to modify the rules, you can follow the rest of the instructions below to installLNgenandOtt:
-
Make sure
Haskellwithstackis installed, then installLNgen:- Open terminal
git clone https://github.com/plclub/lngencd lngenstack install
-
Install
Ott 0.32if you want to rewrite the rules. Make sureopamis installed:- Open terminal
git clone https://github.com/sweirich/ott -b ln-closecd ottopam pin add ott .opam pin add coq-ott .
Check the Ott website for detailed instructions. Remember to switch to the correct forked version of
Ott 0.32during the installation process.
-
Enter the coq directory you would like to build.
-
Type
makein the terminal to build and compile the proofs.
Other make commands (with LNgen and Ott installed):
make rules # Generate the syntax_ott.v and rules_inf.v files
make pdf # Generate the latex pdf from the Ott specification
make realclean # Clean all the generated files including documents
make clean # Clean all the files generated by Coq checking
There are two directories in this artifact. The cast_main directory contains the proofs for the main system presented in Section 3 and Section 4 of the paper. The cast_sub directory contains the proofs for the main system extended with subtyping presented in Section 5 of the paper.
The cast_main and cast_sub share the same structure, in which all the proof files have a sequential dependency, as can be found in _CoqProject file of each directory. The proof starts from syntax_ott.v, which is generated from the Ott specification in spec directory, and ends with theorems.v. The theorems.v file contains most of the main theorems of the paper. There is also a doc directory that contains a latex pdf generated from the Ott specification that presents all the rules of each system.
In addition, within cast_sub there is a subdirectory subtyping which contains the Coq proofs from the artifact of the paper "Revisiting Iso-recursive Subtyping" (Zhou et al. 2022). We transported their results (e.g. unfolding lemma) to our setting through subtyping.v in the cast_sub directory.
| Definition | File | Notation in Paper | Name in Coq |
|---|---|---|---|
| Fig. 2. Brandt and Henglein's equi-recursive type equality | syntax_ott.v | eqe2 |
|
| Fig. 4. Typing | syntax_ott.v | Typing |
|
| Fig. 4. Type Casting | syntax_ott.v | TypCast |
|
| Fig. 5. Equi-recursive typing with rule Typ-eq | syntax_ott.v | EquiTyping |
|
| Fig. 5. Full iso-recursive elaboration | syntax_ott.v | EquiTypingC |
|
| Fig. 6. Reduction rules | syntax_ott.v | Reduction |
|
| Fig. 7. Iso-recursive Subtyping | syntax_ott.v | AmberSubtyping |
|
| Fig. 7. Equi-recursive Subtyping | syntax_ott.v | ACSubtyping |
Note, in the formalization of the rules in literature (e.g. Brandt and Henglein's equi-recursive type equality in Fig. 2, Iso-recursive Subtyping, and Equi-recursive Subtyping in Fig. 7), we add a type context and well-formedness check to the rules in order to be consistent with the rest of the rules. The well-formedness conditions are omitted in the paper for simplicity.
Contains the proofs for the main system presented in Section 3 and Section 4 of the paper.
The paper to proof table:
| Theorem | File | Name in Coq |
|---|---|---|
| Theorem 3.1 Soundness of Type Casting | theorems.v | TypCast_soundness |
| Theorem 3.1 Completeness of Type Casting | theorems.v | TypCast_completeness |
| Theorem 3.2 Equivalence of Alternative equi-recursive typing | theorems.v | equi_alt_equiv |
| Theorem 3.3 Equi-recursive to full iso-recursive typing | theorems.v | EquiTypingC_sem |
| Theorem 3.4 Full iso-recursive to equi-recursive typing | theorems.v | typing_i2e |
| Theorem 3.5 Round-tripping of the encoding | theorems.v | erase_typing |
| Theorem 3.6 Progress | Progress.v | progress |
| Theorem 3.7 Preservation | Preservation.v | preservation |
| Theorem 3.8 Full iso-recursive to equi-recursive reduction | theorems.v | reductions_i2e |
| Theorem 3.9 Behavioral equivalence | theorems.v | behavior_equiv |
Contains the proofs for the main system extended with subtyping presented in Section 5 of the paper.
The paper to proof table:
| Theorem | File | Name in Coq |
|---|---|---|
| Theorem 5.1 Reflxixivty of Iso-recursive Subtyping | subtyping.v | AmberWFT_refl |
| Theorem 5.2 Transitivity of Iso-recursive Subtyping | subtyping.v | AmberSub_trans |
| Lemma 5.3 Unfolding Lemma | subtyping.v | unfolding_lemma |
| Theorem 5.4(1) Progress | Progress.v | progress |
| Theorem 5.4(2) Preservation | Preservation.v | preservation |
| Theorem 5.5 Equi-recursive subtyping decomposition | theorems.v | subtyping_decomposition |
| Theorem 5.6(1) Typing Equivalence - soundness | theorems.v | typing_i2e |
| Theorem 5.6(2) Typing Equivalence - completeness | theorems.v | EquiTypingC_sem |
| Theorem 5.6(3) Typing Equivalence - round-tripping | theorems.v | erase_typing |
| Theorem 5.7 Behavioral Equivalence | theorems.v | behavior_equiv |